From ad647bd0a050a54a2db4c15e363d2f0143f6d34e Mon Sep 17 00:00:00 2001 From: Simon Paul St James Date: Mon, 27 Oct 2008 20:55:54 +0000 Subject: [PATCH] Restore behaviour (I don't have an old version to check against, though!) - if CTRL is pressed when initiating elastic band, respect the item selection at that time while dragging the band. CCMAIL : peter.penz@gmx.at svn path=/trunk/KDE/kdebase/apps/; revision=876690 --- src/dolphindetailsview.cpp | 9 ++++++--- src/dolphindetailsview.h | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index 8aff93bfa..a40e6236d 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -245,6 +245,7 @@ void DolphinDetailsView::mousePressEvent(QMouseEvent* event) const QPoint scrollPos(horizontalScrollBar()->value(), verticalScrollBar()->value()); m_band.origin = event->pos() + pos + scrollPos; m_band.destination = m_band.origin; + m_band.originalSelection = selectionModel()->selection(); } } } @@ -655,7 +656,7 @@ void DolphinDetailsView::updateElasticBandSelection() selRect = nameColumnRect.intersect(selRect).normalized(); if (selRect.isNull()) { - clearSelection(); + selectionModel()->select(m_band.originalSelection, QItemSelectionModel::ClearAndSelect); m_band.ignoreOldInfo = true; return; } @@ -718,7 +719,7 @@ void DolphinDetailsView::updateElasticBandSelection() startIndex = model()->index(startIndex.row(), KDirModel::Name); } if (!startIndex.isValid()) { - clearSelection(); + selectionModel()->select(m_band.originalSelection, QItemSelectionModel::ClearAndSelect); m_band.ignoreOldInfo = true; return; } @@ -764,8 +765,10 @@ void DolphinDetailsView::updateElasticBandSelection() } bool currentlySelected = selectionModel()->isSelected(currIndex); + bool originallySelected = m_band.originalSelection.contains(currIndex); bool intersectsSelectedRect = currIndexRect.intersects(selRect); - bool needToToggleItem = (currentlySelected && !intersectsSelectedRect) || (!currentlySelected && intersectsSelectedRect); + bool shouldBeSelected = (intersectsSelectedRect && !originallySelected) || (!intersectsSelectedRect && originallySelected); + bool needToToggleItem = (currentlySelected && !shouldBeSelected) || (!currentlySelected && shouldBeSelected); if (needToToggleItem && !formingToggleIndexRange) { toggleIndexRangeBegin = currIndex; formingToggleIndexRange = true; diff --git a/src/dolphindetailsview.h b/src/dolphindetailsview.h index e974635e5..f564773bc 100644 --- a/src/dolphindetailsview.h +++ b/src/dolphindetailsview.h @@ -212,6 +212,9 @@ private: int outsideNearestRightEdge; int insideNearestLeftEdge; int insideNearestRightEdge; + // The set of items that were selected at the time this band was shown. + // NOTE: Unless CTRL was pressed when the band was created, this is always empty. + QItemSelection originalSelection; } m_band; }; -- 2.47.3