From e2bc3b0e2439cecebe2138d9362085c58df94415 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Mon, 11 Jan 2016 16:04:46 -0200 Subject: 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 Signed-off-by: Dirk Hohndel --- subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 37 ++++++++++------------ subsurface-core/subsurface-qt/DiveObjectHelper.h | 1 - 2 files changed, 16 insertions(+), 22 deletions(-) (limited to 'subsurface-core/subsurface-qt') 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("", "" _NOTES_BR); - notesFormatted = notesFormatted.replace("
", "
" _NOTES_BR); - notesFormatted = notesFormatted.replace("", "" _NOTES_BR); - notesFormatted = notesFormatted.replace("", "" _NOTES_BR); - notes.setHtml(notesFormatted); - m_notes = notes.toPlainText(); - m_notes.replace(_NOTES_BR, "
"); -#undef _NOTES_BR - } else { - m_notes.replace("\n", "
"); - } - - 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("", "" _NOTES_BR) + .replace("
", "
" _NOTES_BR) + .replace("", "" _NOTES_BR) + .replace("", "" _NOTES_BR); + notes.setHtml(tmp); + tmp = notes.toPlainText(); + tmp.replace(_NOTES_BR, "
"); + #undef _NOTES_BR + } else { + tmp.replace("\n", "
"); + } + 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; -- cgit v1.2.3-70-g09d2