diff options
author | Joakim Bygdell <j.bygdell@gmail.com> | 2016-08-30 16:24:19 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-09-04 07:36:13 -0700 |
commit | 674d8331f5c15a8c3095afd1deca2b087fd82464 (patch) | |
tree | defca414c3ca03c51b8dd65840b1d5ba6dedf963 /core | |
parent | 7b3665827a3fdf6717be5419b41641d8e2d95c93 (diff) | |
download | subsurface-674d8331f5c15a8c3095afd1deca2b087fd82464.tar.gz |
QML UI: Enable cylinder edit
This adds the option to select a cylinder when adding or editing a dive.
Due to limited screen size we restrict the editing to the first cylinder only.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/subsurface-qt/DiveObjectHelper.cpp | 25 | ||||
-rw-r--r-- | core/subsurface-qt/DiveObjectHelper.h | 4 |
2 files changed, 22 insertions, 7 deletions
diff --git a/core/subsurface-qt/DiveObjectHelper.cpp b/core/subsurface-qt/DiveObjectHelper.cpp index 768d4a860..87fae7c06 100644 --- a/core/subsurface-qt/DiveObjectHelper.cpp +++ b/core/subsurface-qt/DiveObjectHelper.cpp @@ -5,6 +5,7 @@ #include "../qthelper.h" #include "../helpers.h" +#include "../../qt-models/tankinfomodel.h" static QString EMPTY_DIVE_STRING = QStringLiteral(""); enum returnPressureSelector {START_PRESSURE, END_PRESSURE}; @@ -252,15 +253,29 @@ QString DiveObjectHelper::suit() const return m_dive->suit ? m_dive->suit : EMPTY_DIVE_STRING; } -QString DiveObjectHelper::cylinderList() const +QStringList DiveObjectHelper::cylinderList() const { - QString cylinders; - for (int i = 0; i < MAX_CYLINDERS; i++) { - QString cyl = getFormattedCylinder(m_dive, i); + QStringList cylinders; + struct dive *d; + int i = 0; + for_each_dive (i, d) { + for (int j = 0; j < MAX_CYLINDERS; j++) { + QString cyl = d->cylinder[j].type.description; + if (cyl == EMPTY_DIVE_STRING) + continue; + cylinders << cyl; + } + } + + for (i = 0; i < sizeof(tank_info) && tank_info[i].name != NULL; i++) { + QString cyl = tank_info[i].name; if (cyl == EMPTY_DIVE_STRING) continue; - cylinders += cyl + "; "; + cylinders << cyl; } + + cylinders.removeDuplicates(); + cylinders.sort(); return cylinders; } diff --git a/core/subsurface-qt/DiveObjectHelper.h b/core/subsurface-qt/DiveObjectHelper.h index c685690cf..8650f7a98 100644 --- a/core/subsurface-qt/DiveObjectHelper.h +++ b/core/subsurface-qt/DiveObjectHelper.h @@ -33,7 +33,7 @@ class DiveObjectHelper : public QObject { Q_PROPERTY(QStringList weights READ weights CONSTANT) Q_PROPERTY(bool singleWeight READ singleWeight CONSTANT) Q_PROPERTY(QString suit READ suit CONSTANT) - Q_PROPERTY(QString cylinderList READ cylinderList CONSTANT) + Q_PROPERTY(QStringList cylinderList READ cylinderList CONSTANT) Q_PROPERTY(QStringList cylinders READ cylinders CONSTANT) Q_PROPERTY(QList<CylinderObjectHelper*> cylinderObjects READ cylinderObjects CONSTANT) Q_PROPERTY(QString trip READ trip CONSTANT) @@ -76,7 +76,7 @@ public: QString weight(int idx) const; bool singleWeight() const; QString suit() const; - QString cylinderList() const; + QStringList cylinderList() const; QStringList cylinders() const; QString cylinder(int idx) const; QList<CylinderObjectHelper*> cylinderObjects() const; |