]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kstandarditemlistwidget.cpp
Make "open path" and "open path in new tab" scroll to the selected item
[dolphin.git] / src / kitemviews / kstandarditemlistwidget.cpp
index fe686d4fe4d6f0b6024c088f497c76b8aab21417..a8fee62449dc28e7c379e5db885b75fde8a5caea 100644 (file)
@@ -109,11 +109,20 @@ bool KStandardItemListWidgetInformant::itemIsLink(int index, const KItemListView
     return false;
 }
 
-QString KStandardItemListWidgetInformant::roleText(const QByteArray &role, const QHash<QByteArray, QVariant> &values) const
+QString KStandardItemListWidgetInformant::roleText(const QByteArray &role, const QHash<QByteArray, QVariant> &values, ForUsageAs forUsageAs) const
 {
     if (role == "rating") {
-        // Always use an empty text, as the rating is shown by the image m_rating.
-        return QString();
+        if (forUsageAs == ForUsageAs::DisplayedText) {
+            // Always use an empty text, as the rating is shown by the image m_rating.
+            return QString();
+        } else {
+            const int rating{values.value(role).toInt()};
+            // Check if there are half stars
+            if (rating % 2) {
+                return i18ncp("@accessible rating", "%1 and a half stars", "%1 and a half stars", rating / 2);
+            }
+            return i18ncp("@accessible rating", "%1 star", "%1 stars", rating / 2);
+        }
     }
     return values.value(role).toString();
 }