diff options
author | Joakim Bygdell <j.bygdell@gmail.com> | 2016-05-16 19:59:04 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-05-16 11:02:27 -0700 |
commit | fcc370b2fe532c42f52834ec7200c07f8e853313 (patch) | |
tree | 4b554b2ed94352fd942dc99a2b926adf967d6a48 /core/subsurface-qt | |
parent | 6392bf83ab35054d52e14e9282f3879b07a1e77e (diff) | |
download | subsurface-fcc370b2fe532c42f52834ec7200c07f8e853313.tar.gz |
Add functions to DiveObjectsHelper
This generated the QStringLists needed to populate the combobxes
in DiveDetailsEdit.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/subsurface-qt')
-rw-r--r-- | core/subsurface-qt/DiveObjectHelper.cpp | 51 | ||||
-rw-r--r-- | core/subsurface-qt/DiveObjectHelper.h | 6 |
2 files changed, 57 insertions, 0 deletions
diff --git a/core/subsurface-qt/DiveObjectHelper.cpp b/core/subsurface-qt/DiveObjectHelper.cpp index e2847f7c9..9f694c513 100644 --- a/core/subsurface-qt/DiveObjectHelper.cpp +++ b/core/subsurface-qt/DiveObjectHelper.cpp @@ -360,3 +360,54 @@ QString DiveObjectHelper::firstGas() const gas = get_gas_string(m_dive->cylinder[0].gasmix); return gas; } + +QStringList DiveObjectHelper::suitList() const +{ + QStringList suits; + struct dive *d; + int i = 0; + for_each_dive (i, d) { + QString temp = d->suit; + if (!temp.isEmpty()) + suits << d->suit; + } + suits.removeDuplicates(); + suits.sort(); + return suits; +} + +QStringList DiveObjectHelper::buddyList() const +{ + QStringList buddies; + struct dive *d; + int i = 0; + for_each_dive (i, d) { + QString temp = d->buddy; + if (!temp.isEmpty() && !temp.contains(",")){ + buddies << d->buddy; + } + else if (!temp.isEmpty()){ + QRegExp sep("(,\\s)"); + QStringList tempList = temp.split(sep); + buddies << tempList; + } + } + buddies.removeDuplicates(); + buddies.sort(); + return buddies; +} + +QStringList DiveObjectHelper::divemasterList() const +{ + QStringList divemasters; + struct dive *d; + int i = 0; + for_each_dive (i, d) { + QString temp = d->divemaster; + if (!temp.isEmpty()) + divemasters << d->divemaster; + } + divemasters.removeDuplicates(); + divemasters.sort(); + return divemasters; +} diff --git a/core/subsurface-qt/DiveObjectHelper.h b/core/subsurface-qt/DiveObjectHelper.h index e3b5d1eaa..fd44f81b8 100644 --- a/core/subsurface-qt/DiveObjectHelper.h +++ b/core/subsurface-qt/DiveObjectHelper.h @@ -42,6 +42,9 @@ class DiveObjectHelper : public QObject { Q_PROPERTY(QString startPressure READ startPressure CONSTANT) Q_PROPERTY(QString endPressure READ endPressure CONSTANT) Q_PROPERTY(QString firstGas READ firstGas CONSTANT) + Q_PROPERTY(QStringList suitList READ suitList CONSTANT) + Q_PROPERTY(QStringList buddyList READ buddyList CONSTANT) + Q_PROPERTY(QStringList divemasterList READ divemasterList CONSTANT) public: DiveObjectHelper(struct dive *dive = NULL); ~DiveObjectHelper(); @@ -81,6 +84,9 @@ public: QString startPressure() const; QString endPressure() const; QString firstGas() const; + QStringList suitList() const; + QStringList buddyList() const; + QStringList divemasterList() const; private: struct dive *m_dive; |