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.
This commit is contained in:
Jérôme Duval 2014-11-17 19:57:35 +01:00
parent f3e381dd0c
commit 073da30265
1 changed files with 21 additions and 0 deletions

View File

@ -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;