mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Selection: automatically unselect old selection in selectDives()
DiveListView::selectDives() would only select new dives but not clear the old selection. Thus, callers would have to clear the selection first. That would lead to two selection-changed signals. Move the unselectDives() call into DiveListView::selectDives(). The DiveListView has an internal flag to prevent double signals. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
8eb586d1d4
commit
403206ca06
2 changed files with 8 additions and 9 deletions
|
@ -277,9 +277,7 @@ void DiveListView::restoreSelection()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
selectionSaved = false;
|
selectionSaved = false;
|
||||||
dontEmitDiveChangedSignal = true;
|
QList<int> divesToSelect;
|
||||||
unselectDives();
|
|
||||||
dontEmitDiveChangedSignal = false;
|
|
||||||
Q_FOREACH (dive_trip_t *trip, selectedDives.keys()) {
|
Q_FOREACH (dive_trip_t *trip, selectedDives.keys()) {
|
||||||
QList<int> divesOnTrip = getDivesInTrip(trip);
|
QList<int> divesOnTrip = getDivesInTrip(trip);
|
||||||
QList<int> selectedDivesOnTrip = selectedDives.values(trip);
|
QList<int> selectedDivesOnTrip = selectedDives.values(trip);
|
||||||
|
@ -289,8 +287,9 @@ void DiveListView::restoreSelection()
|
||||||
selectTrip(trip);
|
selectTrip(trip);
|
||||||
selectedDivesOnTrip.removeAll(-1);
|
selectedDivesOnTrip.removeAll(-1);
|
||||||
}
|
}
|
||||||
selectDives(selectedDivesOnTrip);
|
divesToSelect += selectedDivesOnTrip;
|
||||||
}
|
}
|
||||||
|
selectDives(divesToSelect);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a bit ugly: we hook directly into the tripChanged signal to
|
// This is a bit ugly: we hook directly into the tripChanged signal to
|
||||||
|
@ -417,6 +416,10 @@ void DiveListView::selectDives(const QList<int> &newDiveSelection)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dontEmitDiveChangedSignal = true;
|
dontEmitDiveChangedSignal = true;
|
||||||
|
|
||||||
|
// First, clear the old selection
|
||||||
|
unselectDives();
|
||||||
|
|
||||||
// select the dives, highest index first - this way the oldest of the dives
|
// select the dives, highest index first - this way the oldest of the dives
|
||||||
// becomes the selected_dive that we scroll to
|
// becomes the selected_dive that we scroll to
|
||||||
QList<int> sortedSelection = newDiveSelection;
|
QList<int> sortedSelection = newDiveSelection;
|
||||||
|
|
|
@ -105,11 +105,7 @@ void MapWidget::prepareForGetDiveCoordinates(struct dive_site *ds)
|
||||||
void MapWidget::selectedDivesChanged(const QList<int> &list)
|
void MapWidget::selectedDivesChanged(const QList<int> &list)
|
||||||
{
|
{
|
||||||
CHECK_IS_READY_RETURN_VOID();
|
CHECK_IS_READY_RETURN_VOID();
|
||||||
skipReload = true;
|
|
||||||
MainWindow::instance()->diveList->unselectDives();
|
|
||||||
if (!list.empty())
|
|
||||||
MainWindow::instance()->diveList->selectDives(list);
|
MainWindow::instance()->diveList->selectDives(list);
|
||||||
skipReload = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapWidget::coordinatesChanged(struct dive_site *ds, const location_t &location)
|
void MapWidget::coordinatesChanged(struct dive_site *ds, const location_t &location)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue