diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2014-07-21 20:34:15 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-07-23 08:09:58 -0700 |
commit | 99922722d29d1e4e772580d14f6710726e324496 (patch) | |
tree | 7f85db2b2188c99fa58a664ebb83b922ef46da26 /qt-ui | |
parent | 607d450cd6d659a99fda9b73870d340a2e16af1f (diff) | |
download | subsurface-99922722d29d1e4e772580d14f6710726e324496.tar.gz |
Only use HTML if the text has a <table>
The text we generate for the diveplan has a table inside, and
we must use HTML only for the dive plan. so I treat all text
as HTML, look for a table item, if it doesn't have, I treat
it as Simple text and set it on the notes. Works and makes
linus loves me again.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/maintab.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 7c85825d4..87d2a1beb 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -331,7 +331,7 @@ void MainTab::clearStats() #define UPDATE_TEXT(d, field) \ if (clear || !d.field) \ - ui.field->setText(""); \ + ui.field->setText(QString()); \ else \ ui.field->setText(d.field) @@ -370,6 +370,16 @@ void MainTab::updateDiveInfo(bool clear) process_all_dives(&displayed_dive, &prevd); divePictureModel->updateDivePictures(); + + ui.notes->setText(QString()); + if (!clear) { + QString tmp(displayed_dive.notes); + if (tmp.indexOf("<table") != -1) + ui.notes->setHtml(tmp); + else + ui.notes->setPlainText(tmp); + } + UPDATE_TEXT(displayed_dive, notes); UPDATE_TEXT(displayed_dive, location); UPDATE_TEXT(displayed_dive, suit); @@ -1004,7 +1014,10 @@ void MainTab::on_notes_textChanged() if (editMode == IGNORE) return; free(displayed_dive.notes); - displayed_dive.notes = strdup(ui.notes->toHtml().toUtf8().data()); + if (ui.notes->toHtml().indexOf("<table") != -1) + displayed_dive.notes = strdup(ui.notes->toHtml().toUtf8().data()); + else + displayed_dive.notes = strdup(ui.notes->toPlainText().toUtf8().data()); markChangedWidget(ui.notes); } |