From 009f47c5dcd5f255aeb24d71f9a7f2e509e533db Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 29 Aug 2019 23:16:38 +0200 Subject: Desktop: improve recognition of HTML-notes To recognize HTML-notes the text was scanned for
tags. But apparently the planner notes do not feature such a thing. Therefore extend recognition of HTML to tags. Note we can't use the or tags, because these are *always* produced by the QTextEdit::toHtml() function. Fixes #2265 Signed-off-by: Berthold Stoeger --- desktop-widgets/tab-widgets/maintab.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'desktop-widgets') diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp index 613398109..5c6e5104c 100644 --- a/desktop-widgets/tab-widgets/maintab.cpp +++ b/desktop-widgets/tab-widgets/maintab.cpp @@ -369,11 +369,15 @@ bool MainTab::isEditing() return editMode != NONE; } +static bool isHtml(const QString &s) +{ + return s.contains("notes); - if (tmp.indexOf("")); + if (isHtml(tmp)) { ui.notes->setHtml(tmp); } else { ui.notes->setPlainText(tmp); @@ -881,8 +885,8 @@ void MainTab::on_notes_editingFinished() if (!currentTrip && !current_dive) return; - QString notes = ui.notes->toHtml().indexOf("toHtml() : ui.notes->toPlainText(); + QString html = ui.notes->toHtml(); + QString notes = isHtml(html) ? html : ui.notes->toPlainText(); if (currentTrip) Command::editTripNotes(currentTrip, notes); -- cgit v1.2.3-70-g09d2