From 9d342d0e1aac56c44a80e5025d4cf3b89c5746cf Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 3 May 2018 16:50:46 +0200 Subject: 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 --- desktop-widgets/mainwindow.cpp | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) (limited to 'desktop-widgets') 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(); } } -- cgit v1.2.3-70-g09d2