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>
This commit is contained in:
Stefan Fuchs 2017-11-28 18:10:37 +01:00 committed by Lubomir I. Ivanov
parent 00e3346835
commit b7806d1b94

View file

@ -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);