When splitting out dive computers, the dives were sorted in
an arbitrary way (according to an internal id), since all
data are identical.
Therefore, consider the dive-computer model names when sorting
dives. Equal dives are now sorted alphabetically by model.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The units.h file has two functions to convert atm pressure to mbar
and also to convert mbar to atm pressure. Implement these two
functions in the planner.
Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
This is just a trivial update to recognize the BT name, and a
libdivecomputer submodule update to get the updates to libdivecomputer
to recognize the new USB IDs etc.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The Information tab shows the atmospheric pressure. Make this value editable
and also ensure that changes to it are undo-able.
Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
The application state was encoded in a QByteArray. Thus, there was
no compile-time checking. Typos would lead to silent failures.
Turn the application state into an enum. Use the enum-class construct,
so that the values don't polute the global namespace. Moreover,
this makes them strongly typed, i.e. they don't auto-convert to
integers.
A disadvantage is that the enums now have to be cast to int
explicitly when used to index an array.
Replace two hash-maps in MainWindow to arrays of fixed sizes.
Move the application-state details into their own files.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
A user reports a problem when dives have the same time but different
numbers. The dives appear sorted randomly (effectively they are sorted
by an internal unique-id).
Try to sort by number for dives at the same date in this case.
Fixes#2086
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
At some places we use UTF8 string literals. Therefore, we effectively
only support UTF8 build systems. We might just as well remove all
the other UTF_* macros and use direct string literals.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Some dive computers save GPS data. Currently, this is stored
by libdivecomputer in an "extra field". When generating a
new dive site for a dive try to use this data to place the
dive site.
To do so, create a "dive_get_gps_location()" function. This
function can be extended later to use e.g. event. When creating
a dive site, use the result of this function over a potential
pre-existing dive site.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The parse_location() function was used in three places. In two
of them, the declaration was in the translation unit. Instead,
move the declaration into a header file, to avoid duplication
and the possibility of inconsistencies.
The "units.h" header was chosen as this is where location_t
is defined.
Moreover, make the string argument to parse_location() "const
char *", so that it can be used on non-owned buffers.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This has been a feature people have asked for quite frequently. It is
taking up some valuable screen real estate - so the question could
become if there should be a switch to enable / disable it.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Adds "Import->Import dive sites" menu to mainwindow.cpp and adds the
on_actionImportDiveSites_triggered() method to prompt for the filename
to import from. The files are parsed and then any dive and trip data is
cleared before opening a dialog box to select which sites are to be
imported.
Signed-off-by: Doug Junkins <junkins@foghead.com>
Fixed bug in the Haversine function in get_distance() based on algorithm
at https://www.movable-type.co.uk/scripts/latlong.html and added bounds
to the 'a' term to avoid floating point errors for antipodal points.
Signed-off-by: Doug Junkins <junkins@foghead.com>
This didn't use to matter, because none of the BLE-using backends did
retry on timeout until recently.
But Jef started doing packet sending retry for the Mares Icon backend,
and now we should make sure to distinguish the "IO failed" from "IO
timed out" cases.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit adds an entry to the dive media context
menu which offers to write a subtitle file. This
creates an .ass file for the selected videos.
In an attempt to to clutter the screen too much, don't
show irrelevant entries (zero temperature or
NDL and show TTS only for dives with stops).
VLC is able to show these subtitles directly, they
can be integrated into the video file with ffmpeg.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Commit c69ca4df80 removed the roleNames
function, which is not needed according to the docs, as a default function
is provided. For unknown reasons this broke the QML combo box.
Reinstate the function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Skip gas use calculation for the gas that was used in
the surface segment added by the planner in the end.
Reported-by: philippe@philmassart.net
Signed-off-by: Robert C. Helling <helling@atdotde.de>
The dive splitting code returns an error code when splitting fails, but
it turns out that the C++ UI code doesn't actually look at the error
code, and instead expected the resulting dives to be NULL if an error
happened and the split didn't succeed for whatever reason.
Which is kind of lazy of it, but we might as well clear the resulting
dives and make the UI code happy. This should fix the problem that
Celia Marlowe reported on the Subsurface google groups forum.
Reported-by: Celia Marlowe
Acked-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Fixes: 145f70aab5 ("Undo: implement split-out of dive computer")
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The only external caller of add_single_dive() used it to append a
dive to the global dive list. Rename the function accordingly and
remove the index parameter.
The internal caller can use the local insert_dive() function, which
doesn't consider selection. That shouldn't be a problem, as the
caller is doing import.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Trips and dive sites were changed to use dive tables instead
of linked lists. But the memory used for the tables wasn't freed.
Do this.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Selecting "Selected dives" exports the dive sites for the selected
dives. Selecting "All dives" exports all dive sites.
XML format is the subsection of the divelog XML that describes the
sites headed with a <divesites> section like:
<divesites program='subsurface' version='3'>
</divesites>
Signed-off-by: Doug Junkins <junkins@foghead.com>
Instead of using a random UUID, use an SHA1 hash of name, description
and notes (if defined). This is necessary for testing.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The dive_site_has_gps_location() function already checks for the null
dive site. Remove redundant checks.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Properly implement the unsaved-changes flag(s). Since we currently have
two kinds of changes, there are two flags:
1) dive_list_changed in divelist.c marks non-undoable changes. This flag
is only cleared on save or load.
2) QUndoStack::isClean() is used to determine the state of undoable
changes. Every time the user returns to the state where they saved,
this flag is cleared.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is copying the dive editing code. It uses an OO design with
virtual functions for getting and setting the values. It doesn't
use templates though, as both fields of strig type. This feels
a bit over-engineered, but it is 1) consistent with the dive edit
code and 2) the number / types of dive trip fields might increase.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When pasting (or undoing paste) the cylinders or weights may change.
Send the appropriate signals and update the models accordingly.
Currently, this means copying from current dive to displayed dive,
but hopefully we can get rid of "displayed_dive" in the not so
distant future.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Remove a few cases of
void fun() {
...
}
While touching these functions, fix a few other whitespace
coding style violations.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Taglists were only copied in dive.c using the STRUCTURED_LIST_COPY
macro. Export that functionality in a function. This will be
needed for undo of dive-pasting.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The dive list was not updated automatically when an edit command was
executed. There was already a signal to do that, viz. divesChanged().
But that signal worked by-trip and didn't have a dive-field specifier.
The edit-commands used the divesEdited() signal that isn't by-trip
but has a dive-field specifier.
Unify these two signals to be by-trip and with dive-field specifier.
This needs common code to generate the by-trip list that is moved to
a command_private.h header.
Since there might now be multiple signals (one per trip) actually
check in the main-tab whether the current trip is affected to
avoid multiple update of fields. This has the positive(?) effect
of not doing any update if the current dive isn't changed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This was a bit different from the other editing commands:
1) Only the current dive is edited not all selected dives.
Therefore, create a function that turns the current dive
into a one-element list.
2) The profile has to be replot. Here, likewise, create a
function to do that.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This one is a bit more tricky. There are two modes: set dive site
and set newly created dive site. This is realized using an OO model
with derived classed. Quite convoluted - but it seems to work.
Moreover, editing a dive site is not simply setting a value,
but the list of dives in a dive site has to be kept up to date.
Finally, we have to inform the dive site list of the changed
number of dives. Therefore add a new signal diveSiteDivesChanged.
To send only one signal per dive site, hook into the undo() and
redo() functions and call the functions of the base class there.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To keep the UI in a consistent state, update the notes field if
it is changed by an undo command. To that purpose, add a new
signal to diveListNotifier with a list of dives and a field-id
as payload.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This one was rather trivial, as there is no actual merging
done. Quite simply, a number of dive sites are removed and
their dive added to a different dive site.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Implement an undo command that edits the name of a dive site.
Connect it to the dive site table, so that names can be edited
directly in the table.
Send signals on undo / redo so that the dive site table and
the dive site edit widget can be updated.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Introduce two DiveListNotifier signals which are sent by
the undo commands if dives are added to / removed from the
core.
The signal has the dive site and the index in the global
dive site table as payload. Thus, the model has only to
remove the appropriate rows.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Turn the table functions of the dive site handling into macros
as was already used for dives and dive trips. This has the effect
that the table is kept sorted by UUID.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
dive- and trip-table functions are generated in dive.c by macros.
Move this macros to a new "core/table.h" header file.
Thus, these functions can be used for other tables (e.g. dive site)
and the trip function can be moved to a separate translation unit
(divelist.c being quite large already).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The other dive- and trip-table functions were already autogenerated.
Let's do the same for these two.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
For consistency with remove_dive(). Moreover, swap parameter order
in remove_dive() so that both functions use the same parameter order.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Add a new signal to DiveListNotifier. Send signal if dives are
added or removed and therefore the dive count of a dive site
changes. The dive sites are collected and the signal is sent
at the end of the command.
Add code to update the table view.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
1) The second parameter (selected_only) was always false. Therefore,
remove it.
2) Simplify the function by simply returning the reference count.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of setting dive->dive_site directly, call the
add_dive_to_dive_site() and unregister_dive_from_dive_site()
functions. In the parser this turned out to be a bit tricky.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>