]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Allow to remember view-properties for search-results
authorPeter Penz <peter.penz19@gmail.com>
Sun, 6 May 2012 10:31:21 +0000 (12:31 +0200)
committerPeter Penz <peter.penz19@gmail.com>
Sun, 6 May 2012 10:33:28 +0000 (12:33 +0200)
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
src/views/viewproperties.h

index d19b3bfdac3b6d3e3a36eb76ab0a1d544edb0c23..8dadf4e49300404767e8dabdd5e458ecbb98f3e6 100644 (file)
@@ -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;
+}
index 29f7c282cc7144296c3bb03f6cae8db97717a053..cfa98e9e44b86afdcac2edd5d5bef74a10723cd1 100644 (file)
@@ -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: