From 296a391faa1625350b5561d8ce17f5dc8a38300c Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 11 Dec 2020 23:55:18 +0100 Subject: prefs: add option to display only actually used tanks A user complained about the default cylinders list. Provide a preferences option to turn this off. When changing the preferences, the tank-info model will be completely rebuilt. Currently, this is a bit crude as this will be done for any preferences change. Suggested-by: Adolph Weidanz Signed-off-by: Berthold Stoeger --- desktop-widgets/preferences/preferences_equipment.cpp | 12 ++++++++++++ desktop-widgets/preferences/preferences_equipment.ui | 9 +++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'desktop-widgets/preferences') diff --git a/desktop-widgets/preferences/preferences_equipment.cpp b/desktop-widgets/preferences/preferences_equipment.cpp index 00bd9aa53..877e904d8 100644 --- a/desktop-widgets/preferences/preferences_equipment.cpp +++ b/desktop-widgets/preferences/preferences_equipment.cpp @@ -4,6 +4,7 @@ #include "core/settings/qPrefEquipment.h" #include "core/qthelper.h" #include "core/dive.h" +#include "qt-models/tankinfomodel.h" #include #include @@ -23,6 +24,7 @@ PreferencesEquipment::~PreferencesEquipment() void PreferencesEquipment::refreshSettings() { ui->display_unused_tanks->setChecked(prefs.display_unused_tanks); + ui->display_default_tank_infos->setChecked(prefs.display_default_tank_infos); ui->default_cylinder->clear(); for (int i = 0; i < tank_info_table.nr; i++) { const tank_info &ti = tank_info_table.infos[i]; @@ -36,5 +38,15 @@ void PreferencesEquipment::syncSettings() { auto equipment = qPrefEquipment::instance(); qPrefEquipment::set_display_unused_tanks(ui->display_unused_tanks->isChecked()); + qPrefEquipment::set_display_default_tank_infos(ui->display_default_tank_infos->isChecked()); equipment->set_default_cylinder(ui->default_cylinder->currentText()); + + // In case the user changed the tank info settings, + // reset the tank_info_table and inform the TankInfoModel of + // the changed table. It is somewhat questionable to do this here. + // Moreover, it is a bit crude, as this will be called for *any* + // preferences change. Perhaps, the model should listen to the + // precise changed signal of the preferences system? + reset_tank_info_table(&tank_info_table); + TankInfoModel::instance()->update(); } diff --git a/desktop-widgets/preferences/preferences_equipment.ui b/desktop-widgets/preferences/preferences_equipment.ui index 4526f9618..7461cd913 100644 --- a/desktop-widgets/preferences/preferences_equipment.ui +++ b/desktop-widgets/preferences/preferences_equipment.ui @@ -61,7 +61,6 @@ - @@ -69,7 +68,13 @@ - + + + + Show default cylinder sizes in the cylinders selection of the equipment tab + + + -- cgit v1.2.3-70-g09d2