summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Stefan Fuchs <sfuchs@gmx.de>2017-11-28 18:10:37 +0100
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2017-11-28 23:58:35 +0100
commitb7806d1b945851a6a1713e7d619e1b3f4ddee464 (patch)
treea83c6b2b1e3447cd658c86c63d1f10585a12a932
parent00e33468355b718dab1fa49f63206b8e3be16bad (diff)
downloadsubsurface-b7806d1b945851a6a1713e7d619e1b3f4ddee464.tar.gz
Correctly handle dive notes in maintab.cpp
Remove duplicate and incorrect setPlainText call via macro for dive notes. Deal correctly with ASCII line breaks "\n" in dive notes with html markup (replace them with <br>). Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
-rw-r--r--desktop-widgets/tab-widgets/maintab.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp
index 3a2b3af89..0a57fd4e8 100644
--- a/desktop-widgets/tab-widgets/maintab.cpp
+++ b/desktop-widgets/tab-widgets/maintab.cpp
@@ -426,12 +426,13 @@ void MainTab::updateDiveInfo(bool clear)
ui.notes->setText(QString());
if (!clear) {
QString tmp(displayed_dive.notes);
- if (tmp.indexOf("<table") != -1)
+ if (tmp.indexOf("<table") != -1) {
+ tmp.replace(QString("\n"), QString("<br>"));
ui.notes->setHtml(tmp);
- else
+ } else {
ui.notes->setPlainText(tmp);
+ }
}
- UPDATE_TEXT(displayed_dive, notes);
UPDATE_TEXT(displayed_dive, suit);
UPDATE_TEXT(displayed_dive, divemaster);
UPDATE_TEXT(displayed_dive, buddy);
@@ -1494,10 +1495,12 @@ void MainTab::showAndTriggerEditSelective(struct dive_components what)
SHOW_SELECTIVE(suit);
if (what.notes) {
QString tmp(displayed_dive.notes);
- if (tmp.contains("<table"))
+ if (tmp.contains("<table")) {
+ tmp.replace(QString("\n"), QString("<br>"));
ui.notes->setHtml(tmp);
- else
+ } else {
ui.notes->setPlainText(tmp);
+ }
}
if (what.rating)
ui.rating->setCurrentStars(displayed_dive.rating);