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/DiveObjectHelper.cpp | |
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/DiveObjectHelper.cpp')
-rw-r--r-- | core/subsurface-qt/DiveObjectHelper.cpp | 51 |
1 files changed, 51 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; +} |