From 073da30265d23a762719b1bad96ce668fbd73e1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Mon, 17 Nov 2014 19:57:35 +0100 Subject: [PATCH] ColumnListView: deselect the last selected row when the shift movement goes back. This behavior feels better to me, but opinions are welcome. Tested with HaikuDepot package listview. Noticed that CLV uses Ctrl whereas Tracker uses Alt for single item selection. --- src/kits/interface/ColumnListView.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/kits/interface/ColumnListView.cpp b/src/kits/interface/ColumnListView.cpp index b05d496112..9c1ec4d72c 100644 --- a/src/kits/interface/ColumnListView.cpp +++ b/src/kits/interface/ColumnListView.cpp @@ -4008,6 +4008,7 @@ OutlineView::ChangeFocusRow(bool up, bool updateSelection, fFocusRowRect.right = 10000; Invalidate(fFocusRowRect); } + BRow* oldFocusRow = fFocusRow; fFocusRow = newRow; fFocusRowRect.top = top; fFocusRowRect.left = 0; @@ -4021,12 +4022,32 @@ OutlineView::ChangeFocusRow(bool up, bool updateSelection, DeselectAll(); } + // if the focus row isn't selected, add it to the selection if (fFocusRow->fNextSelected == 0) { fFocusRow->fNextSelected = fSelectionListDummyHead.fNextSelected; fFocusRow->fPrevSelected = &fSelectionListDummyHead; fFocusRow->fNextSelected->fPrevSelected = fFocusRow; fFocusRow->fPrevSelected->fNextSelected = fFocusRow; + } else if (oldFocusRow != NULL + && fSelectionListDummyHead.fNextSelected == oldFocusRow + && (((IndexOf(oldFocusRow->fNextSelected) + < IndexOf(oldFocusRow)) == up) + || fFocusRow == oldFocusRow->fNextSelected)) { + // if the focus row is selected, if: + // 1. the previous focus row is last in the selection + // 2a. the next selected row is now the focus row + // 2b. or the next selected row is beyond the focus row + // in the move direction + // then deselect the previous focus row + fSelectionListDummyHead.fNextSelected + = oldFocusRow->fNextSelected; + if (fSelectionListDummyHead.fNextSelected != NULL) { + fSelectionListDummyHead.fNextSelected->fPrevSelected + = &fSelectionListDummyHead; + oldFocusRow->fNextSelected = NULL; + } + oldFocusRow->fPrevSelected = NULL; } fLastSelectedItem = fFocusRow;