summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Stefan Fuchs <sfuchs@gmx.de>2017-03-29 21:25:30 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-04-16 07:42:32 -0700
commita5d54b04a7ff02f40537193181d00c3dadf59317 (patch)
tree5744cb0ea2232ac2132106bd7b7873740c0187a1
parentd82f8cbd3febbb84714bb3d78bcab5ddcc06ec4d (diff)
downloadsubsurface-a5d54b04a7ff02f40537193181d00c3dadf59317.tar.gz
Handle notes from planner
New strategy to identify old planner output in notes when replanning a dive: Text anchors ("*!*" and "***") added for planner output For backwards compatibility: If there is no anchor but an old table delete everything. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
-rw-r--r--core/planner.c6
-rw-r--r--qt-models/diveplannermodel.cpp18
2 files changed, 16 insertions, 8 deletions
diff --git a/core/planner.c b/core/planner.c
index aa58552d2..e57bd10ed 100644
--- a/core/planner.c
+++ b/core/planner.c
@@ -588,10 +588,10 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
return;
}
- len = show_disclaimer ? snprintf(buffer, sz_buffer, "<div><b>%s</b><br></div>", disclaimer) : 0;
+ len = show_disclaimer ? snprintf(buffer, sz_buffer, "<div>*!* <b>%s</b><br></div>", disclaimer) : 0;
if (diveplan->surface_interval > 60) {
- len += snprintf(buffer + len, sz_buffer - len, "<div><b>%s (%s) %s %d:%02d) %s %s<br>",
+ len += snprintf(buffer + len, sz_buffer - len, "<div>*** <b>%s (%s) %s %d:%02d) %s %s<br>",
translate("gettextFromC", "Subsurface"),
subsurface_canonical_version(),
translate("gettextFromC", "dive plan</b> (surface interval "),
@@ -599,7 +599,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
translate("gettextFromC", "created on"),
get_current_date());
} else {
- len += snprintf(buffer + len, sz_buffer - len, "<div><b>%s (%s) %s %s</b><br>",
+ len += snprintf(buffer + len, sz_buffer - len, "<div>*** <b>%s (%s) %s %s</b><br>",
translate("gettextFromC", "Subsurface"),
subsurface_canonical_version(),
translate("gettextFromC", "dive plan</b> created on"),
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp
index 35f696c01..29dda8c6a 100644
--- a/qt-models/diveplannermodel.cpp
+++ b/qt-models/diveplannermodel.cpp
@@ -884,6 +884,19 @@ void DivePlannerPointsModel::createPlan(bool replanCopy)
displayed_dive.maxdepth.mm = 0;
displayed_dive.dc.maxdepth.mm = 0;
fixup_dive(&displayed_dive);
+ // Try to identify old planner output and remove only this part
+ // If we don't manage to identify old plan start but there is a
+ // table, delete everything
+ QString oldnotes(current_dive->notes);
+ if (oldnotes.indexOf(QString("*!*")) >= 0)
+ oldnotes.truncate(oldnotes.indexOf(QString("*!*")));
+ else if (oldnotes.indexOf(QString("***")) >= 0)
+ oldnotes.truncate(oldnotes.indexOf(QString("***")));
+ else if (oldnotes.indexOf(QString("<table")) >= 0)
+ oldnotes.truncate(0);
+ oldnotes.append(displayed_dive.notes);
+ displayed_dive.notes = strdup(oldnotes.toUtf8().data());
+ // If we save as new create a copy of the dive here
if (replanCopy) {
struct dive *copy = alloc_dive();
copy_dive(current_dive, copy);
@@ -893,11 +906,6 @@ void DivePlannerPointsModel::createPlan(bool replanCopy)
if (current_dive->divetrip)
add_dive_to_trip(copy, current_dive->divetrip);
record_dive(copy);
- QString oldnotes(current_dive->notes);
- if (oldnotes.indexOf(QString(disclaimer).left(40)) >= 0)
- oldnotes.truncate(oldnotes.indexOf(QString(displayed_dive.notes).left(40)));
- oldnotes.append(displayed_dive.notes);
- displayed_dive.notes = strdup(oldnotes.toUtf8().data());
}
copy_dive(&displayed_dive, current_dive);
}