diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-08-13 08:19:04 +0200 |
---|---|---|
committer | bstoeger <32835590+bstoeger@users.noreply.github.com> | 2019-09-14 13:20:59 +0200 |
commit | f8c5c8bedf9c0af8f031da7fc74c516a40e9e1c6 (patch) | |
tree | 92c557ab1de0506e1e0a33bc2ab22738e17393e4 /core | |
parent | be763452adc110cfcc011322d989698d897dd6ed (diff) | |
download | subsurface-f8c5c8bedf9c0af8f031da7fc74c516a40e9e1c6.tar.gz |
Mobile: Generate DiveObjectHelpers on the fly
Instead of keeping track of a list of DiveObjectHelpers, generate
them on-the-fly in DiveListModel. Thus, there is less danger of
model and core getting out of sync. On the flip-side, now the
DiveListModel and the DiveListSortModel might get out of sync.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r-- | core/subsurface-qt/DiveObjectHelper.cpp | 10 | ||||
-rw-r--r-- | core/subsurface-qt/DiveObjectHelper.h | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/core/subsurface-qt/DiveObjectHelper.cpp b/core/subsurface-qt/DiveObjectHelper.cpp index c19c03eb4..cb6cf6dd1 100644 --- a/core/subsurface-qt/DiveObjectHelper.cpp +++ b/core/subsurface-qt/DiveObjectHelper.cpp @@ -67,6 +67,16 @@ DiveObjectHelper::DiveObjectHelper(struct dive *d) : { } +DiveObjectHelper::operator bool() const +{ + return !!m_dive; +} + +bool DiveObjectHelper::operator!() const +{ + return !m_dive; +} + int DiveObjectHelper::number() const { return m_dive->number; diff --git a/core/subsurface-qt/DiveObjectHelper.h b/core/subsurface-qt/DiveObjectHelper.h index 7071c1580..674386e56 100644 --- a/core/subsurface-qt/DiveObjectHelper.h +++ b/core/subsurface-qt/DiveObjectHelper.h @@ -50,6 +50,8 @@ class DiveObjectHelper { public: DiveObjectHelper(); // This is only to be used by Qt's metatype system! DiveObjectHelper(struct dive *dive); + operator bool() const; // Returns false if this is an invalid default-generated object + bool operator!() const; // Returns true if this is an invalid default-generated object int number() const; int id() const; struct dive *getDive() const; |