┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kfileitemmodel.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2012-05-16 23:41:04 +0200
committerPeter Penz <[email protected]>2012-05-16 23:42:13 +0200
commit855560dd32e8f275a7a3e6eb4cc7c2e1d262a47b (patch)
tree635d0ef62b952559a3146c276ba0988db1975948 /src/kitemviews/kfileitemmodel.cpp
parent3ad3dd5afbe2dce7a28c58227f2a2aa1e78f5d64 (diff)
Shorten the "path" content if possible
Replace the home-path by '~' for having a shorter content.
Diffstat (limited to 'src/kitemviews/kfileitemmodel.cpp')
-rw-r--r--src/kitemviews/kfileitemmodel.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp
index 8f8b80c5a..9f92d8a81 100644
--- a/src/kitemviews/kfileitemmodel.cpp
+++ b/src/kitemviews/kfileitemmodel.cpp
@@ -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());