From 6b615ccb4bed5dc7ab0c5b2ebbe7641942919d49 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 12 Apr 2021 22:20:46 +0200 Subject: [PATCH] desktop: fold configureToolBar() into plotCurrentDive() The MainWindow::configureToolBar() function is called every time plotCurrentDive() is called. Moreover, this is the only time that it is called. We might just fold the former into the latter. Signed-off-by: Berthold Stoeger --- desktop-widgets/mainwindow.cpp | 15 +++------------ desktop-widgets/mainwindow.h | 1 - 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index d5fa59235..c426d753a 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -398,8 +398,9 @@ void MainWindow::refreshDisplay() ui.actionAutoGroup->setChecked(autogroup); } -void MainWindow::configureToolbar() +void MainWindow::plotCurrentDive() { + setEnabledToolbar(current_dive != nullptr); if (current_dive) { bool freeDiveMode = current_dive->dc.divemode == FREEDIVE; ui.profCalcCeiling->setDisabled(freeDiveMode); @@ -423,21 +424,14 @@ void MainWindow::configureToolbar() ui.profTogglePicture->setDisabled(false); ui.profHR->setDisabled(false); } -} - -void MainWindow::plotCurrentDive() -{ - setEnabledToolbar(current_dive != nullptr); graphics->plotDive(current_dive, dc_number); } void MainWindow::selectionChanged() { mainTab->updateDiveInfo(); - if (current_dive) { - configureToolbar(); + if (current_dive) enableDisableOtherDCsActions(); - } plotCurrentDive(); MapWidget::instance()->selectionChanged(); } @@ -741,7 +735,6 @@ bool MainWindow::plannerStateClean() void MainWindow::refreshProfile() { showProfile(); - configureToolbar(); plotCurrentDive(); } @@ -926,7 +919,6 @@ void MainWindow::on_actionPreviousDC_triggered() { unsigned nrdc = number_of_computers(current_dive); dc_number = (dc_number + nrdc - 1) % nrdc; - configureToolbar(); plotCurrentDive(); mainTab->updateDiveInfo(); } @@ -935,7 +927,6 @@ void MainWindow::on_actionNextDC_triggered() { unsigned nrdc = number_of_computers(current_dive); dc_number = (dc_number + 1) % nrdc; - configureToolbar(); plotCurrentDive(); mainTab->updateDiveInfo(); } diff --git a/desktop-widgets/mainwindow.h b/desktop-widgets/mainwindow.h index 1675415e3..a1c3a646e 100644 --- a/desktop-widgets/mainwindow.h +++ b/desktop-widgets/mainwindow.h @@ -201,7 +201,6 @@ private: std::unique_ptr diveSiteEdit; bool plannerStateClean(); - void configureToolbar(); void setupSocialNetworkMenu(); QDialog *findMovedImagesDialog; struct dive copyPasteDive;