From: Peter Penz Date: Thu, 14 Dec 2006 19:54:59 +0000 (+0000) Subject: Support 'select all' and 'invert selection' again. X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/418cfc1d7420eec3b8624b03e1e8250ba31dc08b?ds=inline Support 'select all' and 'invert selection' again. svn path=/trunk/playground/utils/dolphin/; revision=613698 --- diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 2f287f353..1dba37ad5 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -302,12 +302,12 @@ void DolphinView::renameSelectedItems() void DolphinView::selectAll() { - //fileView()->selectAll(); + selectAll(QItemSelectionModel::Select); } void DolphinView::invertSelection() { - //fileView()->invertSelection(); + selectAll(QItemSelectionModel::Toggle); } DolphinStatusBar* DolphinView::statusBar() const @@ -814,23 +814,6 @@ void DolphinView::slotContentsMoving(int x, int y) } } -/*KFileView* DolphinView::fileView() const -{ - return (m_mode == DetailsView) ? static_cast(m_iconsView) : - static_cast(m_iconsView); -}*/ - -Q3ScrollView* DolphinView::scrollView() const -{ - return 0; //(m_mode == DetailsView) ? static_cast(m_iconsView) : - // static_cast(m_iconsView); -} - -ItemEffectsManager* DolphinView::itemEffectsManager() const -{ - return 0; -} - void DolphinView::startDirLister(const KUrl& url, bool reload) { if (!url.isValid()) { @@ -997,19 +980,6 @@ void DolphinView::slotChangeNameFilter(const QString& nameFilter) m_dirLister->setNameFilter(adjustedFilter); m_dirLister->emitChanges(); - - // TODO: this is a workaround for QIconView: the item position - // stay as they are by filtering, only an inserting of an item - // results to an automatic adjusting of the item position. In Qt4/KDE4 - // this workaround should get obsolete due to Interview. - /*KFileView* view = fileView(); - if (view == m_iconsView) { - KFileItem* first = view->firstFileItem(); - if (first != 0) { - view->removeItem(first); - view->insertItem(first); - } - }*/ } void DolphinView::applyModeToView() @@ -1028,11 +998,6 @@ void DolphinView::applyModeToView() m_iconsView->setViewMode(QListView::ListMode); m_iconsView->setGridSize(QSize(256, 24)); break; - - //case PreviewsView: - // m_iconsView->setViewMode(QListView::IconMode); - // m_iconsView->setGridSize(QSize(128, 128)); - // break; } } @@ -1048,4 +1013,17 @@ int DolphinView::columnIndex(Sorting sorting) const return index; } +void DolphinView::selectAll(QItemSelectionModel::SelectionFlags flags) +{ + QItemSelectionModel* selectionModel = m_iconsView->selectionModel(); + const QAbstractItemModel* itemModel = selectionModel->model(); + + const QModelIndex topLeft = itemModel->index(0, 0); + const QModelIndex bottomRight = itemModel->index(itemModel->rowCount() - 1, + itemModel->columnCount() - 1); + + QItemSelection selection(topLeft, bottomRight); + selectionModel->select(selection, flags); +} + #include "dolphinview.moc" diff --git a/src/dolphinview.h b/src/dolphinview.h index e5af61f3f..6aa5967f6 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -45,16 +45,13 @@ class QTimer; class Q3IconViewItem; class Q3ListViewItem; class Q3VBoxLayout; -//class KFileView; class DolphinMainWindow; class DolphinDirLister; class DolphinStatusBar; class DolphinIconsView; class DolphinDetailsView; class ViewProperties; -class Q3ScrollView; class KProgress; -class ItemEffectsManager; class FilterBar; class QModelIndex; @@ -413,9 +410,6 @@ private slots: void slotChangeNameFilter(const QString& nameFilter); private: - //KFileView* fileView() const; - Q3ScrollView* scrollView() const; - ItemEffectsManager* itemEffectsManager() const; void startDirLister(const KUrl& url, bool reload = false); /** @@ -447,6 +441,12 @@ private: */ int columnIndex(Sorting sorting) const; + /** + * Selects all items by using the selection flags \a flags. This is a helper + * method for the slots DolphinView::selectAll() and DolphinView::invertSelection(). + */ + void selectAll(QItemSelectionModel::SelectionFlags flags); + private: bool m_refreshing; bool m_showProgress;