]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kfileitemlistwidget.cpp
Make it compile against last kf5 version without deprecated methods
[dolphin.git] / src / kitemviews / kfileitemlistwidget.cpp
index 1ea537d1df7000a9c41a058223d811457dd2fe5d..40b8ccf3717a4a10965cf8c361c8be7e743fb57a 100644 (file)
 #include "kfileitemmodel.h"
 #include "kitemlistview.h"
 
-#include <kmimetype.h>
-#include <KDebug>
-#include <KGlobal>
-#include <KLocale>
-#include <KIO/MetaData>
-#include <QDateTime>
+#include <KFormat>
+#include <KLocalizedString>
+
+#include <QMimeDatabase>
 
 KFileItemListWidgetInformant::KFileItemListWidgetInformant() :
     KStandardItemListWidgetInformant()
@@ -78,11 +76,17 @@ QString KFileItemListWidgetInformant::roleText(const QByteArray& role,
             }
         } else {
             const KIO::filesize_t size = roleValue.value<KIO::filesize_t>();
-            text = KGlobal::locale()->formatByteSize(size);
+            text = KFormat().formatByteSize(size);
         }
-    } else if (role == "date") {
+    } else if (role == "modificationtime" || role == "creationtime" || role == "accesstime") {
+            bool ok;
+            const long long time = roleValue.toLongLong(&ok);
+            if (ok && time != -1) {
+                return QLocale().toString(QDateTime::fromSecsSinceEpoch(time), QLocale::ShortFormat);
+            }
+    } else if (role == "deletiontime" || role == "imageDateTime") {
         const QDateTime dateTime = roleValue.toDateTime();
-        text = KGlobal::locale()->formatDateTime(dateTime);
+        text = QLocale().toString(dateTime, QLocale::ShortFormat);
     } else {
         text = KStandardItemListWidgetInformant::roleText(role, values);
     }
@@ -120,7 +124,7 @@ bool KFileItemListWidget::isRoleRightAligned(const QByteArray& role) const
 
 bool KFileItemListWidget::isHidden() const
 {
-    return data().value("text").toString().startsWith(QLatin1Char('.'));
+    return data().value("isHidden").toBool();
 }
 
 QFont KFileItemListWidget::customizedFont(const QFont& baseFont) const
@@ -142,7 +146,8 @@ int KFileItemListWidget::selectionLength(const QString& text) const
         return selectionLength;
     }
 
-    const QString extension = KMimeType::extractKnownExtension(text);
+    QMimeDatabase db;
+    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