mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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 <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
4f5621c4c6
commit
9bbd8b8169
1 changed files with 10 additions and 20 deletions
|
@ -1668,31 +1668,21 @@ void MainWindow::on_actionImportDiveSites_triggered()
|
||||||
|
|
||||||
void MainWindow::editCurrentDive()
|
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;
|
return;
|
||||||
|
|
||||||
if (mainTab->isEditing() || DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING) {
|
// This shouldn't be possible, but let's make sure no weird "double editing" takes place.
|
||||||
QMessageBox::warning(this, tr("Warning"), tr("Please, first finish the current edition before trying to do another."));
|
if (mainTab->isEditing() || DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
struct dive *d = current_dive;
|
disableShortcuts();
|
||||||
QString defaultDC(d->dc.model);
|
|
||||||
DivePlannerPointsModel::instance()->clear();
|
DivePlannerPointsModel::instance()->clear();
|
||||||
if (defaultDC == "manually added dive") {
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
|
||||||
disableShortcuts();
|
graphics->setAddState();
|
||||||
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
|
setApplicationState(ApplicationState::EditDive);
|
||||||
graphics->setAddState();
|
DivePlannerPointsModel::instance()->loadFromDive(current_dive);
|
||||||
setApplicationState(ApplicationState::EditDive);
|
mainTab->enableEdition();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::turnOffNdlTts()
|
void MainWindow::turnOffNdlTts()
|
||||||
|
|
Loading…
Reference in a new issue