|
a |
|
b/src/qtgui/viewaction_w.cpp |
|
|
1 |
#ifndef lint
|
|
|
2 |
static char rcsid[] = "@(#$Id: viewaction_w.cpp,v 1.1 2006-12-14 13:53:43 dockes Exp $ (C) 2006 J.F.Dockes";
|
|
|
3 |
#endif
|
|
|
4 |
/*
|
|
|
5 |
* This program is free software; you can redistribute it and/or modify
|
|
|
6 |
* it under the terms of the GNU General Public License as published by
|
|
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
|
|
8 |
* (at your option) any later version.
|
|
|
9 |
*
|
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
13 |
* GNU General Public License for more details.
|
|
|
14 |
*
|
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
|
16 |
* along with this program; if not, write to the
|
|
|
17 |
* Free Software Foundation, Inc.,
|
|
|
18 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
19 |
*/
|
|
|
20 |
#include <vector>
|
|
|
21 |
#include <utility>
|
|
|
22 |
#include <string>
|
|
|
23 |
|
|
|
24 |
using namespace std;
|
|
|
25 |
|
|
|
26 |
#include <qcombobox.h>
|
|
|
27 |
#include <qspinbox.h>
|
|
|
28 |
#include <qcheckbox.h>
|
|
|
29 |
#include <qpushbutton.h>
|
|
|
30 |
#include <qlistview.h>
|
|
|
31 |
#include <qlayout.h>
|
|
|
32 |
#include <qmessagebox.h>
|
|
|
33 |
#include <qinputdialog.h>
|
|
|
34 |
|
|
|
35 |
#include "recoll.h"
|
|
|
36 |
#include "debuglog.h"
|
|
|
37 |
#include "guiutils.h"
|
|
|
38 |
|
|
|
39 |
#include "viewaction_w.h"
|
|
|
40 |
|
|
|
41 |
void ViewAction::init()
|
|
|
42 |
{
|
|
|
43 |
connect(closePB, SIGNAL(clicked()), this, SLOT(close()));
|
|
|
44 |
connect(chgActPB, SIGNAL(clicked()), this, SLOT(editAction()));
|
|
|
45 |
fillLists();
|
|
|
46 |
actionsLV->setColumnWidth(0, 150);
|
|
|
47 |
actionsLV->setColumnWidth(1, 150);
|
|
|
48 |
resize(550,350);
|
|
|
49 |
}
|
|
|
50 |
void ViewAction::fillLists()
|
|
|
51 |
{
|
|
|
52 |
actionsLV->clear();
|
|
|
53 |
vector<pair<string, string> > defs;
|
|
|
54 |
rclconfig->getMimeViewerDefs(defs);
|
|
|
55 |
for (vector<pair<string, string> >::const_iterator it = defs.begin();
|
|
|
56 |
it != defs.end(); it++) {
|
|
|
57 |
new QListViewItem(actionsLV,
|
|
|
58 |
QString::fromAscii(it->first.c_str()),
|
|
|
59 |
QString::fromAscii(it->second.c_str()));
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
void ViewAction::editAction()
|
|
|
65 |
{
|
|
|
66 |
QString action0;
|
|
|
67 |
list<string> mtypes;
|
|
|
68 |
bool dowarnmultiple = true;
|
|
|
69 |
|
|
|
70 |
QListViewItemIterator it(actionsLV);
|
|
|
71 |
while (it.current()) {
|
|
|
72 |
QListViewItem *item = it.current();
|
|
|
73 |
if (!item->isSelected()) {
|
|
|
74 |
++it;
|
|
|
75 |
continue;
|
|
|
76 |
}
|
|
|
77 |
mtypes.push_back((const char *)item->text(0).utf8());
|
|
|
78 |
QString action = (const char *)item->text(1).utf8();
|
|
|
79 |
if (action0.isEmpty()) {
|
|
|
80 |
action0 = action;
|
|
|
81 |
} else {
|
|
|
82 |
if (action != action0 && dowarnmultiple) {
|
|
|
83 |
switch (QMessageBox::warning(0, "Recoll",
|
|
|
84 |
tr("Changing actions with different"
|
|
|
85 |
"current values"),
|
|
|
86 |
"Continue",
|
|
|
87 |
"Cancel",
|
|
|
88 |
0, 0, 1)) {
|
|
|
89 |
case 0: dowarnmultiple = false;break;
|
|
|
90 |
case 1: return;
|
|
|
91 |
}
|
|
|
92 |
}
|
|
|
93 |
}
|
|
|
94 |
++it;
|
|
|
95 |
}
|
|
|
96 |
if (action0.isEmpty())
|
|
|
97 |
return;
|
|
|
98 |
|
|
|
99 |
bool ok;
|
|
|
100 |
QString text = QInputDialog::getText(
|
|
|
101 |
"Recoll", "Edit action:",
|
|
|
102 |
QLineEdit::Normal,
|
|
|
103 |
action0, &ok, this);
|
|
|
104 |
if (!ok || text.isEmpty() )
|
|
|
105 |
return;
|
|
|
106 |
|
|
|
107 |
string sact = (const char *)text.utf8();
|
|
|
108 |
for (list<string>::const_iterator it = mtypes.begin();
|
|
|
109 |
it != mtypes.end(); it++) {
|
|
|
110 |
rclconfig->setMimeViewerDef(*it, sact);
|
|
|
111 |
}
|
|
|
112 |
fillLists();
|
|
|
113 |
}
|