|
a/src/qtgui/advsearch_w.cpp |
|
b/src/qtgui/advsearch_w.cpp |
1 |
#ifndef lint
|
1 |
#ifndef lint
|
2 |
static char rcsid[] = "@(#$Id: advsearch_w.cpp,v 1.16 2006-12-20 13:12:49 dockes Exp $ (C) 2005 J.F.Dockes";
|
2 |
static char rcsid[] = "@(#$Id: advsearch_w.cpp,v 1.17 2007-02-19 16:10:00 dockes Exp $ (C) 2005 J.F.Dockes";
|
3 |
#endif
|
3 |
#endif
|
4 |
/*
|
4 |
/*
|
5 |
* This program is free software; you can redistribute it and/or modify
|
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
|
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
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
|
... |
|
... |
58 |
|
58 |
|
59 |
extern RclConfig *rclconfig;
|
59 |
extern RclConfig *rclconfig;
|
60 |
|
60 |
|
61 |
static const int initclausetypes[] = {1, 3, 0, 2, 5};
|
61 |
static const int initclausetypes[] = {1, 3, 0, 2, 5};
|
62 |
static const unsigned int iclausescnt = sizeof(initclausetypes) / sizeof(int);
|
62 |
static const unsigned int iclausescnt = sizeof(initclausetypes) / sizeof(int);
|
|
|
63 |
static map<QString,QString> cat_translations;
|
|
|
64 |
static map<QString,QString> cat_rtranslations;
|
|
|
65 |
|
63 |
|
66 |
|
64 |
void AdvSearch::init()
|
67 |
void AdvSearch::init()
|
65 |
{
|
68 |
{
|
66 |
// signals and slots connections
|
69 |
// signals and slots connections
|
67 |
connect(delFiltypPB, SIGNAL(clicked()), this, SLOT(delFiltypPB_clicked()));
|
70 |
connect(delFiltypPB, SIGNAL(clicked()), this, SLOT(delFiltypPB_clicked()));
|
|
... |
|
... |
106 |
}
|
109 |
}
|
107 |
}
|
110 |
}
|
108 |
|
111 |
|
109 |
// Initialize lists of accepted and ignored mime types from config
|
112 |
// Initialize lists of accepted and ignored mime types from config
|
110 |
// and settings
|
113 |
// and settings
|
111 |
restrictCtCB->setChecked(prefs.fileTypesByCats);
|
114 |
m_ignTypes = prefs.asearchIgnFilTyps;
|
|
|
115 |
m_ignByCats = prefs.fileTypesByCats;
|
112 |
restrictCtCB->setEnabled(false);
|
116 |
restrictCtCB->setEnabled(false);
|
|
|
117 |
restrictCtCB->setChecked(m_ignByCats);
|
113 |
fillFileTypes();
|
118 |
fillFileTypes();
|
114 |
|
119 |
|
115 |
subtreeCMB->insertStringList(prefs.asearchSubdirHist);
|
120 |
subtreeCMB->insertStringList(prefs.asearchSubdirHist);
|
116 |
subtreeCMB->setEditText("");
|
121 |
subtreeCMB->setEditText("");
|
117 |
|
122 |
|
118 |
// The clauseline frame is needed to force designer to accept a
|
123 |
// The clauseline frame is needed to force designer to accept a
|
119 |
// vbox to englobe the base clauses grid and 'something else' (the
|
124 |
// vbox to englobe the base clauses grid and 'something else' (the
|
120 |
// vbox is so that we can then insert SearchClauseWs), but we
|
125 |
// vbox is so that we can then insert SearchClauseWs), but we
|
121 |
// don't want to see it.
|
126 |
// don't want to see it.
|
122 |
clauseline->close();
|
127 |
clauseline->close();
|
|
|
128 |
|
|
|
129 |
// Translations for known categories
|
|
|
130 |
cat_translations[QString::fromUtf8("texts")] = tr("texts");
|
|
|
131 |
cat_rtranslations[tr("texts")] = QString::fromUtf8("texts");
|
|
|
132 |
|
|
|
133 |
cat_translations[QString::fromUtf8("spreadsheets")] = tr("spreadsheets");
|
|
|
134 |
cat_rtranslations[tr("spreadsheets")] = QString::fromUtf8("spreadsheets");
|
|
|
135 |
|
|
|
136 |
cat_translations[QString::fromUtf8("presentations")] = tr("presentations");
|
|
|
137 |
cat_rtranslations[tr("presentations")] =QString::fromUtf8("presentations");
|
|
|
138 |
|
|
|
139 |
cat_translations[QString::fromUtf8("media")] = tr("media");
|
|
|
140 |
cat_rtranslations[tr("media")] = QString::fromUtf8("media");
|
|
|
141 |
|
|
|
142 |
cat_translations[QString::fromUtf8("messages")] = tr("messages");
|
|
|
143 |
cat_rtranslations[tr("messages")] = QString::fromUtf8("messages");
|
|
|
144 |
|
|
|
145 |
cat_translations[QString::fromUtf8("other")] = tr("other");
|
|
|
146 |
cat_rtranslations[tr("other")] = QString::fromUtf8("other");
|
123 |
}
|
147 |
}
|
124 |
|
148 |
|
125 |
void AdvSearch::saveCnf()
|
149 |
void AdvSearch::saveCnf()
|
126 |
{
|
150 |
{
|
127 |
// Save my state
|
151 |
// Save my state
|
|
... |
|
... |
142 |
#define QListBoxItem Q3ListBoxItem
|
166 |
#define QListBoxItem Q3ListBoxItem
|
143 |
#define clauseVBox Ui::AdvSearchBase::clauseVBox
|
167 |
#define clauseVBox Ui::AdvSearchBase::clauseVBox
|
144 |
#define AdvSearchBaseLayout Ui::AdvSearchBase::AdvSearchBaseLayout
|
168 |
#define AdvSearchBaseLayout Ui::AdvSearchBase::AdvSearchBaseLayout
|
145 |
#endif
|
169 |
#endif
|
146 |
|
170 |
|
147 |
// Move selected file types from the searched to the ignored box
|
|
|
148 |
void AdvSearch::delFiltypPB_clicked()
|
|
|
149 |
{
|
|
|
150 |
list<int> trl;
|
|
|
151 |
QStringList moved;
|
|
|
152 |
for (unsigned int i = 0; i < yesFiltypsLB->count();i++) {
|
|
|
153 |
QListBoxItem *item = yesFiltypsLB->item(i);
|
|
|
154 |
if (item && item->isSelected()) {
|
|
|
155 |
moved.push_back(item->text());
|
|
|
156 |
trl.push_front(i);
|
|
|
157 |
}
|
|
|
158 |
}
|
|
|
159 |
if (!moved.empty()) {
|
|
|
160 |
noFiltypsLB->insertStringList(moved);
|
|
|
161 |
for (list<int>::iterator it = trl.begin();it != trl.end(); it++)
|
|
|
162 |
yesFiltypsLB->removeItem(*it);
|
|
|
163 |
}
|
|
|
164 |
yesFiltypsLB->sort();
|
|
|
165 |
noFiltypsLB->sort();
|
|
|
166 |
}
|
|
|
167 |
|
|
|
168 |
void AdvSearch::delAFiltypPB_clicked()
|
171 |
void AdvSearch::delAFiltypPB_clicked()
|
169 |
{
|
172 |
{
|
170 |
for (unsigned int i = 0; i < yesFiltypsLB->count();i++) {
|
173 |
for (unsigned int i = 0; i < yesFiltypsLB->count();i++) {
|
171 |
yesFiltypsLB->setSelected(i, true);
|
174 |
yesFiltypsLB->setSelected(i, true);
|
172 |
}
|
175 |
}
|
173 |
delFiltypPB_clicked();
|
176 |
delFiltypPB_clicked();
|
174 |
}
|
177 |
}
|
175 |
|
178 |
|
176 |
// Save current list of ignored file types to prefs
|
|
|
177 |
void AdvSearch::saveFileTypes()
|
|
|
178 |
{
|
|
|
179 |
prefs.asearchIgnFilTyps.clear();
|
|
|
180 |
for (unsigned int i = 0; i < noFiltypsLB->count();i++) {
|
|
|
181 |
QListBoxItem *item = noFiltypsLB->item(i);
|
|
|
182 |
prefs.asearchIgnFilTyps.append(item->text());
|
|
|
183 |
}
|
|
|
184 |
rwSettings(true);
|
|
|
185 |
}
|
|
|
186 |
void AdvSearch::addClause()
|
179 |
void AdvSearch::addClause()
|
187 |
{
|
180 |
{
|
188 |
addClause(0);
|
181 |
addClause(0);
|
189 |
}
|
182 |
}
|
190 |
|
183 |
|
|
... |
|
... |
232 |
QSize sz = sizeHint();
|
225 |
QSize sz = sizeHint();
|
233 |
resize(QSize(sz.width()+HORADJ+10, sz.height()+VERTADJ-20));
|
226 |
resize(QSize(sz.width()+HORADJ+10, sz.height()+VERTADJ-20));
|
234 |
}
|
227 |
}
|
235 |
#endif
|
228 |
#endif
|
236 |
|
229 |
|
|
|
230 |
|
|
|
231 |
// Move selected file types from the searched to the ignored box
|
|
|
232 |
void AdvSearch::delFiltypPB_clicked()
|
|
|
233 |
{
|
|
|
234 |
list<int> trl;
|
|
|
235 |
QStringList moved;
|
|
|
236 |
for (unsigned int i = 0; i < yesFiltypsLB->count();i++) {
|
|
|
237 |
QListBoxItem *item = yesFiltypsLB->item(i);
|
|
|
238 |
if (item && item->isSelected()) {
|
|
|
239 |
moved.push_back(item->text());
|
|
|
240 |
trl.push_front(i);
|
|
|
241 |
}
|
|
|
242 |
}
|
|
|
243 |
if (!moved.empty()) {
|
|
|
244 |
noFiltypsLB->insertStringList(moved);
|
|
|
245 |
for (list<int>::iterator it = trl.begin();it != trl.end(); it++)
|
|
|
246 |
yesFiltypsLB->removeItem(*it);
|
|
|
247 |
}
|
|
|
248 |
yesFiltypsLB->sort();
|
|
|
249 |
noFiltypsLB->sort();
|
|
|
250 |
m_ignTypes.clear();
|
|
|
251 |
for (unsigned int i = 0; i < noFiltypsLB->count();i++) {
|
|
|
252 |
QListBoxItem *item = noFiltypsLB->item(i);
|
|
|
253 |
m_ignTypes.append(item->text());
|
|
|
254 |
}
|
|
|
255 |
}
|
|
|
256 |
|
237 |
// Move selected file types from the ignored to the searched box
|
257 |
// Move selected file types from the ignored to the searched box
|
238 |
void AdvSearch::addFiltypPB_clicked()
|
258 |
void AdvSearch::addFiltypPB_clicked()
|
239 |
{
|
259 |
{
|
240 |
list<int> trl;
|
260 |
list<int> trl;
|
241 |
QStringList moved;
|
261 |
QStringList moved;
|
|
... |
|
... |
251 |
for (list<int>::iterator it = trl.begin();it != trl.end(); it++)
|
271 |
for (list<int>::iterator it = trl.begin();it != trl.end(); it++)
|
252 |
noFiltypsLB->removeItem(*it);
|
272 |
noFiltypsLB->removeItem(*it);
|
253 |
}
|
273 |
}
|
254 |
yesFiltypsLB->sort();
|
274 |
yesFiltypsLB->sort();
|
255 |
noFiltypsLB->sort();
|
275 |
noFiltypsLB->sort();
|
|
|
276 |
m_ignTypes.clear();
|
|
|
277 |
for (unsigned int i = 0; i < noFiltypsLB->count();i++) {
|
|
|
278 |
QListBoxItem *item = noFiltypsLB->item(i);
|
|
|
279 |
m_ignTypes.append(item->text());
|
|
|
280 |
}
|
256 |
}
|
281 |
}
|
257 |
|
282 |
|
258 |
void AdvSearch::addAFiltypPB_clicked()
|
283 |
void AdvSearch::addAFiltypPB_clicked()
|
259 |
{
|
284 |
{
|
260 |
for (unsigned int i = 0; i < noFiltypsLB->count();i++) {
|
285 |
for (unsigned int i = 0; i < noFiltypsLB->count();i++) {
|
|
... |
|
... |
276 |
saveFileTypesPB->setEnabled(on);
|
301 |
saveFileTypesPB->setEnabled(on);
|
277 |
}
|
302 |
}
|
278 |
|
303 |
|
279 |
void AdvSearch::restrictCtCB_toggled(bool on)
|
304 |
void AdvSearch::restrictCtCB_toggled(bool on)
|
280 |
{
|
305 |
{
|
281 |
prefs.fileTypesByCats = on;
|
306 |
m_ignByCats = on;
|
|
|
307 |
// Only reset the list if we're enabled. Else this is init from prefs
|
|
|
308 |
if (restrictCtCB->isEnabled())
|
|
|
309 |
m_ignTypes.clear();
|
282 |
fillFileTypes();
|
310 |
fillFileTypes();
|
283 |
}
|
311 |
}
|
284 |
|
|
|
285 |
static map<QString,QString> cat_translations;
|
|
|
286 |
static map<QString,QString> cat_rtranslations;
|
|
|
287 |
|
312 |
|
288 |
void AdvSearch::fillFileTypes()
|
313 |
void AdvSearch::fillFileTypes()
|
289 |
{
|
314 |
{
|
290 |
noFiltypsLB->clear();
|
315 |
noFiltypsLB->clear();
|
291 |
yesFiltypsLB->clear();
|
316 |
yesFiltypsLB->clear();
|
|
|
317 |
noFiltypsLB->insertStringList(m_ignTypes);
|
292 |
|
318 |
|
|
|
319 |
QStringList ql;
|
293 |
if (prefs.fileTypesByCats == false) {
|
320 |
if (m_ignByCats == false) {
|
294 |
list<string> types = rclconfig->getAllMimeTypes();
|
321 |
list<string> types = rclconfig->getAllMimeTypes();
|
295 |
noFiltypsLB->insertStringList(prefs.asearchIgnFilTyps);
|
|
|
296 |
|
|
|
297 |
QStringList ql;
|
|
|
298 |
for (list<string>::iterator it = types.begin();
|
322 |
for (list<string>::iterator it = types.begin();
|
299 |
it != types.end(); it++) {
|
323 |
it != types.end(); it++) {
|
300 |
if (prefs.asearchIgnFilTyps.findIndex(it->c_str())<0)
|
324 |
QString qs = QString::fromUtf8(it->c_str());
|
301 |
ql.append(it->c_str());
|
325 |
if (m_ignTypes.findIndex(qs) < 0)
|
|
|
326 |
ql.append(qs);
|
302 |
}
|
327 |
}
|
303 |
yesFiltypsLB->insertStringList(ql);
|
|
|
304 |
} else {
|
328 |
} else {
|
305 |
cat_translations.clear();
|
|
|
306 |
// Make sure we have entries for all defined categories
|
|
|
307 |
// Translations for known cats
|
|
|
308 |
cat_translations[QString::fromUtf8("texts")] = tr("texts");
|
|
|
309 |
cat_rtranslations[tr("texts")] = QString::fromUtf8("texts");
|
|
|
310 |
|
|
|
311 |
cat_translations[QString::fromUtf8("spreadsheets")] =
|
|
|
312 |
tr("spreadsheets");
|
|
|
313 |
cat_rtranslations[tr("spreadsheets")] =
|
|
|
314 |
QString::fromUtf8("spreadsheets");
|
|
|
315 |
|
|
|
316 |
cat_translations[QString::fromUtf8("presentations")] =
|
|
|
317 |
tr("presentations");
|
|
|
318 |
cat_rtranslations[tr("presentations")] =
|
|
|
319 |
QString::fromUtf8("presentations");
|
|
|
320 |
|
|
|
321 |
cat_translations[QString::fromUtf8("media")] = tr("media");
|
|
|
322 |
cat_rtranslations[tr("media")] = QString::fromUtf8("media");
|
|
|
323 |
|
|
|
324 |
cat_translations[QString::fromUtf8("messages")] = tr("messages");
|
|
|
325 |
cat_rtranslations[tr("messages")] = QString::fromUtf8("messages");
|
|
|
326 |
|
|
|
327 |
cat_translations[QString::fromUtf8("other")] = tr("other");
|
|
|
328 |
cat_rtranslations[tr("other")] = QString::fromUtf8("other");
|
|
|
329 |
|
|
|
330 |
list<string> cats;
|
329 |
list<string> cats;
|
331 |
rclconfig->getMimeCategories(cats);
|
330 |
rclconfig->getMimeCategories(cats);
|
332 |
QStringList ql;
|
|
|
333 |
for (list<string>::const_iterator it = cats.begin();
|
331 |
for (list<string>::const_iterator it = cats.begin();
|
334 |
it != cats.end(); it++) {
|
332 |
it != cats.end(); it++) {
|
335 |
map<QString, QString>::const_iterator it1;
|
333 |
map<QString, QString>::const_iterator it1;
|
336 |
if ((it1 =
|
334 |
QString cat;
|
337 |
cat_translations.find(QString::fromUtf8((*it).c_str())))
|
335 |
if ((it1 = cat_translations.find(QString::fromUtf8(it->c_str())))
|
338 |
!= cat_translations.end()) {
|
336 |
!= cat_translations.end()) {
|
339 |
ql.append(it1->second);
|
337 |
cat = it1->second;
|
340 |
} else {
|
338 |
} else {
|
341 |
ql.append(QString::fromUtf8((*it).c_str()));
|
339 |
cat = QString::fromUtf8(it->c_str());
|
342 |
}
|
340 |
}
|
|
|
341 |
if (m_ignTypes.findIndex(cat) < 0)
|
|
|
342 |
ql.append(cat);
|
343 |
}
|
343 |
}
|
|
|
344 |
}
|
344 |
yesFiltypsLB->insertStringList(ql);
|
345 |
yesFiltypsLB->insertStringList(ql);
|
345 |
}
|
346 |
}
|
|
|
347 |
|
|
|
348 |
// Save current list of ignored file types to prefs
|
|
|
349 |
void AdvSearch::saveFileTypes()
|
|
|
350 |
{
|
|
|
351 |
prefs.asearchIgnFilTyps = m_ignTypes;
|
|
|
352 |
prefs.fileTypesByCats = m_ignByCats;
|
|
|
353 |
rwSettings(true);
|
346 |
}
|
354 |
}
|
347 |
|
355 |
|
348 |
using namespace Rcl;
|
356 |
using namespace Rcl;
|
349 |
void AdvSearch::searchPB_clicked()
|
357 |
void AdvSearch::searchPB_clicked()
|
350 |
{
|
358 |
{
|