summaryrefslogtreecommitdiffstats
path: root/qt-ui/mainwindow.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-11-08 22:09:46 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-09 15:35:29 +0900
commit8a970c64c2d8f3cdfebf80b58972f66dee1bed44 (patch)
treedc76b117e226d06fdf58f487b28d8be0c53f3663 /qt-ui/mainwindow.cpp
parentf850a0817ccd37bc04945431aed58380e3edcad7 (diff)
downloadsubsurface-8a970c64c2d8f3cdfebf80b58972f66dee1bed44.tar.gz
Removed inconsistency when user tried to add dive while planning.
The user could add a dive, and in the middle click on the 'plan' button. Since we didn't cared about that on the widget, a lot of inconsistencies could occour. this fixes that by setting a flag on the Planner, that has now three modes: nothing, plan and add. (maybe in the future an edit mode will be valid too.) If in 'NOTHING' mode, user can enter the addition, edition and planning. If in any other mode, user can't do a thing. The mode gets back to NOTHING when user accepts or cancels a plan / add / edition. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/mainwindow.cpp')
-rw-r--r--qt-ui/mainwindow.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 5c0a9b350..f7cd31e0e 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -219,8 +219,14 @@ void MainWindow::enableDcShortcuts()
void MainWindow::on_actionDivePlanner_triggered()
{
+ if(DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING){
+ qDebug() << DivePlannerPointsModel::instance()->currentMode();
+ QMessageBox::warning(this, tr("Warning"), "First finish the current edition before trying to do another." );
+ return;
+ }
disableDcShortcuts();
- DivePlannerPointsModel::instance()->setPlanMode(true);
+ DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
+ DivePlannerPointsModel::instance()->clear();
ui.stackedWidget->setCurrentIndex(PLANNERPROFILE);
ui.infoPane->setCurrentIndex(PLANNERWIDGET);
}
@@ -271,6 +277,11 @@ void MainWindow::on_actionEditDeviceNames_triggered()
void MainWindow::on_actionAddDive_triggered()
{
+ if(DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING){
+ QMessageBox::warning(this, tr("Warning"), "First finish the current edition before trying to do another." );
+ return;
+ }
+
// clear the selection
for (int i = 0; i < dive_table.nr; i++) {
struct dive *d = get_dive(i);
@@ -278,7 +289,8 @@ void MainWindow::on_actionAddDive_triggered()
deselect_dive(i);
}
disableDcShortcuts();
- DivePlannerPointsModel::instance()->setPlanMode(false);
+ DivePlannerPointsModel::instance()->clear();
+ DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
// now cheat - create one dive that we use to store the info tab data in
struct dive *dive = alloc_dive();
dive->when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset();
@@ -825,12 +837,17 @@ void MainWindow::on_actionImportCSV_triggered()
void MainWindow::editCurrentDive()
{
+ if(DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING){
+ QMessageBox::warning(this, tr("Warning"), "First finish the current edition before trying to do another." );
+ return;
+ }
+
struct dive *d = current_dive;
QString defaultDC(d->dc.model);
-
+ DivePlannerPointsModel::instance()->clear();
if (defaultDC == "manually added dive"){
disableDcShortcuts();
- DivePlannerPointsModel::instance()->setPlanMode(false);
+ DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
ui.stackedWidget->setCurrentIndex(PLANNERPROFILE); // Planner.
ui.infoPane->setCurrentIndex(MAINTAB);
DivePlannerPointsModel::instance()->loadFromDive(d);