This generated the QStringLists needed to populate the combobxes
in DiveDetailsEdit.

Signed-off-by: Joakim Bygdell <[email protected]>
---
 core/subsurface-qt/DiveObjectHelper.cpp | 51 +++++++++++++++++++++++++++++++++
 core/subsurface-qt/DiveObjectHelper.h   |  6 ++++
 2 files changed, 57 insertions(+)

diff --git a/core/subsurface-qt/DiveObjectHelper.cpp 
b/core/subsurface-qt/DiveObjectHelper.cpp
index e2847f7..9f694c5 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 e3b5d1e..fd44f81 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;
-- 
2.5.4 (Apple Git-61)

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to