diff options
| author | Rafael Fernández López <[email protected]> | 2007-09-18 16:33:17 +0000 |
|---|---|---|
| committer | Rafael Fernández López <[email protected]> | 2007-09-18 16:33:17 +0000 |
| commit | db552079bebc5ac7273ad8389a3dfd738445dbfc (patch) | |
| tree | 418d324744f585dd7fcc6e94ab10e2199d498bf7 /src | |
| parent | db49efe925d3b3bb59835721fa2b1af4cdc5f56a (diff) | |
Fix selections problems (like flickering). Click on category select/deselects all items inside it. Ctrl+Click categories lets you add categories to already
created selections, as well as inverting selections inside the same category.
CCMAIL: [email protected]
svn path=/trunk/KDE/kdebase/apps/; revision=714051
Diffstat (limited to 'src')
| -rw-r--r-- | src/kcategorizedview.cpp | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/kcategorizedview.cpp b/src/kcategorizedview.cpp index e88e6a383..e1597849a 100644 --- a/src/kcategorizedview.cpp +++ b/src/kcategorizedview.cpp @@ -768,20 +768,22 @@ void KCategorizedView::setSelection(const QRect &rect, if (!flags) return; - selectionModel()->clear(); - if (flags & QItemSelectionModel::Clear) { - d->lastSelection = QItemSelection(); + if (!rect.intersects(d->categoryVisualRect(d->hoveredCategory))) + { + d->lastSelection = QItemSelection(); + } } - QModelIndexList dirtyIndexes = d->intersectionSet(rect); + selectionModel()->clear(); - QItemSelection selection; + QModelIndexList dirtyIndexes = d->intersectionSet(rect); if (!dirtyIndexes.count()) { - if (d->lastSelection.count()) + if (!d->lastSelection.isEmpty() && + (rect.intersects(d->categoryVisualRect(d->hoveredCategory)) || d->mouseButtonPressed)) { selectionModel()->select(d->lastSelection, flags); } @@ -789,6 +791,8 @@ void KCategorizedView::setSelection(const QRect &rect, return; } + QItemSelection selection; + if (!d->mouseButtonPressed) { selection = QItemSelection(dirtyIndexes[0], dirtyIndexes[0]); @@ -924,6 +928,7 @@ void KCategorizedView::mouseReleaseEvent(QMouseEvent *event) initialPressPosition.setX(initialPressPosition.x() + horizontalOffset()); QItemSelection selection; + QItemSelection deselection; if (initialPressPosition == d->initialPressPosition) { @@ -935,10 +940,18 @@ void KCategorizedView::mouseReleaseEvent(QMouseEvent *event) { QModelIndex selectIndex = index.model()->index(index.row(), 0); - selection << QItemSelectionRange(selectIndex); + if (!d->lastSelection.contains(selectIndex)) + { + selection << QItemSelectionRange(selectIndex); + } + else + { + deselection << QItemSelectionRange(selectIndex); + } } selectionModel()->select(selection, QItemSelectionModel::Select); + selectionModel()->select(deselection, QItemSelectionModel::Deselect); break; } |
