From 7e311509a4ac89ebe95f3d81928fe78a9f398aa9 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Thu, 4 Nov 2010 17:27:11 +0000 Subject: Interface cleanup: The DolphinView should not expose QAbstractItemView-specific things like QItemSelectionModel. Just providing interfaces for KFileItem and KUrl will make it easier in future to change the view-implementations internally to QML-specific itemviews or whatever. svn path=/trunk/KDE/kdebase/apps/; revision=1193113 --- src/dolphinpart.cpp | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) (limited to 'src/dolphinpart.cpp') diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index 0691791a5..3d0748f84 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -480,49 +480,27 @@ void DolphinPart::slotSelectItemsMatchingPattern() { openSelectionDialog(i18nc("@title:window", "Select"), i18n("Select all items matching this pattern:"), - QItemSelectionModel::Select); + true); } void DolphinPart::slotUnselectItemsMatchingPattern() { openSelectionDialog(i18nc("@title:window", "Unselect"), i18n("Unselect all items matching this pattern:"), - QItemSelectionModel::Deselect); + false); } -void DolphinPart::openSelectionDialog(const QString& title, const QString& text, QItemSelectionModel::SelectionFlags command) +void DolphinPart::openSelectionDialog(const QString& title, const QString& text, bool selectItems) { bool okClicked; QString pattern = KInputDialog::getText(title, text, "*", &okClicked, m_view); if (okClicked && !pattern.isEmpty()) { QRegExp patternRegExp(pattern, Qt::CaseSensitive, QRegExp::Wildcard); - QItemSelection matchingIndexes = childrenMatchingPattern(QModelIndex(), patternRegExp); - m_view->selectionModel()->select(matchingIndexes, command); + m_view->setItemSelectionEnabled(patternRegExp, selectItems); } } -QItemSelection DolphinPart::childrenMatchingPattern(const QModelIndex& parent, const QRegExp& patternRegExp) -{ - QItemSelection matchingIndexes; - int numRows = m_proxyModel->rowCount(parent); - - for (int row = 0; row < numRows; row++) { - QModelIndex index = m_proxyModel->index(row, 0, parent); - QModelIndex sourceIndex = m_proxyModel->mapToSource(index); - - if (sourceIndex.isValid() && patternRegExp.exactMatch(m_dolphinModel->data(sourceIndex).toString())) { - matchingIndexes += QItemSelectionRange(index); - } - - if (m_proxyModel->hasChildren(index)) { - matchingIndexes += childrenMatchingPattern(index, patternRegExp); - } - } - - return matchingIndexes; -} - void DolphinPart::setCurrentViewMode(const QString& viewModeName) { QAction* action = actionCollection()->action(viewModeName); @@ -669,7 +647,7 @@ KFileItemList DolphinPartFileInfoExtension::queryFor(KParts::FileInfoExtension:: return part()->view()->selectedItems(); break; case KParts::FileInfoExtension::AllItems: - return part()->view()->allItems(); + return part()->view()->items(); default: break; } -- cgit v1.3