diff options
| author | Peter Penz <[email protected]> | 2012-05-06 12:31:21 +0200 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2012-05-06 12:33:28 +0200 |
| commit | 7f96282e41012a367b956f8a36758c32c51767c8 (patch) | |
| tree | 7bfa9576d3ca06bacfce8543512a5cc5b95008ab /src | |
| parent | 37bd2116cb1f30a8c465ece41f53ba099c2331a0 (diff) | |
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, ...).
Diffstat (limited to 'src')
| -rw-r--r-- | src/views/viewproperties.cpp | 12 | ||||
| -rw-r--r-- | src/views/viewproperties.h | 6 |
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: |
