|
a/src/qtgui/advsearch_w.cpp |
|
b/src/qtgui/advsearch_w.cpp |
|
... |
|
... |
60 |
|
60 |
|
61 |
|
61 |
|
62 |
void AdvSearch::init()
|
62 |
void AdvSearch::init()
|
63 |
{
|
63 |
{
|
64 |
(void)new HelpClient(this);
|
64 |
(void)new HelpClient(this);
|
65 |
HelpClient::installMap(this->name(), "RCL.SEARCH.COMPLEX");
|
65 |
HelpClient::installMap((const char *)objectName().toUtf8(),
|
|
|
66 |
"RCL.SEARCH.COMPLEX");
|
66 |
|
67 |
|
67 |
this->installEventFilter(this);
|
68 |
this->installEventFilter(this);
|
68 |
|
69 |
|
69 |
// signals and slots connections
|
70 |
// signals and slots connections
|
70 |
connect(delFiltypPB, SIGNAL(clicked()), this, SLOT(delFiltypPB_clicked()));
|
71 |
connect(delFiltypPB, SIGNAL(clicked()), this, SLOT(delFiltypPB_clicked()));
|
|
... |
|
... |
84 |
connect(saveFileTypesPB, SIGNAL(clicked()),
|
85 |
connect(saveFileTypesPB, SIGNAL(clicked()),
|
85 |
this, SLOT(saveFileTypes()));
|
86 |
this, SLOT(saveFileTypes()));
|
86 |
connect(addClausePB, SIGNAL(clicked()), this, SLOT(addClause()));
|
87 |
connect(addClausePB, SIGNAL(clicked()), this, SLOT(addClause()));
|
87 |
connect(delClausePB, SIGNAL(clicked()), this, SLOT(delClause()));
|
88 |
connect(delClausePB, SIGNAL(clicked()), this, SLOT(delClause()));
|
88 |
|
89 |
|
89 |
conjunctCMB->insertItem(tr("All clauses"));
|
90 |
conjunctCMB->insertItem(1, tr("All clauses"));
|
90 |
conjunctCMB->insertItem(tr("Any clause"));
|
91 |
conjunctCMB->insertItem(2, tr("Any clause"));
|
91 |
|
92 |
|
92 |
// Create preconfigured clauses
|
93 |
// Create preconfigured clauses
|
93 |
for (unsigned int i = 0; i < iclausescnt; i++) {
|
94 |
for (unsigned int i = 0; i < iclausescnt; i++) {
|
94 |
addClause(initclausetypes[i]);
|
95 |
addClause(initclausetypes[i]);
|
95 |
}
|
96 |
}
|
|
... |
|
... |
114 |
m_ignByCats = prefs.fileTypesByCats;
|
115 |
m_ignByCats = prefs.fileTypesByCats;
|
115 |
restrictCtCB->setEnabled(false);
|
116 |
restrictCtCB->setEnabled(false);
|
116 |
restrictCtCB->setChecked(m_ignByCats);
|
117 |
restrictCtCB->setChecked(m_ignByCats);
|
117 |
fillFileTypes();
|
118 |
fillFileTypes();
|
118 |
|
119 |
|
119 |
subtreeCMB->insertStringList(prefs.asearchSubdirHist);
|
120 |
subtreeCMB->insertItems(0, prefs.asearchSubdirHist);
|
120 |
subtreeCMB->setEditText("");
|
121 |
subtreeCMB->setEditText("");
|
121 |
|
122 |
|
122 |
// The clauseline frame is needed to force designer to accept a
|
123 |
// The clauseline frame is needed to force designer to accept a
|
123 |
// vbox to englobe the base clauses grid and 'something else' (the
|
124 |
// vbox to englobe the base clauses grid and 'something else' (the
|
124 |
// vbox is so that we can then insert SearchClauseWs), but we
|
125 |
// vbox is so that we can then insert SearchClauseWs), but we
|
|
... |
|
... |
149 |
{
|
150 |
{
|
150 |
// LOGDEB(("AdvSearch::eventFilter. Type %d\n", (int)event->type()));
|
151 |
// LOGDEB(("AdvSearch::eventFilter. Type %d\n", (int)event->type()));
|
151 |
if (event->type() == QEvent::KeyPress ||
|
152 |
if (event->type() == QEvent::KeyPress ||
|
152 |
event->type() == QEvent::ShortcutOverride) {
|
153 |
event->type() == QEvent::ShortcutOverride) {
|
153 |
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
|
154 |
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
|
154 |
if (ke->key() == Qt::Key_Q && (ke->state() & Qt::ControlButton)) {
|
155 |
if (ke->key() == Qt::Key_Q && (ke->modifiers() & Qt::ControlModifier)) {
|
155 |
recollNeedsExit = 1;
|
156 |
recollNeedsExit = 1;
|
156 |
return true;
|
157 |
return true;
|
157 |
}
|
158 |
}
|
158 |
}
|
159 |
}
|
159 |
return false;
|
160 |
return false;
|
|
... |
|
... |
163 |
{
|
164 |
{
|
164 |
// Save my state
|
165 |
// Save my state
|
165 |
prefs.advSearchClauses.clear();
|
166 |
prefs.advSearchClauses.clear();
|
166 |
for (std::list<SearchClauseW *>::iterator cit = m_clauseWins.begin();
|
167 |
for (std::list<SearchClauseW *>::iterator cit = m_clauseWins.begin();
|
167 |
cit != m_clauseWins.end(); cit++) {
|
168 |
cit != m_clauseWins.end(); cit++) {
|
168 |
prefs.advSearchClauses.push_back((*cit)->sTpCMB->currentItem());
|
169 |
prefs.advSearchClauses.push_back((*cit)->sTpCMB->currentIndex());
|
169 |
}
|
170 |
}
|
170 |
}
|
171 |
}
|
171 |
|
172 |
|
172 |
bool AdvSearch::close()
|
173 |
bool AdvSearch::close()
|
173 |
{
|
174 |
{
|
|
... |
|
... |
288 |
if (m_ignByCats == false) {
|
289 |
if (m_ignByCats == false) {
|
289 |
list<string> types = rclconfig->getAllMimeTypes();
|
290 |
list<string> types = rclconfig->getAllMimeTypes();
|
290 |
for (list<string>::iterator it = types.begin();
|
291 |
for (list<string>::iterator it = types.begin();
|
291 |
it != types.end(); it++) {
|
292 |
it != types.end(); it++) {
|
292 |
QString qs = QString::fromUtf8(it->c_str());
|
293 |
QString qs = QString::fromUtf8(it->c_str());
|
293 |
if (m_ignTypes.findIndex(qs) < 0)
|
294 |
if (m_ignTypes.indexOf(qs) < 0)
|
294 |
ql.append(qs);
|
295 |
ql.append(qs);
|
295 |
}
|
296 |
}
|
296 |
} else {
|
297 |
} else {
|
297 |
list<string> cats;
|
298 |
list<string> cats;
|
298 |
rclconfig->getMimeCategories(cats);
|
299 |
rclconfig->getMimeCategories(cats);
|
|
... |
|
... |
304 |
!= cat_translations.end()) {
|
305 |
!= cat_translations.end()) {
|
305 |
cat = it1->second;
|
306 |
cat = it1->second;
|
306 |
} else {
|
307 |
} else {
|
307 |
cat = QString::fromUtf8(it->c_str());
|
308 |
cat = QString::fromUtf8(it->c_str());
|
308 |
}
|
309 |
}
|
309 |
if (m_ignTypes.findIndex(cat) < 0)
|
310 |
if (m_ignTypes.indexOf(cat) < 0)
|
310 |
ql.append(cat);
|
311 |
ql.append(cat);
|
311 |
}
|
312 |
}
|
312 |
}
|
313 |
}
|
313 |
yesFiltypsLB->insertItems(0, ql);
|
314 |
yesFiltypsLB->insertItems(0, ql);
|
314 |
}
|
315 |
}
|
|
... |
|
... |
322 |
}
|
323 |
}
|
323 |
|
324 |
|
324 |
using namespace Rcl;
|
325 |
using namespace Rcl;
|
325 |
void AdvSearch::runSearch()
|
326 |
void AdvSearch::runSearch()
|
326 |
{
|
327 |
{
|
327 |
RefCntr<SearchData> sdata(new SearchData(conjunctCMB->currentItem() == 0 ?
|
328 |
RefCntr<SearchData> sdata(new SearchData(conjunctCMB->currentIndex() == 0 ?
|
328 |
SCLT_AND : SCLT_OR));
|
329 |
SCLT_AND : SCLT_OR));
|
329 |
bool hasclause = false;
|
330 |
bool hasclause = false;
|
330 |
|
331 |
|
331 |
for (list<SearchClauseW*>::iterator it = m_clauseWins.begin();
|
332 |
for (list<SearchClauseW*>::iterator it = m_clauseWins.begin();
|
332 |
it != m_clauseWins.end(); it++) {
|
333 |
it != m_clauseWins.end(); it++) {
|
|
... |
|
... |
337 |
}
|
338 |
}
|
338 |
}
|
339 |
}
|
339 |
if (!hasclause)
|
340 |
if (!hasclause)
|
340 |
return;
|
341 |
return;
|
341 |
|
342 |
|
342 |
if (restrictFtCB->isOn() && noFiltypsLB->count() > 0) {
|
343 |
if (restrictFtCB->isChecked() && noFiltypsLB->count() > 0) {
|
343 |
for (int i = 0; i < yesFiltypsLB->count(); i++) {
|
344 |
for (int i = 0; i < yesFiltypsLB->count(); i++) {
|
344 |
if (restrictCtCB->isOn()) {
|
345 |
if (restrictCtCB->isChecked()) {
|
345 |
QString qcat = yesFiltypsLB->item(i)->text();
|
346 |
QString qcat = yesFiltypsLB->item(i)->text();
|
346 |
map<QString,QString>::const_iterator qit;
|
347 |
map<QString,QString>::const_iterator qit;
|
347 |
string cat;
|
348 |
string cat;
|
348 |
if ((qit = cat_rtranslations.find(qcat)) !=
|
349 |
if ((qit = cat_rtranslations.find(qcat)) !=
|
349 |
cat_rtranslations.end()) {
|
350 |
cat_rtranslations.end()) {
|
350 |
cat = (const char *)qit->second.utf8();
|
351 |
cat = (const char *)qit->second.toUtf8();
|
351 |
} else {
|
352 |
} else {
|
352 |
cat = (const char *)qcat.utf8();
|
353 |
cat = (const char *)qcat.toUtf8();
|
353 |
}
|
354 |
}
|
354 |
list<string> types;
|
355 |
list<string> types;
|
355 |
rclconfig->getMimeCatTypes(cat, types);
|
356 |
rclconfig->getMimeCatTypes(cat, types);
|
356 |
for (list<string>::const_iterator it = types.begin();
|
357 |
for (list<string>::const_iterator it = types.begin();
|
357 |
it != types.end(); it++) {
|
358 |
it != types.end(); it++) {
|
358 |
sdata->addFiletype(*it);
|
359 |
sdata->addFiletype(*it);
|
359 |
}
|
360 |
}
|
360 |
} else {
|
361 |
} else {
|
361 |
sdata->addFiletype((const char *)
|
362 |
sdata->addFiletype((const char *)
|
362 |
yesFiltypsLB->item(i)->text().utf8());
|
363 |
yesFiltypsLB->item(i)->text().toUtf8());
|
363 |
}
|
364 |
}
|
364 |
}
|
365 |
}
|
365 |
}
|
366 |
}
|
366 |
|
367 |
|
367 |
if (!subtreeCMB->currentText().isEmpty()) {
|
368 |
if (!subtreeCMB->currentText().isEmpty()) {
|
368 |
QString current = subtreeCMB->currentText();
|
369 |
QString current = subtreeCMB->currentText();
|
369 |
sdata->setTopdir((const char*)subtreeCMB->currentText().utf8());
|
370 |
sdata->setTopdir((const char*)subtreeCMB->currentText().toUtf8());
|
370 |
// Keep history list clean and sorted. Maybe there would be a
|
371 |
// Keep history list clean and sorted. Maybe there would be a
|
371 |
// simpler way to do this
|
372 |
// simpler way to do this
|
372 |
list<QString> entries;
|
373 |
list<QString> entries;
|
373 |
for (int i = 0; i < subtreeCMB->count(); i++) {
|
374 |
for (int i = 0; i < subtreeCMB->count(); i++) {
|
374 |
entries.push_back(subtreeCMB->text(i));
|
375 |
entries.push_back(subtreeCMB->itemText(i));
|
375 |
}
|
376 |
}
|
376 |
entries.push_back(subtreeCMB->currentText());
|
377 |
entries.push_back(subtreeCMB->currentText());
|
377 |
entries.sort();
|
378 |
entries.sort();
|
378 |
unique(entries.begin(), entries.end());
|
379 |
unique(entries.begin(), entries.end());
|
379 |
subtreeCMB->clear();
|
380 |
subtreeCMB->clear();
|
380 |
for (list<QString>::iterator it = entries.begin();
|
381 |
for (list<QString>::iterator it = entries.begin();
|
381 |
it != entries.end(); it++) {
|
382 |
it != entries.end(); it++) {
|
382 |
subtreeCMB->insertItem(*it);
|
383 |
subtreeCMB->addItem(*it);
|
383 |
}
|
384 |
}
|
384 |
subtreeCMB->setCurrentText(current);
|
385 |
subtreeCMB->setCurrentIndex(subtreeCMB->findText(current));
|
385 |
prefs.asearchSubdirHist.clear();
|
386 |
prefs.asearchSubdirHist.clear();
|
386 |
for (int index = 0; index < subtreeCMB->count(); index++)
|
387 |
for (int index = 0; index < subtreeCMB->count(); index++)
|
387 |
prefs.asearchSubdirHist.push_back(subtreeCMB->text(index));
|
388 |
prefs.asearchSubdirHist.push_back(subtreeCMB->itemText(index));
|
388 |
}
|
389 |
}
|
389 |
saveCnf();
|
390 |
saveCnf();
|
390 |
|
391 |
|
391 |
emit startSearch(sdata);
|
392 |
emit startSearch(sdata);
|
392 |
}
|
393 |
}
|