From 32de8a13871729b86d888129bbdea50cd96cd52e Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 17 Sep 2022 16:35:31 +0200 Subject: [PATCH] tab-widgets: make delegates subobject The dive-equipment tab has a number of "delegates" for editing tanks sizes, etc. Instead of allocating them, make them subobjects. The main point here is that, in an upcoming commit, the sensor delegate will have to be accessed to change the current dive computer. So far it didn't have a name and therefore was hard to access. By making it a subobject it also gets a name. Signed-off-by: Berthold Stoeger --- desktop-widgets/tab-widgets/TabDiveEquipment.cpp | 8 ++++---- desktop-widgets/tab-widgets/TabDiveEquipment.h | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/desktop-widgets/tab-widgets/TabDiveEquipment.cpp b/desktop-widgets/tab-widgets/TabDiveEquipment.cpp index 0e0c1fee1..ef739c131 100644 --- a/desktop-widgets/tab-widgets/TabDiveEquipment.cpp +++ b/desktop-widgets/tab-widgets/TabDiveEquipment.cpp @@ -50,10 +50,10 @@ TabDiveEquipment::TabDiveEquipment(MainTab *parent) : TabBase(parent), connect(cylindersModel, &CylindersModel::divesEdited, this, &TabDiveEquipment::divesEdited); connect(weightModel, &WeightModel::divesEdited, this, &TabDiveEquipment::divesEdited); - ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate(this)); - ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::USE, new TankUseDelegate(this)); - ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::SENSORS, new SensorDelegate(this)); - ui.weights->view()->setItemDelegateForColumn(WeightModel::TYPE, new WSInfoDelegate(this)); + ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::TYPE, &tankInfoDelegate); + ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::USE, &tankUseDelegate); + ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::SENSORS, &sensorDelegate); + ui.weights->view()->setItemDelegateForColumn(WeightModel::TYPE, &wsInfoDelegate); ui.cylinders->view()->setColumnHidden(CylindersModel::DEPTH, true); ui.cylinders->view()->setColumnHidden(CylindersModel::WORKINGPRESS_INT, true); ui.cylinders->view()->setColumnHidden(CylindersModel::SIZE_INT, true); diff --git a/desktop-widgets/tab-widgets/TabDiveEquipment.h b/desktop-widgets/tab-widgets/TabDiveEquipment.h index 934ec9126..d01786aa9 100644 --- a/desktop-widgets/tab-widgets/TabDiveEquipment.h +++ b/desktop-widgets/tab-widgets/TabDiveEquipment.h @@ -6,6 +6,7 @@ #include "ui_TabDiveEquipment.h" #include "qt-models/completionmodels.h" #include "desktop-widgets/divelistview.h" +#include "desktop-widgets/modeldelegates.h" namespace Ui { class TabDiveEquipment; @@ -38,6 +39,11 @@ private: SuitCompletionModel suitModel; CylindersModel *cylindersModel; WeightModel *weightModel; + + TankInfoDelegate tankInfoDelegate; + TankUseDelegate tankUseDelegate; + SensorDelegate sensorDelegate; + WSInfoDelegate wsInfoDelegate; }; #endif // TAB_DIVE_EQUIPMENT_H