From 7f96282e41012a367b956f8a36758c32c51767c8 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Sun, 6 May 2012 12:31:21 +0200 Subject: [PATCH] Allow to remember view-properties for search-results Until now it was only possible to adjust the view-properties for searching in general. Now the view-properties can be adjusted dependent on the query (e.g. images, documents, ...). --- src/views/viewproperties.cpp | 12 +++++++++++- src/views/viewproperties.h | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-) 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 #include +#include #include #include #include @@ -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: -- 2.47.3