]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kfileitemlistwidget.cpp
GIT_SILENT Sync po/docbooks with svn
[dolphin.git] / src / kitemviews / kfileitemlistwidget.cpp
index b4e0895f2a7fcb0548e8393f63d9dd3832b28fb6..37b115cc3a7ca9972306be7b8118461bbfad988b 100644 (file)
@@ -45,7 +45,7 @@ bool KFileItemListWidgetInformant::itemIsLink(int index, const KItemListView *vi
     return item.isLink();
 }
 
-QString KFileItemListWidgetInformant::roleText(const QByteArray &role, const QHash<QByteArray, QVariant> &values) const
+QString KFileItemListWidgetInformant::roleText(const QByteArray &role, const QHash<QByteArray, QVariant> &values, ForUsageAs forUsageAs) const
 {
     QString text;
     const QVariant roleValue = values.value(role);
@@ -55,11 +55,13 @@ QString KFileItemListWidgetInformant::roleText(const QByteArray &role, const QHa
     // Implementation note: In case if more roles require a custom handling
     // use a hash + switch for a linear runtime.
 
-    auto formatDate = [formatter, local](const QDateTime &time) {
+    auto formatDate = [formatter, local, forUsageAs](const QDateTime &time) {
         if (ContentDisplaySettings::useShortRelativeDates()) {
-            return formatter.formatRelativeDateTime(time, QLocale::ShortFormat);
+            return formatter.formatRelativeDateTime(time,
+                                                    forUsageAs == KStandardItemListWidgetInformant::ForUsageAs::DisplayedText ? QLocale::ShortFormat
+                                                                                                                              : QLocale::LongFormat);
         } else {
-            return local.toString(time, QLocale::ShortFormat);
+            return local.toString(time, forUsageAs == KStandardItemListWidgetInformant::ForUsageAs::DisplayedText ? QLocale::ShortFormat : QLocale::LongFormat);
         }
     };
 
@@ -114,7 +116,7 @@ QString KFileItemListWidgetInformant::roleText(const QByteArray &role, const QHa
             break;
         }
     } else {
-        text = KStandardItemListWidgetInformant::roleText(role, values);
+        text = KStandardItemListWidgetInformant::roleText(role, values, forUsageAs);
     }
 
     return text;
@@ -174,15 +176,14 @@ int KFileItemListWidget::selectionLength(const QString &text) const
     const QString extension = db.suffixForFileName(text);
     if (extension.isEmpty()) {
         // For an unknown extension just exclude the extension after
-        // the last point. This does not work for multiple extensions like
+        // the last dot. This does not work for multiple extensions like
         // *.tar.gz but usually this is anyhow a known extension.
         indexOfExtension = text.lastIndexOf(QLatin1Char('.'));
 
-        // If no point could be found, use whole text length for selection.
-        if (indexOfExtension < 1) {
+        // if there either is no dot, or the last dot is the first or last char, treat as no extension.
+        if (indexOfExtension < 1 || indexOfExtension == text.length() - 1) {
             indexOfExtension = text.length();
         }
-
     } else {
         indexOfExtension -= extension.length() + 1;
     }
@@ -218,7 +219,7 @@ void KFileItemListWidget::hoverSequenceIndexChanged(int sequenceIndex)
 {
     KFileItemListView *view = listView();
 
-    if (!view) {
+    if (!view || !data().value("supportsSequencing").toBool()) {
         return;
     }