From be763452adc110cfcc011322d989698d897dd6ed Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 13 Aug 2019 07:28:24 +0200 Subject: DiveObjectHelper: Turn DiveObjectHelper into Q_GADGET based object DiveObjectHelper is a tiny wrapper around dive * to allow access to dive data from QML and grantlee. It doesn't have to be a full-fledged QObject with support for signals, etc. Therefore, turn it into a Q_GADGET based object. This allows us passing the object around as object, not as pointer to DiveObjectHelper. This makes memory-management distinctly easier. Signed-off-by: Berthold Stoeger --- core/subsurface-qt/DiveObjectHelper.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'core/subsurface-qt/DiveObjectHelper.h') diff --git a/core/subsurface-qt/DiveObjectHelper.h b/core/subsurface-qt/DiveObjectHelper.h index 397bc4d36..7071c1580 100644 --- a/core/subsurface-qt/DiveObjectHelper.h +++ b/core/subsurface-qt/DiveObjectHelper.h @@ -9,8 +9,8 @@ #include #include -class DiveObjectHelper : public QObject { - Q_OBJECT +class DiveObjectHelper { + Q_GADGET Q_PROPERTY(int number READ number CONSTANT) Q_PROPERTY(int id READ id CONSTANT) Q_PROPERTY(int rating READ rating CONSTANT) @@ -48,6 +48,7 @@ class DiveObjectHelper : public QObject { Q_PROPERTY(QStringList endPressure READ endPressure CONSTANT) Q_PROPERTY(QStringList firstGas READ firstGas CONSTANT) public: + DiveObjectHelper(); // This is only to be used by Qt's metatype system! DiveObjectHelper(struct dive *dive); int number() const; int id() const; @@ -92,6 +93,6 @@ public: private: struct dive *m_dive; }; - Q_DECLARE_METATYPE(DiveObjectHelper *) + Q_DECLARE_METATYPE(DiveObjectHelper) #endif -- cgit v1.2.3-70-g09d2