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 <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2022-09-17 16:35:31 +02:00 committed by bstoeger
parent 6f03fc9689
commit 32de8a1387
2 changed files with 10 additions and 4 deletions

View file

@ -50,10 +50,10 @@ TabDiveEquipment::TabDiveEquipment(MainTab *parent) : TabBase(parent),
connect(cylindersModel, &CylindersModel::divesEdited, this, &TabDiveEquipment::divesEdited); connect(cylindersModel, &CylindersModel::divesEdited, this, &TabDiveEquipment::divesEdited);
connect(weightModel, &WeightModel::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::TYPE, &tankInfoDelegate);
ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::USE, new TankUseDelegate(this)); ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::USE, &tankUseDelegate);
ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::SENSORS, new SensorDelegate(this)); ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::SENSORS, &sensorDelegate);
ui.weights->view()->setItemDelegateForColumn(WeightModel::TYPE, new WSInfoDelegate(this)); ui.weights->view()->setItemDelegateForColumn(WeightModel::TYPE, &wsInfoDelegate);
ui.cylinders->view()->setColumnHidden(CylindersModel::DEPTH, true); ui.cylinders->view()->setColumnHidden(CylindersModel::DEPTH, true);
ui.cylinders->view()->setColumnHidden(CylindersModel::WORKINGPRESS_INT, true); ui.cylinders->view()->setColumnHidden(CylindersModel::WORKINGPRESS_INT, true);
ui.cylinders->view()->setColumnHidden(CylindersModel::SIZE_INT, true); ui.cylinders->view()->setColumnHidden(CylindersModel::SIZE_INT, true);

View file

@ -6,6 +6,7 @@
#include "ui_TabDiveEquipment.h" #include "ui_TabDiveEquipment.h"
#include "qt-models/completionmodels.h" #include "qt-models/completionmodels.h"
#include "desktop-widgets/divelistview.h" #include "desktop-widgets/divelistview.h"
#include "desktop-widgets/modeldelegates.h"
namespace Ui { namespace Ui {
class TabDiveEquipment; class TabDiveEquipment;
@ -38,6 +39,11 @@ private:
SuitCompletionModel suitModel; SuitCompletionModel suitModel;
CylindersModel *cylindersModel; CylindersModel *cylindersModel;
WeightModel *weightModel; WeightModel *weightModel;
TankInfoDelegate tankInfoDelegate;
TankUseDelegate tankUseDelegate;
SensorDelegate sensorDelegate;
WSInfoDelegate wsInfoDelegate;
}; };
#endif // TAB_DIVE_EQUIPMENT_H #endif // TAB_DIVE_EQUIPMENT_H