From 40dd6f4c3931e58ca18754ecfe9c8da5f2c6f542 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Wed, 4 Jun 2014 23:34:09 +0200 Subject: [PATCH] Disclaimer included in the printed diveplan Signed-off-by: Robert C. Helling Signed-off-by: Dirk Hohndel --- planner.c | 16 +++++++++------- planner.h | 2 +- qt-ui/mainwindow.cpp | 6 ++++++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/planner.c b/planner.c index 2306294b0..438b84c73 100644 --- a/planner.c +++ b/planner.c @@ -26,6 +26,8 @@ int decostoplevels[] = { 0, 3000, 6000, 9000, 12000, 15000, 18000, 21000, 24000, double plangflow, plangfhigh; bool plan_verbatim = false, plan_display_runtime = true, plan_display_duration = false, plan_display_transitions = false; +const char *disclaimer; + #if DEBUG_PLAN void dump_plan(struct diveplan *diveplan) { @@ -514,20 +516,20 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool char buffer[20000]; int len, gasidx, lastdepth = 0, lasttime = 0; struct divedatapoint *dp = diveplan->dp; - const char *disclaimer = ""; + const char *empty = ""; bool gaschange = !plan_verbatim; + disclaimer = translate("gettextFromC", "DISCLAIMER / WARNING: THIS IS A NEW IMPLEMENTATION OF THE BUHLMANN " + "ALGORITHM AND A DIVE PLANNER IMPLEMENTION BASED ON THAT WHICH HAS " + "RECEIVED ONLY A LIMITED AMOUNT OF TESTING. WE STRONGLY RECOMMEND NOT TO " + "PLAN DIVES SIMPLY BASED ON THE RESULTS GIVEN HERE.
"); + if (!dp) return; - if (show_disclaimer) - disclaimer = translate("gettextFromC", "DISCLAIMER / WARNING: THIS IS A NEW IMPLEMENTATION OF THE BUHLMANN " - "ALGORITHM AND A DIVE PLANNER IMPLEMENTION BASED ON THAT WHICH HAS " - "RECEIVED ONLY A LIMITED AMOUNT OF TESTING. WE STRONGLY RECOMMEND NOT TO " - "PLAN DIVES SIMPLY BASED ON THE RESULTS GIVEN HERE."); len = snprintf(buffer, sizeof(buffer), translate("gettextFromC", "%s
Subsurface dive plan
based on GFlow = %d and GFhigh = %d

"), - disclaimer, diveplan->gflow, diveplan->gfhigh); + show_disclaimer ? disclaimer : empty, diveplan->gflow, diveplan->gfhigh); if (!plan_verbatim) { len += snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", "")); if (plan_display_runtime) diff --git a/planner.h b/planner.h index 32419d073..12ea3d9d0 100644 --- a/planner.h +++ b/planner.h @@ -21,7 +21,7 @@ extern bool diveplan_empty(struct diveplan *diveplan); extern struct dive *planned_dive; extern char *cache_data; -extern char *disclaimer; +extern const char *disclaimer; extern double plangflow, plangfhigh; diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index ee0e6f090..99539a0a4 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -41,6 +41,7 @@ #include "about.h" #include "worldmap-save.h" #include "updatemanager.h" +#include "planner.h" #ifndef NO_PRINTING #include "printdialog.h" #endif @@ -424,13 +425,18 @@ void MainWindow::setPlanNotes(const char *notes) void MainWindow::printPlan() { + QString diveplan = ui.divePlanOutput->toHtml(); + QString withDisclaimer = diveplan + QString(disclaimer); + QPrinter printer; QPrintDialog *dialog = new QPrintDialog(&printer, this); dialog->setWindowTitle(tr("Print runtime table")); if (dialog->exec() != QDialog::Accepted) return; + ui.divePlanOutput->setHtml(withDisclaimer); ui.divePlanOutput->print(&printer); + ui.divePlanOutput->setHtml(diveplan); } void MainWindow::on_actionDivePlanner_triggered()
depth