planner: on printing, restore textual plan using a saved string

When printing, the dive plan was prepended with a logo, a disclaimer
and the profile. Then it was restored by setting the plan of
displayed_dive.

Instead, simply save the original plan in a QString and restore that.
This removes a further dependency on displayed_dive, which I'd like
to make local to the planner.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-04-13 18:30:03 +02:00 committed by Robert C. Helling
parent acfcd866bd
commit 4d0a200cfd

View file

@ -808,8 +808,11 @@ void MainWindow::printPlan()
{
#ifndef NO_PRINTING
char *disclaimer = get_planner_disclaimer_formatted();
// Prepend a logo and a disclaimer to the plan.
// Save the old plan so that it can be restored at the end of the function.
QString origPlan = plannerDetails->divePlanOutput()->toHtml();
QString diveplan = QStringLiteral("<img height=50 src=\":subsurface-icon\"> ") +
QString(disclaimer) + plannerDetails->divePlanOutput()->toHtml();
QString(disclaimer) + origPlan;
free(disclaimer);
QPrinter printer;
@ -848,7 +851,7 @@ void MainWindow::printPlan()
plannerDetails->divePlanOutput()->setHtml(diveplan);
plannerDetails->divePlanOutput()->print(&printer);
plannerDetails->divePlanOutput()->setHtml(displayed_dive.notes);
plannerDetails->divePlanOutput()->setHtml(origPlan); // restore original plan
#endif
}