┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views/viewproperties.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2010-09-22 18:10:45 +0000
committerPeter Penz <[email protected]>2010-09-22 18:10:45 +0000
commit5517e4cf10c8aee590b404072aebaffb55bafec3 (patch)
tree5e1a206d7d700cc5333c4b445fffd4f1cc98a92e /src/views/viewproperties.cpp
parent1f45355b7dab5377ef2f504289210e4374576f7e (diff)
If 'remember view-properties' is selected, store the .directory files only if the directory is part of the home-path. Otherwise use the mirror in ~/.kde/share/apps/dolphin/view_properties to store the .directory file. This prevents conflicting view-properties if several users have write-access to a common directory.
BUG: 63347 FIXED-IN: 4.6.0 svn path=/trunk/KDE/kdebase/apps/; revision=1178321
Diffstat (limited to 'src/views/viewproperties.cpp')
-rw-r--r--src/views/viewproperties.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/views/viewproperties.cpp b/src/views/viewproperties.cpp
index d6d5bfd94..d5330ffaa 100644
--- a/src/views/viewproperties.cpp
+++ b/src/views/viewproperties.cpp
@@ -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);
+}