From cb9669d71cf10e73305c6a60fe0d832f4eb0ac7a Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Thu, 13 May 2010 22:06:10 +0000 Subject: If an information entry will be added to KFileItemDelegate (like done recently), adjusting the corresponding code in Dolphin is a real pain, as the new 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 To prevent similar painful transitions in future, the class AdditionalInfoManager has been introduced. All parts in Dolphin that access/show/store additional information, use the AdditionalInfoManager now. If a new information entry will be added in KFileItemDelegate in future, only a small adjustment in AdditionalInfoManager will be required. Still open currently: - AdditionalInfoDialog does not use AdditionalInfoManager yet - DolphinView::Sorting should be replaced by KFileItemDelegate::Information, so that the sorting can also be done in a generic way. - The data for KFileItemDelegate::PathOrUrl is not determined The open issues will get fixed during the next days. Kudos to the brave warriors Sebastian and Frank, that tried to add a new information ;-) CCMAIL: sebastian@trueg.de CCMAIL: frank78ac@googlemail.com svn path=/trunk/KDE/kdebase/apps/; revision=1126410 --- src/dolphinview.cpp | 61 ++++++++++------------------------------------------- 1 file changed, 11 insertions(+), 50 deletions(-) (limited to 'src/dolphinview.cpp') diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 5ad77f726..3cfeccfde 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -49,6 +49,7 @@ #include #include +#include "additionalinfomanager.h" #include "dolphinmodel.h" #include "dolphincolumnviewcontainer.h" #include "dolphinviewcontroller.h" @@ -971,59 +972,19 @@ void DolphinView::updateAdditionalInfo(const KFileItemDelegate::InformationList& 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)); } } -- cgit v1.3