summaryrefslogtreecommitdiffstats
path: root/qt-ui/diveplanner.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-15 03:29:43 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-15 03:33:48 -0700
commitdff92f188a811f13a0d8008439cc6f4264b44a89 (patch)
treea68e0d0d1af25567808fd79b44dadcc407110bdc /qt-ui/diveplanner.cpp
parent133e1043937e20de592e14de5666bd2a00efb82b (diff)
downloadsubsurface-dff92f188a811f13a0d8008439cc6f4264b44a89.tar.gz
Planner: don't allow the user to remove the last point
This causes all kinds of assumptions to go wrong - and it makes no sense. Move the point to where you want it or cancel the plan. Fixes #623 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r--qt-ui/diveplanner.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index b099cbe40..6b3c7b591 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -206,9 +206,12 @@ void DiveHandler::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
connect(action, SIGNAL(triggered(bool)), this, SLOT(changeGas()));
m.addAction(action);
}
- m.addSeparator();
- m.addAction(QObject::tr("Remove this point"), this, SLOT(selfRemove()));
- m.exec(event->screenPos());
+ // don't allow removing the last point
+ if (DivePlannerPointsModel::instance()->rowCount() > 1) {
+ m.addSeparator();
+ m.addAction(QObject::tr("Remove this point"), this, SLOT(selfRemove()));
+ m.exec(event->screenPos());
+ }
}
void DiveHandler::selfRemove()
@@ -530,7 +533,8 @@ QVariant DivePlannerPointsModel::data(const QModelIndex &index, int role) const
} else if (role == Qt::DecorationRole) {
switch (index.column()) {
case REMOVE:
- return p.entered ? QIcon(":trash") : QVariant();
+ if (rowCount() > 1)
+ return p.entered ? QIcon(":trash") : QVariant();
}
} else if (role == Qt::FontRole) {
if (divepoints.at(index.row()).entered) {
@@ -872,7 +876,7 @@ divedatapoint DivePlannerPointsModel::at(int row)
void DivePlannerPointsModel::remove(const QModelIndex &index)
{
- if (index.column() != REMOVE)
+ if (index.column() != REMOVE || rowCount() == 1)
return;
divedatapoint dp = at(index.row());