From 2d56f70e5fe64d1371714a0c382d09b8d16ce456 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 9 Mar 2024 17:08:13 +0100 Subject: [PATCH] profile: add plan-mode flag to ProfileWidget::plotDive() The flag is passed down to the ProfileView to give a different background. Amazingly, this seems to survive light testing. Signed-off-by: Berthold Stoeger --- desktop-widgets/mainwindow.cpp | 4 ++-- desktop-widgets/profilewidget.cpp | 15 ++++----------- desktop-widgets/profilewidget.h | 3 +-- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 00b31e1a3..2ecc6ba44 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -674,7 +674,7 @@ void MainWindow::on_actionReplanDive_triggered() disableShortcuts(true); plannerWidgets->prepareReplanDive(current_dive, profile->dc); - profile->setPlanState(plannerWidgets->getDive(), plannerWidgets->getDcNr()); + profile->plotDive(plannerWidgets->getDive(), profile->dc, true); plannerWidgets->replanDive(); } @@ -689,7 +689,7 @@ void MainWindow::on_actionDivePlanner_triggered() disableShortcuts(true); profile->exitEditMode(); plannerWidgets->preparePlanDive(current_dive, profile->dc); - profile->setPlanState(plannerWidgets->getDive(), plannerWidgets->getDcNr()); + profile->plotDive(plannerWidgets->getDive(), plannerWidgets->getDcNr(), true); plannerWidgets->planDive(); } diff --git a/desktop-widgets/profilewidget.cpp b/desktop-widgets/profilewidget.cpp index 90dc32a31..b5ceb3782 100644 --- a/desktop-widgets/profilewidget.cpp +++ b/desktop-widgets/profilewidget.cpp @@ -274,7 +274,7 @@ void ProfileWidget::plotCurrentDive() plotDive(d, dc); } -void ProfileWidget::plotDive(dive *dIn, int dcIn) +void ProfileWidget::plotDive(dive *dIn, int dcIn, bool planMode) { bool endEditMode = false; if (editedDive && (dIn != d || dcIn != dc)) @@ -308,9 +308,10 @@ void ProfileWidget::plotDive(dive *dIn, int dcIn) view->plotDive(editedDive.get(), dc, ProfileView::RenderFlags::EditMode); setDive(editedDive.get(), dc); } else if (d) { - //view->setProfileState(d, dc); + int flags = planMode ? ProfileView::RenderFlags::PlanMode + : ProfileView::RenderFlags::None; view->resetZoom(); // when switching dive, reset the zoomLevel - view->plotDive(d, dc); + view->plotDive(d, dc, flags); setDive(d, dc); } else { view->clear(); @@ -383,13 +384,6 @@ void ProfileWidget::cylindersChanged(struct dive *changed, int pos) } } -void ProfileWidget::setPlanState(const struct dive *d, int dcNr) -{ - dc = dcNr; - //view->setPlanState(d, dcNr); - setDive(d, dcNr); -} - void ProfileWidget::unsetProfHR() { ui.profHR->setChecked(false); @@ -413,7 +407,6 @@ void ProfileWidget::editDive() QSignalBlocker blocker(DivePlannerPointsModel::instance()); DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::EDIT); DivePlannerPointsModel::instance()->loadFromDive(editedDive.get(), dc); - //view->setEditState(editedDive.get(), editedDc); } void ProfileWidget::exitEditMode() diff --git a/desktop-widgets/profilewidget.h b/desktop-widgets/profilewidget.h index 9e78c1bd5..1af2ec55c 100644 --- a/desktop-widgets/profilewidget.h +++ b/desktop-widgets/profilewidget.h @@ -20,9 +20,8 @@ class ProfileWidget : public QWidget { public: ProfileWidget(); ~ProfileWidget(); - void plotDive(struct dive *d, int dc); // Attempt to keep DC number id dc < 0 + void plotDive(struct dive *d, int dc, bool planMode = false); // Attempt to keep DC number id dc < 0 void plotCurrentDive(); - void setPlanState(const struct dive *d, int dc); void setEnabledToolbar(bool enabled); void nextDC(); void prevDC();