]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinview.cpp
Restore the "Edit->Selection" menu from Konqueror 3 for file
[dolphin.git] / src / dolphinview.cpp
index b805543fded0dde982d1f0bcbfd8044a5d0c385c..e057c950acd6d83ce4ccd2347ceb38484e0d5b47 100644 (file)
@@ -285,45 +285,12 @@ bool DolphinView::supportsCategorizedSorting() const
     return m_viewAccessor.supportsCategorizedSorting();
 }
 
-void DolphinView::selectAll()
-{
-    QAbstractItemView* view = m_viewAccessor.itemView();
-    // TODO: there seems to be a bug in QAbstractItemView::selectAll(); if
-    // the Ctrl-key is pressed (e. g. for Ctrl+A), selectAll() inverts the
-    // selection instead of selecting all items. This is bypassed for KDE 4.0
-    // by invoking clearSelection() first.
-    view->clearSelection();
-    view->selectAll();
-}
-
-void DolphinView::invertSelection()
-{
-    QItemSelectionModel* selectionModel = m_viewAccessor.itemView()->selectionModel();
-    const QAbstractItemModel* itemModel = selectionModel->model();
-
-    const QModelIndex topLeft = itemModel->index(0, 0);
-    const QModelIndex bottomRight = itemModel->index(itemModel->rowCount() - 1,
-                                                     itemModel->columnCount() - 1);
-
-    const QItemSelection selection(topLeft, bottomRight);
-    selectionModel->select(selection, QItemSelectionModel::Toggle);
-}
-
 bool DolphinView::hasSelection() const
 {
     const QAbstractItemView* view = m_viewAccessor.itemView();
     return view && view->selectionModel()->hasSelection();
 }
 
-void DolphinView::clearSelection()
-{
-    QItemSelectionModel* selModel = m_viewAccessor.itemView()->selectionModel();
-    const QModelIndex currentIndex = selModel->currentIndex();
-    selModel->setCurrentIndex(currentIndex, QItemSelectionModel::Current |
-                                            QItemSelectionModel::Clear);
-    m_selectedItems.clear();
-}
-
 KFileItemList DolphinView::selectedItems() const
 {
     const QAbstractItemView* view = m_viewAccessor.itemView();
@@ -361,6 +328,11 @@ int DolphinView::selectedItemsCount() const
     return m_viewAccessor.itemView()->selectionModel()->selectedIndexes().count();
 }
 
+QItemSelectionModel* DolphinView::selectionModel() const
+{
+    return m_viewAccessor.itemView()->selectionModel();
+}
+
 void DolphinView::setContentsPosition(int x, int y)
 {
     QAbstractItemView* view = m_viewAccessor.itemView();
@@ -595,6 +567,39 @@ void DolphinView::setUrl(const KUrl& url)
     updateView(url, KUrl());
 }
 
+void DolphinView::selectAll()
+{
+    QAbstractItemView* view = m_viewAccessor.itemView();
+    // TODO: there seems to be a bug in QAbstractItemView::selectAll(); if
+    // the Ctrl-key is pressed (e. g. for Ctrl+A), selectAll() inverts the
+    // selection instead of selecting all items. This is bypassed for KDE 4.0
+    // by invoking clearSelection() first.
+    view->clearSelection();
+    view->selectAll();
+}
+
+void DolphinView::invertSelection()
+{
+    QItemSelectionModel* selectionModel = m_viewAccessor.itemView()->selectionModel();
+    const QAbstractItemModel* itemModel = selectionModel->model();
+
+    const QModelIndex topLeft = itemModel->index(0, 0);
+    const QModelIndex bottomRight = itemModel->index(itemModel->rowCount() - 1,
+                                                     itemModel->columnCount() - 1);
+
+    const QItemSelection selection(topLeft, bottomRight);
+    selectionModel->select(selection, QItemSelectionModel::Toggle);
+}
+
+void DolphinView::clearSelection()
+{
+    QItemSelectionModel* selModel = m_viewAccessor.itemView()->selectionModel();
+    const QModelIndex currentIndex = selModel->currentIndex();
+    selModel->setCurrentIndex(currentIndex, QItemSelectionModel::Current |
+                                            QItemSelectionModel::Clear);
+    m_selectedItems.clear();
+}
+
 void DolphinView::changeSelection(const KFileItemList& selection)
 {
     clearSelection();