summaryrefslogtreecommitdiffstats
path: root/qt-ui/diveplanner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r--qt-ui/diveplanner.cpp30
1 files changed, 19 insertions, 11 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 0701cb6d6..ec7a8a21f 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -559,7 +559,7 @@ void DivePlannerGraphics::mouseMoveEvent(QMouseEvent* event)
horizontalLine->setPos(fromPercent(0, Qt::Horizontal), mappedPos.y());
depthString->setText(get_depth_string(depthLine->valueAt(mappedPos), true, false));
- depthString->setPos(fromPercent(5, Qt::Horizontal), mappedPos.y());
+ depthString->setPos(fromPercent(1, Qt::Horizontal), mappedPos.y());
timeString->setText(QString::number(rint(timeLine->valueAt(mappedPos))) + "min");
timeString->setPos(mappedPos.x()+1, fromPercent(95, Qt::Vertical));
@@ -944,9 +944,9 @@ void DivePlannerWidget::lastStopChanged(bool checked)
plannerModel->setLastStop6m(checked);
}
-void DivePlannerPointsModel::setPlanMode(bool isPlan)
+void DivePlannerPointsModel::setPlanMode(Mode m)
{
- mode = isPlan ? PLAN : ADD;
+ mode = m;
}
bool DivePlannerPointsModel::isPlanner()
@@ -1044,7 +1044,7 @@ int DivePlannerPointsModel::rowCount(const QModelIndex& parent) const
return divepoints.count();
}
-DivePlannerPointsModel::DivePlannerPointsModel(QObject* parent): QAbstractTableModel(parent)
+DivePlannerPointsModel::DivePlannerPointsModel(QObject* parent): QAbstractTableModel(parent), mode(NOTHING)
{
}
@@ -1186,13 +1186,24 @@ void DivePlannerPointsModel::cancelPlan()
return;
}
}
+ clear();
+ emit planCanceled();
+ setPlanMode(NOTHING);
+}
+DivePlannerPointsModel::Mode DivePlannerPointsModel::currentMode() const
+{
+ return mode;
+}
+
+void DivePlannerPointsModel::clear()
+{
beginRemoveRows(QModelIndex(), 0, rowCount()-1);
divepoints.clear();
endRemoveRows();
- emit planCanceled();
}
+
void DivePlannerPointsModel::createTemporaryPlan()
{
// This needs to be done in the following steps:
@@ -1228,9 +1239,7 @@ void DivePlannerPointsModel::createTemporaryPlan()
void DivePlannerPointsModel::undoEdition()
{
- beginRemoveRows(QModelIndex(), 0, rowCount()-1);
- divepoints.clear();
- endRemoveRows();
+ clear();
Q_FOREACH(const sample &s, backupSamples){
int o2, he;
get_gas_from_events(&current_dive->dc, s.time.seconds, &o2, &he);
@@ -1270,8 +1279,7 @@ void DivePlannerPointsModel::createPlan()
// Remove and clean the diveplan, so we don't delete
// the dive by mistake.
diveplan.dp = NULL;
- beginRemoveRows(QModelIndex(), 0, rowCount() -1 );
- divepoints.clear();
- endRemoveRows();
+ clear();
planCreated();
+ setPlanMode(NOTHING);
}