]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Sort the tag-values alphabetically in the "Tags" column
authorAthanasios Kanellopoulos <ath.kanellopoulos@gmail.com>
Sat, 29 Apr 2017 10:59:30 +0000 (12:59 +0200)
committerElvis Angelaccio <elvis.angelaccio@kde.org>
Sat, 29 Apr 2017 10:59:30 +0000 (12:59 +0200)
Up until now tag-values have appeared unsorted in the Tags column
when the selected View Mode is "Details".
In older versions of Dolphin (in KDE4) the tags-values were
alphabetically sorted in the Tags column, which means that back then
this was the desired behavior.
This commit restores this functionality.

BUG: 377589
FIXED-IN: 17.04.1
REVIEW: 130068

src/kitemviews/private/kbaloorolesprovider.cpp
src/kitemviews/private/kbaloorolesprovider.h

index 16e3935ca9477134045d0fb1ee7031d0108025cd..d6c15afcdbb42ac5ba0d563d00e5d36cf92cc58b 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <QTime>
 #include <QMap>
 
 #include <QTime>
 #include <QMap>
+#include <QCollator>
 
 struct KBalooRolesProviderSingleton
 {
 
 struct KBalooRolesProviderSingleton
 {
@@ -159,7 +160,11 @@ KBalooRolesProvider::KBalooRolesProvider() :
 
 QString KBalooRolesProvider::tagsFromValues(const QStringList& values) const
 {
 
 QString KBalooRolesProvider::tagsFromValues(const QStringList& values) const
 {
-    return values.join(QStringLiteral(", "));
+    QStringList alphabeticalOrderTags = values;
+    QCollator coll;
+    coll.setNumericMode(true);
+    std::sort(alphabeticalOrderTags.begin(), alphabeticalOrderTags.end(), [&](const QString& s1, const QString& s2){ return coll.compare(s1, s2) < 0; });
+    return alphabeticalOrderTags.join(QStringLiteral(", "));
 }
 
 QString KBalooRolesProvider::orientationFromValue(int value) const
 }
 
 QString KBalooRolesProvider::orientationFromValue(int value) const
index a9bd2e8ef335f50bcaba1d990beba352ab505b2c..65b59793cdca051c8acb45fd36a1c37fb4157f90 100644 (file)
@@ -62,6 +62,7 @@ protected:
 private:
     /**
      * @return User visible string for the given tag-values.
 private:
     /**
      * @return User visible string for the given tag-values.
+     *         The tag-values are sorted in alphabetical order.
      */
     QString tagsFromValues(const QStringList& values) const;
 
      */
     QString tagsFromValues(const QStringList& values) const;