Fix several problems in BListView:
- SwapItems() did not correctly swap the item tops of the two items being swapped. This would result in quite broken/confusing behavior due to the view having the wrong idea of their current position. - SwapItems() also did not pass the correct range to _RescanSelection(). This could result in the selection range getting quite confused when swapping items. - _RescanSelection() did not always correctly reset fLastSelection, though this mostly only would've resulted in unnecessary but harmless work. Fixes ticket #4253 and possibly some others. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35571 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1685,14 +1685,14 @@ BListView::_SwapItems(int32 a, int32 b)
|
|||||||
int32 last = max_c(a, b);
|
int32 last = max_c(a, b);
|
||||||
if (ItemAt(a)->IsSelected() != ItemAt(b)->IsSelected()) {
|
if (ItemAt(a)->IsSelected() != ItemAt(b)->IsSelected()) {
|
||||||
if (first < fFirstSelected || last > fLastSelected)
|
if (first < fFirstSelected || last > fLastSelected)
|
||||||
_RescanSelection(min_c(first, fFirstSelected), min_c(last, fLastSelected));
|
_RescanSelection(min_c(first, fFirstSelected), max_c(last, fLastSelected));
|
||||||
// though the actually selected items stayed the
|
// though the actually selected items stayed the
|
||||||
// same, the selection has still changed
|
// same, the selection has still changed
|
||||||
SelectionChanged();
|
SelectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemAt(a)->SetTop(bFrame.top);
|
ItemAt(a)->SetTop(aFrame.top);
|
||||||
ItemAt(b)->SetTop(aFrame.top);
|
ItemAt(b)->SetTop(bFrame.top);
|
||||||
|
|
||||||
// take care of invalidation
|
// take care of invalidation
|
||||||
if (Window()) {
|
if (Window()) {
|
||||||
@@ -1818,6 +1818,8 @@ BListView::_RescanSelection(int32 from, int32 to)
|
|||||||
|
|
||||||
if (fFirstSelected > from)
|
if (fFirstSelected > from)
|
||||||
from = fFirstSelected;
|
from = fFirstSelected;
|
||||||
|
|
||||||
|
fLastSelected = fFirstSelected;
|
||||||
for (int32 i = from; i <= to; i++) {
|
for (int32 i = from; i <= to; i++) {
|
||||||
if (ItemAt(i)->IsSelected())
|
if (ItemAt(i)->IsSelected())
|
||||||
fLastSelected = i;
|
fLastSelected = i;
|
||||||
|
|||||||
Reference in New Issue
Block a user