X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/487215f0c459ca38c68619325edac4a2fe42ca4b..ab39a5952001cdb3d1b9ca693da7f8e246558fb8:/src/dolphinview.cpp diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 2d95be828..e057c950a 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -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(); @@ -1108,7 +1113,7 @@ void DolphinView::saveState(QDataStream &stream) KUrl currentUrl; if (!currentItem.isNull()) currentUrl = currentItem.url(); - + stream << currentUrl; // view position @@ -1213,7 +1218,7 @@ void DolphinView::slotLoadingCompleted() { m_expanderActive = false; m_loadingDirectory = false; - + if (!m_activeItemUrl.isEmpty()) { // assure that the current item remains visible const QModelIndex dirIndex = m_viewAccessor.dirModel()->indexForUrl(m_activeItemUrl);