┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2011-01-09 15:03:30 +0000
committerPeter Penz <[email protected]>2011-01-09 15:03:30 +0000
commita48679b36b876815fccab3ab8559734f29372907 (patch)
treeda5f18e84c6a71b0480c60d73135b0b4f6b95404 /src/views
parentfae8ba471b0adb917f4edd1a99bca47fdaea0169 (diff)
Fix implementation of DolphinView::invertSelection() which assures that DolphinView::hasSelection() provides a valid return-value. This looks like an issue in Qt, but I did not have the time yet to provide a Qt-only example for a bug-report :-(
svn path=/trunk/KDE/kdebase/apps/; revision=1213199
Diffstat (limited to 'src/views')
-rw-r--r--src/views/dolphinview.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index 2dc21b335..f2340fa89 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -566,15 +566,23 @@ void DolphinView::selectAll()
void DolphinView::invertSelection()
{
- QItemSelectionModel* selectionModel = m_viewAccessor.itemView()->selectionModel();
- const QAbstractItemModel* itemModel = selectionModel->model();
+ // Implementation note: Using selectionModel->select(selection, QItemSelectionModel::Toggle) does not
+ // work, as QItemSelectionModel::hasSelection() provides invalid values in this case. This might be a Qt-issue -
+ // when changing the implementation with an updated Qt-version don't forget to run the Dolphin-unit-tests that
+ // verify this usecase.
+ const KFileItemList selItems = selectedItems();
+ clearSelection();
- const QModelIndex topLeft = itemModel->index(0, 0);
- const QModelIndex bottomRight = itemModel->index(itemModel->rowCount() - 1,
- itemModel->columnCount() - 1);
+ QItemSelection invertedSelection;
+ foreach (const KFileItem& item, items()) {
+ if (!selItems.contains(item)) {
+ const QModelIndex index = m_viewAccessor.proxyModel()->mapFromSource(m_viewAccessor.dirModel()->indexForItem(item));
+ invertedSelection.select(index, index);
+ }
+ }
- const QItemSelection selection(topLeft, bottomRight);
- selectionModel->select(selection, QItemSelectionModel::Toggle);
+ QItemSelectionModel* selectionModel = m_viewAccessor.itemView()->selectionModel();
+ selectionModel->select(invertedSelection, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Current);
}
void DolphinView::clearSelection()
@@ -1100,7 +1108,7 @@ void DolphinView::slotLoadingCompleted()
foreach(const KFileItem& item, m_selectedItems) {
url = item.url().upUrl();
if (baseUrl.equals(url, KUrl::CompareWithoutTrailingSlash)) {
- QModelIndex index = m_viewAccessor.proxyModel()->mapFromSource(m_viewAccessor.dirModel()->indexForItem(item));
+ const QModelIndex index = m_viewAccessor.proxyModel()->mapFromSource(m_viewAccessor.dirModel()->indexForItem(item));
newSelection.select(index, index);
}
}