mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 21:43:23 +00:00
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>
This commit is contained in:
parent
f961ec7a8b
commit
5147131701
1 changed files with 9 additions and 4 deletions
|
@ -554,11 +554,14 @@ void DiveListView::selectionChanged(const QItemSelection &selected, const QItemS
|
||||||
continue;
|
continue;
|
||||||
const QAbstractItemModel *model = index.model();
|
const QAbstractItemModel *model = index.model();
|
||||||
struct dive *dive = model->data(index, DiveTripModelBase::DIVE_ROLE).value<struct dive *>();
|
struct dive *dive = model->data(index, DiveTripModelBase::DIVE_ROLE).value<struct dive *>();
|
||||||
if (!dive) // it's a trip!
|
if (!dive) { // it's a trip!
|
||||||
deselect_dives_in_trip(model->data(index, DiveTripModelBase::TRIP_ROLE).value<dive_trip *>());
|
dive_trip *trip = model->data(index, DiveTripModelBase::TRIP_ROLE).value<dive_trip *>();
|
||||||
else
|
deselect_trip(trip);
|
||||||
|
deselect_dives_in_trip(trip);
|
||||||
|
} else {
|
||||||
deselect_dive(dive);
|
deselect_dive(dive);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Q_FOREACH (const QModelIndex &index, newSelected.indexes()) {
|
Q_FOREACH (const QModelIndex &index, newSelected.indexes()) {
|
||||||
if (index.column() != 0)
|
if (index.column() != 0)
|
||||||
continue;
|
continue;
|
||||||
|
@ -566,9 +569,11 @@ void DiveListView::selectionChanged(const QItemSelection &selected, const QItemS
|
||||||
const QAbstractItemModel *model = index.model();
|
const QAbstractItemModel *model = index.model();
|
||||||
struct dive *dive = model->data(index, DiveTripModelBase::DIVE_ROLE).value<struct dive *>();
|
struct dive *dive = model->data(index, DiveTripModelBase::DIVE_ROLE).value<struct dive *>();
|
||||||
if (!dive) { // it's a trip!
|
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)) {
|
if (model->rowCount(index)) {
|
||||||
QItemSelection selection;
|
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));
|
selection.select(index.child(0, 0), index.child(model->rowCount(index) - 1, 0));
|
||||||
selectionModel()->select(selection, QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
selectionModel()->select(selection, QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||||
selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select | QItemSelectionModel::NoUpdate);
|
selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select | QItemSelectionModel::NoUpdate);
|
||||||
|
|
Loading…
Add table
Reference in a new issue