From 0111d9b0a02098065a32b34c9b04fde72addb626 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Mon, 6 Aug 2007 06:56:36 +0000 Subject: Fixed 'Select All' and 'Invert Selection' for the column view (only the items of the currently active column will be selected, not the whole tree). The current implementation is quite slow, but this will be fixed later. svn path=/trunk/KDE/kdebase/apps/; revision=696893 --- src/dolphincolumnview.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'src/dolphincolumnview.cpp') diff --git a/src/dolphincolumnview.cpp b/src/dolphincolumnview.cpp index f4a5ef19a..ee7fb52aa 100644 --- a/src/dolphincolumnview.cpp +++ b/src/dolphincolumnview.cpp @@ -173,6 +173,7 @@ void ColumnWidget::obtainSelectionModel() if (selectionModel() != m_view->selectionModel()) { selectionModel()->deleteLater(); setSelectionModel(m_view->selectionModel()); + clearSelection(); } } @@ -428,6 +429,16 @@ DolphinColumnView::~DolphinColumnView() { } +void DolphinColumnView::invertSelection() +{ + selectActiveColumn(QItemSelectionModel::Toggle); +} + +void DolphinColumnView::selectAll() +{ + selectActiveColumn(QItemSelectionModel::Select); +} + QAbstractItemView* DolphinColumnView::createColumn(const QModelIndex& index) { // let the column widget be aware about its URL... @@ -598,7 +609,7 @@ void DolphinColumnView::requestActivation(QWidget* column) const bool isActive = (widget == column); widget->setActive(isActive); if (isActive) { - m_controller->setUrl(widget->url()); + m_controller->setUrl(widget->url()); } } } @@ -618,4 +629,23 @@ void DolphinColumnView::requestSelectionModel(QAbstractItemView* view) } } +void DolphinColumnView::selectActiveColumn(QItemSelectionModel::SelectionFlags flags) +{ + // TODO: this approach of selecting the active column is very slow. It should be + // possible to speedup the implementation by using QItemSelection, but all adempts + // have failed yet... + + QItemSelectionModel* selModel = selectionModel(); + + const QAbstractProxyModel* proxyModel = static_cast(model()); + const KDirModel* dirModel = static_cast(proxyModel->sourceModel()); + KDirLister* dirLister = dirModel->dirLister(); + + const KFileItemList list = dirLister->itemsForDir(m_controller->url()); + foreach (KFileItem* item, list) { + const QModelIndex index = dirModel->indexForUrl(item->url()); + selModel->select(proxyModel->mapFromSource(index), flags); + } +} + #include "dolphincolumnview.moc" -- cgit v1.3