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
This commit is contained in:
Peter Penz 2008-07-26 13:46:58 +00:00
parent 8a51f70377
commit d337ece6df
2 changed files with 17 additions and 0 deletions

View file

@ -329,6 +329,17 @@ KUrl::List DolphinView::selectedUrls() const
return urls; 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) void DolphinView::setContentsPosition(int x, int y)
{ {
QAbstractItemView* view = itemView(); QAbstractItemView* view = itemView();

View file

@ -218,6 +218,12 @@ public:
*/ */
KUrl::List selectedUrls() const; 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 * Sets the upper left position of the view content
* to (x,y). The content of the view might be larger than the visible area * to (x,y). The content of the view might be larger than the visible area