Changeset a5d54b0 in subsurface


Ignore:
Timestamp:
Apr 16, 2017, 7:42:32 AM (8 days ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
f2d8861
Parents:
d82f8cb
git-author:
Stefan Fuchs <sfuchs@…> (03/29/17 12:25:30)
git-committer:
Dirk Hohndel <dirk@…> (04/16/17 07:42:32)
Message:

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@…>

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • core/planner.c

    r6afcbee ra5d54b0  
    589589        }
    590590
    591         len = show_disclaimer ? snprintf(buffer, sz_buffer, "<div><b>%s</b><br></div>", disclaimer) : 0;
     591        len = show_disclaimer ? snprintf(buffer, sz_buffer, "<div>*!* <b>%s</b><br></div>", disclaimer) : 0;
    592592
    593593        if (diveplan->surface_interval > 60) {
    594                 len += snprintf(buffer + len, sz_buffer - len, "<div><b>%s (%s) %s %d:%02d) %s %s<br>",
     594                len += snprintf(buffer + len, sz_buffer - len, "<div>*** <b>%s (%s) %s %d:%02d) %s %s<br>",
    595595                                translate("gettextFromC", "Subsurface"),
    596596                                subsurface_canonical_version(),
     
    600600                                get_current_date());
    601601        } else {
    602                 len += snprintf(buffer + len, sz_buffer - len, "<div><b>%s (%s) %s %s</b><br>",
     602                len += snprintf(buffer + len, sz_buffer - len, "<div>*** <b>%s (%s) %s %s</b><br>",
    603603                                translate("gettextFromC", "Subsurface"),
    604604                                subsurface_canonical_version(),
  • qt-models/diveplannermodel.cpp

    ra19f9c2 ra5d54b0  
    885885                displayed_dive.dc.maxdepth.mm = 0;
    886886                fixup_dive(&displayed_dive);
     887                // Try to identify old planner output and remove only this part
     888                // If we don't manage to identify old plan start but there is a
     889                // table, delete everything
     890                QString oldnotes(current_dive->notes);
     891                if (oldnotes.indexOf(QString("*!*")) >= 0)
     892                        oldnotes.truncate(oldnotes.indexOf(QString("*!*")));
     893                else if (oldnotes.indexOf(QString("***")) >= 0)
     894                        oldnotes.truncate(oldnotes.indexOf(QString("***")));
     895                else if (oldnotes.indexOf(QString("<table")) >= 0)
     896                        oldnotes.truncate(0);
     897                oldnotes.append(displayed_dive.notes);
     898                displayed_dive.notes = strdup(oldnotes.toUtf8().data());
     899                // If we save as new create a copy of the dive here
    887900                if (replanCopy) {
    888901                        struct dive *copy = alloc_dive();
     
    894907                                add_dive_to_trip(copy, current_dive->divetrip);
    895908                        record_dive(copy);
    896                         QString oldnotes(current_dive->notes);
    897                         if (oldnotes.indexOf(QString(disclaimer).left(40)) >= 0)
    898                                 oldnotes.truncate(oldnotes.indexOf(QString(displayed_dive.notes).left(40)));
    899                         oldnotes.append(displayed_dive.notes);
    900                         displayed_dive.notes = strdup(oldnotes.toUtf8().data());
    901909                }
    902910                copy_dive(&displayed_dive, current_dive);
Note: See TracChangeset for help on using the changeset viewer.