mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Fix selection after downloading dives from the dive computer
If we successfully download dives, the old selection should be cleared and the one of the newly downloaded dives should be selected. I decided to pick the last dive downloaded, which for most dive computers (but for example not for the Uemis SDA) will be the first or earliest of the dives. That seems much more intuitive than keeping the previous selection around. Of course this is harder than it should be because of the way we track selections and because we need a consistent dive list model in order to change the selection. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
b36c8f07c7
commit
5e3f7ba22f
4 changed files with 30 additions and 5 deletions
|
@ -189,6 +189,8 @@ void DiveListView::selectTrip(dive_trip_t *trip)
|
|||
void DiveListView::unselectDives()
|
||||
{
|
||||
selectionModel()->clearSelection();
|
||||
if (amount_selected != 0)
|
||||
qDebug() << "selection information inconsistent";
|
||||
}
|
||||
|
||||
QList<dive_trip_t *> DiveListView::selectedTrips()
|
||||
|
@ -211,6 +213,8 @@ void DiveListView::selectDive(int i, bool scrollto, bool toggle)
|
|||
QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel *>(model());
|
||||
QModelIndexList match = m->match(m->index(0, 0), DiveTripModel::DIVE_IDX, i, 2, Qt::MatchRecursive);
|
||||
QItemSelectionModel::SelectionFlags flags;
|
||||
if (match.isEmpty())
|
||||
return;
|
||||
QModelIndex idx = match.first();
|
||||
flags = toggle ? QItemSelectionModel::Toggle : QItemSelectionModel::Select;
|
||||
flags |= QItemSelectionModel::Rows;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue