|
a/src/qtgui/advsearch_w.cpp |
|
b/src/qtgui/advsearch_w.cpp |
|
... |
|
... |
24 |
#include <qlabel.h>
|
24 |
#include <qlabel.h>
|
25 |
#include <qlineedit.h>
|
25 |
#include <qlineedit.h>
|
26 |
#include <qframe.h>
|
26 |
#include <qframe.h>
|
27 |
#include <qcheckbox.h>
|
27 |
#include <qcheckbox.h>
|
28 |
#include <qevent.h>
|
28 |
#include <qevent.h>
|
29 |
|
|
|
30 |
#if (QT_VERSION < 0x040000)
|
|
|
31 |
#include <qcombobox.h>
|
|
|
32 |
#include <qlistbox.h>
|
|
|
33 |
#define Q34EVOVERRIDE QEvent::AccelOverride
|
|
|
34 |
#else
|
|
|
35 |
#include <q3combobox.h>
|
|
|
36 |
#include <q3listbox.h>
|
|
|
37 |
#define Q34EVOVERRIDE QEvent::ShortcutOverride
|
|
|
38 |
#endif
|
|
|
39 |
|
|
|
40 |
#include <qlayout.h>
|
29 |
#include <qlayout.h>
|
41 |
#include <qtooltip.h>
|
30 |
#include <qtooltip.h>
|
42 |
#include <qwhatsthis.h>
|
31 |
#include <qwhatsthis.h>
|
43 |
#include <qfiledialog.h>
|
32 |
#include <qfiledialog.h>
|
44 |
#include <qmessagebox.h>
|
33 |
#include <qmessagebox.h>
|
|
... |
|
... |
157 |
}
|
146 |
}
|
158 |
|
147 |
|
159 |
bool AdvSearch::eventFilter(QObject *, QEvent *event)
|
148 |
bool AdvSearch::eventFilter(QObject *, QEvent *event)
|
160 |
{
|
149 |
{
|
161 |
// LOGDEB(("AdvSearch::eventFilter. Type %d\n", (int)event->type()));
|
150 |
// LOGDEB(("AdvSearch::eventFilter. Type %d\n", (int)event->type()));
|
162 |
if (event->type() == QEvent::KeyPress || event->type() == Q34EVOVERRIDE) {
|
151 |
if (event->type() == QEvent::KeyPress ||
|
|
|
152 |
event->type() == QEvent::ShortcutOverride) {
|
163 |
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
|
153 |
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
|
164 |
if (ke->key() == Qt::Key_Q && (ke->state() & Qt::ControlButton)) {
|
154 |
if (ke->key() == Qt::Key_Q && (ke->state() & Qt::ControlButton)) {
|
165 |
recollNeedsExit = 1;
|
155 |
recollNeedsExit = 1;
|
166 |
return true;
|
156 |
return true;
|
167 |
}
|
157 |
}
|
|
... |
|
... |
183 |
{
|
173 |
{
|
184 |
saveCnf();
|
174 |
saveCnf();
|
185 |
return QWidget::close();
|
175 |
return QWidget::close();
|
186 |
}
|
176 |
}
|
187 |
|
177 |
|
188 |
#if (QT_VERSION >= 0x040000)
|
|
|
189 |
#define QListBoxItem Q3ListBoxItem
|
|
|
190 |
#define clauseVBox Ui::AdvSearchBase::clauseVBox
|
|
|
191 |
#define AdvSearchBaseLayout Ui::AdvSearchBase::AdvSearchBaseLayout
|
|
|
192 |
#endif
|
|
|
193 |
|
|
|
194 |
void AdvSearch::delAFiltypPB_clicked()
|
178 |
void AdvSearch::delAFiltypPB_clicked()
|
195 |
{
|
179 |
{
|
196 |
for (unsigned int i = 0; i < yesFiltypsLB->count();i++) {
|
180 |
yesFiltypsLB->selectAll();
|
197 |
yesFiltypsLB->setSelected(i, true);
|
|
|
198 |
}
|
|
|
199 |
delFiltypPB_clicked();
|
181 |
delFiltypPB_clicked();
|
200 |
}
|
182 |
}
|
201 |
|
183 |
|
202 |
void AdvSearch::addClause()
|
184 |
void AdvSearch::addClause()
|
203 |
{
|
185 |
{
|
|
... |
|
... |
232 |
}
|
214 |
}
|
233 |
|
215 |
|
234 |
// Move selected file types from the searched to the ignored box
|
216 |
// Move selected file types from the searched to the ignored box
|
235 |
void AdvSearch::delFiltypPB_clicked()
|
217 |
void AdvSearch::delFiltypPB_clicked()
|
236 |
{
|
218 |
{
|
237 |
list<int> trl;
|
219 |
QList<QListWidgetItem *> items = yesFiltypsLB->selectedItems();
|
238 |
QStringList moved;
|
220 |
for (QList<QListWidgetItem *>::iterator it = items.begin();
|
239 |
for (unsigned int i = 0; i < yesFiltypsLB->count();i++) {
|
221 |
it != items.end(); it++) {
|
|
|
222 |
int row = yesFiltypsLB->row(*it);
|
240 |
QListBoxItem *item = yesFiltypsLB->item(i);
|
223 |
QListWidgetItem *item = yesFiltypsLB->takeItem(row);
|
241 |
if (item && item->isSelected()) {
|
224 |
noFiltypsLB->insertItem(0, item);
|
242 |
moved.push_back(item->text());
|
|
|
243 |
trl.push_front(i);
|
|
|
244 |
}
|
|
|
245 |
}
|
225 |
}
|
246 |
if (!moved.empty()) {
|
226 |
guiListsToIgnTypes();
|
247 |
noFiltypsLB->insertStringList(moved);
|
|
|
248 |
for (list<int>::iterator it = trl.begin();it != trl.end(); it++)
|
|
|
249 |
yesFiltypsLB->removeItem(*it);
|
|
|
250 |
}
|
|
|
251 |
yesFiltypsLB->sort();
|
|
|
252 |
noFiltypsLB->sort();
|
|
|
253 |
m_ignTypes.clear();
|
|
|
254 |
for (unsigned int i = 0; i < noFiltypsLB->count();i++) {
|
|
|
255 |
QListBoxItem *item = noFiltypsLB->item(i);
|
|
|
256 |
m_ignTypes.append(item->text());
|
|
|
257 |
}
|
|
|
258 |
}
|
227 |
}
|
259 |
|
228 |
|
260 |
// Move selected file types from the ignored to the searched box
|
229 |
// Move selected file types from the ignored to the searched box
|
261 |
void AdvSearch::addFiltypPB_clicked()
|
230 |
void AdvSearch::addFiltypPB_clicked()
|
262 |
{
|
231 |
{
|
263 |
list<int> trl;
|
232 |
QList<QListWidgetItem *> items = noFiltypsLB->selectedItems();
|
264 |
QStringList moved;
|
233 |
for (QList<QListWidgetItem *>::iterator it = items.begin();
|
265 |
for (unsigned int i = 0; i < noFiltypsLB->count(); i++) {
|
234 |
it != items.end(); it++) {
|
|
|
235 |
int row = noFiltypsLB->row(*it);
|
266 |
QListBoxItem *item = noFiltypsLB->item(i);
|
236 |
QListWidgetItem *item = noFiltypsLB->takeItem(row);
|
267 |
if (item && item->isSelected()) {
|
237 |
yesFiltypsLB->insertItem(0, item);
|
268 |
moved.push_back(item->text());
|
|
|
269 |
trl.push_front(i);
|
|
|
270 |
}
|
|
|
271 |
}
|
238 |
}
|
272 |
if (!moved.empty()) {
|
239 |
guiListsToIgnTypes();
|
273 |
yesFiltypsLB->insertStringList(moved);
|
240 |
}
|
274 |
for (list<int>::iterator it = trl.begin();it != trl.end(); it++)
|
241 |
|
275 |
noFiltypsLB->removeItem(*it);
|
242 |
// Compute list of ignored mime type from widget lists
|
276 |
}
|
243 |
void AdvSearch::guiListsToIgnTypes()
|
|
|
244 |
{
|
277 |
yesFiltypsLB->sort();
|
245 |
yesFiltypsLB->sortItems();
|
278 |
noFiltypsLB->sort();
|
246 |
noFiltypsLB->sortItems();
|
279 |
m_ignTypes.clear();
|
247 |
m_ignTypes.clear();
|
280 |
for (unsigned int i = 0; i < noFiltypsLB->count();i++) {
|
248 |
for (int i = 0; i < noFiltypsLB->count();i++) {
|
281 |
QListBoxItem *item = noFiltypsLB->item(i);
|
249 |
QListWidgetItem *item = noFiltypsLB->item(i);
|
282 |
m_ignTypes.append(item->text());
|
250 |
m_ignTypes.append(item->text());
|
283 |
}
|
251 |
}
|
284 |
}
|
252 |
}
|
285 |
|
|
|
286 |
void AdvSearch::addAFiltypPB_clicked()
|
253 |
void AdvSearch::addAFiltypPB_clicked()
|
287 |
{
|
254 |
{
|
288 |
for (unsigned int i = 0; i < noFiltypsLB->count();i++) {
|
255 |
noFiltypsLB->selectAll();
|
289 |
noFiltypsLB->setSelected(i, true);
|
|
|
290 |
}
|
|
|
291 |
addFiltypPB_clicked();
|
256 |
addFiltypPB_clicked();
|
292 |
}
|
257 |
}
|
293 |
|
258 |
|
294 |
// Activate file type selection
|
259 |
// Activate file type selection
|
295 |
void AdvSearch::restrictFtCB_toggled(bool on)
|
260 |
void AdvSearch::restrictFtCB_toggled(bool on)
|
|
... |
|
... |
315 |
|
280 |
|
316 |
void AdvSearch::fillFileTypes()
|
281 |
void AdvSearch::fillFileTypes()
|
317 |
{
|
282 |
{
|
318 |
noFiltypsLB->clear();
|
283 |
noFiltypsLB->clear();
|
319 |
yesFiltypsLB->clear();
|
284 |
yesFiltypsLB->clear();
|
320 |
noFiltypsLB->insertStringList(m_ignTypes);
|
285 |
noFiltypsLB->insertItems(0, m_ignTypes);
|
321 |
|
286 |
|
322 |
QStringList ql;
|
287 |
QStringList ql;
|
323 |
if (m_ignByCats == false) {
|
288 |
if (m_ignByCats == false) {
|
324 |
list<string> types = rclconfig->getAllMimeTypes();
|
289 |
list<string> types = rclconfig->getAllMimeTypes();
|
325 |
for (list<string>::iterator it = types.begin();
|
290 |
for (list<string>::iterator it = types.begin();
|
|
... |
|
... |
343 |
}
|
308 |
}
|
344 |
if (m_ignTypes.findIndex(cat) < 0)
|
309 |
if (m_ignTypes.findIndex(cat) < 0)
|
345 |
ql.append(cat);
|
310 |
ql.append(cat);
|
346 |
}
|
311 |
}
|
347 |
}
|
312 |
}
|
348 |
yesFiltypsLB->insertStringList(ql);
|
313 |
yesFiltypsLB->insertItems(0, ql);
|
349 |
}
|
314 |
}
|
350 |
|
315 |
|
351 |
// Save current list of ignored file types to prefs
|
316 |
// Save current list of ignored file types to prefs
|
352 |
void AdvSearch::saveFileTypes()
|
317 |
void AdvSearch::saveFileTypes()
|
353 |
{
|
318 |
{
|
|
... |
|
... |
373 |
}
|
338 |
}
|
374 |
if (!hasclause)
|
339 |
if (!hasclause)
|
375 |
return;
|
340 |
return;
|
376 |
|
341 |
|
377 |
if (restrictFtCB->isOn() && noFiltypsLB->count() > 0) {
|
342 |
if (restrictFtCB->isOn() && noFiltypsLB->count() > 0) {
|
378 |
for (unsigned int i = 0; i < yesFiltypsLB->count(); i++) {
|
343 |
for (int i = 0; i < yesFiltypsLB->count(); i++) {
|
379 |
if (restrictCtCB->isOn()) {
|
344 |
if (restrictCtCB->isOn()) {
|
380 |
QString qcat = yesFiltypsLB->item(i)->text();
|
345 |
QString qcat = yesFiltypsLB->item(i)->text();
|
381 |
map<QString,QString>::const_iterator qit;
|
346 |
map<QString,QString>::const_iterator qit;
|
382 |
string cat;
|
347 |
string cat;
|
383 |
if ((qit = cat_rtranslations.find(qcat)) !=
|
348 |
if ((qit = cat_rtranslations.find(qcat)) !=
|