|
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.11 2006-11-17 10:08:12 dockes Exp $ (C) 2005 J.F.Dockes";
|
2 |
static char rcsid[] = "@(#$Id: advsearch_w.cpp,v 1.12 2006-11-17 15:26:40 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
|
|
... |
|
... |
48 |
#include "guiutils.h"
|
48 |
#include "guiutils.h"
|
49 |
|
49 |
|
50 |
extern RclConfig *rclconfig;
|
50 |
extern RclConfig *rclconfig;
|
51 |
|
51 |
|
52 |
static const int initclausetypes[] = {1, 3, 0, 0, 2, 5};
|
52 |
static const int initclausetypes[] = {1, 3, 0, 0, 2, 5};
|
|
|
53 |
static const unsigned int iclausescnt = sizeof(initclausetypes) / sizeof(int);
|
53 |
|
54 |
|
54 |
void AdvSearch::init()
|
55 |
void AdvSearch::init()
|
55 |
{
|
56 |
{
|
56 |
// signals and slots connections
|
57 |
// signals and slots connections
|
57 |
connect(delFiltypPB, SIGNAL(clicked()), this, SLOT(delFiltypPB_clicked()));
|
58 |
connect(delFiltypPB, SIGNAL(clicked()), this, SLOT(delFiltypPB_clicked()));
|
|
... |
|
... |
69 |
connect(addAFiltypPB, SIGNAL(clicked()),
|
70 |
connect(addAFiltypPB, SIGNAL(clicked()),
|
70 |
this, SLOT(addAFiltypPB_clicked()));
|
71 |
this, SLOT(addAFiltypPB_clicked()));
|
71 |
connect(saveFileTypesPB, SIGNAL(clicked()),
|
72 |
connect(saveFileTypesPB, SIGNAL(clicked()),
|
72 |
this, SLOT(saveFileTypes()));
|
73 |
this, SLOT(saveFileTypes()));
|
73 |
connect(addClausePB, SIGNAL(clicked()), this, SLOT(addClause()));
|
74 |
connect(addClausePB, SIGNAL(clicked()), this, SLOT(addClause()));
|
|
|
75 |
connect(delClausePB, SIGNAL(clicked()), this, SLOT(delClause()));
|
74 |
|
76 |
|
75 |
conjunctCMB->insertItem(tr("All clauses"));
|
77 |
conjunctCMB->insertItem(tr("All clauses"));
|
76 |
conjunctCMB->insertItem(tr("Any clause"));
|
78 |
conjunctCMB->insertItem(tr("Any clause"));
|
77 |
|
79 |
|
78 |
// Create preconfigured clauses
|
80 |
// Create preconfigured clauses
|
79 |
for (unsigned int i = 0; i < sizeof(initclausetypes) / sizeof(int); i++) {
|
81 |
for (unsigned int i = 0; i < iclausescnt; i++) {
|
80 |
addClause(initclausetypes[i]);
|
82 |
addClause(initclausetypes[i]);
|
81 |
}
|
83 |
}
|
82 |
|
84 |
// Tune initial state according to last saved
|
|
|
85 |
{
|
|
|
86 |
std::list<SearchClauseW *>::iterator cit = m_clauseWins.begin();
|
|
|
87 |
for (vector<int>::iterator it = prefs.advSearchClauses.begin();
|
|
|
88 |
it != prefs.advSearchClauses.end(); it++) {
|
|
|
89 |
if (cit != m_clauseWins.end()) {
|
|
|
90 |
(*cit)->tpChange(*it);
|
|
|
91 |
cit++;
|
|
|
92 |
} else {
|
|
|
93 |
addClause(*it);
|
|
|
94 |
}
|
|
|
95 |
}
|
|
|
96 |
}
|
|
|
97 |
|
83 |
// Initialize lists of accepted and ignored mime types from config
|
98 |
// Initialize lists of accepted and ignored mime types from config
|
84 |
// and settings
|
99 |
// and settings
|
85 |
list<string> types = rclconfig->getAllMimeTypes();
|
100 |
list<string> types = rclconfig->getAllMimeTypes();
|
86 |
noFiltypsLB->insertStringList(prefs.asearchIgnFilTyps);
|
101 |
noFiltypsLB->insertStringList(prefs.asearchIgnFilTyps);
|
87 |
|
102 |
|
|
... |
|
... |
100 |
// vbox is so that we can then insert SearchClauseWs), but we
|
115 |
// vbox is so that we can then insert SearchClauseWs), but we
|
101 |
// don't want to see it.
|
116 |
// don't want to see it.
|
102 |
clauseline->close();
|
117 |
clauseline->close();
|
103 |
}
|
118 |
}
|
104 |
|
119 |
|
|
|
120 |
void AdvSearch::saveCnf()
|
|
|
121 |
{
|
|
|
122 |
// Save my state
|
|
|
123 |
prefs.advSearchClauses.clear();
|
|
|
124 |
for (std::list<SearchClauseW *>::iterator cit = m_clauseWins.begin();
|
|
|
125 |
cit != m_clauseWins.end(); cit++) {
|
|
|
126 |
prefs.advSearchClauses.push_back((*cit)->sTpCMB->currentItem());
|
|
|
127 |
}
|
|
|
128 |
}
|
|
|
129 |
|
|
|
130 |
bool AdvSearch::close()
|
|
|
131 |
{
|
|
|
132 |
saveCnf();
|
|
|
133 |
return AdvSearchBase::close();
|
|
|
134 |
}
|
105 |
|
135 |
|
106 |
// Move selected file types from the searched to the ignored box
|
136 |
// Move selected file types from the searched to the ignored box
|
107 |
void AdvSearch::delFiltypPB_clicked()
|
137 |
void AdvSearch::delFiltypPB_clicked()
|
108 |
{
|
138 |
{
|
109 |
list<int> trl;
|
139 |
list<int> trl;
|
|
... |
|
... |
153 |
connect(w->wordsLE, SIGNAL(returnPressed()),
|
183 |
connect(w->wordsLE, SIGNAL(returnPressed()),
|
154 |
this, SLOT(searchPB_clicked()));
|
184 |
this, SLOT(searchPB_clicked()));
|
155 |
clauseVBox->addWidget(w);
|
185 |
clauseVBox->addWidget(w);
|
156 |
w->show();
|
186 |
w->show();
|
157 |
w->tpChange(tp);
|
187 |
w->tpChange(tp);
|
|
|
188 |
if (m_clauseWins.size() > iclausescnt) {
|
|
|
189 |
delClausePB->setEnabled(true);
|
|
|
190 |
} else {
|
|
|
191 |
delClausePB->setEnabled(false);
|
|
|
192 |
}
|
158 |
// Have to adjust the size else we lose the bottom buttons! Why?
|
193 |
// Have to adjust the size else we lose the bottom buttons! Why?
|
159 |
QSize sz = AdvSearchBaseLayout->sizeHint();
|
194 |
QSize sz = AdvSearchBaseLayout->sizeHint();
|
160 |
resize(QSize(sz.width()+40, sz.height()+80));
|
195 |
resize(QSize(sz.width()+40, sz.height()+80));
|
|
|
196 |
}
|
|
|
197 |
|
|
|
198 |
void AdvSearch::delClause()
|
|
|
199 |
{
|
|
|
200 |
if (m_clauseWins.size() <= iclausescnt)
|
|
|
201 |
return;
|
|
|
202 |
delete m_clauseWins.back();
|
|
|
203 |
m_clauseWins.pop_back();
|
|
|
204 |
if (m_clauseWins.size() > iclausescnt) {
|
|
|
205 |
delClausePB->setEnabled(true);
|
|
|
206 |
} else {
|
|
|
207 |
delClausePB->setEnabled(false);
|
|
|
208 |
}
|
|
|
209 |
QSize sz = AdvSearchBaseLayout->sizeHint();
|
|
|
210 |
resize(QSize(sz.width()+40, sz.height()+80));
|
|
|
211 |
}
|
|
|
212 |
|
|
|
213 |
void AdvSearch::polish()
|
|
|
214 |
{
|
|
|
215 |
QSize sz = AdvSearchBaseLayout->sizeHint();
|
|
|
216 |
resize(QSize(sz.width()+40, sz.height()+80));
|
|
|
217 |
AdvSearchBase::polish();
|
161 |
}
|
218 |
}
|
162 |
|
219 |
|
163 |
// Move selected file types from the ignored to the searched box
|
220 |
// Move selected file types from the ignored to the searched box
|
164 |
void AdvSearch::addFiltypPB_clicked()
|
221 |
void AdvSearch::addFiltypPB_clicked()
|
165 |
{
|
222 |
{
|
|
... |
|
... |
246 |
subtreeCMB->listBox()->sort();
|
303 |
subtreeCMB->listBox()->sort();
|
247 |
prefs.asearchSubdirHist.clear();
|
304 |
prefs.asearchSubdirHist.clear();
|
248 |
for (int index = 0; index < subtreeCMB->count(); index++)
|
305 |
for (int index = 0; index < subtreeCMB->count(); index++)
|
249 |
prefs.asearchSubdirHist.push_back(subtreeCMB->text(index));
|
306 |
prefs.asearchSubdirHist.push_back(subtreeCMB->text(index));
|
250 |
}
|
307 |
}
|
|
|
308 |
saveCnf();
|
|
|
309 |
|
251 |
emit startSearch(sdata);
|
310 |
emit startSearch(sdata);
|
252 |
}
|
311 |
}
|
253 |
|
|
|
254 |
|
312 |
|
255 |
void AdvSearch::browsePB_clicked()
|
313 |
void AdvSearch::browsePB_clicked()
|
256 |
{
|
314 |
{
|
257 |
QString dir = QFileDialog::getExistingDirectory();
|
315 |
QString dir = QFileDialog::getExistingDirectory();
|
258 |
subtreeCMB->setEditText(dir);
|
316 |
subtreeCMB->setEditText(dir);
|