#include <KLocale>
#include <KStandardDirs>
#include <KUrl>
+#include <KDebug>
+#include <KGlobal>
#include <QCryptographicHash>
#include <QDate>
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.
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(':'));
setVisibleRoles(QList<QByteArray>() << "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;
}
}