From 5517e4cf10c8aee590b404072aebaffb55bafec3 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Wed, 22 Sep 2010 18:10:45 +0000 Subject: [PATCH] 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 --- src/views/viewproperties.cpp | 15 ++++++++++++++- src/views/viewproperties.h | 5 +++++ 2 files changed, 19 insertions(+), 1 deletion(-) 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); +} diff --git a/src/views/viewproperties.h b/src/views/viewproperties.h index 2db67c0f3..787122d35 100644 --- a/src/views/viewproperties.h +++ b/src/views/viewproperties.h @@ -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: -- 2.47.3