|
a/src/qtgui/uiprefs.ui.h |
|
b/src/qtgui/uiprefs.ui.h |
|
... |
|
... |
23 |
** You should not define a constructor or destructor in this file.
|
23 |
** You should not define a constructor or destructor in this file.
|
24 |
** Instead, write your code in functions called init() and destroy().
|
24 |
** Instead, write your code in functions called init() and destroy().
|
25 |
** These will automatically be called by the form's constructor and
|
25 |
** These will automatically be called by the form's constructor and
|
26 |
** destructor.
|
26 |
** destructor.
|
27 |
*****************************************************************************/
|
27 |
*****************************************************************************/
|
|
|
28 |
#include <string>
|
|
|
29 |
#include <algorithm>
|
|
|
30 |
#include <list>
|
28 |
|
31 |
|
29 |
#include "qfontdialog.h"
|
32 |
#include "qfontdialog.h"
|
30 |
#include "qfiledialog.h"
|
33 |
#include "qfiledialog.h"
|
31 |
#include "qspinbox.h"
|
34 |
#include "qspinbox.h"
|
32 |
#include "qmessagebox.h"
|
35 |
#include "qmessagebox.h"
|
33 |
|
36 |
|
34 |
#include "recoll.h"
|
37 |
#include "recoll.h"
|
35 |
#include "guiutils.h"
|
38 |
#include "guiutils.h"
|
|
|
39 |
#include "rcldb.h"
|
36 |
|
40 |
|
37 |
void UIPrefsDialog::init()
|
41 |
void UIPrefsDialog::init()
|
38 |
{
|
42 |
{
|
39 |
// Entries per result page spinbox
|
43 |
// Entries per result page spinbox
|
40 |
pageLenSB->setValue(prefs.respagesize);
|
44 |
pageLenSB->setValue(prefs.respagesize);
|
|
... |
|
... |
80 |
buildAbsCB->setDown(prefs.queryBuildAbstract);
|
84 |
buildAbsCB->setDown(prefs.queryBuildAbstract);
|
81 |
if (!prefs.queryBuildAbstract) {
|
85 |
if (!prefs.queryBuildAbstract) {
|
82 |
replAbsCB->setEnabled(false);
|
86 |
replAbsCB->setEnabled(false);
|
83 |
}
|
87 |
}
|
84 |
replAbsCB->setDown(prefs.queryReplaceAbstract);
|
88 |
replAbsCB->setDown(prefs.queryReplaceAbstract);
|
|
|
89 |
|
|
|
90 |
// Initialize the extra databases listboxes
|
|
|
91 |
QStringList ql;
|
|
|
92 |
for (list<string>::iterator it = prefs.allExtraDbs.begin();
|
|
|
93 |
it != prefs.allExtraDbs.end(); it++) {
|
|
|
94 |
ql.append(QString::fromLocal8Bit(it->c_str()));
|
|
|
95 |
}
|
|
|
96 |
allDbsLB->insertStringList(ql);
|
|
|
97 |
ql.clear();
|
|
|
98 |
for (list<string>::iterator it = prefs.activeExtraDbs.begin();
|
|
|
99 |
it != prefs.activeExtraDbs.end(); it++) {
|
|
|
100 |
ql.append(QString::fromLocal8Bit(it->c_str()));
|
|
|
101 |
}
|
|
|
102 |
actDbsLB->insertStringList(ql);
|
|
|
103 |
ql.clear();
|
85 |
|
104 |
|
86 |
connect(reslistFontPB, SIGNAL(clicked()), this, SLOT(showFontDialog()));
|
105 |
connect(reslistFontPB, SIGNAL(clicked()), this, SLOT(showFontDialog()));
|
87 |
connect(helpBrowserPB, SIGNAL(clicked()), this, SLOT(showBrowserDialog()));
|
106 |
connect(helpBrowserPB, SIGNAL(clicked()), this, SLOT(showBrowserDialog()));
|
88 |
connect(resetFontPB, SIGNAL(clicked()), this, SLOT(resetReslistFont()));
|
107 |
connect(resetFontPB, SIGNAL(clicked()), this, SLOT(resetReslistFont()));
|
|
|
108 |
connect(extraDbLE,SIGNAL(textChanged(const QString&)), this,
|
|
|
109 |
SLOT(extraDbTextChanged(const QString&)));
|
|
|
110 |
connect(addAADbPB, SIGNAL(clicked()), this, SLOT(addAADbPB_clicked()));
|
|
|
111 |
connect(addADbPB, SIGNAL(clicked()), this, SLOT(addADbPB_clicked()));
|
|
|
112 |
connect(delADbPB, SIGNAL(clicked()), this, SLOT(delADbPB_clicked()));
|
|
|
113 |
connect(delAADbPB, SIGNAL(clicked()), this, SLOT(delAADbPB_clicked()));
|
|
|
114 |
connect(addExtraDbPB, SIGNAL(clicked()), this, SLOT(addExtraDbPB_clicked()));
|
|
|
115 |
connect(browseDbPB, SIGNAL(clicked()), this, SLOT(browseDbPB_clicked()));
|
|
|
116 |
|
|
|
117 |
|
89 |
}
|
118 |
}
|
90 |
|
119 |
|
91 |
void UIPrefsDialog::accept()
|
120 |
void UIPrefsDialog::accept()
|
92 |
{
|
121 |
{
|
93 |
prefs.showicons = useIconsCB->isChecked();
|
122 |
prefs.showicons = useIconsCB->isChecked();
|
|
... |
|
... |
157 |
"open file dialog",
|
186 |
"open file dialog",
|
158 |
"Choose a file" );
|
187 |
"Choose a file" );
|
159 |
if (s)
|
188 |
if (s)
|
160 |
helpBrowserLE->setText(s);
|
189 |
helpBrowserLE->setText(s);
|
161 |
}
|
190 |
}
|
|
|
191 |
|
|
|
192 |
////////////////////////////////////////////
|
|
|
193 |
// External / extra search databases setup: this should modify to take
|
|
|
194 |
// effect only when Ok is clicked. Currently modifs take effect as soon as
|
|
|
195 |
// done in the Gui
|
|
|
196 |
// Also needed: means to remove entry from 'all' list (del button? )
|
|
|
197 |
|
|
|
198 |
void UIPrefsDialog::extraDbTextChanged(const QString &text)
|
|
|
199 |
{
|
|
|
200 |
if (text.isEmpty()) {
|
|
|
201 |
addExtraDbPB->setEnabled(false);
|
|
|
202 |
} else {
|
|
|
203 |
addExtraDbPB->setEnabled(true);
|
|
|
204 |
}
|
|
|
205 |
}
|
|
|
206 |
|
|
|
207 |
// Add selected dbs to the active list
|
|
|
208 |
void UIPrefsDialog::addADbPB_clicked()
|
|
|
209 |
{
|
|
|
210 |
for (unsigned int i = 0; i < allDbsLB->count();i++) {
|
|
|
211 |
QListBoxItem *item = allDbsLB->item(i);
|
|
|
212 |
if (item && item->isSelected()) {
|
|
|
213 |
allDbsLB->setSelected(i, false);
|
|
|
214 |
string dbname = (const char*)item->text().local8Bit();
|
|
|
215 |
if (std::find(prefs.activeExtraDbs.begin(), prefs.activeExtraDbs.end(),
|
|
|
216 |
dbname) == prefs.activeExtraDbs.end()) {
|
|
|
217 |
actDbsLB->insertItem(item->text());
|
|
|
218 |
prefs.activeExtraDbs.push_back(dbname);
|
|
|
219 |
}
|
|
|
220 |
}
|
|
|
221 |
}
|
|
|
222 |
actDbsLB->sort();
|
|
|
223 |
}
|
|
|
224 |
|
|
|
225 |
void UIPrefsDialog::addAADbPB_clicked()
|
|
|
226 |
{
|
|
|
227 |
for (unsigned int i = 0; i < allDbsLB->count();i++) {
|
|
|
228 |
allDbsLB->setSelected(i, true);
|
|
|
229 |
}
|
|
|
230 |
addADbPB_clicked();
|
|
|
231 |
}
|
|
|
232 |
|
|
|
233 |
void UIPrefsDialog::delADbPB_clicked()
|
|
|
234 |
{
|
|
|
235 |
list<int> rmi;
|
|
|
236 |
for (unsigned int i = 0; i < actDbsLB->count(); i++) {
|
|
|
237 |
QListBoxItem *item = actDbsLB->item(i);
|
|
|
238 |
if (item && item->isSelected()) {
|
|
|
239 |
string dbname = (const char*)item->text().local8Bit();
|
|
|
240 |
list<string>::iterator sit;
|
|
|
241 |
if ((sit = ::std::find(prefs.activeExtraDbs.begin(),
|
|
|
242 |
prefs.activeExtraDbs.end(), dbname)) !=
|
|
|
243 |
prefs.activeExtraDbs.end()) {
|
|
|
244 |
prefs.activeExtraDbs.erase(sit);
|
|
|
245 |
}
|
|
|
246 |
rmi.push_front(i);
|
|
|
247 |
}
|
|
|
248 |
}
|
|
|
249 |
for (list<int>::iterator ii = rmi.begin(); ii != rmi.end(); ii++) {
|
|
|
250 |
actDbsLB->removeItem(*ii);
|
|
|
251 |
}
|
|
|
252 |
}
|
|
|
253 |
|
|
|
254 |
void UIPrefsDialog::delAADbPB_clicked()
|
|
|
255 |
{
|
|
|
256 |
for (unsigned int i = 0; i < actDbsLB->count(); i++) {
|
|
|
257 |
actDbsLB->setSelected(i, true);
|
|
|
258 |
}
|
|
|
259 |
delADbPB_clicked();
|
|
|
260 |
}
|
|
|
261 |
|
|
|
262 |
void UIPrefsDialog::addExtraDbPB_clicked()
|
|
|
263 |
{
|
|
|
264 |
string dbdir = (const char *)extraDbLE->text().local8Bit();
|
|
|
265 |
if (!Rcl::Db::testDbDir(dbdir)) {
|
|
|
266 |
QMessageBox::warning(0, "Recoll",
|
|
|
267 |
tr("The selected directory does not appear to be a Xapian database"));
|
|
|
268 |
return;
|
|
|
269 |
}
|
|
|
270 |
|
|
|
271 |
if (::std::find(prefs.allExtraDbs.begin(), prefs.allExtraDbs.end(),
|
|
|
272 |
dbdir) != prefs.allExtraDbs.end()) {
|
|
|
273 |
QMessageBox::warning(0, "Recoll",
|
|
|
274 |
tr("The selected directory is already in the database list"));
|
|
|
275 |
return;
|
|
|
276 |
}
|
|
|
277 |
prefs.allExtraDbs.push_back(dbdir);
|
|
|
278 |
allDbsLB->insertItem(extraDbLE->text());
|
|
|
279 |
allDbsLB->sort();
|
|
|
280 |
}
|
|
|
281 |
|
|
|
282 |
void UIPrefsDialog::browseDbPB_clicked()
|
|
|
283 |
{
|
|
|
284 |
QFileDialog fdia;
|
|
|
285 |
bool savedh = fdia.showHiddenFiles();
|
|
|
286 |
fdia.setShowHiddenFiles(true);
|
|
|
287 |
QString s = QFileDialog::getExistingDirectory("", this, 0,
|
|
|
288 |
tr("Select directory holding xapian database (ie: /home/someone/.recoll/xapiandb)"));
|
|
|
289 |
|
|
|
290 |
fdia.setShowHiddenFiles(savedh);
|
|
|
291 |
if (s)
|
|
|
292 |
extraDbLE->setText(s);
|
|
|
293 |
}
|