profile: set profile-mode in ProfileWidget, not MainWindow

The mode of the profile (profile, edit, plan) was set in
MainWindow and ProfileWidget. For consistency move the one
setProfileState() call from MainWindow to ProfileWidget.
This removes a direct access to the profile-view and
therefore improves encapsulation.

Also, clear the profile, when no dive is shown to remove
any potentially dangling references.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-08-08 15:22:15 +02:00 committed by Dirk Hohndel
parent 12fd102e4f
commit f8fbff9f7d
2 changed files with 3 additions and 2 deletions

View file

@ -577,7 +577,7 @@ void MainWindow::enableShortcuts()
void MainWindow::showProfile()
{
enableShortcuts();
profile->view->setProfileState(current_dive, dc_number);
profile->plotCurrentDive();
setApplicationState(ApplicationState::Default);
}
@ -629,7 +629,6 @@ bool MainWindow::plannerStateClean()
void MainWindow::refreshProfile()
{
showProfile();
profile->plotCurrentDive();
}
void MainWindow::planCanceled()

View file

@ -197,8 +197,10 @@ void ProfileWidget::plotCurrentDive()
ui.profScaled->setDisabled(false); // measuring and scaling
ui.profTogglePicture->setDisabled(false);
ui.profHR->setDisabled(false);
view->setProfileState(current_dive, dc_number);
view->plotDive(current_dive, dc_number);
} else {
view->clear();
stack->setCurrentIndex(0);
}
}