]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Move the code handling the additional-info-actions to DolphinView; simplify signal...
authorDavid Faure <faure@kde.org>
Tue, 22 Jan 2008 01:22:56 +0000 (01:22 +0000)
committerDavid Faure <faure@kde.org>
Tue, 22 Jan 2008 01:22:56 +0000 (01:22 +0000)
The fact that the last additional-info doesn't show up in the icon view is in fact a KFileItemDelegate bug, not a bug in this code :)

svn path=/branches/KDE/4.0/kdebase/apps/; revision=764544

src/dolphindetailsview.cpp
src/dolphiniconsview.cpp
src/dolphiniconsview.h
src/dolphinmainwindow.cpp
src/dolphinmainwindow.h
src/dolphinview.cpp
src/dolphinview.h

index 4fdb76e1a777785690be48b194dcf027a88a73b7..2861c134fb6d90da874e47f74924109716079d2d 100644 (file)
@@ -101,7 +101,7 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
             this, SLOT(zoomIn()));
     connect(controller, SIGNAL(zoomOut()),
             this, SLOT(zoomOut()));
-    connect(controller->dolphinView(), SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList&)),
+    connect(controller->dolphinView(), SIGNAL(additionalInfoChanged()),
             this, SLOT(updateColumnVisibility()));
 
     // apply the details mode settings to the widget
index 553cdcfe62e8a84630aaa945a222f0f76dc1282b..d3d485f1a05f1f3cb600dd7f11d53ce7e7d1a98d 100644 (file)
@@ -78,8 +78,8 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
     const DolphinView* view = controller->dolphinView();
     connect(view, SIGNAL(showPreviewChanged()),
             this, SLOT(slotShowPreviewChanged()));
-    connect(view, SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList&)),
-            this, SLOT(slotAdditionalInfoChanged(const KFileItemDelegate::InformationList&)));
+    connect(view, SIGNAL(additionalInfoChanged()),
+            this, SLOT(slotAdditionalInfoChanged()));
 
     connect(this, SIGNAL(entered(const QModelIndex&)),
             this, SLOT(slotEntered(const QModelIndex&)));
@@ -301,10 +301,11 @@ void DolphinIconsView::slotShowPreviewChanged()
     updateGridSize(view->showPreview(), additionalInfoCount());
 }
 
-void DolphinIconsView::slotAdditionalInfoChanged(const KFileItemDelegate::InformationList& info)
+void DolphinIconsView::slotAdditionalInfoChanged()
 {
-    const bool showPreview = m_controller->dolphinView()->showPreview();
-    updateGridSize(showPreview, info.count());
+    const DolphinView* view = m_controller->dolphinView();
+    const bool showPreview = view->showPreview();
+    updateGridSize(showPreview, view->additionalInfo().count());
 }
 
 void DolphinIconsView::zoomIn()
index 06c41786822c537dac08863ad9621ae60fce5e08..af65bbda8af715ebcedf7c7c69fd183ac5e2a08c 100644 (file)
@@ -67,7 +67,7 @@ private slots:
     void triggerItem(const QModelIndex& index);
     void slotEntered(const QModelIndex& index);
     void slotShowPreviewChanged();
-    void slotAdditionalInfoChanged(const KFileItemDelegate::InformationList& info);
+    void slotAdditionalInfoChanged();
     void zoomIn();
     void zoomOut();
 
index ce13796ac3fca63838cf1a8b83ce243823eeff74..44a44efa219868852c5ab487c38cb5b06a3d2259 100644 (file)
@@ -256,58 +256,10 @@ void DolphinMainWindow::slotSortOrderChanged(Qt::SortOrder order)
     descending->setChecked(sortDescending);
 }
 
