]> cloud.milkyroute.net Git - dolphin.git/commitdiff
If 'remember view-properties' is selected, store the .directory files only if the...
authorPeter Penz <peter.penz19@gmail.com>
Wed, 22 Sep 2010 18:10:45 +0000 (18:10 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Wed, 22 Sep 2010 18:10:45 +0000 (18:10 +0000)
BUG: 63347
FIXED-IN: 4.6.0

svn path=/trunk/KDE/kdebase/apps/; revision=1178321

src/views/viewproperties.cpp
src/views/viewproperties.h

index d6d5bfd941ba9f8159b2b6ce306dd3ea59ef04b0..d5330ffaaffa1e8bb84d4bc5f08c62bd8ef7327d 100644 (file)
@@ -61,7 +61,7 @@ ViewProperties::ViewProperties(const KUrl& url) :
     } else if (url.isLocalFile()) {
         m_filePath = url.toLocalFile();
         const QFileInfo info(m_filePath);
-        if (!info.isWritable()) {
+        if (!info.isWritable() || !isPartOfHome(m_filePath)) {
             m_filePath = destinationDir("local") + m_filePath;
         }
     } else {
@@ -432,3 +432,16 @@ QString ViewProperties::viewModePrefix() const
 
     return prefix;
 }
+
+bool ViewProperties::isPartOfHome(const QString& filePath)
+{
+    // For performance reasons cache the path in a static QString
+    // (see QDir::homePath() for more details)
+    static QString homePath;
+    if (homePath.isEmpty()) {
+        homePath = QDir::homePath();
+        Q_ASSERT(!homePath.isEmpty());
+    }
+
+    return filePath.startsWith(homePath);
+}
index 2db67c0f390f74098d2b0c9262c61cb31ec33ee2..787122d354444c5cbac67048118c4066a4e4f214 100644 (file)
@@ -149,6 +149,11 @@ private:
      */
     QString viewModePrefix() const;
 
+    /**
+     * Returns true, if \a filePath is part of the home-path (see QDir::homePath()).
+     */
+    static bool isPartOfHome(const QString& filePath);
+
     Q_DISABLE_COPY(ViewProperties)
 
 private: