From 1e6f0231e6b4689c6771e283847734f39e497df6 Mon Sep 17 00:00:00 2001 From: Stefan Fuchs Date: Sun, 23 Apr 2017 13:48:47 +0200 Subject: Deal with additional line break in dive notes from planner With current code when re-planning a dive the planner output in the dive notes is always moved down by one line. This fix avoids that this additional line break is added. Signed-off-by: Stefan Fuchs --- qt-models/diveplannermodel.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'qt-models') diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index 5075453d3..474384d63 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -894,11 +894,12 @@ void DivePlannerPointsModel::createPlan(bool replanCopy) notesDocument.setHtml(current_dive->notes); QString oldnotes(notesDocument.toPlainText()); int disclaimerPosition = oldnotes.indexOf(disclaimer); - if (disclaimerPosition >= 0) - oldnotes.truncate(disclaimerPosition); + if (disclaimerPosition == 0) + oldnotes.clear(); + else if (disclaimerPosition >= 1) + oldnotes.truncate(disclaimerPosition-1); // Deal with line breaks - notesDocument.setPlainText(oldnotes); - oldnotes = notesDocument.toHtml(); + oldnotes.replace("\n", "
"); oldnotes.append(displayed_dive.notes); displayed_dive.notes = strdup(oldnotes.toUtf8().data()); // If we save as new create a copy of the dive here -- cgit v1.2.3-70-g09d2