]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Use the path instead of the display string in PlacesItemModel::closestItem,
authorEmmanuel Pescosta <emmanuelpescosta099@gmail.com>
Tue, 21 Oct 2014 20:54:15 +0000 (22:54 +0200)
committerEmmanuel Pescosta <emmanuelpescosta099@gmail.com>
Tue, 21 Oct 2014 20:54:15 +0000 (22:54 +0200)
fixes the determination of the closest item for me.

src/panels/places/placesitemmodel.cpp

index e49a6a9da61fe5c4b6596472b5863a62ba15a7d2..8e6494919eb6ec093c1bc654678c3d3a651778b2 100644 (file)
@@ -214,8 +214,12 @@ int PlacesItemModel::closestItem(const QUrl& url) const
 
     for (int i = 0; i < count(); ++i) {
         const QUrl itemUrl = placesItem(i)->url();
-        if (itemUrl.isParentOf(url)) {
-            const int length = itemUrl.toDisplayString().length();
+        if (url == itemUrl) {
+            // We can't find a closer one, so stop here.
+            foundIndex = i;
+            break;
+        } else if (itemUrl.isParentOf(url)) {
+            const int length = itemUrl.path().length();
             if (length > maxLength) {
                 foundIndex = i;
                 maxLength = length;