Some simplifications that I realized where simple to do and didn't introduced any regressions.
I'm also thinking of using this class instead of struct dive* directly on the C++ side, but it's not ready for that yet. It's ready to substitute the struct dive* on the DiveTripModel, and when I do that we will kill the DiveListModel since they are redundant. Tomaz
From e7f878777e9b3f04ee992999303ac9a27d959019 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 11 Jan 2016 16:48:46 -0200 Subject: [PATCH 18/18] Simplify: remove weigths and cylinders. This finishes the first round of Simplication patches for the QML basecode. The second one will be about the preferences. Signed-off-by: Tomaz Canabrava <[email protected]> --- subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 23 +++++++++++----------- subsurface-core/subsurface-qt/DiveObjectHelper.h | 2 -- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp index e9d72f1..e26e542 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp @@ -36,11 +36,6 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx) DiveObjectHelper::DiveObjectHelper(struct dive *d) : m_dive(d) { - for (int i = 0; i < MAX_CYLINDERS; i++) - m_cylinders << getFormattedCylinder(d, i); - - for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) - m_weights << getFormattedWeight(d, i); } DiveObjectHelper::~DiveObjectHelper() @@ -186,14 +181,17 @@ QString DiveObjectHelper::sac() const QStringList DiveObjectHelper::weights() const { -return m_weights; + QStringList weights; + for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) + weights << getFormattedWeight(m_dive, i); + return weights; } QString DiveObjectHelper::weight(int idx) const { - if (idx < 0 || idx > m_weights.size() - 1) + if ( (idx < 0) || idx > MAX_WEIGHTSYSTEMS ) return QString(EMPTY_DIVE_STRING); - return m_weights.at(idx); + return getFormattedWeight(m_dive, idx); } QString DiveObjectHelper::suit() const @@ -203,14 +201,17 @@ QString DiveObjectHelper::suit() const QStringList DiveObjectHelper::cylinders() const { - return m_cylinders; + QStringList cylinders; + for (int i = 0; i < MAX_CYLINDERS; i++) + cylinders << getFormattedCylinder(m_dive, i); + return cylinders; } QString DiveObjectHelper::cylinder(int idx) const { - if (idx < 0 || idx > m_cylinders.size() - 1) + if ( (idx < 0) || idx > MAX_CYLINDERS) return QString(EMPTY_DIVE_STRING); - return m_cylinders.at(idx); + return getFormattedCylinder(m_dive, idx); } QString DiveObjectHelper::trip() const diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.h b/subsurface-core/subsurface-qt/DiveObjectHelper.h index cab435e..d366794 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.h +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.h @@ -61,8 +61,6 @@ public: QString maxcns() const; QString otu() const; private: - QStringList m_weights; - QStringList m_cylinders; struct dive *m_dive; }; -- 2.7.0
From ec0428b0f62599fcf722d1f6296e577fb7866886 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 11 Jan 2016 16:40:10 -0200 Subject: [PATCH 17/18] Simplify: return date and time directly Signed-off-by: Tomaz Canabrava <[email protected]> --- subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 13 ++++++------- subsurface-core/subsurface-qt/DiveObjectHelper.h | 2 -- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp index 80eef1a..e9d72f1 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp @@ -41,11 +41,6 @@ DiveObjectHelper::DiveObjectHelper(struct dive *d) : for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) m_weights << getFormattedWeight(d, i); - - QDateTime localTime = QDateTime::fromTime_t(d->when - gettimezoneoffset(d->when)); - localTime.setTimeSpec(Qt::UTC); - m_date = localTime.date().toString(prefs.date_format); - m_time = localTime.time().toString(prefs.time_format); } DiveObjectHelper::~DiveObjectHelper() @@ -64,7 +59,9 @@ int DiveObjectHelper::id() const QString DiveObjectHelper::date() const { - return m_date; + QDateTime localTime = QDateTime::fromTime_t(m_dive->when - gettimezoneoffset(m_dive->when)); + localTime.setTimeSpec(Qt::UTC); + return localTime.date().toString(prefs.date_format); } timestamp_t DiveObjectHelper::timestamp() const @@ -74,7 +71,9 @@ timestamp_t DiveObjectHelper::timestamp() const QString DiveObjectHelper::time() const { - return m_time; + QDateTime localTime = QDateTime::fromTime_t(m_dive->when - gettimezoneoffset(m_dive->when)); + localTime.setTimeSpec(Qt::UTC); + return localTime.time().toString(prefs.time_format); } QString DiveObjectHelper::location() const diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.h b/subsurface-core/subsurface-qt/DiveObjectHelper.h index 4fc1ca5..cab435e 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.h +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.h @@ -61,8 +61,6 @@ public: QString maxcns() const; QString otu() const; private: - QString m_date; - QString m_time; QStringList m_weights; QStringList m_cylinders; struct dive *m_dive; -- 2.7.0
From a0eeeba4aefcd1682e9c792b77190d203d4058bb Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 11 Jan 2016 16:37:10 -0200 Subject: [PATCH 16/18] Simplify: remove the gas variable Signed-off-by: Tomaz Canabrava <[email protected]> --- subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 37 +++++++++++----------- subsurface-core/subsurface-qt/DiveObjectHelper.h | 1 - 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp index 8f53ea3..80eef1a 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp @@ -36,23 +36,6 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx) DiveObjectHelper::DiveObjectHelper(struct dive *d) : m_dive(d) { - int added = 0; - QString gas, gases; - for (int i = 0; i < MAX_CYLINDERS; i++) { - if (!is_cylinder_used(d, i)) - continue; - gas = d->cylinder[i].type.description; - gas += QString(!gas.isEmpty() ? " " : "") + 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 (added > 0) - gases += QString(" / "); - gases += gas; - added++; - } - } - m_gas = gases; - for (int i = 0; i < MAX_CYLINDERS; i++) m_cylinders << getFormattedCylinder(d, i); @@ -171,7 +154,25 @@ QString DiveObjectHelper::tags() const QString DiveObjectHelper::gas() const { - return m_gas; + /*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)) + continue; + gas = m_dive->cylinder[i].type.description; + if (!gas.isEmpty()) + gas += QChar(' '); + gas += gasname(&m_dive->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()) + gases += QString(" / "); + gases += gas; + } + } + return gases; } QString DiveObjectHelper::sac() const diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.h b/subsurface-core/subsurface-qt/DiveObjectHelper.h index faba9db..4fc1ca5 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.h +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.h @@ -63,7 +63,6 @@ public: private: QString m_date; QString m_time; - QString m_gas; QStringList m_weights; QStringList m_cylinders; struct dive *m_dive; -- 2.7.0
From 5d7d08511c220b7b15cd672a10ac8b9f4c127e8e Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 11 Jan 2016 16:29:49 -0200 Subject: [PATCH 15/18] Simplify: remove variable tags Signed-off-by: Tomaz Canabrava <[email protected]> --- subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 9 +++------ subsurface-core/subsurface-qt/DiveObjectHelper.h | 1 - 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp index 57dc6f9..8f53ea3 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp @@ -36,11 +36,6 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx) DiveObjectHelper::DiveObjectHelper(struct dive *d) : m_dive(d) { - char buffer[256]; - taglist_get_tagstring(d->tag_list, buffer, 256); - m_tags = QString(buffer); - - int added = 0; QString gas, gases; for (int i = 0; i < MAX_CYLINDERS; i++) { @@ -169,7 +164,9 @@ QString DiveObjectHelper::notes() const QString DiveObjectHelper::tags() const { - return m_tags; + static char buffer[256]; + taglist_get_tagstring(m_dive->tag_list, buffer, 256); + return QString(buffer); } QString DiveObjectHelper::gas() const diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.h b/subsurface-core/subsurface-qt/DiveObjectHelper.h index f2a0014..faba9db 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.h +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.h @@ -63,7 +63,6 @@ public: private: QString m_date; QString m_time; - QString m_tags; QString m_gas; QStringList m_weights; QStringList m_cylinders; -- 2.7.0
From 0aeba8beea97fc300b37d475146f2ca25fd34c8d Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 11 Jan 2016 16:16:48 -0200 Subject: [PATCH 14/18] Simplify: remove SAC variable Signed-off-by: Tomaz Canabrava <[email protected]> --- subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 14 ++++++-------- subsurface-core/subsurface-qt/DiveObjectHelper.h | 1 - 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp index b8ec050..57dc6f9 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp @@ -58,13 +58,6 @@ DiveObjectHelper::DiveObjectHelper(struct dive *d) : } m_gas = gases; - if (d->sac) { - const char *unit; - int decimal; - double value = get_volume_units(d->sac, &decimal, &unit); - m_sac = QString::number(value, 'f', decimal).append(unit); - } - for (int i = 0; i < MAX_CYLINDERS; i++) m_cylinders << getFormattedCylinder(d, i); @@ -186,7 +179,12 @@ QString DiveObjectHelper::gas() const QString DiveObjectHelper::sac() const { - return m_sac; + if (!m_dive->sac) + return QString(); + const char *unit; + int decimal; + double value = get_volume_units(m_dive->sac, &decimal, &unit); + QString::number(value, 'f', decimal).append(unit); } QStringList DiveObjectHelper::weights() const diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.h b/subsurface-core/subsurface-qt/DiveObjectHelper.h index c2a1bda..f2a0014 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.h +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.h @@ -65,7 +65,6 @@ private: QString m_time; QString m_tags; QString m_gas; - QString m_sac; QStringList m_weights; QStringList m_cylinders; struct dive *m_dive; -- 2.7.0
From c040139cbc94e2a3c0194cacc8ae49a7077cc7a6 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 11 Jan 2016 16:13:23 -0200 Subject: [PATCH 13/18] Simplify: remove gps variable And also use existing helper function to get the GPS string Signed-off-by: Tomaz Canabrava <[email protected]> --- subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 7 ++----- subsurface-core/subsurface-qt/DiveObjectHelper.h | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp index c06f654..b8ec050 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp @@ -36,10 +36,6 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx) DiveObjectHelper::DiveObjectHelper(struct dive *d) : m_dive(d) { - struct dive_site *ds = get_dive_site_by_uuid(d->dive_site_uuid); - if (ds) - m_gps = QString("%1,%2").arg(ds->latitude.udeg / 1000000.0).arg(ds->longitude.udeg / 1000000.0); - char buffer[256]; taglist_get_tagstring(d->tag_list, buffer, 256); m_tags = QString(buffer); @@ -117,7 +113,8 @@ QString DiveObjectHelper::location() const QString DiveObjectHelper::gps() const { - return m_gps; + struct dive_site *ds = get_dive_site_by_uuid(m_dive->dive_site_uuid); + return ds ? QString(printGPSCoords(ds->latitude.udeg, ds->longitude.udeg)) : QString(); } QString DiveObjectHelper::duration() const { diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.h b/subsurface-core/subsurface-qt/DiveObjectHelper.h index 79417c1..c2a1bda 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.h +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.h @@ -63,7 +63,6 @@ public: private: QString m_date; QString m_time; - QString m_gps; QString m_tags; QString m_gas; QString m_sac; -- 2.7.0
From cc0786d2bb03e87812b406e3d7a2c6bf4a86a955 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 11 Jan 2016 16:04:46 -0200 Subject: [PATCH 12/18] Simplify: remove m_notes variable I didn't understood the logic of the define & replace, so maybe we want a few comments there. Signed-off-by: Tomaz Canabrava <[email protected]> --- subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 37 ++++++++++------------ subsurface-core/subsurface-qt/DiveObjectHelper.h | 1 - 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp index 4e4dcc1..c06f654 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp @@ -40,26 +40,6 @@ DiveObjectHelper::DiveObjectHelper(struct dive *d) : if (ds) m_gps = QString("%1,%2").arg(ds->latitude.udeg / 1000000.0).arg(ds->longitude.udeg / 1000000.0); - m_notes = QString::fromUtf8(d->notes); - if (m_notes.isEmpty()) - m_notes = EMPTY_DIVE_STRING; - if (same_string(d->dc.model, "planned dive")) { - QTextDocument notes; - QString notesFormatted = m_notes; - #define _NOTES_BR "\n" - notesFormatted = notesFormatted.replace("<thead>", "<thead>" _NOTES_BR); - notesFormatted = notesFormatted.replace("<br>", "<br>" _NOTES_BR); - notesFormatted = notesFormatted.replace("<tr>", "<tr>" _NOTES_BR); - notesFormatted = notesFormatted.replace("</tr>", "</tr>" _NOTES_BR); - notes.setHtml(notesFormatted); - m_notes = notes.toPlainText(); - m_notes.replace(_NOTES_BR, "<br>"); - #undef _NOTES_BR - } else { - m_notes.replace("\n", "<br>"); - } - - char buffer[256]; taglist_get_tagstring(d->tag_list, buffer, 256); m_tags = QString(buffer); @@ -179,7 +159,22 @@ QString DiveObjectHelper::waterTemp() const QString DiveObjectHelper::notes() const { - return m_notes; + QString tmp = m_dive->notes ? QString::fromUtf8(m_dive->notes) : EMPTY_DIVE_STRING; + if (same_string(m_dive->dc.model, "planned dive")) { + QTextDocument notes; + #define _NOTES_BR "\n" + tmp.replace("<thead>", "<thead>" _NOTES_BR) + .replace("<br>", "<br>" _NOTES_BR) + .replace("<tr>", "<tr>" _NOTES_BR) + .replace("</tr>", "</tr>" _NOTES_BR); + notes.setHtml(tmp); + tmp = notes.toPlainText(); + tmp.replace(_NOTES_BR, "<br>"); + #undef _NOTES_BR + } else { + tmp.replace("\n", "<br>"); + } + return tmp; } QString DiveObjectHelper::tags() const diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.h b/subsurface-core/subsurface-qt/DiveObjectHelper.h index 712858b..79417c1 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.h +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.h @@ -64,7 +64,6 @@ private: QString m_date; QString m_time; QString m_gps; - QString m_notes; QString m_tags; QString m_gas; QString m_sac; -- 2.7.0
From 64523526581c79e0af903e5db725e98ec79926ed Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 11 Jan 2016 15:56:50 -0200 Subject: [PATCH 11/18] Simplidy: remove Maxcns and OTU variables Signed-off-by: Tomaz Canabrava <[email protected]> --- subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 6 ++---- subsurface-core/subsurface-qt/DiveObjectHelper.h | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp index 8625329..4e4dcc1 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp @@ -34,8 +34,6 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx) } DiveObjectHelper::DiveObjectHelper(struct dive *d) : - m_maxcns(d->maxcns), - m_otu(d->otu), m_dive(d) { struct dive_site *ds = get_dive_site_by_uuid(d->dive_site_uuid); @@ -235,12 +233,12 @@ QString DiveObjectHelper::trip() const QString DiveObjectHelper::maxcns() const { - return m_maxcns; + return QString(m_dive->maxcns); } QString DiveObjectHelper::otu() const { - return m_otu; + return QString(m_dive->otu); } int DiveObjectHelper::rating() const diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.h b/subsurface-core/subsurface-qt/DiveObjectHelper.h index 797a9d4..712858b 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.h +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.h @@ -70,8 +70,6 @@ private: QString m_sac; QStringList m_weights; QStringList m_cylinders; - QString m_maxcns; - QString m_otu; struct dive *m_dive; }; -- 2.7.0
From 87cf3f806ebb8d88bd398a1df01f2c967444761e Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 11 Jan 2016 15:49:06 -0200 Subject: [PATCH 10/18] Simplify: removed suit and trip Signed-off-by: Tomaz Canabrava <[email protected]> --- subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 6 ++---- subsurface-core/subsurface-qt/DiveObjectHelper.h | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp index 1d50b27..8625329 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp @@ -34,8 +34,6 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx) } DiveObjectHelper::DiveObjectHelper(struct dive *d) : - m_suit(d->suit ? d->suit : EMPTY_DIVE_STRING), - m_trip(d->divetrip ? d->divetrip->location : EMPTY_DIVE_STRING), m_maxcns(d->maxcns), m_otu(d->otu), m_dive(d) @@ -215,7 +213,7 @@ QString DiveObjectHelper::weight(int idx) const QString DiveObjectHelper::suit() const { - return m_suit; + return m_dive->suit ? m_dive->suit : EMPTY_DIVE_STRING; } QStringList DiveObjectHelper::cylinders() const @@ -232,7 +230,7 @@ QString DiveObjectHelper::cylinder(int idx) const QString DiveObjectHelper::trip() const { - return m_trip; + return m_dive->divetrip ? m_dive->divetrip->location : EMPTY_DIVE_STRING; } QString DiveObjectHelper::maxcns() const diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.h b/subsurface-core/subsurface-qt/DiveObjectHelper.h index 0418f19..797a9d4 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.h +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.h @@ -69,9 +69,7 @@ private: QString m_gas; QString m_sac; QStringList m_weights; - QString m_suit; QStringList m_cylinders; - QString m_trip; QString m_maxcns; QString m_otu; struct dive *m_dive; -- 2.7.0
From df552823cff065399b7956d1460fba1ceabbfe3b Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 11 Jan 2016 15:46:30 -0200 Subject: [PATCH 09/18] removed waterTemp variable Signed-off-by: Tomaz Canabrava <[email protected]> --- subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 11 +++++------ subsurface-core/subsurface-qt/DiveObjectHelper.h | 1 - 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp index 2471596..1d50b27 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp @@ -34,7 +34,6 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx) } DiveObjectHelper::DiveObjectHelper(struct dive *d) : - m_waterTemp(get_temperature_string(d->watertemp, true)), m_suit(d->suit ? d->suit : EMPTY_DIVE_STRING), m_trip(d->divetrip ? d->divetrip->location : EMPTY_DIVE_STRING), m_maxcns(d->maxcns), @@ -45,10 +44,6 @@ DiveObjectHelper::DiveObjectHelper(struct dive *d) : if (ds) m_gps = QString("%1,%2").arg(ds->latitude.udeg / 1000000.0).arg(ds->longitude.udeg / 1000000.0); - if (m_waterTemp.isEmpty()) { - m_waterTemp = EMPTY_DIVE_STRING; - } - m_notes = QString::fromUtf8(d->notes); if (m_notes.isEmpty()) m_notes = EMPTY_DIVE_STRING; @@ -179,7 +174,11 @@ QString DiveObjectHelper::airTemp() const QString DiveObjectHelper::waterTemp() const { - return m_waterTemp; + QString temp = get_temperature_string(m_dive->watertemp, true); + if (temp.isEmpty()) { + temp = EMPTY_DIVE_STRING; + } + return temp; } QString DiveObjectHelper::notes() const diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.h b/subsurface-core/subsurface-qt/DiveObjectHelper.h index a6d9ea9..0418f19 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.h +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.h @@ -64,7 +64,6 @@ private: QString m_date; QString m_time; QString m_gps; - QString m_waterTemp; QString m_notes; QString m_tags; QString m_gas; -- 2.7.0
From 1eba730ea2c3b6035638b7cba2530d2122bc9cd9 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 11 Jan 2016 15:40:10 -0200 Subject: [PATCH 08/18] Simplify: removed buddy and airTemp variable also fixed a bug on the depth Signed-off-by: Tomaz Canabrava <[email protected]> --- subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 15 +++++++-------- subsurface-core/subsurface-qt/DiveObjectHelper.h | 2 -- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp index f3c06d2..2471596 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp @@ -34,8 +34,6 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx) } DiveObjectHelper::DiveObjectHelper(struct dive *d) : - m_buddy(d->buddy ? d->buddy : EMPTY_DIVE_STRING), - m_airTemp(get_temperature_string(d->airtemp, true)), m_waterTemp(get_temperature_string(d->watertemp, true)), m_suit(d->suit ? d->suit : EMPTY_DIVE_STRING), m_trip(d->divetrip ? d->divetrip->location : EMPTY_DIVE_STRING), @@ -47,9 +45,6 @@ DiveObjectHelper::DiveObjectHelper(struct dive *d) : if (ds) m_gps = QString("%1,%2").arg(ds->latitude.udeg / 1000000.0).arg(ds->longitude.udeg / 1000000.0); - if (m_airTemp.isEmpty()) { - m_airTemp = EMPTY_DIVE_STRING; - } if (m_waterTemp.isEmpty()) { m_waterTemp = EMPTY_DIVE_STRING; } @@ -160,7 +155,7 @@ QString DiveObjectHelper::duration() const QString DiveObjectHelper::depth() const { - return get_depth_string(d->dc.maxdepth.mm, true, true); + return get_depth_string(m_dive->dc.maxdepth.mm, true, true); } QString DiveObjectHelper::divemaster() const @@ -170,12 +165,16 @@ QString DiveObjectHelper::divemaster() const QString DiveObjectHelper::buddy() const { - return m_buddy; + return m_dive->buddy ? m_dive->buddy : EMPTY_DIVE_STRING; } QString DiveObjectHelper::airTemp() const { - return m_airTemp; + QString temp = get_temperature_string(m_dive->airtemp, true); + if (temp.isEmpty()) { + temp = EMPTY_DIVE_STRING; + } + return temp; } QString DiveObjectHelper::waterTemp() const diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.h b/subsurface-core/subsurface-qt/DiveObjectHelper.h index 324376c..a6d9ea9 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.h +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.h @@ -64,8 +64,6 @@ private: QString m_date; QString m_time; QString m_gps; - QString m_buddy; - QString m_airTemp; QString m_waterTemp; QString m_notes; QString m_tags; -- 2.7.0
From ed2ea1f0fe7046f7ed37a69e141fe4dd2e5b7beb Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 11 Jan 2016 15:39:04 -0200 Subject: [PATCH 07/18] Simplify: removed divemaster Signed-off-by: Tomaz Canabrava <[email protected]> --- subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 3 +-- subsurface-core/subsurface-qt/DiveObjectHelper.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp index 0174721..f3c06d2 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp @@ -34,7 +34,6 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx) } DiveObjectHelper::DiveObjectHelper(struct dive *d) : - m_divemaster(d->divemaster ? d->divemaster : EMPTY_DIVE_STRING), m_buddy(d->buddy ? d->buddy : EMPTY_DIVE_STRING), m_airTemp(get_temperature_string(d->airtemp, true)), m_waterTemp(get_temperature_string(d->watertemp, true)), @@ -166,7 +165,7 @@ QString DiveObjectHelper::depth() const QString DiveObjectHelper::divemaster() const { - return m_divemaster; + return m_dive->divemaster ? m_dive->divemaster : EMPTY_DIVE_STRING; } QString DiveObjectHelper::buddy() const diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.h b/subsurface-core/subsurface-qt/DiveObjectHelper.h index f2c62be..324376c 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.h +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.h @@ -64,7 +64,6 @@ private: QString m_date; QString m_time; QString m_gps; - QString m_divemaster; QString m_buddy; QString m_airTemp; QString m_waterTemp; -- 2.7.0
From 315a89f450152226696307f96b369de5ac825243 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 11 Jan 2016 15:36:12 -0200 Subject: [PATCH 06/18] Simplify: removed duration and depth variables Signed-off-by: Tomaz Canabrava <[email protected]> --- subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 6 ++---- subsurface-core/subsurface-qt/DiveObjectHelper.h | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp index ef02bf2..0174721 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp @@ -34,8 +34,6 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx) } DiveObjectHelper::DiveObjectHelper(struct dive *d) : - m_duration(get_dive_duration_string(d->duration.seconds, QObject::tr("h:"), QObject::tr("min"))), - m_depth(get_depth_string(d->dc.maxdepth.mm, true, true)), m_divemaster(d->divemaster ? d->divemaster : EMPTY_DIVE_STRING), m_buddy(d->buddy ? d->buddy : EMPTY_DIVE_STRING), m_airTemp(get_temperature_string(d->airtemp, true)), @@ -158,12 +156,12 @@ QString DiveObjectHelper::gps() const } QString DiveObjectHelper::duration() const { - return m_duration; + return get_dive_duration_string(m_dive->duration.seconds, QObject::tr("h:"), QObject::tr("min")); } QString DiveObjectHelper::depth() const { - return m_depth; + return get_depth_string(d->dc.maxdepth.mm, true, true); } QString DiveObjectHelper::divemaster() const diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.h b/subsurface-core/subsurface-qt/DiveObjectHelper.h index a92be36..f2c62be 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.h +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.h @@ -64,8 +64,6 @@ private: QString m_date; QString m_time; QString m_gps; - QString m_duration; - QString m_depth; QString m_divemaster; QString m_buddy; QString m_airTemp; -- 2.7.0
From 3fedb5fafded4150d9ab323bf328b88c577fc2ec Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 11 Jan 2016 15:35:21 -0200 Subject: [PATCH 05/18] Simplify: removed location variable Signed-off-by: Tomaz Canabrava <[email protected]> --- subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 3 +-- subsurface-core/subsurface-qt/DiveObjectHelper.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp index 313910d..ef02bf2 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp @@ -34,7 +34,6 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx) } DiveObjectHelper::DiveObjectHelper(struct dive *d) : - m_location(get_dive_location(d) ? QString::fromUtf8(get_dive_location(d)) : EMPTY_DIVE_STRING), m_duration(get_dive_duration_string(d->duration.seconds, QObject::tr("h:"), QObject::tr("min"))), m_depth(get_depth_string(d->dc.maxdepth.mm, true, true)), m_divemaster(d->divemaster ? d->divemaster : EMPTY_DIVE_STRING), @@ -150,7 +149,7 @@ QString DiveObjectHelper::time() const QString DiveObjectHelper::location() const { - return m_location; + return get_dive_location(m_dive) ? QString::fromUtf8(get_dive_location(m_dive)) : EMPTY_DIVE_STRING; } QString DiveObjectHelper::gps() const diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.h b/subsurface-core/subsurface-qt/DiveObjectHelper.h index 13bf470..a92be36 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.h +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.h @@ -63,7 +63,6 @@ public: private: QString m_date; QString m_time; - QString m_location; QString m_gps; QString m_duration; QString m_depth; -- 2.7.0
From b4803906337bc2ea0489b6af63e072103ac20288 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 11 Jan 2016 15:34:53 -0200 Subject: [PATCH 04/18] Simplify: removed timestamp variable Signed-off-by: Tomaz Canabrava <[email protected]> --- subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 3 +-- subsurface-core/subsurface-qt/DiveObjectHelper.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp index a1107e2..313910d 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp @@ -34,7 +34,6 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx) } DiveObjectHelper::DiveObjectHelper(struct dive *d) : - m_timestamp(d->when), m_location(get_dive_location(d) ? QString::fromUtf8(get_dive_location(d)) : EMPTY_DIVE_STRING), m_duration(get_dive_duration_string(d->duration.seconds, QObject::tr("h:"), QObject::tr("min"))), m_depth(get_depth_string(d->dc.maxdepth.mm, true, true)), @@ -141,7 +140,7 @@ QString DiveObjectHelper::date() const timestamp_t DiveObjectHelper::timestamp() const { - return m_timestamp; + return m_dive->when; } QString DiveObjectHelper::time() const diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.h b/subsurface-core/subsurface-qt/DiveObjectHelper.h index c300b0a..13bf470 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.h +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.h @@ -62,7 +62,6 @@ public: QString otu() const; private: QString m_date; - timestamp_t m_timestamp; QString m_time; QString m_location; QString m_gps; -- 2.7.0
From 20027db4a46e077ab2140153bf4857f1b5e131ec Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 11 Jan 2016 15:05:07 -0200 Subject: [PATCH 03/18] Simplify: remove uneeded variable, rating. Signed-off-by: Tomaz Canabrava <[email protected]> --- subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 3 +-- subsurface-core/subsurface-qt/DiveObjectHelper.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp index 718a624..a1107e2 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp @@ -34,7 +34,6 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx) } DiveObjectHelper::DiveObjectHelper(struct dive *d) : - m_rating(d->rating), m_timestamp(d->when), m_location(get_dive_location(d) ? QString::fromUtf8(get_dive_location(d)) : EMPTY_DIVE_STRING), m_duration(get_dive_duration_string(d->duration.seconds, QObject::tr("h:"), QObject::tr("min"))), @@ -255,5 +254,5 @@ QString DiveObjectHelper::otu() const int DiveObjectHelper::rating() const { - return m_rating; + return m_dive->rating; } diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.h b/subsurface-core/subsurface-qt/DiveObjectHelper.h index 8bcf289..c300b0a 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.h +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.h @@ -61,7 +61,6 @@ public: QString maxcns() const; QString otu() const; private: - int m_rating; QString m_date; timestamp_t m_timestamp; QString m_time; -- 2.7.0
From 75af230fa14ff3de1cad1b0b8a93e033aca00e49 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 11 Jan 2016 15:04:21 -0200 Subject: [PATCH 02/18] Remove uneeded variable: id Signed-off-by: Tomaz Canabrava <[email protected]> --- subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 3 +-- subsurface-core/subsurface-qt/DiveObjectHelper.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp index 0d572c7..718a624 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp @@ -34,7 +34,6 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx) } DiveObjectHelper::DiveObjectHelper(struct dive *d) : - m_id(d->id), m_rating(d->rating), m_timestamp(d->when), m_location(get_dive_location(d) ? QString::fromUtf8(get_dive_location(d)) : EMPTY_DIVE_STRING), @@ -133,7 +132,7 @@ int DiveObjectHelper::number() const int DiveObjectHelper::id() const { - return m_id; + return m_dive->id; } QString DiveObjectHelper::date() const diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.h b/subsurface-core/subsurface-qt/DiveObjectHelper.h index 9241f86..8bcf289 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.h +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.h @@ -61,7 +61,6 @@ public: QString maxcns() const; QString otu() const; private: - int m_id; int m_rating; QString m_date; timestamp_t m_timestamp; -- 2.7.0
From 370987aab4cd21e3cad50017959a2f93e6eb18e4 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 11 Jan 2016 15:02:13 -0200 Subject: [PATCH 01/18] Simplify QML Code Handling Series We are starting to do a not-the-best-work on our current QML code, the following series will do small but important updates on the code regarding QML and QtWidget coexistence and behavior. 1 - Simplify Wrapper class, removing uneeded variable. Signed-off-by: Tomaz Canabrava <[email protected]> --- subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 3 +-- subsurface-core/subsurface-qt/DiveObjectHelper.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp index c82a4a9..0d572c7 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp @@ -34,7 +34,6 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx) } DiveObjectHelper::DiveObjectHelper(struct dive *d) : - m_number(d->number), m_id(d->id), m_rating(d->rating), m_timestamp(d->when), @@ -129,7 +128,7 @@ DiveObjectHelper::~DiveObjectHelper() int DiveObjectHelper::number() const { - return m_number; + return m_dive->number; } int DiveObjectHelper::id() const diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.h b/subsurface-core/subsurface-qt/DiveObjectHelper.h index 2833cd3..9241f86 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.h +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.h @@ -61,7 +61,6 @@ public: QString maxcns() const; QString otu() const; private: - int m_number; int m_id; int m_rating; QString m_date; -- 2.7.0
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
