X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/d9eab08fcb8bfc56470a7f418465607888b5f1ba..a46121dc510f987f2d164b43eaf5f84ea8c83cb8:/src/views/viewproperties.cpp diff --git a/src/views/viewproperties.cpp b/src/views/viewproperties.cpp index 96a00dc1d..bcea06253 100644 --- a/src/views/viewproperties.cpp +++ b/src/views/viewproperties.cpp @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include @@ -53,7 +55,7 @@ ViewProperties::ViewProperties(const KUrl& url) : m_node(0) { GeneralSettings* settings = GeneralSettings::self(); - const bool useGlobalViewProps = settings->globalViewProps(); + const bool useGlobalViewProps = settings->globalViewProps() || url.isEmpty(); bool useDetailsViewWithPath = false; // We try and save it to the file .directory in the directory being viewed. @@ -69,8 +71,13 @@ ViewProperties::ViewProperties(const KUrl& url) : useDetailsViewWithPath = true; } else if (url.isLocalFile()) { m_filePath = url.toLocalFile(); - const QFileInfo info(m_filePath); - if (!info.isWritable() || !isPartOfHome(m_filePath)) { + const QFileInfo dirInfo(m_filePath); + const QFileInfo fileInfo(m_filePath + QDir::separator() + ViewPropertiesFileName); + // Check if the directory is writable and check if the ".directory" file exists and + // is read- and writable. + if (!dirInfo.isWritable() + || (fileInfo.exists() && !(fileInfo.isReadable() && fileInfo.isWritable())) + || !isPartOfHome(m_filePath)) { #ifdef Q_OS_WIN // m_filePath probably begins with C:/ - the colon is not a valid character for paths though m_filePath = QDir::separator() + m_filePath.remove(QLatin1Char(':')); @@ -95,13 +102,13 @@ ViewProperties::ViewProperties(const KUrl& url) : setVisibleRoles(QList() << "path"); } else { // The global view-properties act as default for directories without - // any view-property configuration - settings->setGlobalViewProps(true); - - ViewProperties defaultProps(url); + // any view-property configuration. Constructing a ViewProperties + // instance for an empty KUrl ensures that the global view-properties + // are loaded. + KUrl emptyUrl; + ViewProperties defaultProps(emptyUrl); setDirProperties(defaultProps); - settings->setGlobalViewProps(false); m_changedProps = false; } } @@ -284,7 +291,7 @@ QList ViewProperties::visibleRoles() const roles.append("text"); // Iterate through all stored keys and append all roles that match to - // the curren view mode. + // the current view mode. const QString prefix = viewModePrefix(); const int prefixLength = prefix.length(); @@ -426,7 +433,7 @@ void ViewProperties::convertNameRoleToTextRole() { QStringList visibleRoles = m_node->visibleRoles(); for (int i = 0; i < visibleRoles.count(); ++i) { - if (visibleRoles[i].endsWith("_name")) { + if (visibleRoles[i].endsWith(QLatin1String("_name"))) { const int leftLength = visibleRoles[i].length() - 5; visibleRoles[i] = visibleRoles[i].left(leftLength) + "_text"; }