Changeset View
Changeset View
Standalone View
Standalone View
krusader/Search/krsearchdialog.cpp
Show All 36 Lines | |||||
37 | #include <QInputDialog> | 37 | #include <QInputDialog> | ||
38 | #include <QHBoxLayout> | 38 | #include <QHBoxLayout> | ||
39 | #include <QMenu> | 39 | #include <QMenu> | ||
40 | 40 | | |||
41 | #include <KConfigCore/KConfig> | 41 | #include <KConfigCore/KConfig> | ||
42 | #include <KI18n/KLocalizedString> | 42 | #include <KI18n/KLocalizedString> | ||
43 | #include <KWidgetsAddons/KMessageBox> | 43 | #include <KWidgetsAddons/KMessageBox> | ||
44 | 44 | | |||
45 | #include "krsearchmod.h" | | |||
46 | #include "../Dialogs/krdialogs.h" | 45 | #include "../Dialogs/krdialogs.h" | ||
47 | #include "../Dialogs/krspecialwidgets.h" | 46 | #include "../Dialogs/krspecialwidgets.h" | ||
48 | #include "../Dialogs/krsqueezedtextlabel.h" | 47 | #include "../Dialogs/krsqueezedtextlabel.h" | ||
49 | #include "../FileSystem/fileitem.h" | 48 | #include "../FileSystem/fileitem.h" | ||
49 | #include "../FileSystem/filesearcher.h" | ||||
50 | #include "../FileSystem/krquery.h" | 50 | #include "../FileSystem/krquery.h" | ||
51 | #include "../FileSystem/virtualfilesystem.h" | 51 | #include "../FileSystem/virtualfilesystem.h" | ||
52 | #include "../Filter/filtertabs.h" | 52 | #include "../Filter/filtertabs.h" | ||
53 | #include "../Filter/generalfilter.h" | 53 | #include "../Filter/generalfilter.h" | ||
54 | #include "../KViewer/krviewer.h" | 54 | #include "../KViewer/krviewer.h" | ||
55 | #include "../Panel/PanelView/krview.h" | 55 | #include "../Panel/PanelView/krview.h" | ||
56 | #include "../Panel/PanelView/krviewfactory.h" | 56 | #include "../Panel/PanelView/krviewfactory.h" | ||
57 | #include "../Panel/PanelView/krviewitem.h" | 57 | #include "../Panel/PanelView/krviewitem.h" | ||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | |||||
125 | bool KrSearchDialog::lastSearchInSubDirs = true; | 125 | bool KrSearchDialog::lastSearchInSubDirs = true; | ||
126 | bool KrSearchDialog::lastSearchInArchives = false; | 126 | bool KrSearchDialog::lastSearchInArchives = false; | ||
127 | bool KrSearchDialog::lastFollowSymLinks = false; | 127 | bool KrSearchDialog::lastFollowSymLinks = false; | ||
128 | bool KrSearchDialog::lastContainsRegExp = false; | 128 | bool KrSearchDialog::lastContainsRegExp = false; | ||
129 | 129 | | |||
130 | 130 | | |||
131 | // class starts here ///////////////////////////////////////// | 131 | // class starts here ///////////////////////////////////////// | ||
132 | KrSearchDialog::KrSearchDialog(QString profile, QWidget* parent) | 132 | KrSearchDialog::KrSearchDialog(QString profile, QWidget* parent) | ||
133 | : QDialog(parent), query(0), searcher(0), isBusy(false), closed(false) | 133 | : QDialog(parent), searcher(0), isBusy(false), closed(false) | ||
134 | { | 134 | { | ||
135 | KConfigGroup group(krConfig, "Search"); | 135 | KConfigGroup group(krConfig, "Search"); | ||
136 | 136 | | |||
137 | setWindowTitle(i18n("Krusader::Search")); | 137 | setWindowTitle(i18n("Krusader::Search")); | ||
138 | setWindowIcon(Icon("system-search")); | 138 | setWindowIcon(Icon("system-search")); | ||
139 | 139 | | |||
140 | QGridLayout* searchBaseLayout = new QGridLayout(this); | 140 | QGridLayout* searchBaseLayout = new QGridLayout(this); | ||
141 | searchBaseLayout->setSpacing(6); | 141 | searchBaseLayout->setSpacing(6); | ||
▲ Show 20 Lines • Show All 173 Lines • ▼ Show 20 Line(s) | 303 | if (profile.isEmpty()) { | |||
315 | // the path in the active panel should be the default search location | 315 | // the path in the active panel should be the default search location | ||
316 | generalFilter->searchIn->lineEdit()->setText(ACTIVE_PANEL->virtualPath().toDisplayString(QUrl::PreferLocalFile)); | 316 | generalFilter->searchIn->lineEdit()->setText(ACTIVE_PANEL->virtualPath().toDisplayString(QUrl::PreferLocalFile)); | ||
317 | } else | 317 | } else | ||
318 | profileManager->loadProfile(profile); // important: call this _after_ you've connected profileManager ot the loadFromProfile!! | 318 | profileManager->loadProfile(profile); // important: call this _after_ you've connected profileManager ot the loadFromProfile!! | ||
319 | } | 319 | } | ||
320 | 320 | | |||
321 | KrSearchDialog::~KrSearchDialog() | 321 | KrSearchDialog::~KrSearchDialog() | ||
322 | { | 322 | { | ||
323 | delete query; | | |||
324 | query = 0; | | |||
325 | delete resultView; | 323 | delete resultView; | ||
326 | resultView = 0; | 324 | resultView = 0; | ||
327 | } | 325 | } | ||
328 | 326 | | |||
329 | void KrSearchDialog::closeDialog(bool isAccept) | 327 | void KrSearchDialog::closeDialog(bool isAccept) | ||
330 | { | 328 | { | ||
331 | if(isBusy) { | 329 | if(isBusy) { | ||
332 | closed = true; | 330 | closed = true; | ||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | |||||
385 | void KrSearchDialog::slotFound(const FileItem &file, const QString &foundText) | 383 | void KrSearchDialog::slotFound(const FileItem &file, const QString &foundText) | ||
386 | { | 384 | { | ||
387 | result->addItem(file, foundText); | 385 | result->addItem(file, foundText); | ||
388 | foundLabel->setText(i18np("Found %1 match.", "Found %1 matches.", result->numFileItems())); | 386 | foundLabel->setText(i18np("Found %1 match.", "Found %1 matches.", result->numFileItems())); | ||
389 | } | 387 | } | ||
390 | 388 | | |||
391 | bool KrSearchDialog::gui2query() | 389 | bool KrSearchDialog::gui2query() | ||
392 | { | 390 | { | ||
393 | // prepare the query ... | 391 | query = filterTabs->query(); | ||
394 | /////////////////// names, locations and greps | | |||
395 | if (query != 0) { | | |||
396 | delete query; query = 0; | | |||
397 | } | | |||
398 | query = new KRQuery(); | | |||
399 | 392 | | |||
400 | return filterTabs->fillQuery(query); | 393 | return !query.isNull(); | ||
401 | } | 394 | } | ||
402 | 395 | | |||
403 | void KrSearchDialog::startSearch() | 396 | void KrSearchDialog::startSearch() | ||
404 | { | 397 | { | ||
405 | if(isBusy) | 398 | if(isBusy) | ||
406 | return; | 399 | return; | ||
407 | 400 | | |||
408 | // prepare the query ///////////////////////////////////////////// | 401 | // prepare the query ///////////////////////////////////////////// | ||
409 | if (!gui2query()) return; | 402 | if (!gui2query()) return; | ||
410 | 403 | | |||
411 | // first, informative messages | 404 | // first, informative messages | ||
412 | if (query->searchInArchives()) { | 405 | if (query.searchInArchives()) { | ||
413 | KMessageBox::information(this, i18n("Since you chose to also search in archives, " | 406 | KMessageBox::information(this, i18n("Since you chose to also search in archives, " | ||
414 | "note the following limitations:\n" | 407 | "note the following limitations:\n" | ||
415 | "You cannot search for text (grep) while doing" | 408 | "You cannot search for text (grep) while doing" | ||
416 | " a search that includes archives."), 0, "searchInArchives"); | 409 | " a search that includes archives."), 0, "searchInArchives"); | ||
417 | } | 410 | } | ||
418 | 411 | | |||
419 | // prepare the gui /////////////////////////////////////////////// | 412 | // prepare the gui /////////////////////////////////////////////// | ||
420 | mainSearchBtn->setEnabled(false); | 413 | mainSearchBtn->setEnabled(false); | ||
Show All 9 Lines | |||||
430 | 423 | | |||
431 | isBusy = true; | 424 | isBusy = true; | ||
432 | 425 | | |||
433 | qApp->processEvents(); | 426 | qApp->processEvents(); | ||
434 | 427 | | |||
435 | // start the search. | 428 | // start the search. | ||
436 | if (searcher != 0) | 429 | if (searcher != 0) | ||
437 | abort(); | 430 | abort(); | ||
438 | searcher = new KRSearchMod(query); | 431 | searcher = new FileSearcher(query); | ||
439 | connect(searcher, SIGNAL(searching(QString)), | 432 | connect(searcher, SIGNAL(searching(QString)), | ||
440 | searchingLabel, SLOT(setText(QString))); | 433 | searchingLabel, SLOT(setText(QString))); | ||
441 | connect(searcher, &KRSearchMod::found, this, &KrSearchDialog::slotFound); | 434 | connect(searcher, &FileSearcher::found, this, &KrSearchDialog::slotFound); | ||
442 | connect(searcher, SIGNAL(finished()), this, SLOT(stopSearch())); | 435 | connect(searcher, SIGNAL(finished()), this, SLOT(stopSearch())); | ||
443 | 436 | | |||
444 | searcher->start(); | 437 | searcher->start(); | ||
445 | 438 | | |||
446 | isBusy = false; | 439 | isBusy = false; | ||
447 | 440 | | |||
448 | delete searcher; | 441 | delete searcher; | ||
449 | searcher = 0; | 442 | searcher = 0; | ||
▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Line(s) | |||||
595 | void KrSearchDialog::feedToListBox() | 588 | void KrSearchDialog::feedToListBox() | ||
596 | { | 589 | { | ||
597 | VirtualFileSystem virtFilesystem; | 590 | VirtualFileSystem virtFilesystem; | ||
598 | virtFilesystem.scanDir(QUrl::fromLocalFile("/")); | 591 | virtFilesystem.scanDir(QUrl::fromLocalFile("/")); | ||
599 | 592 | | |||
600 | KConfigGroup group(krConfig, "Search"); | 593 | KConfigGroup group(krConfig, "Search"); | ||
601 | int listBoxNum = group.readEntry("Feed To Listbox Counter", 1); | 594 | int listBoxNum = group.readEntry("Feed To Listbox Counter", 1); | ||
602 | QString queryName; | 595 | QString queryName; | ||
603 | if(query) { | 596 | if (!query.isNull()) { | ||
604 | QString where = KrServices::toStringList(query->searchInDirs()).join(", "); | 597 | QString where = KrServices::toStringList(query.searchInDirs()).join(", "); | ||
605 | if(query->content().isEmpty()) | 598 | if (query.content().isEmpty()) | ||
606 | queryName = i18n("Search results for \"%1\" in %2", query->nameFilter(), where); | 599 | queryName = i18n("Search results for \"%1\" in %2", query.nameFilter(), where); | ||
607 | else | 600 | else | ||
608 | queryName = i18n("Search results for \"%1\" containing \"%2\" in %3", query->nameFilter(), query->content(), where); | 601 | queryName = i18n("Search results for \"%1\" containing \"%2\" in %3", | ||
602 | query.nameFilter(), query.content(), where); | ||||
609 | } | 603 | } | ||
610 | QString fileSystemName; | 604 | QString fileSystemName; | ||
611 | do { | 605 | do { | ||
612 | fileSystemName = i18n("Search results") + QString(" %1").arg(listBoxNum++); | 606 | fileSystemName = i18n("Search results") + QString(" %1").arg(listBoxNum++); | ||
613 | } while (virtFilesystem.getFileItem(fileSystemName) != 0); | 607 | } while (virtFilesystem.getFileItem(fileSystemName) != 0); | ||
614 | group.writeEntry("Feed To Listbox Counter", listBoxNum); | 608 | group.writeEntry("Feed To Listbox Counter", listBoxNum); | ||
615 | 609 | | |||
616 | KConfigGroup ga(krConfig, "Advanced"); | 610 | KConfigGroup ga(krConfig, "Advanced"); | ||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |