########### next target ###############
set(dolphinprivate_LIB_SRCS
+ additionalinfomanager.cpp
dolphindetailsview.cpp
+ dolphindetailsviewexpander.cpp
dolphiniconsview.cpp
dolphincolumnview.cpp
dolphincolumnviewcontainer.cpp
dolphinviewautoscroller.cpp
dolphinviewcontroller.cpp
dolphinremoteencoding.cpp
- dolphindetailsviewexpander.cpp
draganddrophelper.cpp
folderexpander.cpp
renamedialog.cpp
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2010 by Peter Penz <peter.penz19@gmail.com> *
+ * *
+ * 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 *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+#include "additionalinfomanager.h"
+
+#include "dolphinmodel.h"
+#include <kglobal.h>
+#include <klocale.h>
+
+class AdditionalInfoManagerSingleton
+{
+public:
+ AdditionalInfoManager instance;
+};
+K_GLOBAL_STATIC(AdditionalInfoManagerSingleton, s_additionalInfoManager)
+
+AdditionalInfoManager& AdditionalInfoManager::instance()
+{
+ return s_additionalInfoManager->instance;
+}
+
+KFileItemDelegate::InformationList AdditionalInfoManager::keys() const
+{
+ return m_informations;
+}
+
+KFileItemDelegate::Information AdditionalInfoManager::keyForColumn(int columnIndex) const
+{
+ KFileItemDelegate::Information info = KFileItemDelegate::NoInformation;
+
+ switch (columnIndex) {
+ case DolphinModel::Size: info = KFileItemDelegate::Size; break;
+ case DolphinModel::ModifiedTime: info = KFileItemDelegate::ModificationTime; break;
+ case DolphinModel::Permissions: info = KFileItemDelegate::Permissions; break;
+ case DolphinModel::Owner: info = KFileItemDelegate::Owner; break;
+ case DolphinModel::Group: info = KFileItemDelegate::OwnerAndGroup; break;
+ case DolphinModel::Type: info = KFileItemDelegate::FriendlyMimeType; break;
+ case DolphinModel::LinkDest: info = KFileItemDelegate::LinkDest; break;
+ case DolphinModel::LocalPathOrUrl: info = KFileItemDelegate::LocalPathOrUrl; break;
+ default: break;
+ }
+
+ return info;
+}
+
+QString AdditionalInfoManager::actionCollectionName(KFileItemDelegate::Information info) const
+{
+ return QLatin1String(m_map[info]->actionCollectionName);
+}
+
+QString AdditionalInfoManager::translation(KFileItemDelegate::Information info) const
+{
+ return i18n(m_map[info]->translation);
+}
+
+int AdditionalInfoManager::bitValue(KFileItemDelegate::Information info) const
+{
+ return m_map[info]->bitValue;
+}
+
+AdditionalInfoManager::AdditionalInfoManager() :
+ m_informations(),
+ m_map()
+{
+ static const AdditionalInfoManager::AdditionalInfo additionalInfos[] = {
+ { "size", I18N_NOOP2("@label", "Size"), 1 },
+ { "date", I18N_NOOP2("@label", "Date"), 2 },
+ { "permissions", I18N_NOOP2("@label", "Permissions"), 4 },
+ { "owner", I18N_NOOP2("@label", "Owner"), 8 },
+ { "group", I18N_NOOP2("@label", "Group"), 16 },
+ { "type", I18N_NOOP2("@label", "Type"), 32 },
+ { "destination", I18N_NOOP2("@label", "Destination"), 64 },
+ { "path", I18N_NOOP2("@label", "Path"), 128 }
+ };
+
+ m_map.insert(KFileItemDelegate::Size, &additionalInfos[0]);
+ m_map.insert(KFileItemDelegate::ModificationTime, &additionalInfos[1]);
+ m_map.insert(KFileItemDelegate::Permissions, &additionalInfos[2]);
+ m_map.insert(KFileItemDelegate::Owner, &additionalInfos[3]);
+ m_map.insert(KFileItemDelegate::OwnerAndGroup, &additionalInfos[4]);
+ m_map.insert(KFileItemDelegate::FriendlyMimeType, &additionalInfos[5]);
+ m_map.insert(KFileItemDelegate::LinkDest, &additionalInfos[6]);
+ m_map.insert(KFileItemDelegate::LocalPathOrUrl, &additionalInfos[7]);
+
+ m_informations = m_map.keys();
+}
+
+AdditionalInfoManager::~AdditionalInfoManager()
+{
+}
+
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2010 by Peter Penz <peter.penz19@gmail.com> *
+ * *
+ * 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 *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+#ifndef ADDITIONALINFOMANAGER_H
+#define ADDITIONALINFOMANAGER_H
+
+#include <libdolphin_export.h>
+#include <kfileitemdelegate.h>
+
+#include <QList>
+#include <QMap>
+
+/**
+ * @brief Manages the information that is available by KFileItemDelegate::Information.
+ *
+ * The information that is available by KFileItemDelegate::Information will be shown
+ * in Dolphin the following way:
+ * - As additional columns in the details view
+ * - As additional lines in the icons view
+ * - As menu entries in the "Sort By" and "Additional Information" groups
+ * - As popup menu entries in the details view header popup
+ * - As checkable entries in the View Properties dialog
+ *
+ * The AdditionalInfoManager provides a central place to get all available keys,
+ * the corresponding translations, action names, etc., so that modifications or
+ * extensions in KFileItemDelegate only require adjustments in the implementation
+ * of this class.
+ */
+class LIBDOLPHINPRIVATE_EXPORT AdditionalInfoManager
+{
+public:
+ static AdditionalInfoManager& instance();
+
+ /**
+ * @return List of all available information entries of KFileItemDelegate.
+ * All entries of this list are keys for accessing the corresponding
+ * data (see actionCollectionName(), translation(), bitValue()).
+ */
+ KFileItemDelegate::InformationList keys() const;
+
+ /**
+ * @return Key for the model column with the index \p columnIndex.
+ */
+ KFileItemDelegate::Information keyForColumn(int columnIndex) const;
+
+ QString actionCollectionName(KFileItemDelegate::Information info) const;
+
+ QString translation(KFileItemDelegate::Information info) const;
+
+ /**
+ * @return Bitvalue for \p info that is stored in a ViewProperties instance.
+ */
+ int bitValue(KFileItemDelegate::Information info) const;
+
+protected:
+ AdditionalInfoManager();
+ virtual ~AdditionalInfoManager();
+ friend class AdditionalInfoManagerSingleton;
+
+private:
+ struct AdditionalInfo {
+ const char* const actionCollectionName;
+ const char* const translation;
+ const int bitValue;
+ };
+
+ KFileItemDelegate::InformationList m_informations;
+ QMap<KFileItemDelegate::Information, const AdditionalInfo*> m_map;
+};
+
+#endif
+
#include "dolphindetailsview.h"
+#include "additionalinfomanager.h"
#include "dolphinmodel.h"
#include "dolphinviewcontroller.h"
#include "dolphinfileitemdelegate.h"
for (int i = 0; i < columns; ++i) {
const int logicalIndex = headerView->logicalIndex(i);
const QString text = model()->headerData(logicalIndex, Qt::Horizontal).toString();
- QAction* action = popup.addAction(text);
- action->setCheckable(true);
- action->setChecked(!headerView->isSectionHidden(logicalIndex));
- action->setData(logicalIndex);
- action->setEnabled(logicalIndex != DolphinModel::Name);
+ if (!text.isEmpty()) {
+ QAction* action = popup.addAction(text);
+ action->setCheckable(true);
+ action->setChecked(!headerView->isSectionHidden(logicalIndex));
+ action->setData(logicalIndex);
+ action->setEnabled(logicalIndex != DolphinModel::Name);
+ }
}
popup.addSeparator();
KFileItemDelegate::Information DolphinDetailsView::infoForColumn(int columnIndex) const
{
- KFileItemDelegate::Information info = KFileItemDelegate::NoInformation;
-
- switch (columnIndex) {
- case DolphinModel::Size: info = KFileItemDelegate::Size; break;
- case DolphinModel::ModifiedTime: info = KFileItemDelegate::ModificationTime; break;
- case DolphinModel::Permissions: info = KFileItemDelegate::Permissions; break;
- case DolphinModel::Owner: info = KFileItemDelegate::Owner; break;
- case DolphinModel::Group: info = KFileItemDelegate::OwnerAndGroup; break;
- case DolphinModel::Type: info = KFileItemDelegate::FriendlyMimeType; break;
- case DolphinModel::LinkDestination: info = KFileItemDelegate::LinkDest; break;
- default: break;
- }
-
- return info;
+ return AdditionalInfoManager::instance().keyForColumn(columnIndex);
}
void DolphinDetailsView::resizeColumns()
QFontMetrics fontMetrics(viewport()->font());
int columnWidth[DolphinModel::ExtraColumnCount];
+ const int defaultWidth = fontMetrics.width("xxxxxxxxxx");
+ for (int i = 0; i < DolphinModel::ExtraColumnCount; ++i) {
+ columnWidth[i] = defaultWidth;
+ }
columnWidth[DolphinModel::Size] = fontMetrics.width("00000 Items");
columnWidth[DolphinModel::ModifiedTime] = fontMetrics.width("0000-00-00 00:00");
- columnWidth[DolphinModel::Permissions] = fontMetrics.width("xxxxxxxxxx");
- columnWidth[DolphinModel::Owner] = fontMetrics.width("xxxxxxxxxx");
- columnWidth[DolphinModel::Group] = fontMetrics.width("xxxxxxxxxx");
- columnWidth[DolphinModel::Type] = fontMetrics.width("XXXX Xxxxxxx");
- columnWidth[DolphinModel::Version] = fontMetrics.width("xxxxxxxx");
- columnWidth[DolphinModel::LinkDestination] = fontMetrics.width("xxxxxxxx");
int requiredWidth = 0;
for (int i = KDirModel::Size; i <= KDirModel::Type; ++i) {
break;
case Qt::DisplayRole:
- if (index.column() == DolphinModel::Version) {
- switch (m_revisionHash.value(index, KVersionControlPlugin::UnversionedVersion)) {
- case KVersionControlPlugin::NormalVersion:
- return i18nc("@item::intable", "Normal");
- case KVersionControlPlugin::UpdateRequiredVersion:
- return i18nc("@item::intable", "Update required");
- case KVersionControlPlugin::LocallyModifiedVersion:
- return i18nc("@item::intable", "Locally modified");
- case KVersionControlPlugin::AddedVersion:
- return i18nc("@item::intable", "Added");
- case KVersionControlPlugin::RemovedVersion:
- return i18nc("@item::intable", "Removed");
- case KVersionControlPlugin::ConflictingVersion:
- return i18nc("@item::intable", "Conflicting");
- case KVersionControlPlugin::UnversionedVersion:
- default:
- return i18nc("@item::intable", "Unversioned");
- }
+ switch (index.column()) {
+ case DolphinModel::LinkDest: {
+ const KDirModel *dirModel = qobject_cast<const KDirModel*>(index.model());
+ const KFileItem item = dirModel->itemForIndex(index);
+ return item.linkDest();
+ }
+
+ case DolphinModel::LocalPathOrUrl:
+ // TODO:
+ break;
}
- else if (index.column() == DolphinModel::LinkDestination) {
- const KDirModel *dirModel = qobject_cast<const KDirModel*>(index.model());
- KFileItem item = dirModel->itemForIndex(index);
- return item.linkDest();
- }
-
break;
default:
{
if ((orientation == Qt::Horizontal) && (role == Qt::DisplayRole)) {
switch (section) {
- case DolphinModel::Version:
- return i18nc("@title::column", "Version");
- case DolphinModel::LinkDestination:
- return i18nc("@title::column", "Link Destination");
+ case DolphinModel::LinkDest:
+ return i18nc("@title::column", "Destination");
+ case DolphinModel::LocalPathOrUrl:
+ return i18nc("@title::column", "Path");
default:
return KDirModel::headerData(section, orientation, role);
}
public:
enum AdditionalColumns {
Version = KDirModel::ColumnCount,
- LinkDestination,
- ExtraColumnCount
+ LinkDest,
+ LocalPathOrUrl,
+ ExtraColumnCount // Mandatory last entry
};
DolphinModel(QObject* parent = 0);
virtual ~DolphinModel();
virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
- virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
+ virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
#include <ktoggleaction.h>
#include <kurl.h>
+#include "additionalinfomanager.h"
#include "dolphinmodel.h"
#include "dolphincolumnviewcontainer.h"
#include "dolphinviewcontroller.h"
void DolphinView::updateAdditionalInfoActions(KActionCollection* collection)
{
+ const AdditionalInfoManager& infoManager = AdditionalInfoManager::instance();
+
+ const KFileItemDelegate::InformationList checkedInfos = m_viewAccessor.itemDelegate()->showInformation();
+ const KFileItemDelegate::InformationList infos = infoManager.keys();
+
const bool enable = (m_mode == DolphinView::DetailsView) ||
(m_mode == DolphinView::IconsView);
- QAction* showSizeInfo = collection->action("show_size_info");
- QAction* showDateInfo = collection->action("show_date_info");
- QAction* showPermissionsInfo = collection->action("show_permissions_info");
- QAction* showOwnerInfo = collection->action("show_owner_info");
- QAction* showGroupInfo = collection->action("show_group_info");
- QAction* showMimeInfo = collection->action("show_mime_info");
- QAction* showPathOrUrlInfo = collection->action("show_path_or_url_info");
-
- showSizeInfo->setChecked(false);
- showDateInfo->setChecked(false);
- showPermissionsInfo->setChecked(false);
- showOwnerInfo->setChecked(false);
- showGroupInfo->setChecked(false);
- showMimeInfo->setChecked(false);
- showPathOrUrlInfo->setChecked(false);
-
- showSizeInfo->setEnabled(enable);
- showDateInfo->setEnabled(enable);
- showPermissionsInfo->setEnabled(enable);
- showOwnerInfo->setEnabled(enable);
- showGroupInfo->setEnabled(enable);
- showMimeInfo->setEnabled(enable);
- showPathOrUrlInfo->setEnabled(enable);
-
- foreach (KFileItemDelegate::Information info, m_viewAccessor.itemDelegate()->showInformation()) {
- switch (info) {
- case KFileItemDelegate::Size:
- showSizeInfo->setChecked(true);
- break;
- case KFileItemDelegate::ModificationTime:
- showDateInfo->setChecked(true);
- break;
- case KFileItemDelegate::Permissions:
- showPermissionsInfo->setChecked(true);
- break;
- case KFileItemDelegate::Owner:
- showOwnerInfo->setChecked(true);
- break;
- case KFileItemDelegate::OwnerAndGroup:
- showGroupInfo->setChecked(true);
- break;
- case KFileItemDelegate::FriendlyMimeType:
- showMimeInfo->setChecked(true);
- break;
- case KFileItemDelegate::LocalPathOrUrl:
- showPathOrUrlInfo->setChecked(true);
- break;
- default:
- break;
- }
+ foreach (const KFileItemDelegate::Information& info, infos) {
+ QAction* action = collection->action(infoManager.actionCollectionName(info));
+ Q_ASSERT(action != 0);
+ action->setEnabled(enable);
+ action->setChecked(checkedInfos.contains(info));
}
}
#include "dolphinviewactionhandler.h"
+#include "additionalinfomanager.h"
#include "settings/viewpropertiesdialog.h"
#include "dolphinview.h"
#include "zoomlevelinfo.h"
#include <kaction.h>
#include <kactioncollection.h>
#include <kactionmenu.h>
-#include <kselectaction.h>
+#include <kfileitemdelegate.h>
#include <klocale.h>
#include <knewmenu.h>
+#include <kselectaction.h>
#include <ktoggleaction.h>
#include <krun.h>
#include <kpropertiesdialog.h>
showInformationMenu->setText(i18nc("@action:inmenu View", "Additional Information"));
showInformationMenu->setDelayed(false);
- KToggleAction* showSizeInfo = m_actionCollection->add<KToggleAction>("show_size_info");
- showSizeInfo->setText(i18nc("@action:inmenu Additional information", "Size"));
- showSizeInfo->setData(KFileItemDelegate::Size);
- showSizeInfo->setActionGroup(additionalInfoGroup);
-
- KToggleAction* showDateInfo = m_actionCollection->add<KToggleAction>("show_date_info");
- showDateInfo->setText(i18nc("@action:inmenu Additional information", "Date"));
- showDateInfo->setData(KFileItemDelegate::ModificationTime);
- showDateInfo->setActionGroup(additionalInfoGroup);
-
- KToggleAction* showPermissionsInfo = m_actionCollection->add<KToggleAction>("show_permissions_info");
- showPermissionsInfo->setText(i18nc("@action:inmenu Additional information", "Permissions"));
- showPermissionsInfo->setData(KFileItemDelegate::Permissions);
- showPermissionsInfo->setActionGroup(additionalInfoGroup);
-
- KToggleAction* showOwnerInfo = m_actionCollection->add<KToggleAction>("show_owner_info");
- showOwnerInfo->setText(i18nc("@action:inmenu Additional information", "Owner"));
- showOwnerInfo->setData(KFileItemDelegate::Owner);
- showOwnerInfo->setActionGroup(additionalInfoGroup);
-
- KToggleAction* showGroupInfo = m_actionCollection->add<KToggleAction>("show_group_info");
- showGroupInfo->setText(i18nc("@action:inmenu Additional information", "Group"));
- showGroupInfo->setData(KFileItemDelegate::OwnerAndGroup);
- showGroupInfo->setActionGroup(additionalInfoGroup);
-
- KToggleAction* showMimeInfo = m_actionCollection->add<KToggleAction>("show_mime_info");
- showMimeInfo->setText(i18nc("@action:inmenu Additional information", "Type"));
- showMimeInfo->setData(KFileItemDelegate::FriendlyMimeType);
- showMimeInfo->setActionGroup(additionalInfoGroup);
-
- KToggleAction* showPathOrUrlInfo = m_actionCollection->add<KToggleAction>("show_path_or_url_info");
- showPathOrUrlInfo->setText(i18nc("@action:inmenu Additional information", "Path"));
- showPathOrUrlInfo->setData(KFileItemDelegate::LocalPathOrUrl);
- showPathOrUrlInfo->setActionGroup(additionalInfoGroup);
+ const AdditionalInfoManager& infoManager = AdditionalInfoManager::instance();
+
+ const KFileItemDelegate::InformationList infos = infoManager.keys();
+ foreach (KFileItemDelegate::Information info, infos) {
+ const QString name = infoManager.actionCollectionName(info);
+ KToggleAction* action = m_actionCollection->add<KToggleAction>(name);
+ action->setText(infoManager.translation(info));
+ action->setData(info);
+ action->setActionGroup(additionalInfoGroup);
+ }
return additionalInfoGroup;
}
QActionGroup* sortByActionGroup = new QActionGroup(m_actionCollection);
sortByActionGroup->setExclusive(true);
- KToggleAction* sortByName = m_actionCollection->add<KToggleAction>("sort_by_name");
+ KToggleAction* sortByName = m_actionCollection->add<KToggleAction>("name");
sortByName->setText(i18nc("@action:inmenu Sort By", "Name"));
sortByName->setData(QVariant::fromValue(DolphinView::SortByName));
sortByActionGroup->addAction(sortByName);
- KToggleAction* sortBySize = m_actionCollection->add<KToggleAction>("sort_by_size");
- sortBySize->setText(i18nc("@action:inmenu Sort By", "Size"));
- sortBySize->setData(QVariant::fromValue(DolphinView::SortBySize));
- sortByActionGroup->addAction(sortBySize);
-
- KToggleAction* sortByDate = m_actionCollection->add<KToggleAction>("sort_by_date");
- sortByDate->setText(i18nc("@action:inmenu Sort By", "Date"));
- sortByDate->setData(QVariant::fromValue(DolphinView::SortByDate));
- sortByActionGroup->addAction(sortByDate);
-
- KToggleAction* sortByPermissions = m_actionCollection->add<KToggleAction>("sort_by_permissions");
- sortByPermissions->setText(i18nc("@action:inmenu Sort By", "Permissions"));
- sortByPermissions->setData(QVariant::fromValue(DolphinView::SortByPermissions));
- sortByActionGroup->addAction(sortByPermissions);
-
- KToggleAction* sortByOwner = m_actionCollection->add<KToggleAction>("sort_by_owner");
- sortByOwner->setText(i18nc("@action:inmenu Sort By", "Owner"));
- sortByOwner->setData(QVariant::fromValue(DolphinView::SortByOwner));
- sortByActionGroup->addAction(sortByOwner);
-
- KToggleAction* sortByGroup = m_actionCollection->add<KToggleAction>("sort_by_group");
- sortByGroup->setText(i18nc("@action:inmenu Sort By", "Group"));
- sortByGroup->setData(QVariant::fromValue(DolphinView::SortByGroup));
- sortByActionGroup->addAction(sortByGroup);
-
- KToggleAction* sortByType = m_actionCollection->add<KToggleAction>("sort_by_type");
- sortByType->setText(i18nc("@action:inmenu Sort By", "Type"));
- sortByType->setData(QVariant::fromValue(DolphinView::SortByType));
- sortByActionGroup->addAction(sortByType);
+ const AdditionalInfoManager& infoManager = AdditionalInfoManager::instance();
+ const KFileItemDelegate::InformationList infos = infoManager.keys();
+ foreach (KFileItemDelegate::Information info, infos) {
+ const QString name = infoManager.actionCollectionName(info);
+ KToggleAction* action = m_actionCollection->add<KToggleAction>(name);
+ action->setText(infoManager.translation(info));
+ // TODO: replace DolphinView::Sorting by KFileItemDelegate::Information!
+ action->setData(QVariant::fromValue(DolphinView::SortByName));
+ sortByActionGroup->addAction(action);
+ }
return sortByActionGroup;
}
{
switch (event->type()) {
case QEvent::Polish:
- // hide all columns except of the 'Name' column
- hideColumn(DolphinModel::Size);
- hideColumn(DolphinModel::ModifiedTime);
- hideColumn(DolphinModel::Permissions);
- hideColumn(DolphinModel::Owner);
- hideColumn(DolphinModel::Group);
- hideColumn(DolphinModel::Type);
- hideColumn(DolphinModel::Version);
- hideColumn(DolphinModel::LinkDestination);
+ // Hide all columns except of the 'Name' column
+ for (int i = DolphinModel::Name + 1; i < DolphinModel::ExtraColumnCount; ++i) {
+ hideColumn(i);
+ }
header()->hide();
break;
#include "viewproperties.h"
+#include "additionalinfomanager.h"
#include "settings/dolphinsettings.h"
#include "dolphin_directoryviewpropertysettings.h"
#include "dolphin_generalsettings.h"
#include <QFile>
#include <QFileInfo>
-#define FILE_NAME "/.directory"
-
ViewProperties::ViewProperties(const KUrl& url) :
m_changedProps(false),
m_autoSave(true),
cleanUrl.cleanPath();
m_filepath = cleanUrl.toLocalFile();
+ const QLatin1String fileName("/.directory");
+
if ((m_filepath.length() < 1) || (!QDir::isAbsolutePath(m_filepath))) {
- const QString file = destinationDir("global") + FILE_NAME;
+ const QString file = destinationDir("global") + fileName;
m_node = new ViewPropertySettings(KSharedConfig::openConfig(file));
return;
}
m_filepath = destinationDir("remote") + m_filepath;
}
- const QString file = m_filepath + FILE_NAME;
+ const QString file = m_filepath + fileName;
m_node = new ViewPropertySettings(KSharedConfig::openConfig(file));
const bool useDefaultProps = !useGlobalViewProps &&
return m_node->sortFoldersFirst();
}
-void ViewProperties::setAdditionalInfo(KFileItemDelegate::InformationList list)
+void ViewProperties::setAdditionalInfo(const KFileItemDelegate::InformationList& list)
{
- int info = NoInfo;
+ AdditionalInfoManager& infoManager = AdditionalInfoManager::instance();
+
+ int infoMask = 0;
foreach (KFileItemDelegate::Information currentInfo, list) {
- switch (currentInfo) {
- case KFileItemDelegate::Size:
- info = info | SizeInfo;
- break;
- case KFileItemDelegate::ModificationTime:
- info = info | DateInfo;
- break;
- case KFileItemDelegate::Permissions:
- info = info | PermissionsInfo;
- break;
- case KFileItemDelegate::Owner:
- info = info | OwnerInfo;
- break;
- case KFileItemDelegate::OwnerAndGroup:
- info = info | GroupInfo;
- break;
- case KFileItemDelegate::FriendlyMimeType:
- info = info | TypeInfo;
- break;
- case KFileItemDelegate::LocalPathOrUrl:
- info = info | PathOrUrlInfo;
- break;
- default:
- break;
- }
+ infoMask = infoMask | infoManager.bitValue(currentInfo);
}
- const int encodedInfo = encodedAdditionalInfo(info);
+ const int encodedInfo = encodedAdditionalInfo(infoMask);
if (m_node->additionalInfo() != encodedInfo) {
m_node->setAdditionalInfo(encodedInfo);
updateTimeStamp();
KFileItemDelegate::InformationList ViewProperties::additionalInfo() const
{
- const int info = decodedAdditionalInfo();
+ KFileItemDelegate::InformationList usedInfos;
- KFileItemDelegate::InformationList list;
- if (info & SizeInfo) {
- list.append(KFileItemDelegate::Size);
- }
- if (info & DateInfo) {
- list.append(KFileItemDelegate::ModificationTime);
- }
- if (info & PermissionsInfo) {
- list.append(KFileItemDelegate::Permissions);
- }
- if (info & OwnerInfo) {
- list.append(KFileItemDelegate::Owner);
- }
- if (info & GroupInfo) {
- list.append(KFileItemDelegate::OwnerAndGroup);
- }
- if (info & TypeInfo) {
- list.append(KFileItemDelegate::FriendlyMimeType);
- }
- if (info & PathOrUrlInfo) {
- list.append(KFileItemDelegate::LocalPathOrUrl);
+ const int decodedInfo = decodedAdditionalInfo();
+
+ AdditionalInfoManager& infoManager = AdditionalInfoManager::instance();
+ const KFileItemDelegate::InformationList infos = infoManager.keys();
+
+ foreach (const KFileItemDelegate::Information info, infos) {
+ if (decodedInfo & infoManager.bitValue(info)) {
+ usedInfos.append(info);
+ }
}
- return list;
+ return usedInfos;
}
switch (viewMode()) {
case DolphinView::DetailsView:
decodedInfo = decodedInfo & 0xFF;
- if (decodedInfo == NoInfo) {
- // a details view without any additional info makes no sense, hence
+ 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
- decodedInfo = SizeInfo | DateInfo;
+ AdditionalInfoManager& infoManager = AdditionalInfoManager::instance();
+ decodedInfo = infoManager.bitValue(KFileItemDelegate::Size) |
+ infoManager.bitValue(KFileItemDelegate::ModificationTime);
}
break;
case DolphinView::IconsView:
* Note that the additional-info property is the only property where
* the value is dependent from another property (in this case the view-mode).
*/
- void setAdditionalInfo(KFileItemDelegate::InformationList info);
+ void setAdditionalInfo(const KFileItemDelegate::InformationList& info);
/**
* Returns the additional information for the current set view-mode.
Q_DISABLE_COPY(ViewProperties)
private:
- enum AdditionalInfoValues
- {
- NoInfo = 0,
- SizeInfo = 1,
- DateInfo = 2,
- PermissionsInfo = 4,
- OwnerInfo = 8,
- GroupInfo = 16,
- TypeInfo = 32,
- PathOrUrlInfo = 64
- };
-
bool m_changedProps;
bool m_autoSave;
QString m_filepath;