mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
6392bf83ab
commit
fcc370b2fe
2 changed files with 57 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue