|
a/src/qtgui/uiprefs.ui.h |
|
b/src/qtgui/uiprefs.ui.h |
1 |
/*
|
|
|
2 |
* This program is free software; you can redistribute it and/or modify
|
|
|
3 |
* it under the terms of the GNU General Public License as published by
|
|
|
4 |
* the Free Software Foundation; either version 2 of the License, or
|
|
|
5 |
* (at your option) any later version.
|
|
|
6 |
*
|
|
|
7 |
* This program is distributed in the hope that it will be useful,
|
|
|
8 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
10 |
* GNU General Public License for more details.
|
|
|
11 |
*
|
|
|
12 |
* You should have received a copy of the GNU General Public License
|
|
|
13 |
* along with this program; if not, write to the
|
|
|
14 |
* Free Software Foundation, Inc.,
|
|
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
16 |
*/
|
|
|
17 |
/****************************************************************************
|
1 |
/****************************************************************************
|
18 |
** ui.h extension file, included from the uic-generated form implementation.
|
2 |
** ui.h extension file, included from the uic-generated form implementation.
|
19 |
**
|
3 |
**
|
20 |
** If you want to add, delete, or rename functions or slots, use
|
4 |
** If you want to add, delete, or rename functions or slots, use
|
21 |
** Qt Designer to update this file, preserving your code.
|
5 |
** Qt Designer to update this file, preserving your code.
|
|
... |
|
... |
23 |
** You should not define a constructor or destructor in this file.
|
7 |
** You should not define a constructor or destructor in this file.
|
24 |
** Instead, write your code in functions called init() and destroy().
|
8 |
** Instead, write your code in functions called init() and destroy().
|
25 |
** These will automatically be called by the form's constructor and
|
9 |
** These will automatically be called by the form's constructor and
|
26 |
** destructor.
|
10 |
** destructor.
|
27 |
*****************************************************************************/
|
11 |
*****************************************************************************/
|
28 |
#include <sys/stat.h>
|
|
|
29 |
|
|
|
30 |
#include <string>
|
|
|
31 |
#include <algorithm>
|
|
|
32 |
#include <list>
|
|
|
33 |
|
|
|
34 |
#include "qfontdialog.h"
|
|
|
35 |
#include "qfiledialog.h"
|
|
|
36 |
#include "qspinbox.h"
|
|
|
37 |
#include "qmessagebox.h"
|
|
|
38 |
|
|
|
39 |
#include "recoll.h"
|
|
|
40 |
#include "guiutils.h"
|
|
|
41 |
#include "rcldb.h"
|
|
|
42 |
#include "pathut.h"
|
|
|
43 |
|
|
|
44 |
void UIPrefsDialog::init()
|
|
|
45 |
{
|
|
|
46 |
// Entries per result page spinbox
|
|
|
47 |
pageLenSB->setValue(prefs.respagesize);
|
|
|
48 |
// Show icons checkbox
|
|
|
49 |
useIconsCB->setChecked(prefs.showicons);
|
|
|
50 |
autoSearchCB->setChecked(prefs.autoSearchOnWS);
|
|
|
51 |
// Result list font family and size
|
|
|
52 |
reslistFontFamily = prefs.reslistfontfamily;
|
|
|
53 |
reslistFontSize = prefs.reslistfontsize;
|
|
|
54 |
QString s;
|
|
|
55 |
if (prefs.reslistfontfamily.length() == 0) {
|
|
|
56 |
reslistFontPB->setText(this->font().family() + "-" +
|
|
|
57 |
s.setNum(this->font().pointSize()));
|
|
|
58 |
} else {
|
|
|
59 |
reslistFontPB->setText(reslistFontFamily + "-" +
|
|
|
60 |
s.setNum(reslistFontSize));
|
|
|
61 |
}
|
|
|
62 |
helpBrowserLE->setText(prefs.htmlBrowser);
|
|
|
63 |
// Stemming language combobox
|
|
|
64 |
stemLangCMB->insertItem("(no stemming)");
|
|
|
65 |
list<string> langs;
|
|
|
66 |
string reason;
|
|
|
67 |
if (!maybeOpenDb(reason)) {
|
|
|
68 |
QMessageBox::critical(0, "Recoll", QString(reason.c_str()));
|
|
|
69 |
exit(1);
|
|
|
70 |
}
|
|
|
71 |
langs = rcldb->getStemLangs();
|
|
|
72 |
|
|
|
73 |
int i = 0, cur = -1;
|
|
|
74 |
for (list<string>::const_iterator it = langs.begin();
|
|
|
75 |
it != langs.end(); it++) {
|
|
|
76 |
stemLangCMB->
|
|
|
77 |
insertItem(QString::fromAscii(it->c_str(), it->length()));
|
|
|
78 |
i++;
|
|
|
79 |
if (cur == -1) {
|
|
|
80 |
if (!strcmp(prefs.queryStemLang.ascii(), it->c_str()))
|
|
|
81 |
cur = i;
|
|
|
82 |
}
|
|
|
83 |
}
|
|
|
84 |
if (cur < 0)
|
|
|
85 |
cur = 0;
|
|
|
86 |
stemLangCMB->setCurrentItem(cur);
|
|
|
87 |
|
|
|
88 |
buildAbsCB->setDown(prefs.queryBuildAbstract);
|
|
|
89 |
if (!prefs.queryBuildAbstract) {
|
|
|
90 |
replAbsCB->setEnabled(false);
|
|
|
91 |
}
|
|
|
92 |
replAbsCB->setDown(prefs.queryReplaceAbstract);
|
|
|
93 |
|
|
|
94 |
// Initialize the extra databases listboxes
|
|
|
95 |
QStringList ql;
|
|
|
96 |
for (list<string>::iterator it = prefs.allExtraDbs.begin();
|
|
|
97 |
it != prefs.allExtraDbs.end(); it++) {
|
|
|
98 |
ql.append(QString::fromLocal8Bit(it->c_str()));
|
|
|
99 |
}
|
|
|
100 |
allDbsLB->insertStringList(ql);
|
|
|
101 |
ql.clear();
|
|
|
102 |
for (list<string>::iterator it = prefs.activeExtraDbs.begin();
|
|
|
103 |
it != prefs.activeExtraDbs.end(); it++) {
|
|
|
104 |
ql.append(QString::fromLocal8Bit(it->c_str()));
|
|
|
105 |
}
|
|
|
106 |
actDbsLB->insertStringList(ql);
|
|
|
107 |
ql.clear();
|
|
|
108 |
|
|
|
109 |
connect(reslistFontPB, SIGNAL(clicked()), this, SLOT(showFontDialog()));
|
|
|
110 |
connect(helpBrowserPB, SIGNAL(clicked()), this, SLOT(showBrowserDialog()));
|
|
|
111 |
connect(resetFontPB, SIGNAL(clicked()), this, SLOT(resetReslistFont()));
|
|
|
112 |
connect(extraDbLE,SIGNAL(textChanged(const QString&)), this,
|
|
|
113 |
SLOT(extraDbTextChanged(const QString&)));
|
|
|
114 |
connect(addAADbPB, SIGNAL(clicked()), this, SLOT(addAADbPB_clicked()));
|
|
|
115 |
connect(addADbPB, SIGNAL(clicked()), this, SLOT(addADbPB_clicked()));
|
|
|
116 |
connect(delADbPB, SIGNAL(clicked()), this, SLOT(delADbPB_clicked()));
|
|
|
117 |
connect(delAADbPB, SIGNAL(clicked()), this, SLOT(delAADbPB_clicked()));
|
|
|
118 |
connect(addExtraDbPB, SIGNAL(clicked()), this, SLOT(addExtraDbPB_clicked()));
|
|
|
119 |
connect(browseDbPB, SIGNAL(clicked()), this, SLOT(browseDbPB_clicked()));
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
void UIPrefsDialog::accept()
|
|
|
125 |
{
|
|
|
126 |
prefs.showicons = useIconsCB->isChecked();
|
|
|
127 |
prefs.autoSearchOnWS = autoSearchCB->isChecked();
|
|
|
128 |
prefs.respagesize = pageLenSB->value();
|
|
|
129 |
|
|
|
130 |
prefs.reslistfontfamily = reslistFontFamily;
|
|
|
131 |
prefs.reslistfontsize = reslistFontSize;
|
|
|
132 |
|
|
|
133 |
prefs.htmlBrowser = helpBrowserLE->text();
|
|
|
134 |
|
|
|
135 |
if (stemLangCMB->currentItem() == 0) {
|
|
|
136 |
prefs.queryStemLang = "";
|
|
|
137 |
} else {
|
|
|
138 |
prefs.queryStemLang = stemLangCMB->currentText();
|
|
|
139 |
}
|
|
|
140 |
prefs.queryBuildAbstract = buildAbsCB->isChecked();
|
|
|
141 |
prefs.queryReplaceAbstract = buildAbsCB->isChecked() &&
|
|
|
142 |
replAbsCB->isChecked();
|
|
|
143 |
|
|
|
144 |
prefs.activeExtraDbs.clear();
|
|
|
145 |
for (unsigned int i = 0; i < actDbsLB->count(); i++) {
|
|
|
146 |
QListBoxItem *item = actDbsLB->item(i);
|
|
|
147 |
if (item)
|
|
|
148 |
prefs.activeExtraDbs.push_back((const char *)item->text().local8Bit());
|
|
|
149 |
}
|
|
|
150 |
prefs.allExtraDbs.clear();
|
|
|
151 |
for (unsigned int i = 0; i < allDbsLB->count(); i++) {
|
|
|
152 |
QListBoxItem *item = allDbsLB->item(i);
|
|
|
153 |
if (item)
|
|
|
154 |
prefs.allExtraDbs.push_back((const char *)item->text().local8Bit());
|
|
|
155 |
}
|
|
|
156 |
|
|
|
157 |
|
|
|
158 |
rwSettings(true);
|
|
|
159 |
string reason;
|
|
|
160 |
maybeOpenDb(reason, true);
|
|
|
161 |
emit uiprefsDone();
|
|
|
162 |
QDialog::accept();
|
|
|
163 |
}
|
|
|
164 |
|
|
|
165 |
void UIPrefsDialog::showFontDialog()
|
|
|
166 |
{
|
|
|
167 |
bool ok;
|
|
|
168 |
QFont font;
|
|
|
169 |
if (prefs.reslistfontfamily.length()) {
|
|
|
170 |
font.setFamily(prefs.reslistfontfamily);
|
|
|
171 |
font.setPointSize(prefs.reslistfontsize);
|
|
|
172 |
}
|
|
|
173 |
|
|
|
174 |
font = QFontDialog::getFont(&ok, font, this );
|
|
|
175 |
if (ok) {
|
|
|
176 |
// Check if the default font was set, in which case we
|
|
|
177 |
// erase the preference
|
|
|
178 |
if (font.family().compare(this->font().family()) ||
|
|
|
179 |
font.pointSize() != this->font().pointSize()) {
|
|
|
180 |
reslistFontFamily = font.family();
|
|
|
181 |
reslistFontSize = font.pointSize();
|
|
|
182 |
QString s;
|
|
|
183 |
reslistFontPB->setText(reslistFontFamily + "-" +
|
|
|
184 |
s.setNum(reslistFontSize));
|
|
|
185 |
} else {
|
|
|
186 |
reslistFontFamily = "";
|
|
|
187 |
reslistFontSize = 0;
|
|
|
188 |
}
|
|
|
189 |
}
|
|
|
190 |
}
|
|
|
191 |
|
|
|
192 |
|
|
|
193 |
void UIPrefsDialog::resetReslistFont()
|
|
|
194 |
{
|
|
|
195 |
reslistFontFamily = "";
|
|
|
196 |
reslistFontSize = 0;
|
|
|
197 |
reslistFontPB->setText(this->font().family() + "-" +
|
|
|
198 |
QString().setNum(this->font().pointSize()));
|
|
|
199 |
}
|
|
|
200 |
|
|
|
201 |
void UIPrefsDialog::showBrowserDialog()
|
|
|
202 |
{
|
|
|
203 |
QString s = QFileDialog::getOpenFileName("/usr",
|
|
|
204 |
"",
|
|
|
205 |
this,
|
|
|
206 |
"open file dialog",
|
|
|
207 |
"Choose a file" );
|
|
|
208 |
if (s)
|
|
|
209 |
helpBrowserLE->setText(s);
|
|
|
210 |
}
|
|
|
211 |
|
|
|
212 |
////////////////////////////////////////////
|
|
|
213 |
// External / extra search databases setup
|
|
|
214 |
// TBD: a way to remove entry from 'all' list (del button? )
|
|
|
215 |
|
|
|
216 |
void UIPrefsDialog::extraDbTextChanged(const QString &text)
|
|
|
217 |
{
|
|
|
218 |
if (text.isEmpty()) {
|
|
|
219 |
addExtraDbPB->setEnabled(false);
|
|
|
220 |
} else {
|
|
|
221 |
addExtraDbPB->setEnabled(true);
|
|
|
222 |
}
|
|
|
223 |
}
|
|
|
224 |
|
|
|
225 |
/**
|
|
|
226 |
* Add the selected extra dbs to the active list
|
|
|
227 |
*/
|
|
|
228 |
void UIPrefsDialog::addADbPB_clicked()
|
|
|
229 |
{
|
|
|
230 |
for (unsigned int i = 0; i < allDbsLB->count();i++) {
|
|
|
231 |
QListBoxItem *item = allDbsLB->item(i);
|
|
|
232 |
if (item && item->isSelected()) {
|
|
|
233 |
allDbsLB->setSelected(i, false);
|
|
|
234 |
if (!actDbsLB->findItem(item->text(),
|
|
|
235 |
Qt::CaseSensitive|Qt::ExactMatch)) {
|
|
|
236 |
actDbsLB->insertItem(item->text());
|
|
|
237 |
}
|
|
|
238 |
}
|
|
|
239 |
}
|
|
|
240 |
actDbsLB->sort();
|
|
|
241 |
}
|
|
|
242 |
|
|
|
243 |
/**
|
|
|
244 |
* Make all extra dbs active
|
|
|
245 |
*/
|
|
|
246 |
void UIPrefsDialog::addAADbPB_clicked()
|
|
|
247 |
{
|
|
|
248 |
for (unsigned int i = 0; i < allDbsLB->count();i++) {
|
|
|
249 |
allDbsLB->setSelected(i, true);
|
|
|
250 |
}
|
|
|
251 |
addADbPB_clicked();
|
|
|
252 |
}
|
|
|
253 |
|
|
|
254 |
/**
|
|
|
255 |
* Remove the selected entries from the list of active extra search dbs
|
|
|
256 |
*/
|
|
|
257 |
void UIPrefsDialog::delADbPB_clicked()
|
|
|
258 |
{
|
|
|
259 |
list<int> rmi;
|
|
|
260 |
for (unsigned int i = 0; i < actDbsLB->count(); i++) {
|
|
|
261 |
QListBoxItem *item = actDbsLB->item(i);
|
|
|
262 |
if (item && item->isSelected()) {
|
|
|
263 |
rmi.push_front(i);
|
|
|
264 |
}
|
|
|
265 |
}
|
|
|
266 |
for (list<int>::iterator ii = rmi.begin(); ii != rmi.end(); ii++) {
|
|
|
267 |
actDbsLB->removeItem(*ii);
|
|
|
268 |
}
|
|
|
269 |
}
|
|
|
270 |
|
|
|
271 |
/**
|
|
|
272 |
* Remove all extra search databases from the active list
|
|
|
273 |
*/
|
|
|
274 |
void UIPrefsDialog::delAADbPB_clicked()
|
|
|
275 |
{
|
|
|
276 |
for (unsigned int i = 0; i < actDbsLB->count(); i++) {
|
|
|
277 |
actDbsLB->setSelected(i, true);
|
|
|
278 |
}
|
|
|
279 |
delADbPB_clicked();
|
|
|
280 |
}
|
|
|
281 |
|
|
|
282 |
/**
|
|
|
283 |
* Add the current content of the extra db line editor to the list of all
|
|
|
284 |
* extra dbs. We do a textual comparison to check for duplicates, except for
|
|
|
285 |
* the main db for which we check inode numbers.
|
|
|
286 |
*/
|
|
|
287 |
void UIPrefsDialog::addExtraDbPB_clicked()
|
|
|
288 |
{
|
|
|
289 |
string dbdir = (const char *)extraDbLE->text().local8Bit();
|
|
|
290 |
path_catslash(dbdir);
|
|
|
291 |
if (!Rcl::Db::testDbDir(dbdir)) {
|
|
|
292 |
QMessageBox::warning(0, "Recoll",
|
|
|
293 |
tr("The selected directory does not appear to be a Xapian database"));
|
|
|
294 |
return;
|
|
|
295 |
}
|
|
|
296 |
struct stat st1, st2;
|
|
|
297 |
stat(dbdir.c_str(), &st1);
|
|
|
298 |
string rcldbdir;
|
|
|
299 |
if (rcldb)
|
|
|
300 |
rcldbdir = rcldb->getDbDir();
|
|
|
301 |
stat(rcldbdir.c_str(), &st2);
|
|
|
302 |
path_catslash(rcldbdir);
|
|
|
303 |
fprintf(stderr, "rcldbdir: [%s]\n", rcldbdir.c_str());
|
|
|
304 |
if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino) {
|
|
|
305 |
QMessageBox::warning(0, "Recoll",
|
|
|
306 |
tr("This is the main/local database!"));
|
|
|
307 |
return;
|
|
|
308 |
}
|
|
|
309 |
if (allDbsLB->findItem(extraDbLE->text(),
|
|
|
310 |
Qt::CaseSensitive|Qt::ExactMatch)) {
|
|
|
311 |
QMessageBox::warning(0, "Recoll",
|
|
|
312 |
tr("The selected directory is already in the database list"));
|
|
|
313 |
return;
|
|
|
314 |
}
|
|
|
315 |
allDbsLB->insertItem(extraDbLE->text());
|
|
|
316 |
allDbsLB->sort();
|
|
|
317 |
}
|
|
|
318 |
|
|
|
319 |
void UIPrefsDialog::browseDbPB_clicked()
|
|
|
320 |
{
|
|
|
321 |
QFileDialog fdia;
|
|
|
322 |
bool savedh = fdia.showHiddenFiles();
|
|
|
323 |
fdia.setShowHiddenFiles(true);
|
|
|
324 |
QString s = QFileDialog::getExistingDirectory("", this, 0,
|
|
|
325 |
tr("Select directory holding xapian database (ie: /home/someone/.recoll/xapiandb)"));
|
|
|
326 |
|
|
|
327 |
fdia.setShowHiddenFiles(savedh);
|
|
|
328 |
if (s)
|
|
|
329 |
extraDbLE->setText(s);
|
|
|
330 |
}
|
|
|