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 <sfuchs@gmx.de>
This commit is contained in:
Stefan Fuchs 2017-04-23 13:48:47 +02:00 committed by Dirk Hohndel
parent 9b5d3b60ab
commit 1e6f0231e6

View file

@ -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", "<br>");
oldnotes.append(displayed_dive.notes);
displayed_dive.notes = strdup(oldnotes.toUtf8().data());
// If we save as new create a copy of the dive here