diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-05-24 13:19:05 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-24 13:19:05 -0700 |
commit | dbb86374e00df9e06c4d96c436e3c3a998cc1ae9 (patch) | |
tree | a0895c7856570ef2764c7a0c6d18b420d9197201 /qt-ui/divelistview.cpp | |
parent | 032ea241916549801cd656593821d43bb8fd9f55 (diff) | |
download | subsurface-dbb86374e00df9e06c4d96c436e3c3a998cc1ae9.tar.gz |
Dive list: move trip selection / deselection logic to divelist.c
This is core logic, not UI code.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/divelistview.cpp')
-rw-r--r-- | qt-ui/divelistview.cpp | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index c541783cc..91b3dadf5 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -455,18 +455,10 @@ void DiveListView::selectionChanged(const QItemSelection &selected, const QItemS continue; const QAbstractItemModel *model = index.model(); struct dive *dive = (struct dive *)model->data(index, DiveTripModel::DIVE_ROLE).value<void *>(); - if (!dive) { // it's a trip! - //TODO: deselect_trip_dives on c-code? - if (model->rowCount(index)) { - struct dive *child = (struct dive *)model->data(index.child(0, 0), DiveTripModel::DIVE_ROLE).value<void *>(); - while (child) { - deselect_dive(get_divenr(child)); - child = child->next; - } - } - } else { + if (!dive) // it's a trip! + deselect_dives_in_trip((dive_trip_t *)model->data(index, DiveTripModel::TRIP_ROLE).value<void *>()); + else deselect_dive(get_divenr(dive)); - } } Q_FOREACH (const QModelIndex &index, newSelected.indexes()) { if (index.column() != 0) @@ -475,14 +467,9 @@ void DiveListView::selectionChanged(const QItemSelection &selected, const QItemS const QAbstractItemModel *model = index.model(); struct dive *dive = (struct dive *)model->data(index, DiveTripModel::DIVE_ROLE).value<void *>(); if (!dive) { // it's a trip! - //TODO: select_trip_dives on C code? if (model->rowCount(index)) { QItemSelection selection; - struct dive *child = (struct dive *)model->data(index.child(0, 0), DiveTripModel::DIVE_ROLE).value<void *>(); - while (child) { - select_dive(get_divenr(child)); - child = child->next; - } + select_dives_in_trip((dive_trip_t *)model->data(index, DiveTripModel::TRIP_ROLE).value<void *>()); 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); |