-void DolphinMainWindow::slotAdditionalInfoChanged(KFileItemDelegate::InformationList list)
-{
-    QAction* showSizeInfo = actionCollection()->action("show_size_info");
-    QAction* showDateInfo = actionCollection()->action("show_date_info");
-    QAction* showPermissionsInfo = actionCollection()->action("show_permissions_info");
-    QAction* showOwnerInfo = actionCollection()->action("show_owner_info");
-    QAction* showGroupInfo = actionCollection()->action("show_group_info");
-    QAction* showMimeInfo = actionCollection()->action("show_mime_info");
-
-    showSizeInfo->setChecked(false);
-    showDateInfo->setChecked(false);
-    showPermissionsInfo->setChecked(false);
-    showOwnerInfo->setChecked(false);
-    showGroupInfo->setChecked(false);
-    showMimeInfo->setChecked(false);
-
-    const DolphinView* view = m_activeViewContainer->view();
-
-    const bool enable = (view->mode() == DolphinView::DetailsView) ||
-                        (view->mode() == DolphinView::IconsView);
-
-    showSizeInfo->setEnabled(enable);
-    showDateInfo->setEnabled(enable);
-    showPermissionsInfo->setEnabled(enable);
-    showOwnerInfo->setEnabled(enable);
-    showGroupInfo->setEnabled(enable);
-    showMimeInfo->setEnabled(enable);
-
-    foreach (KFileItemDelegate::Information info, list) {
-        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;
-        default:
-            break;
-        }
-    }
+void DolphinMainWindow::slotAdditionalInfoChanged()
+{
+    DolphinView* view = m_activeViewContainer->view();
+    view->updateAdditionalInfoActions(actionCollection());
 }
 
 void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection)
@@ -1333,7 +1285,7 @@ void DolphinMainWindow::updateViewActions()
     slotSortingChanged(view->sorting());
     slotSortOrderChanged(view->sortOrder());
     slotCategorizedSortingChanged();
-    slotAdditionalInfoChanged(view->additionalInfo());
+    slotAdditionalInfoChanged();
 
     KToggleAction* showFilterBarAction =
         static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
@@ -1386,8 +1338,8 @@ void DolphinMainWindow::connectViewSignals(int viewIndex)
             this, SLOT(slotSortingChanged(DolphinView::Sorting)));
     connect(view, SIGNAL(sortOrderChanged(Qt::SortOrder)),
             this, SLOT(slotSortOrderChanged(Qt::SortOrder)));
