diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-05-02 17:57:31 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-05-03 15:02:21 -0700 |
commit | 51471317011bef1b6e51a42951f61073bb8be905 (patch) | |
tree | 7339928bd326c0902450b73ccf845c044d8727a5 /desktop-widgets/divelistview.cpp | |
parent | f961ec7a8b399683b5b9aedc56827fa307511487 (diff) | |
download | subsurface-51471317011bef1b6e51a42951f61073bb8be905.tar.gz |
selection: inform core of trip selection in DiveListView
When selecting / deselecting trips, keep the core updated.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/divelistview.cpp')
-rw-r--r-- | desktop-widgets/divelistview.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp index 8edcb0655..3e1ec6baa 100644 --- a/desktop-widgets/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp @@ -554,10 +554,13 @@ void DiveListView::selectionChanged(const QItemSelection &selected, const QItemS continue; const QAbstractItemModel *model = index.model(); struct dive *dive = model->data(index, DiveTripModelBase::DIVE_ROLE).value<struct dive *>(); - if (!dive) // it's a trip! - deselect_dives_in_trip(model->data(index, DiveTripModelBase::TRIP_ROLE).value<dive_trip *>()); - else + if (!dive) { // it's a trip! + dive_trip *trip = model->data(index, DiveTripModelBase::TRIP_ROLE).value<dive_trip *>(); + deselect_trip(trip); + deselect_dives_in_trip(trip); + } else { deselect_dive(dive); + } } Q_FOREACH (const QModelIndex &index, newSelected.indexes()) { if (index.column() != 0) @@ -566,9 +569,11 @@ void DiveListView::selectionChanged(const QItemSelection &selected, const QItemS const QAbstractItemModel *model = index.model(); struct dive *dive = model->data(index, DiveTripModelBase::DIVE_ROLE).value<struct dive *>(); if (!dive) { // it's a trip! + dive_trip *trip = model->data(index, DiveTripModelBase::TRIP_ROLE).value<dive_trip *>(); + select_trip(trip); + select_dives_in_trip(trip); if (model->rowCount(index)) { QItemSelection selection; - select_dives_in_trip(model->data(index, DiveTripModelBase::TRIP_ROLE).value<dive_trip *>()); selection.select(index.child(0, 0), index.child(model->rowCount(index) - 1, 0)); selectionModel()->select(selection, QItemSelectionModel::Select | QItemSelectionModel::Rows); selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select | QItemSelectionModel::NoUpdate); |