]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Use KUrl::isParentOf() instead of doing custom QString-operations
authorPeter Penz <peter.penz19@gmail.com>
Thu, 3 Feb 2011 16:23:45 +0000 (17:23 +0100)
committerPeter Penz <peter.penz19@gmail.com>
Thu, 3 Feb 2011 16:23:45 +0000 (17:23 +0100)
This fixes the issue that a directory might be declared as indexed/non-indexed although it just starts with a similar name like another directory.

src/search/dolphinsearchinformation.cpp

index 2cba5a1475615bd8f6d6b179e841304a415c14c1..28863034b6fc54838da31c555be2213327781b7c 100644 (file)
@@ -53,15 +53,14 @@ bool DolphinSearchInformation::isIndexingEnabled() const
 bool DolphinSearchInformation::isPathIndexed(const KUrl& url) const
 {
 #ifdef HAVE_NEPOMUK
 bool DolphinSearchInformation::isPathIndexed(const KUrl& url) const
 {
 #ifdef HAVE_NEPOMUK
-    const QString path = url.path();
-
     const KConfig strigiConfig("nepomukstrigirc");
     const QStringList indexedFolders = strigiConfig.group("General").readPathEntry("folders", QStringList());
 
     // Check whether the path is part of an indexed folder
     bool isIndexed = false;
     foreach (const QString& indexedFolder, indexedFolders) {
     const KConfig strigiConfig("nepomukstrigirc");
     const QStringList indexedFolders = strigiConfig.group("General").readPathEntry("folders", QStringList());
 
     // Check whether the path is part of an indexed folder
     bool isIndexed = false;
     foreach (const QString& indexedFolder, indexedFolders) {
-        if (path.startsWith(indexedFolder)) {
+        const KUrl indexedPath(indexedFolder);
+        if (indexedPath.isParentOf(url)) {
             isIndexed = true;
             break;
         }
             isIndexed = true;
             break;
         }
@@ -72,7 +71,8 @@ bool DolphinSearchInformation::isPathIndexed(const KUrl& url) const
         // excluded folder is part of the path.
         const QStringList excludedFolders = strigiConfig.group("General").readPathEntry("exclude folders", QStringList());
         foreach (const QString& excludedFolder, excludedFolders) {
         // excluded folder is part of the path.
         const QStringList excludedFolders = strigiConfig.group("General").readPathEntry("exclude folders", QStringList());
         foreach (const QString& excludedFolder, excludedFolders) {
-            if (path.startsWith(excludedFolder)) {
+            const KUrl excludedPath(excludedFolder);
+            if (excludedPath.isParentOf(url)) {
                 isIndexed = false;
                 break;
             }
                 isIndexed = false;
                 break;
             }