From df55b9d89f0b064f1dfa0fd2ca0f6bd08ea0c8e4 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Wed, 14 May 2008 15:15:31 +0000 Subject: [PATCH] Only the infosidebar panel is interested in selections -> move it from the sidebar panel to the infosidebar panel. svn path=/trunk/KDE/kdebase/apps/; revision=807729 --- src/infosidebarpage.cpp | 19 +++++++++---------- src/infosidebarpage.h | 8 ++++++-- src/sidebarpage.cpp | 13 +------------ src/sidebarpage.h | 11 +---------- 4 files changed, 17 insertions(+), 34 deletions(-) diff --git a/src/infosidebarpage.cpp b/src/infosidebarpage.cpp index a6d8a0916..a9cc356d4 100644 --- a/src/infosidebarpage.cpp +++ b/src/infosidebarpage.cpp @@ -53,6 +53,7 @@ InfoSidebarPage::InfoSidebarPage(QWidget* parent) : m_shownUrl(), m_urlCandidate(), m_fileItem(), + m_selection(), m_nameLabel(0), m_preview(0), m_metaDataWidget(0), @@ -128,7 +129,7 @@ void InfoSidebarPage::setUrl(const KUrl& url) void InfoSidebarPage::setSelection(const KFileItemList& selection) { - SidebarPage::setSelection(selection); + m_selection = selection; const int count = selection.count(); if (count == 0) { @@ -150,7 +151,7 @@ void InfoSidebarPage::requestDelayedItemInfo(const KFileItem& item) if (item.isNull()) { // The cursor is above the viewport. If files are selected, // show information regarding the selection. - if (selection().size() > 0) { + if (m_selection.size() > 0) { m_timer->start(TimerDelay); } } else if (!item.url().isEmpty()) { @@ -194,13 +195,12 @@ void InfoSidebarPage::showItemInfo() cancelRequest(); - const KFileItemList& selectedItems = selection(); - const KUrl file = (!m_fileItem.isNull() || selectedItems.isEmpty()) ? m_shownUrl : selectedItems[0].url(); + const KUrl file = (!m_fileItem.isNull() || m_selection.isEmpty()) ? m_shownUrl : m_selection[0].url(); if (!file.isValid()) { return; } - const int selectionCount = selectedItems.count(); + const int selectionCount = m_selection.count(); if (m_fileItem.isNull() && (selectionCount > 1)) { KIconLoader iconLoader; QPixmap icon = iconLoader.loadIcon("dialog-information", @@ -290,12 +290,11 @@ void InfoSidebarPage::showMetaInfo() { m_metaTextLabel->clear(); - const KFileItemList& selectedItems = selection(); - if ((selectedItems.size() <= 1) || !m_fileItem.isNull()) { + if ((m_selection.size() <= 1) || !m_fileItem.isNull()) { KFileItem fileItem; if (m_fileItem.isNull()) { // no pending request is ongoing - const KUrl url = (selectedItems.size() == 1) ? selectedItems.first().url() : m_shownUrl; + const KUrl url = (m_selection.size() == 1) ? m_selection.first().url() : m_shownUrl; fileItem = KFileItem(KFileItem::Unknown, KFileItem::Unknown, url); fileItem.refresh(); } else { @@ -341,14 +340,14 @@ void InfoSidebarPage::showMetaInfo() } else { if (m_metaDataWidget != 0) { KUrl::List urls; - foreach (const KFileItem& item, selectedItems) { + foreach (const KFileItem& item, m_selection) { urls.append(item.targetUrl()); } m_metaDataWidget->setFiles(urls); } unsigned long int totalSize = 0; - foreach (const KFileItem& item, selectedItems) { + foreach (const KFileItem& item, m_selection) { // Only count the size of files, not dirs to match what // DolphinViewContainer::selectionStatusBarText() does. if (!item.isDir() && !item.isLink()) { diff --git a/src/infosidebarpage.h b/src/infosidebarpage.h index 6cdc1e824..fa9fa9d41 100644 --- a/src/infosidebarpage.h +++ b/src/infosidebarpage.h @@ -59,8 +59,11 @@ public slots: /** @see SidebarPage::setUrl() */ virtual void setUrl(const KUrl& url); - /** @see SidebarPage::setSelection() */ - virtual void setSelection(const KFileItemList& selection); + /** + * This is invoked to inform the sidebar that the user has selected a new + * set of items. + */ + void setSelection(const KFileItemList& selection); /** * Does a delayed request of information for the item \a item. @@ -135,6 +138,7 @@ private: KUrl m_shownUrl; // URL that is shown as info KUrl m_urlCandidate; // URL candidate that will replace m_shownURL after a delay KFileItem m_fileItem; // file item for m_shownUrl if available (otherwise null) + KFileItemList m_selection; QLabel* m_nameLabel; PixmapViewer* m_preview; diff --git a/src/sidebarpage.cpp b/src/sidebarpage.cpp index 889dc48c4..594f59f24 100644 --- a/src/sidebarpage.cpp +++ b/src/sidebarpage.cpp @@ -25,8 +25,7 @@ SidebarPage::SidebarPage(QWidget* parent) : QWidget(parent), - m_url(KUrl()), - m_currentSelection() + m_url(KUrl()) { } @@ -39,19 +38,9 @@ const KUrl& SidebarPage::url() const return m_url; } -const KFileItemList& SidebarPage::selection() const -{ - return m_currentSelection; -} - void SidebarPage::setUrl(const KUrl& url) { m_url = url; } -void SidebarPage::setSelection(const KFileItemList& selection) -{ - m_currentSelection = selection; -} - #include "sidebarpage.moc" diff --git a/src/sidebarpage.h b/src/sidebarpage.h index 1c6b26be3..20a44758e 100644 --- a/src/sidebarpage.h +++ b/src/sidebarpage.h @@ -31,6 +31,7 @@ class SidebarPage : public QWidget { Q_OBJECT + public: explicit SidebarPage(QWidget* parent = 0); virtual ~SidebarPage(); @@ -38,9 +39,6 @@ public: /** Returns the current set URL of the active Dolphin view. */ const KUrl& url() const; - /** Returns the current selected items of the active Dolphin view. */ - const KFileItemList& selection() const; - public slots: /** * This is invoked every time the folder being displayed in the @@ -48,15 +46,8 @@ public slots: */ virtual void setUrl(const KUrl& url); - /** - * This is invoked to inform the sidebar that the user has selected a new - * set of items. - */ - virtual void setSelection(const KFileItemList& selection); - private: KUrl m_url; - KFileItemList m_currentSelection; }; #endif // _SIDEBARPAGE_H_ -- 2.47.3