diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2016-01-11 16:04:46 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-01-11 15:47:07 -0800 |
commit | e2bc3b0e2439cecebe2138d9362085c58df94415 (patch) | |
tree | b6e5608ee37be14c423bdef3cd7ecffe3537805d | |
parent | 6f95242ff121f0d5e6cace4c7c07aa8536c78fdc (diff) | |
download | subsurface-e2bc3b0e2439cecebe2138d9362085c58df94415.tar.gz |
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 <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 37 | ||||
-rw-r--r-- | 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 cd9d018b6..3d9c9cb95 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 c3c8defda..4ef51141d 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.h +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.h @@ -65,7 +65,6 @@ private: QString m_date; QString m_time; QString m_gps; - QString m_notes; QString m_tags; QString m_gas; QString m_sac; |