diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/dolphindetailsview.cpp | 24 | ||||
| -rw-r--r-- | src/dolphindetailsview.h | 9 |
2 files changed, 20 insertions, 13 deletions
diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index 6d9038b46..b127aad49 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -654,6 +654,9 @@ void DolphinDetailsView::updateElasticBandSelection() QRect selRect = elasticBandRect().normalized(); QRect nameColumnArea(nameColumnX, selRect.y(), nameColumnWidth, selRect.height()); selRect = nameColumnArea.intersect(selRect).normalized(); + // Get the last elastic band rectangle, expressed in viewpoint coordinates. + const QPoint scrollPos(horizontalScrollBar()->value(), verticalScrollBar()->value()); + QRect oldSelRect = QRect(m_band.lastSelectionOrigin - scrollPos, m_band.lastSelectionDestination - scrollPos).normalized(); if (selRect.isNull()) { selectionModel()->select(m_band.originalSelection, QItemSelectionModel::ClearAndSelect); @@ -670,17 +673,16 @@ void DolphinDetailsView::updateElasticBandSelection() // No items in the model presumably. return; } - + // If the elastic band does not cover the same rows as before, we'll // need to re-check, and also invalidate the old item distances. const int rowHeight = QTreeView::rowHeight(dummyIndex); const bool coveringSameRows = - (selRect.top() / rowHeight == m_band.oldSelectionRect.top() / rowHeight) && - (selRect.bottom() / rowHeight == m_band.oldSelectionRect.bottom() / rowHeight); + (selRect.top() / rowHeight == oldSelRect.top() / rowHeight) && + (selRect.bottom() / rowHeight == oldSelRect.bottom() / rowHeight); if (coveringSameRows) { // Covering the same rows, but have we moved far enough horizontally // that we might have (de)selected some other items? - const QRect oldSelRect = m_band.oldSelectionRect; const bool itemSelectionChanged = ((selRect.left() > oldSelRect.left()) && (selRect.left() > m_band.insideNearestLeftEdge)) || @@ -699,7 +701,9 @@ void DolphinDetailsView::updateElasticBandSelection() else { // This is the only piece of optimisation data that needs to be explicitly // discarded. - m_band.oldSelectionRect = selRect; + m_band.lastSelectionOrigin = QPoint(); + m_band.lastSelectionDestination = QPoint(); + oldSelRect = selRect; } // Do the selection from scratch. Force a update of the horizontal distances info. @@ -710,7 +714,7 @@ void DolphinDetailsView::updateElasticBandSelection() // Include the old selection rect as well, so we can deselect // items that were inside it but not in the new selRect. - const QRect boundingRect = selRect.united(m_band.oldSelectionRect).normalized(); + const QRect boundingRect = selRect.united(oldSelRect).normalized(); if (boundingRect.isNull()) { return; } @@ -735,7 +739,7 @@ void DolphinDetailsView::updateElasticBandSelection() QModelIndex currIndex = startIndex; QModelIndex lastIndex; bool allItemsInBoundDone = false; - + // Calling selectionModel()->select(...) for each item that needs to be // toggled is slow as each call emits selectionChanged(...) so store them // and do the selection toggle in one batch. @@ -810,7 +814,8 @@ void DolphinDetailsView::updateElasticBandSelection() selectionModel()->select(itemsToToggle, QItemSelectionModel::Toggle); - m_band.oldSelectionRect = selRect; + m_band.lastSelectionOrigin = m_band.origin; + m_band.lastSelectionDestination = m_band.destination; m_band.ignoreOldInfo = false; } @@ -915,7 +920,8 @@ DolphinDetailsView::ElasticBand::ElasticBand() : show(false), origin(), destination(), - oldSelectionRect(), + lastSelectionOrigin(), + lastSelectionDestination(), ignoreOldInfo(true), outsideNearestLeftEdge(0), outsideNearestRightEdge(0), diff --git a/src/dolphindetailsview.h b/src/dolphindetailsview.h index f564773bc..996c87793 100644 --- a/src/dolphindetailsview.h +++ b/src/dolphindetailsview.h @@ -191,8 +191,8 @@ private: { ElasticBand(); - // Elastic band coordinates are relative to the origin of the - // view, not the viewport. + // Elastic band origin and destination coordinates are relative to t + // he origin of the view, not the viewport. bool show; QPoint origin; QPoint destination; @@ -200,10 +200,11 @@ private: // Optimisation mechanisms for use with elastic band selection. // Basically, allow "incremental" updates to the selection based // on the last elastic band shape. - QRect oldSelectionRect; + QPoint lastSelectionOrigin; + QPoint lastSelectionDestination; // If true, compute the set of selected elements from scratch (slower) - bool ignoreOldInfo; + bool ignoreOldInfo; // Edges of the filenames that are closest to the edges of oldSelectionRect. // Used to decide whether horizontal changes in the elastic band are likely |
