From f25fa2adc5dd37aca17335d8278fd00e39e9b733 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 12 Aug 2019 18:26:42 +0200 Subject: Cleanup: turn CylinderObjectHelper into value type 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 --- core/subsurface-qt/DiveObjectHelper.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'core/subsurface-qt/DiveObjectHelper.h') diff --git a/core/subsurface-qt/DiveObjectHelper.h b/core/subsurface-qt/DiveObjectHelper.h index 7e3073c00..a090811de 100644 --- a/core/subsurface-qt/DiveObjectHelper.h +++ b/core/subsurface-qt/DiveObjectHelper.h @@ -6,6 +6,7 @@ #include #include #include +#include #include class DiveObjectHelper : public QObject { @@ -38,7 +39,7 @@ class DiveObjectHelper : public QObject { Q_PROPERTY(QString suit READ suit CONSTANT) Q_PROPERTY(QStringList cylinderList READ cylinderList CONSTANT) Q_PROPERTY(QStringList cylinders READ cylinders CONSTANT) - Q_PROPERTY(QList cylinderObjects READ cylinderObjects CONSTANT) + Q_PROPERTY(QVector cylinderObjects READ cylinderObjects CONSTANT) Q_PROPERTY(QString tripId READ tripId CONSTANT) Q_PROPERTY(int tripNrDives READ tripNrDives CONSTANT) Q_PROPERTY(int maxcns READ maxcns CONSTANT) @@ -52,7 +53,6 @@ class DiveObjectHelper : public QObject { Q_PROPERTY(QString fullTextNoNotes READ fullTextNoNotes CONSTANT) public: DiveObjectHelper(struct dive *dive); - ~DiveObjectHelper(); int number() const; int id() const; struct dive *getDive() const; @@ -84,7 +84,7 @@ public: QStringList cylinderList() const; QStringList cylinders() const; QString cylinder(int idx) const; - QList cylinderObjects() const; + QVector cylinderObjects() const; QString tripId() const; int tripNrDives() const; int maxcns() const; @@ -99,7 +99,7 @@ public: private: struct dive *m_dive; - QList m_cyls; + QVector m_cyls; }; Q_DECLARE_METATYPE(DiveObjectHelper *) -- cgit v1.2.3-70-g09d2