From d337ece6df43337eff338758ace5204937a000b7 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Sat, 26 Jul 2008 13:46:58 +0000 Subject: [PATCH] Provide a 'int selectedItemsCount() const' interface for performance reasons, so that code which just needs to know whether items have been selected does not need to invoke selectedItems().count(), which is quite expensive. svn path=/trunk/KDE/kdebase/apps/; revision=838037 --- src/dolphinview.cpp | 11 +++++++++++ src/dolphinview.h | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 0b04d0afa..97bce5aac 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -329,6 +329,17 @@ KUrl::List DolphinView::selectedUrls() const return urls; } +int DolphinView::selectedItemsCount() const +{ + if (isColumnViewActive()) { + // TODO: get rid of this special case by adjusting the dir lister + // to the current column + return m_columnView->selectedItems().count(); + } + + return itemView()->selectionModel()->selection().count(); +} + void DolphinView::setContentsPosition(int x, int y) { QAbstractItemView* view = itemView(); diff --git a/src/dolphinview.h b/src/dolphinview.h index 6f4327c52..e74975f67 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -218,6 +218,12 @@ public: */ KUrl::List selectedUrls() const; + /** + * Returns the number of selected items (this is faster than + * invoking selectedItems().count()). + */ + int selectedItemsCount() const; + /** * Sets the upper left position of the view content * to (x,y). The content of the view might be larger than the visible area -- 2.47.3