diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-05-03 16:50:46 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-05-13 07:08:34 -0700 |
commit | 9d342d0e1aac56c44a80e5025d4cf3b89c5746cf (patch) | |
tree | 8b9a45574b2179dcbe705188f68a32b9aceff19f /desktop-widgets | |
parent | d2d2e3af3d7bd292bb6dee7ff2f50a36dcefb0ea (diff) | |
download | subsurface-9d342d0e1aac56c44a80e5025d4cf3b89c5746cf.tar.gz |
Desktop: Make "Edit dive" menu entry work for downloaded dives
Confusingly, "Edit dive" did only work for planned / manually
entered dives. Change this, but only start profile-editing for
planned / manually entered dives.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/mainwindow.cpp | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index beaf3227e..910c7a290 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -1096,25 +1096,7 @@ void MainWindow::on_actionAddDive_triggered() void MainWindow::on_actionEditDive_triggered() { - if (information()->isEditing() || DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING) { - QMessageBox::warning(this, tr("Warning"), tr("Please, first finish the current edition before trying to do another.")); - return; - } - - const bool isTripEdit = dive_list()->selectedTrips().count() >= 1; - if (!current_dive || isTripEdit || (current_dive->dc.model && strcmp(current_dive->dc.model, "manually added dive"))) { - QMessageBox::warning(this, tr("Warning"), tr("Trying to edit a dive that's not a manually added dive.")); - return; - } - - DivePlannerPointsModel::instance()->clear(); - disableShortcuts(); - DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD); - graphics()->setAddState(); - MapWidget::instance()->endGetDiveCoordinates(); - setApplicationState("EditDive"); - DivePlannerPointsModel::instance()->loadFromDive(current_dive); - information()->enableEdition(MainTab::MANUALLY_ADDED_DIVE); + editCurrentDive(); } void MainWindow::on_actionRenumber_triggered() @@ -1881,6 +1863,9 @@ void MainWindow::on_actionImportDiveLog_triggered() void MainWindow::editCurrentDive() { + if (!current_dive) + return; + if (information()->isEditing() || DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING) { QMessageBox::warning(this, tr("Warning"), tr("Please, first finish the current edition before trying to do another.")); return; @@ -1889,19 +1874,21 @@ void MainWindow::editCurrentDive() struct dive *d = current_dive; QString defaultDC(d->dc.model); DivePlannerPointsModel::instance()->clear(); + disableShortcuts(); if (defaultDC == "manually added dive") { - disableShortcuts(); DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD); graphics()->setAddState(); setApplicationState("EditDive"); DivePlannerPointsModel::instance()->loadFromDive(d); information()->enableEdition(MainTab::MANUALLY_ADDED_DIVE); } else if (defaultDC == "planned dive") { - disableShortcuts(); DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN); setApplicationState("EditPlannedDive"); DivePlannerPointsModel::instance()->loadFromDive(d); information()->enableEdition(MainTab::MANUALLY_ADDED_DIVE); + } else { + setApplicationState("EditDive"); + information()->enableEdition(); } } |