Commit graph

1668 commits

Author SHA1 Message Date
Berthold Stoeger
77b5d714fb Core: consider dive computers when sorting dives
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>
2019-05-17 07:55:34 -07:00
willemferguson
a969d1dd45 Implement height-to-pressure functions in planner
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>
2019-05-17 09:46:05 +02:00
Linus Torvalds
9590709e8c Add support for the new Suunto D5
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>
2019-05-17 09:42:05 +02:00
Dirk Hohndel
2feedf46fa Cleanup: small coding style fixes
And addressing a cut and paste error in a comment.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-05-15 07:42:14 -07:00
willemferguson
1bdf00b2b4 Convert the atmospheric pressure in the Information Tab to an editable field
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>
2019-05-15 07:37:14 -07:00
Berthold Stoeger
75767c456a Turn application state into enum
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>
2019-05-12 12:33:55 -07:00
Berthold Stoeger
114b3d9d47 Core: consider dive-number on sorting
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>
2019-05-12 12:28:06 -07:00
Berthold Stoeger
e362afe43c Cleanup: remove UTF8 macros
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>
2019-05-12 12:25:43 -07:00
Berthold Stoeger
bab7033ccb Dive site: create new dive site at location from GPS data
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>
2019-05-11 12:35:11 -07:00
Berthold Stoeger
c529cfd361 Cleanup: remove for_each_gps_location macro
This macro had no users.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11 12:35:11 -07:00
Berthold Stoeger
6586ba5579 Cleanup: move parse_location() declaration into header file
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>
2019-05-11 12:35:11 -07:00
Dirk Hohndel
144de49ad4 Mobile: add checkbox to force downloading all dives
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>
2019-05-11 11:40:07 -07:00
Doug Junkins
98b3a326bd Add "Import dive sites" menu to mainwindow
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>
2019-05-06 10:48:44 +02:00
Berthold Stoeger
9442e17ba8 Cleanup: remove unused macro SURFACE_PRESSURE_STRING
The last user was removed in c3f07b9f81.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-05 08:36:21 -07:00
Doug Junkins
14a763a6a0 Bugfix for algorithm in get_distance()
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>
2019-04-30 23:32:50 +02:00
William Perry
9bb7bbef84 Support for Scubapro G2 HUD discovery via bluetooth
Signed-off-by: William M Perry <wmperry@gmail.com>
2019-04-28 09:39:50 +02:00
Linus Torvalds
866ca76a58 qt-ble: return DC_STATUS_TIMEOUT rather than DC_STATUS_IO on timeout
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>
2019-04-18 05:42:54 +12:00
Robert C. Helling
52105e5217 Write dive data as video subtitles
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>
2019-04-16 20:38:19 +02:00
Berthold Stoeger
15b2dbede4 Mobile: reinstate roleNames function in ConnectionListModel
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>
2019-04-16 23:43:14 +12:00
Robert C. Helling
aa86d47e47 Don't show surface gas in gas use list
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>
2019-04-16 02:00:35 +12:00
Linus Torvalds
606c3a0245 make sure to clear dives on dive split failure
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>
2019-04-15 11:22:44 +12:00
Dirk Hohndel
88a9b8abf5 FTDI support: ignore case when comparing magic device name
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-04-15 10:30:33 +12:00
Berthold Stoeger
88dc32fdfc Core: turn add_single_dive() to append_dive()
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>
2019-04-15 10:24:31 +12:00
Berthold Stoeger
1bc977452d Cleanup: free dive table in trips and dive sites
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>
2019-04-15 10:21:10 +12:00
Doug Junkins
27927f74a1 Add export option to export dive sites.
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>
2019-04-13 08:18:32 -07:00
Berthold Stoeger
b024ca101e Dive site: make UUID generation deterministic
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
d5953318ca Cleanup: replace QString("") by QString()
That should be more effective.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
779c4eb5d0 Cleanup: remove redundant checks for null dive site
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>
2019-04-12 18:19:07 +03:00
Doug Junkins
9b5eab4ca1 Remove check for whether a site is used before saving it.
Signed-off-by: Doug Junkins <junkins@foghead.com>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
58f2e5f77c Undo: use QUndoStack::isClean() to determine unsaved changes
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
d7d408a99e Undo: implement undo of dive trip editing
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
9fd87fa080 Undo: update cylinder and weight models on paste
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
9ed5cf16a4 Coding style: remove Java-style function definition
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
92e6e2bba1 Core: introduce taglist_copy() function
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
cddd5942f8 Undo: update dive list after edit command
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
c82f4487f9 Undo: implement undo of depth and duration editing
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
6f574c53a3 Undo: implement undo of dive site editing
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
a12adf8e2a Pedantic: K are an absolute scale, which are not given in degrees
Since somewhere in the 1960s. "Fix" a few comments.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
45ef879546 Undo: update notes field if changed by undo commands
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
59239cec02 Undo: make dive site merging undoable
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
0e1b0cf1da Undo: Implement undo of dive site name editing
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
59e602447b Dive site: inform model of dive site addition / deletion
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
84f7179367 Cleanup: macroize dive site table functions, keep table sorted
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
a6f65d744f Cleanup: move table-macros into own header
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
efb770c979 Cleanup: autogenerate remove_dive() and remove_trip()
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
dc9427d16a Cleanup: rename unregister_trip() to remove_trip()
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
8dcc33d8ab Undo: keep frontend informed of changes to dive site count
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
992ad2fa27 Dive sites: simplify nr_of_dives_at_dive_site()
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
9e9821551f Dive site: use ref-counts to see if dive site is used
Checking for dive site usage is now simply checking the number
of dives.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
e2df38d868 Dive site: add dive site ref-counting
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>
2019-04-12 18:19:07 +03:00