mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-11 19:41:30 +00:00
f25fa2adc5
CylinderObjectHelper is used for structured formatting of cylinder values in grantlee types. Instead of keeping a reference to a cylinder, turn it into a value type containing the formatted strings. This should be distinctly safer, as we don't risk having stale references flying around. Moreover, we don't have to use pointers but can use containers containing plain CylinderObjectHelper. Thus, no explicit memory management is needed, making the code distinctly easier to understand. Sadly, currently grantlee does not support Q_GADGET based Q_PROPERTY. Therefore a GRANTLEE_*_LOOKUP block has to be added. This can be removed in due course, as a patch to remedy this issue is in current grantlee master. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
29 lines
788 B
C++
29 lines
788 B
C++
// SPDX-License-Identifier: GPL-2.0
|
|
#ifndef CYLINDER_QOBJECT_H
|
|
#define CYLINDER_QOBJECT_H
|
|
|
|
#include "../equipment.h"
|
|
#include <QObject>
|
|
#include <QString>
|
|
|
|
class CylinderObjectHelper {
|
|
Q_GADGET
|
|
Q_PROPERTY(QString description MEMBER description CONSTANT)
|
|
Q_PROPERTY(QString size MEMBER size CONSTANT)
|
|
Q_PROPERTY(QString workingPressure MEMBER workingPressure CONSTANT)
|
|
Q_PROPERTY(QString startPressure MEMBER startPressure CONSTANT)
|
|
Q_PROPERTY(QString endPressure MEMBER endPressure CONSTANT)
|
|
Q_PROPERTY(QString gasMix MEMBER gasMix CONSTANT)
|
|
public:
|
|
CylinderObjectHelper(cylinder_t *cylinder = NULL);
|
|
QString description;
|
|
QString size;
|
|
QString workingPressure;
|
|
QString startPressure;
|
|
QString endPressure;
|
|
QString gasMix;
|
|
};
|
|
|
|
Q_DECLARE_METATYPE(CylinderObjectHelper)
|
|
|
|
#endif
|