]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Shorten the "path" content if possible
authorPeter Penz <peter.penz19@gmail.com>
Wed, 16 May 2012 21:41:04 +0000 (23:41 +0200)
committerPeter Penz <peter.penz19@gmail.com>
Wed, 16 May 2012 21:42:13 +0000 (23:42 +0200)
Replace the home-path by '~' for having a shorter content.

src/kitemviews/kfileitemmodel.cpp

index 8f8b80c5af170b89a0cdd80516eefaaffccb3d9b..9f92d8a81fdc832ac45751031728efaa101a1a72 100644 (file)
@@ -1209,7 +1209,17 @@ QHash<QByteArray, QVariant> KFileItemModel::retrieveData(const KFileItem& item)
         if (item.url().protocol() == QLatin1String("trash")) {
             path = item.entry().stringValue(KIO::UDSEntry::UDS_EXTRA);
         } else {
+            // For performance reasons cache the home-path in a static QString
+            // (see QDir::homePath() for more details)
+            static QString homePath;
+            if (homePath.isEmpty()) {
+                homePath = QDir::homePath();
+            }
+
             path = item.localPath();
+            if (path.startsWith(homePath)) {
+                path.replace(0, homePath.length(), QLatin1Char('~'));
+            }
         }
 
         const int index = path.lastIndexOf(item.text());