|
a/src/qtgui/uiprefs_w.cpp |
|
b/src/qtgui/uiprefs_w.cpp |
|
... |
|
... |
29 |
#include <qspinbox.h>
|
29 |
#include <qspinbox.h>
|
30 |
#include <qmessagebox.h>
|
30 |
#include <qmessagebox.h>
|
31 |
#include <qvariant.h>
|
31 |
#include <qvariant.h>
|
32 |
#include <qpushbutton.h>
|
32 |
#include <qpushbutton.h>
|
33 |
#include <qtabwidget.h>
|
33 |
#include <qtabwidget.h>
|
|
|
34 |
#include <qlistwidget.h>
|
34 |
#include <qwidget.h>
|
35 |
#include <qwidget.h>
|
35 |
#include <qlabel.h>
|
36 |
#include <qlabel.h>
|
36 |
#include <qspinbox.h>
|
37 |
#include <qspinbox.h>
|
37 |
#include <qlineedit.h>
|
38 |
#include <qlineedit.h>
|
38 |
#include <qcheckbox.h>
|
39 |
#include <qcheckbox.h>
|
39 |
#include <qcombobox.h>
|
40 |
#include <qcombobox.h>
|
40 |
#if QT_VERSION < 0x040000
|
|
|
41 |
#include <qlistbox.h>
|
|
|
42 |
#include <qlistview.h>
|
|
|
43 |
#include <qfiledialog.h>
|
41 |
#include <qfiledialog.h>
|
44 |
#else
|
|
|
45 |
#include <q3listbox.h>
|
|
|
46 |
#include <q3listview.h>
|
|
|
47 |
#include <q3filedialog.h>
|
|
|
48 |
#define QListView Q3ListView
|
|
|
49 |
#define QCheckListItem Q3CheckListItem
|
|
|
50 |
#define QFileDialog Q3FileDialog
|
|
|
51 |
#define QListViewItemIterator Q3ListViewItemIterator
|
|
|
52 |
#endif
|
|
|
53 |
#include <qlayout.h>
|
42 |
#include <qlayout.h>
|
54 |
#include <qtooltip.h>
|
43 |
#include <qtooltip.h>
|
55 |
#include <qwhatsthis.h>
|
44 |
#include <qwhatsthis.h>
|
56 |
#include <qtextedit.h>
|
45 |
#include <qtextedit.h>
|
|
|
46 |
#include <qlist.h>
|
57 |
|
47 |
|
58 |
#include "recoll.h"
|
48 |
#include "recoll.h"
|
59 |
#include "guiutils.h"
|
49 |
#include "guiutils.h"
|
60 |
#include "rcldb.h"
|
50 |
#include "rcldb.h"
|
61 |
#include "rclconfig.h"
|
51 |
#include "rclconfig.h"
|
|
... |
|
... |
126 |
s.setNum(this->font().pointSize()));
|
116 |
s.setNum(this->font().pointSize()));
|
127 |
} else {
|
117 |
} else {
|
128 |
reslistFontPB->setText(reslistFontFamily + "-" +
|
118 |
reslistFontPB->setText(reslistFontFamily + "-" +
|
129 |
s.setNum(reslistFontSize));
|
119 |
s.setNum(reslistFontSize));
|
130 |
}
|
120 |
}
|
131 |
rlfTE->setText(prefs.reslistformat);
|
121 |
rlfTE->setPlainText(prefs.reslistformat);
|
132 |
|
122 |
|
133 |
// Stemming language combobox
|
123 |
// Stemming language combobox
|
134 |
stemLangCMB->clear();
|
124 |
stemLangCMB->clear();
|
135 |
stemLangCMB->insertItem(g_stringNoStem);
|
125 |
stemLangCMB->insertItem(g_stringNoStem);
|
136 |
stemLangCMB->insertItem(g_stringAllStem);
|
126 |
stemLangCMB->insertItem(g_stringAllStem);
|
|
... |
|
... |
161 |
|
151 |
|
162 |
// Initialize the extra indexes listboxes
|
152 |
// Initialize the extra indexes listboxes
|
163 |
idxLV->clear();
|
153 |
idxLV->clear();
|
164 |
for (list<string>::iterator it = prefs.allExtraDbs.begin();
|
154 |
for (list<string>::iterator it = prefs.allExtraDbs.begin();
|
165 |
it != prefs.allExtraDbs.end(); it++) {
|
155 |
it != prefs.allExtraDbs.end(); it++) {
|
166 |
QCheckListItem *item =
|
156 |
QListWidgetItem *item =
|
167 |
new QCheckListItem(idxLV, QString::fromLocal8Bit(it->c_str()),
|
157 |
new QListWidgetItem(QString::fromLocal8Bit(it->c_str()),
|
168 |
QCheckListItem::CheckBox);
|
158 |
idxLV);
|
169 |
if (item) item->setOn(false);
|
159 |
if (item)
|
|
|
160 |
item->setCheckState(Qt::Unchecked);
|
170 |
}
|
161 |
}
|
171 |
for (list<string>::iterator it = prefs.activeExtraDbs.begin();
|
162 |
for (list<string>::iterator it = prefs.activeExtraDbs.begin();
|
172 |
it != prefs.activeExtraDbs.end(); it++) {
|
163 |
it != prefs.activeExtraDbs.end(); it++) {
|
173 |
QCheckListItem *item;
|
164 |
QList<QListWidgetItem *>items =
|
174 |
if ((item = (QCheckListItem *)
|
|
|
175 |
idxLV->findItem (QString::fromLocal8Bit(it->c_str()), 0))) {
|
165 |
idxLV->findItems (QString::fromLocal8Bit(it->c_str()),
|
176 |
item->setOn(true);
|
166 |
Qt::MatchFixedString|Qt::MatchCaseSensitive);
|
|
|
167 |
for (QList<QListWidgetItem *>::iterator it = items.begin();
|
|
|
168 |
it != items.end(); it++) {
|
|
|
169 |
(*it)->setCheckState(Qt::Checked);
|
177 |
}
|
170 |
}
|
178 |
}
|
171 |
}
|
|
|
172 |
idxLV->sortItems();
|
179 |
}
|
173 |
}
|
180 |
|
174 |
|
181 |
void UIPrefsDialog::accept()
|
175 |
void UIPrefsDialog::accept()
|
182 |
{
|
176 |
{
|
183 |
prefs.autoSearchOnWS = autoSearchCB->isChecked();
|
177 |
prefs.autoSearchOnWS = autoSearchCB->isChecked();
|
|
... |
|
... |
193 |
// Don't let us set the old default format from here, this would
|
187 |
// Don't let us set the old default format from here, this would
|
194 |
// get reset to the new default. Ugly hack
|
188 |
// get reset to the new default. Ugly hack
|
195 |
if (prefs.reslistformat ==
|
189 |
if (prefs.reslistformat ==
|
196 |
QString::fromAscii(prefs.getV18DfltResListFormat())) {
|
190 |
QString::fromAscii(prefs.getV18DfltResListFormat())) {
|
197 |
prefs.reslistformat += " ";
|
191 |
prefs.reslistformat += " ";
|
198 |
rlfTE->setText(prefs.reslistformat);
|
192 |
rlfTE->setPlainText(prefs.reslistformat);
|
199 |
}
|
193 |
}
|
200 |
if (prefs.reslistformat.stripWhiteSpace().isEmpty()) {
|
194 |
if (prefs.reslistformat.stripWhiteSpace().isEmpty()) {
|
201 |
prefs.reslistformat = prefs.getDfltResListFormat();
|
195 |
prefs.reslistformat = prefs.getDfltResListFormat();
|
202 |
rlfTE->setText(prefs.reslistformat);
|
196 |
rlfTE->setPlainText(prefs.reslistformat);
|
203 |
}
|
197 |
}
|
204 |
prefs.creslistformat = (const char*)prefs.reslistformat.utf8();
|
198 |
prefs.creslistformat = (const char*)prefs.reslistformat.utf8();
|
205 |
|
199 |
|
206 |
if (stemLangCMB->currentItem() == 0) {
|
200 |
if (stemLangCMB->currentItem() == 0) {
|
207 |
prefs.queryStemLang = "";
|
201 |
prefs.queryStemLang = "";
|
|
... |
|
... |
226 |
|
220 |
|
227 |
|
221 |
|
228 |
prefs.autoSuffsEnable = autoSuffsCB->isChecked();
|
222 |
prefs.autoSuffsEnable = autoSuffsCB->isChecked();
|
229 |
prefs.autoSuffs = autoSuffsLE->text();
|
223 |
prefs.autoSuffs = autoSuffsLE->text();
|
230 |
|
224 |
|
231 |
QListViewItemIterator it(idxLV);
|
|
|
232 |
prefs.allExtraDbs.clear();
|
225 |
prefs.allExtraDbs.clear();
|
233 |
prefs.activeExtraDbs.clear();
|
226 |
prefs.activeExtraDbs.clear();
|
234 |
while (it.current()) {
|
227 |
for (int i = 0; i < idxLV->count(); i++) {
|
235 |
QCheckListItem *item = (QCheckListItem *)it.current();
|
228 |
QListWidgetItem *item = idxLV->item(i);
|
|
|
229 |
if (item) {
|
236 |
prefs.allExtraDbs.push_back((const char *)item->text().local8Bit());
|
230 |
prefs.allExtraDbs.push_back((const char *)item->text().local8Bit());
|
237 |
if (item->isOn()) {
|
231 |
if (item->checkState() == Qt::Checked) {
|
238 |
prefs.activeExtraDbs.push_back((const char *)
|
232 |
prefs.activeExtraDbs.push_back((const char *)
|
239 |
item->text().local8Bit());
|
233 |
item->text().local8Bit());
|
|
|
234 |
}
|
240 |
}
|
235 |
}
|
241 |
++it;
|
|
|
242 |
}
|
236 |
}
|
243 |
|
237 |
|
244 |
rwSettings(true);
|
238 |
rwSettings(true);
|
245 |
string reason;
|
239 |
string reason;
|
246 |
maybeOpenDb(reason, true);
|
240 |
maybeOpenDb(reason, true);
|
|
... |
|
... |
323 |
m_viewAction->selectMT(mt);
|
317 |
m_viewAction->selectMT(mt);
|
324 |
}
|
318 |
}
|
325 |
|
319 |
|
326 |
////////////////////////////////////////////
|
320 |
////////////////////////////////////////////
|
327 |
// External / extra search indexes setup
|
321 |
// External / extra search indexes setup
|
328 |
// TBD: a way to remove entry from 'all' list (del button?)
|
|
|
329 |
|
322 |
|
330 |
void UIPrefsDialog::togExtraDbPB_clicked()
|
323 |
void UIPrefsDialog::togExtraDbPB_clicked()
|
331 |
{
|
324 |
{
|
332 |
QListViewItemIterator it(idxLV);
|
325 |
for (int i = 0; i < idxLV->count(); i++) {
|
333 |
while (it.current()) {
|
326 |
QListWidgetItem *item = idxLV->item(i);
|
334 |
QCheckListItem *item = (QCheckListItem *)it.current();
|
|
|
335 |
if (item->isSelected()) {
|
327 |
if (item->isSelected()) {
|
336 |
item->setOn(!item->isOn());
|
328 |
if (item->checkState() == Qt::Checked) {
|
|
|
329 |
item->setCheckState(Qt::Unchecked);
|
|
|
330 |
} else {
|
|
|
331 |
item->setCheckState(Qt::Checked);
|
|
|
332 |
}
|
337 |
}
|
333 |
}
|
338 |
++it;
|
|
|
339 |
}
|
334 |
}
|
340 |
}
|
335 |
}
|
341 |
void UIPrefsDialog::actAllExtraDbPB_clicked()
|
336 |
void UIPrefsDialog::actAllExtraDbPB_clicked()
|
342 |
{
|
337 |
{
|
343 |
QListViewItemIterator it(idxLV);
|
338 |
for (int i = 0; i < idxLV->count(); i++) {
|
344 |
while (it.current()) {
|
339 |
QListWidgetItem *item = idxLV->item(i);
|
345 |
QCheckListItem *item = (QCheckListItem *)it.current();
|
340 |
item->setCheckState(Qt::Checked);
|
346 |
item->setOn(true);
|
|
|
347 |
++it;
|
|
|
348 |
}
|
341 |
}
|
349 |
}
|
342 |
}
|
350 |
void UIPrefsDialog::unacAllExtraDbPB_clicked()
|
343 |
void UIPrefsDialog::unacAllExtraDbPB_clicked()
|
351 |
{
|
344 |
{
|
352 |
QListViewItemIterator it(idxLV);
|
345 |
for (int i = 0; i < idxLV->count(); i++) {
|
353 |
while (it.current()) {
|
346 |
QListWidgetItem *item = idxLV->item(i);
|
354 |
QCheckListItem *item = (QCheckListItem *)it.current();
|
347 |
item->setCheckState(Qt::Unchecked);
|
355 |
item->setOn(false);
|
|
|
356 |
++it;
|
|
|
357 |
}
|
348 |
}
|
358 |
}
|
349 |
}
|
359 |
|
350 |
|
360 |
void UIPrefsDialog::delExtraDbPB_clicked()
|
351 |
void UIPrefsDialog::delExtraDbPB_clicked()
|
361 |
{
|
352 |
{
|
362 |
list<QCheckListItem*> dlt;
|
353 |
QList<QListWidgetItem *> items = idxLV->selectedItems();
|
363 |
QListViewItemIterator it(idxLV);
|
|
|
364 |
while (it.current()) {
|
|
|
365 |
QCheckListItem *item = (QCheckListItem *)it.current();
|
|
|
366 |
if (item->isSelected()) {
|
|
|
367 |
dlt.push_back(item);
|
|
|
368 |
}
|
|
|
369 |
++it;
|
|
|
370 |
}
|
|
|
371 |
for (list<QCheckListItem*>::iterator it = dlt.begin();
|
354 |
for (QList<QListWidgetItem *>::iterator it = items.begin();
|
372 |
it != dlt.end(); it++)
|
355 |
it != items.end(); it++) {
|
373 |
delete *it;
|
356 |
delete *it;
|
|
|
357 |
}
|
374 |
}
|
358 |
}
|
375 |
|
359 |
|
376 |
/**
|
360 |
/**
|
377 |
* Browse to add another index.
|
361 |
* Browse to add another index.
|
378 |
* We do a textual comparison to check for duplicates, except for
|
362 |
* We do a textual comparison to check for duplicates, except for
|
379 |
* the main db for which we check inode numbers.
|
363 |
* the main db for which we check inode numbers.
|
380 |
*/
|
364 |
*/
|
381 |
void UIPrefsDialog::addExtraDbPB_clicked()
|
365 |
void UIPrefsDialog::addExtraDbPB_clicked()
|
382 |
{
|
366 |
{
|
383 |
QFileDialog fdia;
|
367 |
static QString lastdir;
|
384 |
bool savedh = fdia.showHiddenFiles();
|
368 |
|
385 |
fdia.setShowHiddenFiles(true);
|
|
|
386 |
QString input = QFileDialog::getExistingDirectory("", this, 0,
|
369 |
QString input = QFileDialog::getExistingDirectory(this,
|
387 |
tr("Select xapian index directory (ie: /home/buddy/.recoll/xapiandb)"));
|
370 |
tr("Select xapian index directory (ie: /home/buddy/.recoll/xapiandb)"),
|
388 |
fdia.setShowHiddenFiles(savedh);
|
371 |
lastdir);
|
389 |
if (input.isEmpty())
|
372 |
if (input.isEmpty())
|
390 |
return;
|
373 |
return;
|
|
|
374 |
lastdir = input;
|
391 |
|
375 |
|
392 |
string dbdir = (const char *)input.local8Bit();
|
376 |
string dbdir = (const char *)input.local8Bit();
|
393 |
LOGDEB(("ExtraDbDial: got: [%s]\n", dbdir.c_str()));
|
377 |
LOGDEB(("ExtraDbDial: got: [%s]\n", dbdir.c_str()));
|
394 |
path_catslash(dbdir);
|
378 |
path_catslash(dbdir);
|
395 |
if (!Rcl::Db::testDbDir(dbdir)) {
|
379 |
if (!Rcl::Db::testDbDir(dbdir)) {
|
|
... |
|
... |
409 |
return;
|
393 |
return;
|
410 |
}
|
394 |
}
|
411 |
|
395 |
|
412 |
// For some reason, finditem (which we used to use to detect duplicates
|
396 |
// For some reason, finditem (which we used to use to detect duplicates
|
413 |
// here) does not work anymore here: qt 4.6.3
|
397 |
// here) does not work anymore here: qt 4.6.3
|
|
|
398 |
QList<QListWidgetItem *>items =
|
|
|
399 |
idxLV->findItems (input, Qt::MatchFixedString|Qt::MatchCaseSensitive);
|
|
|
400 |
if (!items.empty()) {
|
|
|
401 |
QMessageBox::warning(0, "Recoll",
|
|
|
402 |
tr("The selected directory is already in the index list"));
|
|
|
403 |
return;
|
|
|
404 |
}
|
414 |
#if 1
|
405 |
#if 0
|
415 |
string nv = (const char *)input.local8Bit();
|
406 |
string nv = (const char *)input.local8Bit();
|
416 |
QListViewItemIterator it(idxLV);
|
407 |
QListViewItemIterator it(idxLV);
|
417 |
while (it.current()) {
|
408 |
while (it.current()) {
|
418 |
QCheckListItem *item = (QCheckListItem *)it.current();
|
409 |
QCheckListItem *item = (QCheckListItem *)it.current();
|
419 |
string ov = (const char *)item->text().local8Bit();
|
410 |
string ov = (const char *)item->text().local8Bit();
|
|
... |
|
... |
422 |
tr("The selected directory is already in the index list"));
|
413 |
tr("The selected directory is already in the index list"));
|
423 |
return;
|
414 |
return;
|
424 |
}
|
415 |
}
|
425 |
++it;
|
416 |
++it;
|
426 |
}
|
417 |
}
|
427 |
#else // if findItem worked...
|
|
|
428 |
if (idxLV->findItem(input,
|
|
|
429 |
#if QT_VERSION < 0x040000
|
|
|
430 |
Qt::CaseSensitive|Qt::ExactMatch
|
|
|
431 |
#else
|
|
|
432 |
Q3ListView::CaseSensitive|Q3ListView::ExactMatch
|
|
|
433 |
#endif
|
418 |
#endif
|
434 |
)) {
|
419 |
QListWidgetItem *item = new QListWidgetItem(input, idxLV);
|
435 |
QMessageBox::warning(0, "Recoll",
|
420 |
item->setCheckState(Qt::Unchecked);
|
436 |
tr("The selected directory is already in the index list"));
|
|
|
437 |
return;
|
|
|
438 |
}
|
|
|
439 |
#endif
|
|
|
440 |
|
|
|
441 |
new QCheckListItem(idxLV, input, QCheckListItem::CheckBox);
|
|
|
442 |
idxLV->sort();
|
421 |
idxLV->sortItems();
|
443 |
}
|
422 |
}
|