]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Support 'select all' and 'invert selection' again.
authorPeter Penz <peter.penz19@gmail.com>
Thu, 14 Dec 2006 19:54:59 +0000 (19:54 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Thu, 14 Dec 2006 19:54:59 +0000 (19:54 +0000)
svn path=/trunk/playground/utils/dolphin/; revision=613698

src/dolphinview.cpp
src/dolphinview.h

index 2f287f353359b4c524c9c38c0effd94c372e9f6b..1dba37ad511cf562d689a2135b620348cb21491b 100644 (file)
@@ -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<KFileView*>(m_iconsView) :
-                                     static_cast<KFileView*>(m_iconsView);
-}*/
-
-Q3ScrollView* DolphinView::scrollView() const
-{
-    return 0; //(m_mode == DetailsView) ? static_cast<Q3ScrollView*>(m_iconsView) :
-              //                       static_cast<Q3ScrollView*>(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"
index e5af61f3f96874db569f5c36df7173b0bfdecf9a..6aa5967f6b97c06efb29b42da6bbf4e72235fb34 100644 (file)
@@ -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;