-    connect(view, SIGNAL(additionalInfoChanged(KFileItemDelegate::InformationList)),
-            this, SLOT(slotAdditionalInfoChanged(KFileItemDelegate::InformationList)));
+    connect(view, SIGNAL(additionalInfoChanged()),
+            this, SLOT(slotAdditionalInfoChanged()));
     connect(view, SIGNAL(selectionChanged(KFileItemList)),
             this, SLOT(slotSelectionChanged(KFileItemList)));
     connect(view, SIGNAL(requestItemInfo(KFileItem)),
@@ -1424,25 +1376,7 @@ void DolphinMainWindow::updateSplitAction()
 void DolphinMainWindow::toggleAdditionalInfo(QAction* action)
 {
     clearStatusBar();
-
-    const KFileItemDelegate::Information info =
-        static_cast<KFileItemDelegate::Information>(action->data().toInt());
-
-    DolphinView* view = m_activeViewContainer->view();
-    KFileItemDelegate::InformationList list = view->additionalInfo();
-
-    const bool show = action->isChecked();
-
-    const int index = list.indexOf(info);
-    const bool containsInfo = (index >= 0);
-    if (show && !containsInfo) {
-        list.append(info);
-        view->setAdditionalInfo(list);
-    } else if (!show && containsInfo) {
-        list.removeAt(index);
-        view->setAdditionalInfo(list);
-        Q_ASSERT(list.indexOf(info) < 0);
-    }
+    m_activeViewContainer->view()->toggleAdditionalInfo(action);
 }
 
 DolphinMainWindow::UndoUiInterface::UndoUiInterface(DolphinMainWindow* mainWin) :
index ab96cd1552f62b306cc6587956ee4ef8c19e2460..444a4a94687023ffb048eab3d06047e04239d070 100644 (file)
@@ -274,8 +274,8 @@ private slots:
     void toggleSortCategorization();
 
     /**
-     * Applies \a info dependent from the current checked state of the action
-     * \a actionName to the file item delegate.
+     * Switches on or off the displaying of additional information
+     * as specified by \a action.
      */
     void toggleAdditionalInfo(QAction* action);
 
@@ -376,7 +376,7 @@ private slots:
     void slotSortOrderChanged(Qt::SortOrder order);
 
     /** Updates the state of the 'Additional Information' actions. */
-    void slotAdditionalInfoChanged(KFileItemDelegate::InformationList info);
+    void slotAdditionalInfoChanged();
 
     /**
      * Updates the state of the 'Edit' menu actions and emits
index 575af51bd38af7aea2c85d9cba905c4e5e6f312b..4aeabb265041dd32e1c734c3e3102c8831634ca8 100644 (file)
@@ -215,7 +215,7 @@ void DolphinView::setMode(Mode mode)
     // additional information manually
     const KFileItemDelegate::InformationList infoList = props.additionalInfo();
     m_fileItemDelegate->setShowInformation(infoList);
-    emit additionalInfoChanged(infoList);
+    emit additionalInfoChanged();
 
     // Not all view modes support categorized sorting. Adjust the sorting model
     // if changing the view mode results in a change of the categorized sorting
@@ -467,7 +467,7 @@ void DolphinView::setAdditionalInfo(KFileItemDelegate::InformationList info)
     props.setAdditionalInfo(info);
     m_fileItemDelegate->setShowInformation(info);
 
-    emit additionalInfoChanged(info);
+    emit additionalInfoChanged();
 
     if (itemView() != m_detailsView) {
         // the details view requires no reloading of the directory, as it maps
@@ -708,7 +708,7 @@ void DolphinView::applyViewProperties(const KUrl& url)
     KFileItemDelegate::InformationList info = props.additionalInfo();
     if (info != m_fileItemDelegate->showInformation()) {
         m_fileItemDelegate->setShowInformation(info);
-        emit additionalInfoChanged(info);
+        emit additionalInfoChanged();
     }
 
     const bool showPreview = props.showPreview();
@@ -810,8 +810,80 @@ void DolphinView::updateAdditionalInfo(const KFileItemDelegate::InformationList&
 
     m_fileItemDelegate->setShowInformation(info);
 
-    emit additionalInfoChanged(info);
+    emit additionalInfoChanged(); // will call updateAdditionalInfoActions just below
+}
+
+void DolphinView::updateAdditionalInfoActions(KActionCollection* collection)
+{
+    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");
+
+    showSizeInfo->setChecked(false);
+    showDateInfo->setChecked(false);
+    showPermissionsInfo->setChecked(false);
+    showOwnerInfo->setChecked(false);
+    showGroupInfo->setChecked(false);
+    showMimeInfo->setChecked(false);
+
+    showSizeInfo->setEnabled(enable);
+    showDateInfo->setEnabled(enable);
+    showPermissionsInfo->setEnabled(enable);
+    showOwnerInfo->setEnabled(enable);
+    showGroupInfo->setEnabled(enable);
+    showMimeInfo->setEnabled(enable);
+
+    foreach (KFileItemDelegate::Information info, m_fileItemDelegate->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;
+        default:
+            break;
+        }
+    }
+}
+
+void DolphinView::toggleAdditionalInfo(QAction* action)
+{
+    const KFileItemDelegate::Information info =
+        static_cast<KFileItemDelegate::Information>(action->data().toInt());
+
+    KFileItemDelegate::InformationList list = additionalInfo();
 
+    const bool show = action->isChecked();
+
+    const int index = list.indexOf(info);
+    const bool containsInfo = (index >= 0);
+    if (show && !containsInfo) {
+        list.append(info);
+        setAdditionalInfo(list);
+    } else if (!show && containsInfo) {
+        list.removeAt(index);
+        setAdditionalInfo(list);
+        Q_ASSERT(list.indexOf(info) < 0);
+    }
 }
 
 void DolphinView::emitContentsMoved()
index e69f0bbc6562f9a8e2d7540c5b128524c2b90b17..a85c184ef3febd945471f8eae4493abe3e0ff5f1 100644 (file)
@@ -381,6 +381,11 @@ public:
      */
     static QActionGroup* createAdditionalInformationActionGroup(KActionCollection* collection);
 
+    /**
+     * Updates the state of the 'Additional Information' actions in \a collection.
+     */
+    void updateAdditionalInfoActions(KActionCollection* collection);
+
     /**
      * Returns the action name corresponding to the current view mode
      */
@@ -439,6 +444,12 @@ public slots:
     /** Switches between an ascending and descending sorting order. */
     void toggleSortOrder();
 
+    /**
+     * Switches on or off the displaying of additional information
+     * as specified by \a action.
+     */
+    void toggleAdditionalInfo(QAction* action);
+
 signals:
     /**
      * Is emitted if the view has been activated by e. g. a mouse click.
@@ -474,8 +485,8 @@ signals:
     /** Is emitted if the sort order (ascending or descending) has been changed. */
     void sortOrderChanged(Qt::SortOrder order);
 
-    /** Is emitted if the additional information for an item has been changed. */
-    void additionalInfoChanged(const KFileItemDelegate::InformationList& info);
+    /** Is emitted if the additional information shown for this view has been changed. */
+    void additionalInfoChanged();
 
     /**
      * Is emitted if information of an item is requested to be shown e. g. in the sidebar.