mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Core: move cylinder list getter into helper function
Thie way we can use it from the dive list model. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
613a3112d2
commit
32ae3810ce
1 changed files with 27 additions and 22 deletions
|
@ -215,6 +215,32 @@ QStringList getFirstGas(const dive *d)
|
||||||
return gas;
|
return gas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList getFullCylinderList()
|
||||||
|
{
|
||||||
|
QStringList cylinders;
|
||||||
|
int i = 0;
|
||||||
|
struct dive *d;
|
||||||
|
for_each_dive (i, d) {
|
||||||
|
for (int j = 0; j < MAX_CYLINDERS; j++) {
|
||||||
|
QString cyl = d->cylinder[j].type.description;
|
||||||
|
if (cyl.isEmpty())
|
||||||
|
continue;
|
||||||
|
cylinders << cyl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int ti = 0; ti < MAX_TANK_INFO && tank_info[ti].name != NULL; ti++) {
|
||||||
|
QString cyl = tank_info[ti].name;
|
||||||
|
if (cyl.isEmpty())
|
||||||
|
continue;
|
||||||
|
cylinders << cyl;
|
||||||
|
}
|
||||||
|
|
||||||
|
cylinders.removeDuplicates();
|
||||||
|
cylinders.sort();
|
||||||
|
return cylinders;
|
||||||
|
}
|
||||||
|
|
||||||
// Qt's metatype system insists on generating a default constructed object, even if that makes no sense.
|
// Qt's metatype system insists on generating a default constructed object, even if that makes no sense.
|
||||||
DiveObjectHelper::DiveObjectHelper()
|
DiveObjectHelper::DiveObjectHelper()
|
||||||
{
|
{
|
||||||
|
@ -293,26 +319,5 @@ QString DiveObjectHelper::time() const
|
||||||
|
|
||||||
QStringList DiveObjectHelper::cylinderList() const
|
QStringList DiveObjectHelper::cylinderList() const
|
||||||
{
|
{
|
||||||
QStringList cylinders;
|
return getFullCylinderList();
|
||||||
int i = 0;
|
|
||||||
struct dive *d;
|
|
||||||
for_each_dive (i, d) {
|
|
||||||
for (int j = 0; j < MAX_CYLINDERS; j++) {
|
|
||||||
QString cyl = d->cylinder[j].type.description;
|
|
||||||
if (cyl.isEmpty())
|
|
||||||
continue;
|
|
||||||
cylinders << cyl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int ti = 0; ti < MAX_TANK_INFO && tank_info[ti].name != NULL; ti++) {
|
|
||||||
QString cyl = tank_info[ti].name;
|
|
||||||
if (cyl.isEmpty())
|
|
||||||
continue;
|
|
||||||
cylinders << cyl;
|
|
||||||
}
|
|
||||||
|
|
||||||
cylinders.removeDuplicates();
|
|
||||||
cylinders.sort();
|
|
||||||
return cylinders;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue