diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-06-02 20:36:41 +0900 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-06-02 20:36:41 +0900 |
commit | de8395e09e0e6c6ada06dbd3d5e6a053fd821a71 (patch) | |
tree | e56f5f3101fbbc274eafad70060f71d3e499ad54 /qt-ui/divelistview.cpp | |
parent | a98a7a135199bbe3dc25290da47c1915861b2300 (diff) | |
parent | e88a9aa83eacaa6a003ca440947fa20c9b598834 (diff) | |
download | subsurface-de8395e09e0e6c6ada06dbd3d5e6a053fd821a71.tar.gz |
Merge branch 'selection'
Diffstat (limited to 'qt-ui/divelistview.cpp')
-rw-r--r-- | qt-ui/divelistview.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index 075f12d4a..5883ea615 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -210,7 +210,7 @@ void DiveListView::selectionChanged(const QItemSelection& selected, const QItemS disconnect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(currentChanged(QModelIndex,QModelIndex))); Q_FOREACH(const QModelIndex& index, newSelected.indexes()) { - if(index.column() != 0) + if (index.column() != 0) continue; const QAbstractItemModel *model = index.model(); @@ -218,16 +218,42 @@ void DiveListView::selectionChanged(const QItemSelection& selected, const QItemS if (!dive) { // it's a trip! if (model->rowCount(index)) { QItemSelection selection; + struct dive *child = (struct dive*) model->data(index.child(0,0), TreeItemDT::DIVE_ROLE).value<void*>(); + while (child) { + select_dive(get_index_for_dive(child)); + child = child->next; + } 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); if (!isExpanded(index)) expand(index); } + } else { + select_dive(get_index_for_dive(dive)); + } + } + Q_FOREACH(const QModelIndex& index, newDeselected.indexes()) { + if (index.column() != 0) + continue; + const QAbstractItemModel *model = index.model(); + struct dive *dive = (struct dive*) model->data(index, TreeItemDT::DIVE_ROLE).value<void*>(); + if (!dive) { // it's a trip! + if (model->rowCount(index)) { + struct dive *child = (struct dive*) model->data(index.child(0,0), TreeItemDT::DIVE_ROLE).value<void*>(); + while (child) { + deselect_dive(get_index_for_dive(child)); + child = child->next; + } + } + } else { + deselect_dive(get_index_for_dive(dive)); } } QTreeView::selectionChanged(selectionModel()->selection(), newDeselected); connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(selectionChanged(QItemSelection,QItemSelection))); connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(currentChanged(QModelIndex,QModelIndex))); + // now that everything is up to date, update the widgets + Q_EMIT currentDiveChanged(selected_dive); } |