summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/subsurface-qt/DiveObjectHelper.cpp326
-rw-r--r--core/subsurface-qt/DiveObjectHelper.h137
-rw-r--r--desktop-widgets/templatelayout.h66
-rw-r--r--mobile-widgets/qmlmanager.cpp38
4 files changed, 242 insertions, 325 deletions
diff --git a/core/subsurface-qt/DiveObjectHelper.cpp b/core/subsurface-qt/DiveObjectHelper.cpp
index f30ca0eab..ec62a9fec 100644
--- a/core/subsurface-qt/DiveObjectHelper.cpp
+++ b/core/subsurface-qt/DiveObjectHelper.cpp
@@ -12,9 +12,9 @@
enum returnPressureSelector {START_PRESSURE, END_PRESSURE};
-static QString getFormattedWeight(struct dive *dive, unsigned int idx)
+static QString getFormattedWeight(const struct dive *dive, unsigned int idx)
{
- weightsystem_t *weight = &dive->weightsystems.weightsystems[idx];
+ const weightsystem_t *weight = &dive->weightsystems.weightsystems[idx];
if (!weight->description)
return QString();
QString fmt = QString(weight->description);
@@ -22,9 +22,9 @@ static QString getFormattedWeight(struct dive *dive, unsigned int idx)
return fmt;
}
-static QString getFormattedCylinder(struct dive *dive, unsigned int idx)
+static QString getFormattedCylinder(const struct dive *dive, unsigned int idx)
{
- cylinder_t *cyl = &dive->cylinder[idx];
+ const cylinder_t *cyl = &dive->cylinder[idx];
const char *desc = cyl->type.description;
if (!desc && idx > 0)
return QString();
@@ -36,9 +36,9 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx)
return fmt;
}
-static QString getPressures(struct dive *dive, int i, enum returnPressureSelector ret)
+static QString getPressures(const struct dive *dive, int i, enum returnPressureSelector ret)
{
- cylinder_t *cyl = &dive->cylinder[i];
+ const cylinder_t *cyl = &dive->cylinder[i];
QString fmt;
if (ret == START_PRESSURE) {
if (cyl->start.mbar)
@@ -55,115 +55,20 @@ static QString getPressures(struct dive *dive, int i, enum returnPressureSelecto
return fmt;
}
-// Qt's metatype system insists on generating a default constructed object,
-// even if that makes no sense. Usage of this object *will* crash.
-DiveObjectHelper::DiveObjectHelper() :
- m_dive(nullptr)
-{
-}
-
-DiveObjectHelper::DiveObjectHelper(struct dive *d) :
- m_dive(d)
-{
-}
-
-int DiveObjectHelper::number() const
-{
- return m_dive->number;
-}
-
-int DiveObjectHelper::id() const
-{
- return m_dive->id;
-}
-
-QString DiveObjectHelper::date() const
-{
- QDateTime localTime = QDateTime::fromMSecsSinceEpoch(1000*m_dive->when, Qt::UTC);
- localTime.setTimeSpec(Qt::UTC);
- return localTime.date().toString(prefs.date_format_short);
-}
-
-timestamp_t DiveObjectHelper::timestamp() const
-{
- return m_dive->when;
-}
-
-QString DiveObjectHelper::time() const
-{
- QDateTime localTime = QDateTime::fromMSecsSinceEpoch(1000*m_dive->when, Qt::UTC);
- localTime.setTimeSpec(Qt::UTC);
- return localTime.time().toString(prefs.time_format);
-}
-
-QString DiveObjectHelper::location() const
-{
- return get_dive_location(m_dive) ? QString::fromUtf8(get_dive_location(m_dive)) : QString();
-}
-
-QString DiveObjectHelper::gps() const
-{
- struct dive_site *ds = m_dive->dive_site;
- if (!ds)
- return QString();
- return printGPSCoords(&ds->location);
-}
-
-QString DiveObjectHelper::gps_decimal() const
+static QString format_gps_decimal(const dive *d)
{
bool savep = prefs.coordinates_traditional;
- QString val;
prefs.coordinates_traditional = false;
- val = gps();
+ QString val = d->dive_site ? printGPSCoords(&d->dive_site->location) : QString();
prefs.coordinates_traditional = savep;
return val;
}
-QVariant DiveObjectHelper::dive_site() const
-{
- return QVariant::fromValue(m_dive->dive_site);
-}
-
-QString DiveObjectHelper::duration() const
+static QString formatNotes(const dive *d)
{
- return get_dive_duration_string(m_dive->duration.seconds, gettextFromC::tr("h"), gettextFromC::tr("min"));
-}
-
-bool DiveObjectHelper::noDive() const
-{
- return m_dive->duration.seconds == 0 && m_dive->dc.duration.seconds == 0;
-}
-
-QString DiveObjectHelper::depth() const
-{
- return get_depth_string(m_dive->dc.maxdepth.mm, true, true);
-}
-
-QString DiveObjectHelper::divemaster() const
-{
- return m_dive->divemaster ? m_dive->divemaster : QString();
-}
-
-QString DiveObjectHelper::buddy() const
-{
- return m_dive->buddy ? m_dive->buddy : QString();
-}
-
-QString DiveObjectHelper::airTemp() const
-{
- return get_temperature_string(m_dive->airtemp, true);
-}
-
-QString DiveObjectHelper::waterTemp() const
-{
- return get_temperature_string(m_dive->watertemp, true);
-}
-
-QString DiveObjectHelper::notes() const
-{
- QString tmp = m_dive->notes ? QString::fromUtf8(m_dive->notes) : QString();
- if (is_dc_planner(&m_dive->dc)) {
+ QString tmp = d->notes ? QString::fromUtf8(d->notes) : QString();
+ if (is_dc_planner(&d->dc)) {
QTextDocument notes;
#define _NOTES_BR "&#92n"
tmp.replace("<thead>", "<thead>" _NOTES_BR)
@@ -182,24 +87,19 @@ QString DiveObjectHelper::notes() const
return tmp;
}
-QString DiveObjectHelper::tags() const
-{
- return get_taglist_string(m_dive->tag_list);
-}
-
-QString DiveObjectHelper::gas() const
+static QString formatGas(const dive *d)
{
/*WARNING: here should be the gastlist, returned
* from the get_gas_string function or this is correct?
*/
QString gas, gases;
for (int i = 0; i < MAX_CYLINDERS; i++) {
- if (!is_cylinder_used(m_dive, i))
+ if (!is_cylinder_used(d, i))
continue;
- gas = m_dive->cylinder[i].type.description;
+ gas = d->cylinder[i].type.description;
if (!gas.isEmpty())
gas += QChar(' ');
- gas += gasname(m_dive->cylinder[i].gasmix);
+ gas += gasname(d->cylinder[i].gasmix);
// if has a description and if such gas is not already present
if (!gas.isEmpty() && gases.indexOf(gas) == -1) {
if (!gases.isEmpty())
@@ -210,21 +110,21 @@ QString DiveObjectHelper::gas() const
return gases;
}
-QString DiveObjectHelper::sac() const
+static QString formatSac(const dive *d)
{
- if (!m_dive->sac)
+ if (!d->sac)
return QString();
const char *unit;
int decimal;
- double value = get_volume_units(m_dive->sac, &decimal, &unit);
+ double value = get_volume_units(d->sac, &decimal, &unit);
return QString::number(value, 'f', decimal).append(unit);
}
-QString DiveObjectHelper::weightList() const
+static QString formatWeightList(const dive *d)
{
QString weights;
- for (int i = 0; i < m_dive->weightsystems.nr; i++) {
- QString w = getFormattedWeight(m_dive, i);
+ for (int i = 0; i < d->weightsystems.nr; i++) {
+ QString w = getFormattedWeight(d, i);
if (w.isEmpty())
continue;
weights += w + "; ";
@@ -232,11 +132,11 @@ QString DiveObjectHelper::weightList() const
return weights;
}
-QStringList DiveObjectHelper::weights() const
+static QStringList formatWeights(const dive *d)
{
QStringList weights;
- for (int i = 0; i < m_dive->weightsystems.nr; i++) {
- QString w = getFormattedWeight(m_dive, i);
+ for (int i = 0; i < d->weightsystems.nr; i++) {
+ QString w = getFormattedWeight(d, i);
if (w.isEmpty())
continue;
weights << w;
@@ -244,47 +144,11 @@ QStringList DiveObjectHelper::weights() const
return weights;
}
-bool DiveObjectHelper::singleWeight() const
-{
- return m_dive->weightsystems.nr <= 1;
-}
-
-QString DiveObjectHelper::suit() const
-{
- return m_dive->suit ? m_dive->suit : QString();
-}
-
-QStringList DiveObjectHelper::cylinderList() const
-{
- 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.isEmpty())
- continue;
- cylinders << cyl;
- }
- }
-
- for (unsigned long 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;
-}
-
-QStringList DiveObjectHelper::cylinders() const
+static QStringList formatCylinders(const dive *d)
{
QStringList cylinders;
for (int i = 0; i < MAX_CYLINDERS; i++) {
- QString cyl = getFormattedCylinder(m_dive, i);
+ QString cyl = getFormattedCylinder(d, i);
if (cyl.isEmpty())
continue;
cylinders << cyl;
@@ -292,79 +156,135 @@ QStringList DiveObjectHelper::cylinders() const
return cylinders;
}
-QVector<CylinderObjectHelper> DiveObjectHelper::cylinderObjects() const
+static QVector<CylinderObjectHelper> makeCylinderObjects(const dive *d)
{
QVector<CylinderObjectHelper> res;
for (int i = 0; i < MAX_CYLINDERS; i++) {
//Don't add blank cylinders, only those that have been defined.
- if (m_dive->cylinder[i].type.description)
- res.append(CylinderObjectHelper(&m_dive->cylinder[i])); // no emplace for QVector. :(
+ if (d->cylinder[i].type.description)
+ res.append(CylinderObjectHelper(&d->cylinder[i])); // no emplace for QVector. :(
}
return res;
}
-int DiveObjectHelper::maxcns() const
-{
- return m_dive->maxcns;
-}
-
-int DiveObjectHelper::otu() const
-{
- return m_dive->otu;
-}
-
-int DiveObjectHelper::rating() const
-{
- return m_dive->rating;
-}
-
-int DiveObjectHelper::visibility() const
-{
- return m_dive->visibility;
-}
-
-QString DiveObjectHelper::sumWeight() const
-{
- weight_t sum = { total_weight(m_dive) };
- return get_weight_string(sum, true);
-}
-
-QStringList DiveObjectHelper::getCylinder() const
+static QStringList formatGetCylinder(const dive *d)
{
QStringList getCylinder;
for (int i = 0; i < MAX_CYLINDERS; i++) {
- if (is_cylinder_used(m_dive, i))
- getCylinder << m_dive->cylinder[i].type.description;
+ if (is_cylinder_used(d, i))
+ getCylinder << d->cylinder[i].type.description;
}
return getCylinder;
}
-QStringList DiveObjectHelper::startPressure() const
+static QStringList getStartPressure(const dive *d)
{
QStringList startPressure;
for (int i = 0; i < MAX_CYLINDERS; i++) {
- if (is_cylinder_used(m_dive, i))
- startPressure << getPressures(m_dive, i, START_PRESSURE);
+ if (is_cylinder_used(d, i))
+ startPressure << getPressures(d, i, START_PRESSURE);
}
return startPressure;
}
-QStringList DiveObjectHelper::endPressure() const
+static QStringList getEndPressure(const dive *d)
{
QStringList endPressure;
for (int i = 0; i < MAX_CYLINDERS; i++) {
- if (is_cylinder_used(m_dive, i))
- endPressure << getPressures(m_dive, i, END_PRESSURE);
+ if (is_cylinder_used(d, i))
+ endPressure << getPressures(d, i, END_PRESSURE);
}
return endPressure;
}
-QStringList DiveObjectHelper::firstGas() const
+static QStringList getFirstGas(const dive *d)
{
QStringList gas;
for (int i = 0; i < MAX_CYLINDERS; i++) {
- if (is_cylinder_used(m_dive, i))
- gas << get_gas_string(m_dive->cylinder[i].gasmix);
+ if (is_cylinder_used(d, i))
+ gas << get_gas_string(d->cylinder[i].gasmix);
}
return gas;
}
+
+// Qt's metatype system insists on generating a default constructed object, even if that makes no sense.
+DiveObjectHelper::DiveObjectHelper()
+{
+}
+
+DiveObjectHelper::DiveObjectHelper(const struct dive *d) :
+ number(d->number),
+ id(d->id),
+ rating(d->rating),
+ visibility(d->visibility),
+ timestamp(d->when),
+ location(get_dive_location(d) ? QString::fromUtf8(get_dive_location(d)) : QString()),
+ gps(d->dive_site ? printGPSCoords(&d->dive_site->location) : QString()),
+ gps_decimal(format_gps_decimal(d)),
+ dive_site(QVariant::fromValue(d->dive_site)),
+ duration(get_dive_duration_string(d->duration.seconds, gettextFromC::tr("h"), gettextFromC::tr("min"))),
+ noDive(d->duration.seconds == 0 && d->dc.duration.seconds == 0),
+ depth(get_depth_string(d->dc.maxdepth.mm, true, true)),
+ divemaster(d->divemaster ? d->divemaster : QString()),
+ buddy(d->buddy ? d->buddy : QString()),
+ airTemp(get_temperature_string(d->airtemp, true)),
+ waterTemp(get_temperature_string(d->watertemp, true)),
+ notes(formatNotes(d)),
+ tags(get_taglist_string(d->tag_list)),
+ gas(formatGas(d)),
+ sac(formatSac(d)),
+ weightList(formatWeightList(d)),
+ weights(formatWeights(d)),
+ singleWeight(d->weightsystems.nr <= 1),
+ suit(d->suit ? d->suit : QString()),
+ cylinders(formatCylinders(d)),
+ cylinderObjects(makeCylinderObjects(d)),
+ maxcns(d->maxcns),
+ otu(d->otu),
+ sumWeight(get_weight_string(weight_t { total_weight(d) }, true)),
+ getCylinder(formatGetCylinder(d)),
+ startPressure(getStartPressure(d)),
+ endPressure(getEndPressure(d)),
+ firstGas(getFirstGas(d))
+{
+}
+
+QString DiveObjectHelper::date() const
+{
+ QDateTime localTime = QDateTime::fromMSecsSinceEpoch(1000 * timestamp, Qt::UTC);
+ localTime.setTimeSpec(Qt::UTC);
+ return localTime.date().toString(prefs.date_format_short);
+}
+
+QString DiveObjectHelper::time() const
+{
+ QDateTime localTime = QDateTime::fromMSecsSinceEpoch(1000 * timestamp, Qt::UTC);
+ localTime.setTimeSpec(Qt::UTC);
+ return localTime.time().toString(prefs.time_format);
+}
+
+QStringList DiveObjectHelper::cylinderList() const
+{
+ 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;
+}
diff --git a/core/subsurface-qt/DiveObjectHelper.h b/core/subsurface-qt/DiveObjectHelper.h
index c5662433c..5e6b0c7e1 100644
--- a/core/subsurface-qt/DiveObjectHelper.h
+++ b/core/subsurface-qt/DiveObjectHelper.h
@@ -11,84 +11,81 @@
class DiveObjectHelper {
Q_GADGET
- Q_PROPERTY(int number READ number CONSTANT)
- Q_PROPERTY(int id READ id CONSTANT)
- Q_PROPERTY(int rating READ rating CONSTANT)
- Q_PROPERTY(int visibility READ visibility CONSTANT)
+ Q_PROPERTY(int number MEMBER number CONSTANT)
+ Q_PROPERTY(int id MEMBER id CONSTANT)
+ Q_PROPERTY(int rating MEMBER rating CONSTANT)
+ Q_PROPERTY(int visibility MEMBER visibility CONSTANT)
Q_PROPERTY(QString date READ date CONSTANT)
Q_PROPERTY(QString time READ time CONSTANT)
- Q_PROPERTY(int timestamp READ timestamp CONSTANT)
- Q_PROPERTY(QString location READ location CONSTANT)
- Q_PROPERTY(QString gps READ gps CONSTANT)
- Q_PROPERTY(QString gps_decimal READ gps_decimal CONSTANT)
- Q_PROPERTY(QVariant dive_site READ dive_site CONSTANT)
- Q_PROPERTY(QString duration READ duration CONSTANT)
- Q_PROPERTY(bool noDive READ noDive CONSTANT)
- Q_PROPERTY(QString depth READ depth CONSTANT)
- Q_PROPERTY(QString divemaster READ divemaster CONSTANT)
- Q_PROPERTY(QString buddy READ buddy CONSTANT)
- Q_PROPERTY(QString airTemp READ airTemp CONSTANT)
- Q_PROPERTY(QString waterTemp READ waterTemp CONSTANT)
- Q_PROPERTY(QString notes READ notes CONSTANT)
- Q_PROPERTY(QString tags READ tags CONSTANT)
- Q_PROPERTY(QString gas READ gas CONSTANT)
- Q_PROPERTY(QString sac READ sac CONSTANT)
- Q_PROPERTY(QString weightList READ weightList CONSTANT)
- Q_PROPERTY(QStringList weights READ weights CONSTANT)
- Q_PROPERTY(bool singleWeight READ singleWeight CONSTANT)
- Q_PROPERTY(QString suit READ suit CONSTANT)
+ Q_PROPERTY(int timestamp MEMBER timestamp CONSTANT)
+ Q_PROPERTY(QString location MEMBER location CONSTANT)
+ Q_PROPERTY(QString gps MEMBER gps CONSTANT)
+ Q_PROPERTY(QString gps_decimal MEMBER gps_decimal CONSTANT)
+ Q_PROPERTY(QVariant dive_site MEMBER dive_site CONSTANT)
+ Q_PROPERTY(QString duration MEMBER duration CONSTANT)
+ Q_PROPERTY(bool noDive MEMBER noDive CONSTANT)
+ Q_PROPERTY(QString depth MEMBER depth CONSTANT)
+ Q_PROPERTY(QString divemaster MEMBER divemaster CONSTANT)
+ Q_PROPERTY(QString buddy MEMBER buddy CONSTANT)
+ Q_PROPERTY(QString airTemp MEMBER airTemp CONSTANT)
+ Q_PROPERTY(QString waterTemp MEMBER waterTemp CONSTANT)
+ Q_PROPERTY(QString notes MEMBER notes CONSTANT)
+ Q_PROPERTY(QString tags MEMBER tags CONSTANT)
+ Q_PROPERTY(QString gas MEMBER gas CONSTANT)
+ Q_PROPERTY(QString sac MEMBER sac CONSTANT)
+ Q_PROPERTY(QString weightList MEMBER weightList CONSTANT)
+ Q_PROPERTY(QStringList weights MEMBER weights CONSTANT)
+ Q_PROPERTY(bool singleWeight MEMBER singleWeight CONSTANT)
+ Q_PROPERTY(QString suit MEMBER suit CONSTANT)
Q_PROPERTY(QStringList cylinderList READ cylinderList CONSTANT)
- Q_PROPERTY(QStringList cylinders READ cylinders CONSTANT)
- Q_PROPERTY(QVector<CylinderObjectHelper> cylinderObjects READ cylinderObjects CONSTANT)
- Q_PROPERTY(int maxcns READ maxcns CONSTANT)
- Q_PROPERTY(int otu READ otu CONSTANT)
- Q_PROPERTY(QString sumWeight READ sumWeight CONSTANT)
- Q_PROPERTY(QStringList getCylinder READ getCylinder CONSTANT)
- Q_PROPERTY(QStringList startPressure READ startPressure CONSTANT)
- Q_PROPERTY(QStringList endPressure READ endPressure CONSTANT)
- Q_PROPERTY(QStringList firstGas READ firstGas CONSTANT)
+ Q_PROPERTY(QStringList cylinders MEMBER cylinders CONSTANT)
+ Q_PROPERTY(QVector<CylinderObjectHelper> cylinderObjects MEMBER cylinderObjects CONSTANT)
+ Q_PROPERTY(int maxcns MEMBER maxcns CONSTANT)
+ Q_PROPERTY(int otu MEMBER otu CONSTANT)
+ Q_PROPERTY(QString sumWeight MEMBER sumWeight CONSTANT)
+ Q_PROPERTY(QStringList getCylinder MEMBER getCylinder CONSTANT)
+ Q_PROPERTY(QStringList startPressure MEMBER startPressure CONSTANT)
+ Q_PROPERTY(QStringList endPressure MEMBER endPressure CONSTANT)
+ Q_PROPERTY(QStringList firstGas MEMBER firstGas CONSTANT)
public:
DiveObjectHelper(); // This is only to be used by Qt's metatype system!
- DiveObjectHelper(struct dive *dive);
- int number() const;
- int id() const;
- int rating() const;
- int visibility() const;
+ DiveObjectHelper(const struct dive *dive);
+ int number;
+ int id;
+ int rating;
+ int visibility;
QString date() const;
- timestamp_t timestamp() const;
+ timestamp_t timestamp;
QString time() const;
- QString location() const;
- QString gps() const;
- QString gps_decimal() const;
- QVariant dive_site() const;
- QString duration() const;
- bool noDive() const;
- QString depth() const;
- QString divemaster() const;
- QString buddy() const;
- QString airTemp() const;
- QString waterTemp() const;
- QString notes() const;
- QString tags() const;
- QString gas() const;
- QString sac() const;
- QString weightList() const;
- QStringList weights() const;
- bool singleWeight() const;
- QString suit() const;
+ QString location;
+ QString gps;
+ QString gps_decimal;
+ QVariant dive_site;
+ QString duration;
+ bool noDive;
+ QString depth;
+ QString divemaster;
+ QString buddy;
+ QString airTemp;
+ QString waterTemp;
+ QString notes;
+ QString tags;
+ QString gas;
+ QString sac;
+ QString weightList;
+ QStringList weights;
+ bool singleWeight;
+ QString suit;
QStringList cylinderList() const;
- QStringList cylinders() const;
- QVector<CylinderObjectHelper> cylinderObjects() const;
- int maxcns() const;
- int otu() const;
- QString sumWeight() const;
- QStringList getCylinder() const;
- QStringList startPressure() const;
- QStringList endPressure() const;
- QStringList firstGas() const;
-
-private:
- struct dive *m_dive;
+ QStringList cylinders;
+ QVector<CylinderObjectHelper> cylinderObjects;
+ int maxcns;
+ int otu;
+ QString sumWeight;
+ QStringList getCylinder;
+ QStringList startPressure;
+ QStringList endPressure;
+ QStringList firstGas;
};
Q_DECLARE_METATYPE(DiveObjectHelper)
diff --git a/desktop-widgets/templatelayout.h b/desktop-widgets/templatelayout.h
index aea44b2b8..870cd702a 100644
--- a/desktop-widgets/templatelayout.h
+++ b/desktop-widgets/templatelayout.h
@@ -145,77 +145,77 @@ GRANTLEE_END_LOOKUP
// exists. Remove in due course.
GRANTLEE_BEGIN_LOOKUP(DiveObjectHelper)
if (property == "number") {
- return object.number();
+ return object.number;
} else if (property == "id") {
- return object.id();
+ return object.id;
} else if (property == "rating") {
- return object.rating();
+ return object.rating;
} else if (property == "visibility") {
- return object.visibility();
+ return object.visibility;
} else if (property == "date") {
return object.date();
} else if (property == "time") {
return object.time();
} else if (property == "timestamp") {
- return QVariant::fromValue(object.timestamp());
+ return QVariant::fromValue(object.timestamp);
} else if (property == "location") {
- return object.location();
+ return object.location;
} else if (property == "gps") {
- return object.gps();
+ return object.gps;
} else if (property == "gps_decimal") {
- return object.gps_decimal();
+ return object.gps_decimal;
} else if (property == "dive_site") {
- return object.dive_site();
+ return object.dive_site;
} else if (property == "duration") {
- return object.duration();
+ return object.duration;
} else if (property == "noDive") {
- return object.noDive();
+ return object.noDive;
} else if (property == "depth") {
- return object.depth();
+ return object.depth;
} else if (property == "divemaster") {
- return object.divemaster();
+ return object.divemaster;
} else if (property == "buddy") {
- return object.buddy();
+ return object.buddy;
} else if (property == "airTemp") {
- return object.airTemp();
+ return object.airTemp;
} else if (property == "waterTemp") {
- return object.waterTemp();
+ return object.waterTemp;
} else if (property == "notes") {
- return object.notes();
+ return object.notes;
} else if (property == "tags") {
- return object.tags();
+ return object.tags;
} else if (property == "gas") {
- return object.gas();
+ return object.gas;
} else if (property == "sac") {
- return object.sac();
+ return object.sac;
} else if (property == "weightList") {
- return object.weightList();
+ return object.weightList;
} else if (property == "weights") {
- return object.weights();
+ return object.weights;
} else if (property == "singleWeight") {
- return object.singleWeight();
+ return object.singleWeight;
} else if (property == "suit") {
- return object.suit();
+ return object.suit;
} else if (property == "cylinderList") {
return object.cylinderList();
} else if (property == "cylinders") {
- return object.cylinders();
+ return object.cylinders;
} else if (property == "cylinderObjects") {
- return QVariant::fromValue(object.cylinderObjects());
+ return QVariant::fromValue(object.cylinderObjects);
} else if (property == "maxcns") {
- return object.maxcns();
+ return object.maxcns;
} else if (property == "otu") {
- return object.otu();
+ return object.otu;
} else if (property == "sumWeight") {
- return object.sumWeight();
+ return object.sumWeight;
} else if (property == "getCylinder") {
- return object.getCylinder();
+ return object.getCylinder;
} else if (property == "startPressure") {
- return object.startPressure();
+ return object.startPressure;
} else if (property == "endPressure") {
- return object.endPressure();
+ return object.endPressure;
} else if (property == "firstGas") {
- return object.firstGas();
+ return object.firstGas;
}
GRANTLEE_END_LOOKUP
#endif
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 369c6d14d..4978db02f 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -954,8 +954,8 @@ bool QMLManager::checkLocation(const DiveObjectHelper &myDive, struct dive *d, Q
{
bool diveChanged = false;
struct dive_site *ds = get_dive_site_for_dive(d);
- qDebug() << "checkLocation" << location << "gps" << gps << "dive had" << myDive.location() << "gps" << myDive.gas();
- if (myDive.location() != location) {
+ qDebug() << "checkLocation" << location << "gps" << gps << "dive had" << myDive.location << "gps" << myDive.gas;
+ if (myDive.location != location) {
diveChanged = true;
ds = get_dive_site_by_name(qPrintable(location), &dive_site_table);
if (!ds && !location.isEmpty())
@@ -968,12 +968,12 @@ bool QMLManager::checkLocation(const DiveObjectHelper &myDive, struct dive *d, Q
// now make sure that the GPS coordinates match - if the user changed the name but not
// the GPS coordinates, this still does the right thing as the now new dive site will
// have no coordinates, so the coordinates from the edit screen will get added
- if (myDive.gps() != gps) {
+ if (myDive.gps != gps) {
double lat, lon;
if (parseGpsText(gps, &lat, &lon)) {
qDebug() << "parsed GPS, using it";
// there are valid GPS coordinates - just use them
- setupDivesite(d, ds, lat, lon, qPrintable(myDive.location()));
+ setupDivesite(d, ds, lat, lon, qPrintable(myDive.location));
diveChanged = true;
} else if (gps == GPS_CURRENT_POS) {
qDebug() << "gps was our default text for no GPS";
@@ -982,7 +982,7 @@ bool QMLManager::checkLocation(const DiveObjectHelper &myDive, struct dive *d, Q
if (gpsString != GPS_CURRENT_POS) {
qDebug() << "but now I got a valid location" << gpsString;
if (parseGpsText(qPrintable(gpsString), &lat, &lon)) {
- setupDivesite(d, ds, lat, lon, qPrintable(myDive.location()));
+ setupDivesite(d, ds, lat, lon, qPrintable(myDive.location));
diveChanged = true;
}
} else {
@@ -998,7 +998,7 @@ bool QMLManager::checkLocation(const DiveObjectHelper &myDive, struct dive *d, Q
bool QMLManager::checkDuration(const DiveObjectHelper &myDive, struct dive *d, QString duration)
{
- if (myDive.duration() != duration) {
+ if (myDive.duration != duration) {
int h = 0, m = 0, s = 0;
QRegExp r1(QStringLiteral("(\\d*)\\s*%1[\\s,:]*(\\d*)\\s*%2[\\s,:]*(\\d*)\\s*%3").arg(tr("h")).arg(tr("min")).arg(tr("sec")), Qt::CaseInsensitive);
QRegExp r2(QStringLiteral("(\\d*)\\s*%1[\\s,:]*(\\d*)\\s*%2").arg(tr("h")).arg(tr("min")), Qt::CaseInsensitive);
@@ -1037,7 +1037,7 @@ bool QMLManager::checkDuration(const DiveObjectHelper &myDive, struct dive *d, Q
bool QMLManager::checkDepth(const DiveObjectHelper &myDive, dive *d, QString depth)
{
- if (myDive.depth() != depth) {
+ if (myDive.depth != depth) {
int depthValue = parseLengthToMm(depth);
// the QML code should stop negative depth, but massively huge depth can make
// the profile extremely slow or even run out of memory and crash, so keep
@@ -1084,15 +1084,15 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q
diveChanged |= checkDepth(myDive, d, depth);
- if (myDive.airTemp() != airtemp) {
+ if (myDive.airTemp != airtemp) {
diveChanged = true;
d->airtemp.mkelvin = parseTemperatureToMkelvin(airtemp);
}
- if (myDive.waterTemp() != watertemp) {
+ if (myDive.waterTemp != watertemp) {
diveChanged = true;
d->watertemp.mkelvin = parseTemperatureToMkelvin(watertemp);
}
- if (myDive.sumWeight() != weight) {
+ if (myDive.sumWeight != weight) {
diveChanged = true;
// not sure what we'd do if there was more than one weight system
// defined - for now just ignore that case
@@ -1104,7 +1104,7 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q
}
}
// start and end pressures for first cylinder only
- if (myDive.startPressure() != startpressure || myDive.endPressure() != endpressure) {
+ if (myDive.startPressure != startpressure || myDive.endPressure != endpressure) {
diveChanged = true;
for ( int i = 0, j = 0 ; j < startpressure.length() && j < endpressure.length() ; i++ ) {
if (state != "add" && !is_cylinder_used(d, i))
@@ -1119,7 +1119,7 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q
}
}
// gasmix for first cylinder
- if (myDive.firstGas() != gasmix) {
+ if (myDive.firstGas != gasmix) {
for ( int i = 0, j = 0 ; j < gasmix.length() ; i++ ) {
if (state != "add" && !is_cylinder_used(d, i))
continue;
@@ -1138,7 +1138,7 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q
}
}
// info for first cylinder
- if (myDive.getCylinder() != usedCylinder) {
+ if (myDive.getCylinder != usedCylinder) {
diveChanged = true;
unsigned long i;
int size = 0, wp = 0, j = 0, k = 0;
@@ -1164,12 +1164,12 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q
k++;
}
}
- if (myDive.suit() != suit) {
+ if (myDive.suit != suit) {
diveChanged = true;
free(d->suit);
d->suit = copy_qstring(suit);
}
- if (myDive.buddy() != buddy) {
+ if (myDive.buddy != buddy) {
if (buddy.contains(",")){
buddy = buddy.replace(QRegExp("\\s*,\\s*"), ", ");
}
@@ -1177,7 +1177,7 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q
free(d->buddy);
d->buddy = copy_qstring(buddy);
}
- if (myDive.divemaster() != diveMaster) {
+ if (myDive.divemaster != diveMaster) {
if (diveMaster.contains(",")){
diveMaster = diveMaster.replace(QRegExp("\\s*,\\s*"), ", ");
}
@@ -1185,15 +1185,15 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q
free(d->divemaster);
d->divemaster = copy_qstring(diveMaster);
}
- if (myDive.rating() != rating) {
+ if (myDive.rating != rating) {
diveChanged = true;
d->rating = rating;
}
- if (myDive.visibility() != visibility) {
+ if (myDive.visibility != visibility) {
diveChanged = true;
d->visibility = visibility;
}
- if (myDive.notes() != notes) {
+ if (myDive.notes != notes) {
diveChanged = true;
free(d->notes);
d->notes = copy_qstring(notes);