]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/viewproperties.cpp
Merge remote-tracking branch 'origin/Applications/18.12'
[dolphin.git] / src / views / viewproperties.cpp
index ca52be8907cee97063f2f0ec655b052b348221aa..e056e25e3b5d81da541b7b20b8c71698f84b1841 100644 (file)
 
 #include "dolphin_directoryviewpropertysettings.h"
 #include "dolphin_generalsettings.h"
-
-#include <QUrl>
 #include "dolphindebug.h"
 
 #include <QCryptographicHash>
-#include <QDate>
-#include <QFile>
-#include <QFileInfo>
-#include <QStandardPaths>
 
 namespace {
     const int AdditionalInfoViewPropertiesVersion = 1;
@@ -50,7 +44,7 @@ namespace {
 ViewProperties::ViewProperties(const QUrl& url) :
     m_changedProps(false),
     m_autoSave(true),
-    m_node(0)
+    m_node(nullptr)
 {
     GeneralSettings* settings = GeneralSettings::self();
     const bool useGlobalViewProps = settings->globalViewProps() || url.isEmpty();
@@ -69,17 +63,19 @@ ViewProperties::ViewProperties(const QUrl& url) :
         useDetailsViewWithPath = true;
     } else if (url.isLocalFile()) {
         m_filePath = url.toLocalFile();
-        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(':'));
-#endif
+
+        bool useDestinationDir = !isPartOfHome(m_filePath);
+        if (!useDestinationDir) {
+            const QFileInfo dirInfo(m_filePath);
+            const QFileInfo fileInfo(m_filePath + QDir::separator() + ViewPropertiesFileName);
+            useDestinationDir = !dirInfo.isWritable() || (dirInfo.size() > 0 && fileInfo.exists() && !(fileInfo.isReadable() && fileInfo.isWritable()));
+        }
+
+        if (useDestinationDir) {
+    #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(':'));
+    #endif
             m_filePath = destinationDir(QStringLiteral("local")) + m_filePath;
         }
     } else {
@@ -140,7 +136,7 @@ ViewProperties::~ViewProperties()
     }
 
     delete m_node;
-    m_node = 0;
+    m_node = nullptr;
 }
 
 void ViewProperties::setViewMode(DolphinView::Mode mode)
@@ -287,7 +283,7 @@ QList<QByteArray> ViewProperties::visibleRoles() const
     //
     // For the details-view a special case must be respected: Per default the size
     // and date should be shown without creating a .directory file. Only if
-    // the user explictly has modified the properties of the details view (marked
+    // the user explicitly has modified the properties of the details view (marked
     // by "CustomizedDetails"), also a details-view with no additional information
     // is accepted.