From 9bbd8b8169480f124d81b9cd4d05064ac664ae0d Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 13 Apr 2020 15:50:27 +0200 Subject: desktop: remove unused if-branch in MainWindow::editCurrentDive() MainWindow::editCurrentDive() used to be a general function to enter edit mode. Nowadays, this is only called for one very specific case, namely editing the profile of a manually added dive. Therefore, we can remove the if-branch that dealt with planned dives. Moreover, we can do the test right at the beginning and remove a warning message for duplicate "edition", as this is not possible anymore. Signed-off-by: Berthold Stoeger --- desktop-widgets/mainwindow.cpp | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'desktop-widgets/mainwindow.cpp') diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 0f7078c68..116e19c95 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -1668,31 +1668,21 @@ void MainWindow::on_actionImportDiveSites_triggered() void MainWindow::editCurrentDive() { - if (!current_dive) + // We only allow editing of the profile for manually added dives. + if (!current_dive || !same_string(current_dive->dc.model, "manually added dive")) return; - if (mainTab->isEditing() || DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING) { - QMessageBox::warning(this, tr("Warning"), tr("Please, first finish the current edition before trying to do another.")); + // This shouldn't be possible, but let's make sure no weird "double editing" takes place. + if (mainTab->isEditing() || DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING) return; - } - struct dive *d = current_dive; - QString defaultDC(d->dc.model); + disableShortcuts(); DivePlannerPointsModel::instance()->clear(); - if (defaultDC == "manually added dive") { - disableShortcuts(); - DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD); - graphics->setAddState(); - setApplicationState(ApplicationState::EditDive); - DivePlannerPointsModel::instance()->loadFromDive(d); - mainTab->enableEdition(); - } else if (defaultDC == "planned dive") { - disableShortcuts(); - DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN); - setApplicationState(ApplicationState::EditPlannedDive); - DivePlannerPointsModel::instance()->loadFromDive(d); - mainTab->enableEdition(); - } + DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD); + graphics->setAddState(); + setApplicationState(ApplicationState::EditDive); + DivePlannerPointsModel::instance()->loadFromDive(current_dive); + mainTab->enableEdition(); } void MainWindow::turnOffNdlTts() -- cgit v1.2.3-70-g09d2