[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#626677: [libkfile4] incorrect sorting of nepomuk search results



Package: libkfile4
Version: 4:4.4.5-4
Severity: normal
Tags: patch

Dolphin does incorrectly sort search results for protocols that allow identical
file names from different directories.
See bug #626372: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=626372

As no one seemed to be interested, I did some investigation myself.
The problem was localized in kde4libs 4:4.4.5-4, file kdirsortfilterproxymodel.cpp,
class KDirSortFilterProxyModel, method subSortLessThan.

Patch attached. I hope it will be included in the next debian revision of kde4libs.


--- System information. ---
Architecture: amd64

Debian Release: wheezy/sid
  500 testing         ftp.de.debian.org 

--- Package information. ---
Depends                  (Version) | Installed
==================================-+-===================
libc6                   (>= 2.2.5) | 2.11.2-11
libkdecore5          (= 4:4.4.5-4) | 4:4.4.5-4
libkdeui5            (= 4:4.4.5-4) | 4:4.4.5-4
libkio5              (= 4:4.4.5-4) | 4:4.4.5-4
libqt4-xml            (>= 4:4.6.0) | 4:4.7.2-3
libqtcore4      (>= 4:4.7.0~beta1) | 4:4.7.2-3
libqtgui4             (>= 4:4.6.0) | 4:4.7.2-3
libsolid4            (= 4:4.4.5-4) | 4:4.4.5-4
libstdc++6              (>= 4.1.1) | 4.6.0-2
libxrender1                        | 1:0.9.6-1


Package's Recommends field is empty.

Package's Suggests field is empty.



diff -Naur kde4libs-4.4.5.orig/kfile/kdirsortfilterproxymodel.cpp kde4libs-4.4.5/kfile/kdirsortfilterproxymodel.cpp
--- kde4libs-4.4.5.orig/kfile/kdirsortfilterproxymodel.cpp	2010-05-28 16:43:23.000000000 +0700
+++ kde4libs-4.4.5/kfile/kdirsortfilterproxymodel.cpp	2011-05-14 15:06:29.292236185 +0700
@@ -164,7 +164,18 @@
 
     switch (left.column()) {
     case KDirModel::Name: {
-        return d->compare(leftFileItem.text(), rightFileItem.text(), sortCaseSensitivity()) < 0;
+        int result = d->compare(leftFileItem.text(), rightFileItem.text(), sortCaseSensitivity());
+        if (result == 0) {
+            // KFileItem::text() may not be unique in case UDS_DISPLAY_NAME is used
+            result = d->compare(leftFileItem.name(sortCaseSensitivity() == Qt::CaseInsensitive),
+                                rightFileItem.name(sortCaseSensitivity() == Qt::CaseInsensitive),
+                                sortCaseSensitivity());
+            if (result == 0) {
+                // If KFileItem::text() is also not unique most probably a search protocol is used
+                // that allows showing the same file names from different directories
+                result = d->compare(leftFileItem.url().url(), rightFileItem.url().url(), sortCaseSensitivity());
+            }
+        }
     }
 
     case KDirModel::Size: {

Reply to: