code cleanup: pre-calculate the test and pass it directly

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2018-09-14 16:48:51 +02:00 committed by Dirk Hohndel
parent 6d552d61b9
commit 00ef514da3

View file

@ -503,44 +503,27 @@ void MainWindow::recreateDiveList()
} }
void MainWindow::configureToolbar() { void MainWindow::configureToolbar() {
if (selected_dive>0) { if (selected_dive > 0) {
if (current_dive->dc.divemode == FREEDIVE) { bool freeDiveMode = current_dive->dc.divemode == FREEDIVE;
ui.profCalcCeiling->setDisabled(true); ui.profCalcCeiling->setDisabled(freeDiveMode);
ui.profCalcAllTissues ->setDisabled(true); ui.profCalcCeiling->setDisabled(freeDiveMode);
ui.profIncrement3m->setDisabled(true); ui.profCalcAllTissues ->setDisabled(freeDiveMode);
ui.profDcCeiling->setDisabled(true); ui.profIncrement3m->setDisabled(freeDiveMode);
ui.profPhe->setDisabled(true); ui.profDcCeiling->setDisabled(freeDiveMode);
ui.profPn2->setDisabled(true); //TODO is the same as scuba? ui.profPhe->setDisabled(freeDiveMode);
ui.profPO2->setDisabled(true); //TODO is the same as scuba? ui.profPn2->setDisabled(freeDiveMode); //TODO is the same as scuba?
ui.profRuler->setDisabled(false); ui.profPO2->setDisabled(freeDiveMode); //TODO is the same as scuba?
ui.profScaled->setDisabled(false); // measuring and scaling ui.profTankbar->setDisabled(freeDiveMode);
ui.profTogglePicture->setDisabled(false); ui.profMod->setDisabled(freeDiveMode);
ui.profTankbar->setDisabled(true); ui.profNdl_tts->setDisabled(freeDiveMode);
ui.profMod->setDisabled(true); ui.profEad->setDisabled(freeDiveMode);
ui.profNdl_tts->setDisabled(true); ui.profSAC->setDisabled(freeDiveMode);
ui.profEad->setDisabled(true); ui.profTissues->setDisabled(freeDiveMode);
ui.profSAC->setDisabled(true);
ui.profHR->setDisabled(false); ui.profRuler->setDisabled(false);
ui.profTissues->setDisabled(true); ui.profScaled->setDisabled(false); // measuring and scaling
} else { ui.profTogglePicture->setDisabled(false);
ui.profCalcCeiling->setDisabled(false); ui.profHR->setDisabled(false);
ui.profCalcAllTissues ->setDisabled(false);
ui.profIncrement3m->setDisabled(false);
ui.profDcCeiling->setDisabled(false);
ui.profPhe->setDisabled(false);
ui.profPn2->setDisabled(false);
ui.profPO2->setDisabled(false); // partial pressure graphs
ui.profRuler->setDisabled(false);
ui.profScaled->setDisabled(false); // measuring and scaling
ui.profTogglePicture->setDisabled(false);
ui.profTankbar->setDisabled(false);
ui.profMod->setDisabled(false);
ui.profNdl_tts->setDisabled(false); // various values that a user is either interested in or not
ui.profEad->setDisabled(false);
ui.profSAC->setDisabled(false);
ui.profHR->setDisabled(false); // very few dive computers support this
ui.profTissues->setDisabled(false);; // maybe less frequently used
}
} }
} }