X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/1f45355b7dab5377ef2f504289210e4374576f7e..5517e4cf10c8aee590b404072aebaffb55bafec3:/src/views/viewproperties.cpp 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); +}