X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/cb9669d71cf10e73305c6a60fe0d832f4eb0ac7a..06fb789c2b7c435dce7cf1ff11bf045f3ebc84bf:/src/viewproperties.cpp diff --git a/src/viewproperties.cpp b/src/viewproperties.cpp index d153e5427..3e08358f7 100644 --- a/src/viewproperties.cpp +++ b/src/viewproperties.cpp @@ -1,6 +1,6 @@ /*************************************************************************** - * Copyright (C) 2006 by Peter Penz () * - * Copyright (C) 2006 by Aaron J. Seigo () * + * Copyright (C) 2006-2010 by Peter Penz * + * Copyright (C) 2006 by Aaron J. Seigo * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -20,8 +20,7 @@ #include "viewproperties.h" -#include "additionalinfomanager.h" -#include "settings/dolphinsettings.h" +#include "additionalinfoaccessor.h" #include "dolphin_directoryviewpropertysettings.h" #include "dolphin_generalsettings.h" @@ -34,40 +33,31 @@ #include #include +#include "settings/dolphinsettings.h" + ViewProperties::ViewProperties(const KUrl& url) : m_changedProps(false), m_autoSave(true), m_node(0) { - KUrl cleanUrl(url); - cleanUrl.cleanPath(); - m_filepath = cleanUrl.toLocalFile(); - - const QLatin1String fileName("/.directory"); - - if ((m_filepath.length() < 1) || (!QDir::isAbsolutePath(m_filepath))) { - const QString file = destinationDir("global") + fileName; - m_node = new ViewPropertySettings(KSharedConfig::openConfig(file)); - return; - } - - // We try and save it to a file in the directory being viewed. + // We try and save it to the file .directory in the directory being viewed. // If the directory is not writable by the user or the directory is not local, // we store the properties information in a local file. GeneralSettings* settings = DolphinSettings::instance().generalSettings(); const bool useGlobalViewProps = settings->globalViewProps(); if (useGlobalViewProps) { - m_filepath = destinationDir("global"); - } else if (cleanUrl.isLocalFile()) { - const QFileInfo info(m_filepath); + m_filePath = destinationDir("global"); + } else if (url.isLocalFile()) { + m_filePath = url.toLocalFile(); + const QFileInfo info(m_filePath); if (!info.isWritable()) { - m_filepath = destinationDir("local") + m_filepath; + m_filePath = destinationDir("local") + m_filePath; } } else { - m_filepath = destinationDir("remote") + m_filepath; + m_filePath = destinationDir("remote") + m_filePath; } - const QString file = m_filepath + fileName; + const QString file = m_filePath + QDir::separator() + QLatin1String(".directory"); m_node = new ViewPropertySettings(KSharedConfig::openConfig(file)); const bool useDefaultProps = !useGlobalViewProps && @@ -123,7 +113,6 @@ bool ViewProperties::showPreview() const return m_node->showPreview(); } - void ViewProperties::setShowHiddenFiles(bool show) { if (m_node->showHiddenFiles() != show) { @@ -145,7 +134,6 @@ bool ViewProperties::categorizedSorting() const return m_node->categorizedSorting(); } - bool ViewProperties::showHiddenFiles() const { return m_node->showHiddenFiles(); @@ -192,11 +180,11 @@ bool ViewProperties::sortFoldersFirst() const void ViewProperties::setAdditionalInfo(const KFileItemDelegate::InformationList& list) { - AdditionalInfoManager& infoManager = AdditionalInfoManager::instance(); + AdditionalInfoAccessor& infoAccessor = AdditionalInfoAccessor::instance(); int infoMask = 0; foreach (KFileItemDelegate::Information currentInfo, list) { - infoMask = infoMask | infoManager.bitValue(currentInfo); + infoMask = infoMask | infoAccessor.bitValue(currentInfo); } const int encodedInfo = encodedAdditionalInfo(infoMask); @@ -212,11 +200,11 @@ KFileItemDelegate::InformationList ViewProperties::additionalInfo() const const int decodedInfo = decodedAdditionalInfo(); - AdditionalInfoManager& infoManager = AdditionalInfoManager::instance(); - const KFileItemDelegate::InformationList infos = infoManager.keys(); + AdditionalInfoAccessor& infoAccessor = AdditionalInfoAccessor::instance(); + const KFileItemDelegate::InformationList infos = infoAccessor.keys(); foreach (const KFileItemDelegate::Information info, infos) { - if (decodedInfo & infoManager.bitValue(info)) { + if (decodedInfo & infoAccessor.bitValue(info)) { usedInfos.append(info); } } @@ -255,7 +243,7 @@ void ViewProperties::updateTimeStamp() void ViewProperties::save() { - KStandardDirs::makeDir(m_filepath); + KStandardDirs::makeDir(m_filePath); m_node->writeConfig(); m_changedProps = false; } @@ -304,9 +292,9 @@ int ViewProperties::decodedAdditionalInfo() const if (decodedInfo == 0) { // A details view without any additional info makes no sense, hence // provide at least a size-info and date-info as fallback - AdditionalInfoManager& infoManager = AdditionalInfoManager::instance(); - decodedInfo = infoManager.bitValue(KFileItemDelegate::Size) | - infoManager.bitValue(KFileItemDelegate::ModificationTime); + AdditionalInfoAccessor& infoAccessor = AdditionalInfoAccessor::instance(); + decodedInfo = infoAccessor.bitValue(KFileItemDelegate::Size) | + infoAccessor.bitValue(KFileItemDelegate::ModificationTime); } break; case DolphinView::IconsView: