diff --git a/krusader/FileSystem/krquery.h b/krusader/FileSystem/krquery.h --- a/krusader/FileSystem/krquery.h +++ b/krusader/FileSystem/krquery.h @@ -131,6 +131,10 @@ // gets whether to follow symbolic links bool followLinks() { return followLinksP; } + // sets the paths which the searcher will ignore + void setUseIgnoredPaths(const QList &urls); + // gets the folders where the searcher searches + const QList useIgnoredPaths() { return whereIgnorePath; } // sets the folders where the searcher will search void setSearchInDirs(const QList &urls); // gets the folders where the searcher searches @@ -186,6 +190,7 @@ bool recurse; // if true recurse ob sub-dirs... bool followLinksP; + QList whereIgnorePath; // substrings of paths where not to search QList whereToSearch; // directories to search QList whereNotToSearch; // directories NOT to search diff --git a/krusader/FileSystem/krquery.cpp b/krusader/FileSystem/krquery.cpp --- a/krusader/FileSystem/krquery.cpp +++ b/krusader/FileSystem/krquery.cpp @@ -119,6 +119,7 @@ recurse = old.recurse; followLinksP = old.followLinksP; whereToSearch = old.whereToSearch; + whereIgnorePath = old.whereIgnorePath; whereNotToSearch = old.whereNotToSearch; origFilter = old.origFilter; @@ -746,6 +747,13 @@ url.matches(whereNotToSearch[i], QUrl::StripTrailingSlash)) return true; + // Ignore paths that are configured in settings + QString path = url.path(); + QString basename = path.right(path.length() - path.lastIndexOf('/') - 1); + for (int i = 0; i < whereIgnorePath.count(); ++i) + if (basename == whereIgnorePath[i]) + return true; + if (!matchDirName(url.fileName())) return true; @@ -773,3 +781,10 @@ whereNotToSearch.append(completed); } } +void KRQuery::setUseIgnoredPaths(const QList &paths) +{ + whereIgnorePath.clear(); + for (int i = 0; i < paths.count(); ++i) { + whereIgnorePath.append(paths[i]); + } +} diff --git a/krusader/Filter/filtersettings.h b/krusader/Filter/filtersettings.h --- a/krusader/Filter/filtersettings.h +++ b/krusader/Filter/filtersettings.h @@ -98,6 +98,7 @@ bool followLinks; QList searchIn; QList dontSearchIn; + QList ignorePaths; QString contentEncoding; QString containsText; bool containsTextCase; diff --git a/krusader/Filter/filtersettings.cpp b/krusader/Filter/filtersettings.cpp --- a/krusader/Filter/filtersettings.cpp +++ b/krusader/Filter/filtersettings.cpp @@ -120,6 +120,7 @@ COPY(followLinks); COPY(searchIn); COPY(dontSearchIn); + COPY(ignorePaths); COPY(contentEncoding); COPY(containsText); COPY(containsTextCase); @@ -160,6 +161,7 @@ LOAD("FollowLinks", followLinks); searchIn = KrServices::toUrlList(cfg.readEntry("SearchIn", QStringList())); dontSearchIn = KrServices::toUrlList(cfg.readEntry("DontSearchIn", QStringList())); + ignorePaths = cfg.readEntry("IgnorePaths", QStringList()); LOAD("ContentEncoding", contentEncoding); LOAD("ContainsText", containsText); LOAD("ContainsTextCase", containsTextCase); @@ -212,6 +214,7 @@ cfg.writeEntry("FollowLinks", followLinks); cfg.writeEntry("SearchIn", KrServices::toStringList(searchIn)); cfg.writeEntry("DontSearchIn", KrServices::toStringList(dontSearchIn)); + cfg.writeEntry("IgnorePaths", ignorePaths); cfg.writeEntry("ContentEncoding", contentEncoding); cfg.writeEntry("ContainsText", containsText); cfg.writeEntry("ContainsTextCase", containsTextCase); @@ -290,12 +293,16 @@ query.setSearchInArchives(searchInArchives); query.setFollowLinks(followLinks); + if (!searchIn.isEmpty()) query.setSearchInDirs(searchIn); if (!dontSearchIn.isEmpty()) query.setDontSearchInDirs(dontSearchIn); + if (!ignorePaths.isEmpty()) + query.setUseIgnoredPaths(ignorePaths); + ////////////// Advanced Options ////////////// if (minSizeEnabled) diff --git a/krusader/Filter/generalfilter.h b/krusader/Filter/generalfilter.h --- a/krusader/Filter/generalfilter.h +++ b/krusader/Filter/generalfilter.h @@ -85,6 +85,7 @@ QCheckBox* searchForCase; QCheckBox* containsTextCase; QCheckBox* containsWholeWord; + QCheckBox* useIgnoredPaths; QCheckBox* searchInDirs; QCheckBox* searchInArchives; QCheckBox* followLinks; diff --git a/krusader/Filter/generalfilter.cpp b/krusader/Filter/generalfilter.cpp --- a/krusader/Filter/generalfilter.cpp +++ b/krusader/Filter/generalfilter.cpp @@ -331,6 +331,12 @@ if (properties & FilterTabs::HasRecurseOptions) { // Options for recursive searching + useIgnoredPaths = new QCheckBox(this); + useIgnoredPaths->setText(i18n("Use Ignored Paths")); + useIgnoredPaths->setToolTip(i18n("You can set up ignored paths in Settings > Setup Krusader > Advanced > Fine-Tuning > Ignored Search Paths")); + useIgnoredPaths->setChecked(true); + recurseLayout->addWidget(useIgnoredPaths); + searchInDirs = new QCheckBox(this); searchInDirs->setText(i18n("Search in s&ub folders")); searchInDirs->setChecked(true); @@ -538,6 +544,14 @@ s.containsRegExp = containsRegExp->isChecked(); } + if(useIgnoredPaths->isChecked()) { + KConfigGroup group(krConfig, "Search"); + + s.ignorePaths = group.readEntry("Ignored Paths").split(':'); + } else { + s.ignorePaths = QList(); + } + if (contentEncoding->currentIndex() != 0) s.contentEncoding = KCharsets::charsets()->encodingForName(contentEncoding->currentText()); diff --git a/krusader/Konfigurator/kgadvanced.cpp b/krusader/Konfigurator/kgadvanced.cpp --- a/krusader/Konfigurator/kgadvanced.cpp +++ b/krusader/Konfigurator/kgadvanced.cpp @@ -119,6 +119,13 @@ KonfiguratorEditBox *updatedbArgs = createEditBox("Locate", "UpdateDB Arguments", "", fineTuneGrp, false); fineTuneGrid->addWidget(updatedbArgs, 1, 1); + //This will enable the person to ignore some directories / files while searching the filesystems + addLabel(fineTuneGrid, 2, 0, i18n("Ignored Search Paths:"), + fineTuneGrp); + KonfiguratorEditBox *ignoredPaths = createEditBox("Search", "Ignored Paths", "", fineTuneGrp, false); + ignoredPaths->setToolTip("Put in semicolon-separated list of directories to be ignored when searching files, eg. '.svn:logs'"); + fineTuneGrid->addWidget(ignoredPaths, 2, 1); + kgAdvancedLayout->addWidget(fineTuneGrp, 2 , 0); } diff --git a/krusader/Search/krsearchdialog.h b/krusader/Search/krsearchdialog.h --- a/krusader/Search/krsearchdialog.h +++ b/krusader/Search/krsearchdialog.h @@ -130,6 +130,7 @@ static bool lastSearchInArchives; static bool lastFollowSymLinks; static bool lastContainsRegExp; + static bool lastUseIgnoredPaths; int sizeX; int sizeY; diff --git a/krusader/Search/krsearchdialog.cpp b/krusader/Search/krsearchdialog.cpp --- a/krusader/Search/krsearchdialog.cpp +++ b/krusader/Search/krsearchdialog.cpp @@ -132,6 +132,7 @@ bool KrSearchDialog::lastContainsWholeWord = false; bool KrSearchDialog::lastContainsWithCase = false; bool KrSearchDialog::lastSearchInSubDirs = true; +bool KrSearchDialog::lastUseIgnoredPaths = true; bool KrSearchDialog::lastSearchInArchives = false; bool KrSearchDialog::lastFollowSymLinks = false; bool KrSearchDialog::lastContainsRegExp = false; @@ -319,6 +320,7 @@ generalFilter->containsTextCase->setChecked(lastContainsWithCase); generalFilter->containsRegExp->setChecked(lastContainsRegExp); generalFilter->searchInDirs->setChecked(lastSearchInSubDirs); + generalFilter->useIgnoredPaths->setChecked(lastUseIgnoredPaths); generalFilter->searchInArchives->setChecked(lastSearchInArchives); generalFilter->followLinks->setChecked(lastFollowSymLinks); // the path in the active panel should be the default search location @@ -365,6 +367,7 @@ lastContainsWithCase = generalFilter->containsTextCase->isChecked(); lastContainsRegExp = generalFilter->containsRegExp->isChecked(); lastSearchInSubDirs = generalFilter->searchInDirs->isChecked(); + lastUseIgnoredPaths = generalFilter->useIgnoredPaths->isChecked(); lastSearchInArchives = generalFilter->searchInArchives->isChecked(); lastFollowSymLinks = generalFilter->followLinks->isChecked(); hide();