┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/views/viewproperties.cpp12
-rw-r--r--src/views/viewproperties.h6
2 files changed, 17 insertions, 1 deletions
diff --git a/src/views/viewproperties.cpp b/src/views/viewproperties.cpp
index d19b3bfda..8dadf4e49 100644
--- a/src/views/viewproperties.cpp
+++ b/src/views/viewproperties.cpp
@@ -28,6 +28,7 @@
#include <KStandardDirs>
#include <KUrl>
+#include <QCryptographicHash>
#include <QDate>
#include <QFile>
#include <QFileInfo>
@@ -58,7 +59,7 @@ ViewProperties::ViewProperties(const KUrl& url) :
if (useGlobalViewProps) {
m_filePath = destinationDir("global");
} else if (url.protocol().contains("search")) {
- m_filePath = destinationDir("search");
+ m_filePath = destinationDir("search/") + directoryHashForUrl(url);
useDetailsViewWithPath = true;
} else if (url.protocol() == QLatin1String("trash")) {
m_filePath = destinationDir("trash");
@@ -436,3 +437,12 @@ bool ViewProperties::isPartOfHome(const QString& filePath)
return filePath.startsWith(homePath);
}
+
+QString ViewProperties::directoryHashForUrl(const KUrl& url)
+{
+ const QByteArray hashValue = QCryptographicHash::hash(url.prettyUrl().toLatin1(),
+ QCryptographicHash::Sha1);
+ QString hashString = hashValue.toBase64();
+ hashString.replace('/', '-');
+ return hashString;
+}
diff --git a/src/views/viewproperties.h b/src/views/viewproperties.h
index 29f7c282c..cfa98e9e4 100644
--- a/src/views/viewproperties.h
+++ b/src/views/viewproperties.h
@@ -159,6 +159,12 @@ private:
*/
static bool isPartOfHome(const QString& filePath);
+ /**
+ * @return A hash-value for an URL that can be used as directory name.
+ * Is used to be able to remember view-properties for long nepomuksearch-URLs.
+ */
+ static QString directoryHashForUrl(const KUrl& url);
+
Q_DISABLE_COPY(ViewProperties)
private: