diff options
author | Robert C. Helling <helling@atdotde.de> | 2015-09-11 15:54:17 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-09-11 09:15:14 -0700 |
commit | 5a1c041b78fa8fe74b6c2eee26416d287032d61f (patch) | |
tree | a83072ca1f7917aa7763c0d64d30b7e8a7f7c4b6 /qt-ui/diveplanner.cpp | |
parent | f93c60fc1e68df1684ab09317e2bd20d49dd45e3 (diff) | |
download | subsurface-5a1c041b78fa8fe74b6c2eee26416d287032d61f.tar.gz |
Don't offer gas selection for the last waypoint in planner
Since the gas selection list on a waypoint refers to a gaschange there
influencing the following segments, there must not be a gas selection
on the last manually entered waypoint since from there the planner
handles the gas selection.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r-- | qt-ui/diveplanner.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 7f0d129a2..b4413d11a 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -40,14 +40,18 @@ int DiveHandler::parentIndex() void DiveHandler::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { QMenu m; - GasSelectionModel *model = GasSelectionModel::instance(); - model->repopulate(); - int rowCount = model->rowCount(); - for (int i = 0; i < rowCount; i++) { - QAction *action = new QAction(&m); - action->setText(model->data(model->index(i, 0), Qt::DisplayRole).toString()); - connect(action, SIGNAL(triggered(bool)), this, SLOT(changeGas())); - m.addAction(action); + // Don't have a gas selection for the last point + QModelIndex index = plannerModel->index(parentIndex(), DivePlannerPointsModel::GAS); + if (index.sibling(index.row() + 1, index.column()).isValid()) { + GasSelectionModel *model = GasSelectionModel::instance(); + model->repopulate(); + int rowCount = model->rowCount(); + for (int i = 0; i < rowCount; i++) { + QAction *action = new QAction(&m); + action->setText(model->data(model->index(i, 0), Qt::DisplayRole).toString()); + connect(action, SIGNAL(triggered(bool)), this, SLOT(changeGas())); + m.addAction(action); + } } // don't allow removing the last point if (plannerModel->rowCount() > 1) { |