]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/viewproperties.cpp
If 'remember view-properties' is selected, store the .directory files only if the...
[dolphin.git] / src / views / viewproperties.cpp
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);
+}