Commit graph

2424 commits

Author SHA1 Message Date
Dirk Hohndel
bf556da81a core/bluetooth: make device discovery less noisy
This mainly combines reasonably redundant text to make the output easier
to read.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-13 16:16:31 -08:00
Dirk Hohndel
702d09df9f mobile/GPS: fix two errors in the GPS handling
First, the time zone adjustment was wrong - this as written could only
ever have worked in UTC or by pure chance.

Second, the order of alerting the UI of the availability of a GPS fix
was also incorrect creating a race between the UI and our data
structures.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-13 13:52:00 -08:00
Berthold Stoeger
1a0f6f53ed undo: set dive mode to CCR in undo command, not profile code
When setting a CCR setpoint, the profile code(!) would turn
the dive into a CCR dive. Not only should the display layer
not alter dives, this also means that the action is not
undoable.

Move that to the appropriate undo command, where it makes
more sense, but obviously also makes things more complicated.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-11 09:31:36 -08:00
Berthold Stoeger
cd32c280ae undo: remove invalidate_dive_cache() call from make_first_dc()
The make_first_dc() function clones a dive with a certain dive
computer moved to the front. This is used by the
MoveDiveComputerToFront undo command.

make_first_dc() calls invalidate_dive(). However, the undo
command does that by itself on every undo/redo. Thus,
remove the call in make_first_dc().

Aside from consistency, the goal is to move invalidate_dive()
to command/* so that we can be more aggressive about the whole
topic: Store only "const dive *" pointers and thus force any
writing access to explicitly invalidate the dive cache.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-11 08:42:17 -08:00
Dirk Hohndel
6add24fe3e mobile: enable deco information calculation on mobile
This simply allows us to calculate the information, it doesn't do
anything to actually display it, yet.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-10 15:57:39 -08:00
Berthold Stoeger
235146a95f profile: pass dive to DiveHandler
The DiveHandler shows a context menu where a cylinder can be
chosen. This indirectly accesses the global displayed_dive
variable.

Remove this in a step to make the profile reentrant.

The code was quite ominous: instead of simply generating the
list of cylinders, a global model was reset and then accessed
with Qt's cumbersome model/view API. All this trampling over
global state can be removed by simply making the function
that generates the list globally accessible.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10 15:57:39 -08:00
Berthold Stoeger
88c6ce988d profile: pass dive to RulerItem
Instead of accessing the global displayed_dive variable
in RulerItem, pass the dive. This is a step in making the
profile reentrant.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10 15:57:39 -08:00
Berthold Stoeger
54e8fe5d9e profile: pass dive to ToolTipItem::refresh()
Don't access the global displayed_dive variable in a step
to make the profile reentrant.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10 15:57:39 -08:00
Berthold Stoeger
193513a61f profile: pass dive to plot function of profile-items
Instead of accessing the global displayed_dive variable,
pass the dive to the various profile items. This is a
step in making the profile code reentrant.

This removes the last user of the displayed_dc macro,
which can now be removed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10 15:57:39 -08:00
Berthold Stoeger
be9f9efb0e profile: pass dive to EventItem
Don't access the global displayed_dive variable in an effort
to make the profile reentrant.

Note that this still accesses the global dc_number variable,
which will likely have to be removed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10 15:57:39 -08:00
Berthold Stoeger
09287809eb profile: move adding of ceiling-violation-event
The profile item that shows the ceilings adds a warning event
if the ceiling is violated. This is very unfortunate.

Improve this situation by adding the event up to the function
that calculates the ceiling. This is still not how it should
be - the display layer should not modify the dive that it
displays.

To make this clear, add a comment that details that this
is a contract between planner and display layer: The planner
uses a dive that can be trampled upon by the profile.
Still, this should be solved differently.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10 15:57:39 -08:00
Berthold Stoeger
9bfc6d2520 profile: use a parameter to determine planner state
The in_planner() function is incompatible with a reentrant
profile, since it accesses a global variable. In
create_plot_info_new() it is essentially redundant, because
there is a planner_ds (ds = deco_state) parameter that
is used only when in the planner. Therefore use that as
the in_planner indicator: when non-null, the profile is
showing a planned dive.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10 15:57:39 -08:00
Berthold Stoeger
94a57d9a1d cleanup: make calculate_deco_information() of static linkage
This function was not used outside of profile.c

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10 15:57:39 -08:00
Damian Zaremba
bd6c874be0 btdiscovery - Add second matcher for Ratio iX3M
New (late 2020) iX3M hardware (refered to as 'iX3m with Sequared Buttons'
in the Ratio support section) appears to identify as iX5M, both in the
Bluetooth name and reported revision e.g.

$ ./ratio-toolbox-x86_64.AppImage info | head -n2
Model: Ratio® iX5M GPS TECH+
Firmware version: 4.1.26/016 (English)

Add a second Bluetooth name matcher for this variation, returning the same
(generic) model as is currently used.

Signed-off-by: Damian Zaremba <damian@damianzaremba.co.uk>
2021-01-10 13:44:16 -08:00
Dirk Hohndel
76136010bf preferences: remove pointless member
This could never have worked the way it was used.

Some whitespace fixes snuck into this commit.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-06 10:18:23 -08:00
Berthold Stoeger
106f7a8e0e desktop: add statistics widget dummy and application state
Add a new "statistics" application state. In the statistics state
show the statistics widget and the filter in the top quadrants.
The idea is to allow filtering and doing statistics at the same
time.

Sadly, we can't use the filter-widget in different quadrants,
because Qt's ownership model is completely broken / inflexible.
It does not support a widget having different parents and
thus a widget can only belong to one QStackedWidget.

Hiding the map in the statistics view is quite hacky:
Since the view of the quadrants is not determined by the
"ApplicationState", we have to restore the original quadrant
visibility when exiting the stats mode. Therefore, set the
original visibility-state when changing application state.

The MainWindow-quadrant code really needs to be rewritten!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03 13:41:15 -08:00
Dirk Hohndel
5048a695aa mobile: turn GpsLocation into a regular singleton construct
Simply move the initialization of the logging function into its own method and
call that in the QMLManager constructor.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-02 12:47:15 -08:00
Berthold Stoeger
fdde4c23ea cleanup: move pref related structs and functions to pref.c
These were declared in pref.h and defined in subsurfacestartup.c.
pref.c didn't even exist. Create it and move preferences-related
structs and functions there.

setup_system_prefs() is left in subsurfacestartup.c, since it
works with environment variables.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02 10:26:29 -08:00
Berthold Stoeger
91ffa5a59a cleanup: move definition of get_units() to core/unit.c
The function is declared in core/unit.h, therefore it seems logical
to define it in the corresponding source file.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02 10:26:29 -08:00
Berthold Stoeger
966cd873c5 cleanup: remove support for PASCAL in get_pressure_units()
The user preferences can never end up with PASCAL pressure
units. The only place that uses these units is the XML parser.
Therefore, remove the PASCAL case in get_pressure_units().
This will remove an unused translation string.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02 10:26:29 -08:00
Berthold Stoeger
18acb85a01 cleanup: don't save PASCAL pressure units to git
The way I understand, the PASCAL pressure unit is used to parse
obscure dive logs. However, there is no support in the UI for
using Pa as pressure unit. Therefore remove reading / writing
this unit to git divelogs.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02 10:26:29 -08:00
Dirk Hohndel
b79114c5d0 cleanup: ensure DiveFilter is consistent when created
Otherwise we might access an uninitialized member.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-01 12:38:50 -08:00
Berthold Stoeger
b02847de53 core: add get_*_unit functions with explicit unit system
The get_*_unit() functions return the unit-name as set in
the preferences. Add versions with a "metric" parameter.

This will be used by the statistics code, which may in
the future allow for binning with alternative units.

All the unit-formatting functions should probably be moved
away from qthelper to their own source file.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01 21:10:10 +01:00
Berthold Stoeger
e23d103c5d core: move formatting of day-of-week to string-format.cpp
This was only used by the filter, but will also be used
by the statistics module. To avoid duplicate translation
strings, move to a common place.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01 21:10:10 +01:00
Berthold Stoeger
b0b52d51bd core: add "transparent" parameter to renderSVGIcon
The start-selection widget will need icons with a transparent
background so that the icons don't stick out like a sore thumb.

So far the icons rendered by this function were only used by
the images on the profile and were perfectly rectangular.
Therefore there was no need for this.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01 21:10:10 +01:00
Berthold Stoeger
60999e3a39 core: make gasmix_is_invalid globally accessible
The statistics module will use that to bin dives by gasmix.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01 21:10:10 +01:00
Berthold Stoeger
1270d94701 core: add notion of gas-type to core/gas.c
Create a gastype enum, which describes the type of a gas.
For now: air, nitrox, normoxic, trimix and oxygen.

This probably should be made configurable.

The gas types will be used to bin gasses in the statistics
module.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01 21:10:10 +01:00
Berthold Stoeger
1d93926700 core: move renderSVGIcon() to qthelper.cpp
The renderIcon() function was used by the thumbnailer to
render SVG-based icons. Move it to the global qthelper.cpp
so that it can also be used by the statistics module.
Add "SVG" to the name to emphasize what it is used for.

For consistency also move the renderSVGIconWidth() function,
which renders to a fixed width, to qthelper.cpp

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01 21:10:10 +01:00
Berthold Stoeger
6b46e8ae57 cleanup: const-ify utc_mktime()
To make it clear that the struct tm is only used as an input
parameter.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-29 08:34:09 -08:00
Berthold Stoeger
4c85357dcc cleanup: move monthname to time.c
Weirdly, this function was declared in dive.h and defined in
subsurface-startup.c. Let's move declaration and definition to
more appropriate places, viz. subsurface-time.h and time.c.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-29 08:34:09 -08:00
Berthold Stoeger
bbbd4c8818 cleanup: remove getDivesInTrip() in qthelper.cpp
This function was not used anywhere. Moreover, remove a few
unused includes from qthelper.h. Surprisingly, a number of users
of qthelper.h depend on these, so readd them at the appropriate
places.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-29 08:34:09 -08:00
Berthold Stoeger
8758b95881 filter: provide function that returns all shown dives
This will be used by the statistics widget.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-29 08:34:09 -08:00
Berthold Stoeger
c53bab8965 filter: internalize shown_dives in DiveFilter class
one piece of global state removed!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-29 08:34:09 -08:00
Berthold Stoeger
51d0c42a5c filter: move shown_dive from divelist.c to divefilter.cpp
Arguably, the number of filtered dives is a matter of the divefilter.
Let's move it there.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-29 08:34:09 -08:00
Berthold Stoeger
9e84fd935b filter: keep track on shown_dive on dive removal in DiveFilter
When removing dives, the UndoCommands would keep track of the
shown dives. When adding, they were calling into the filter
instead. Let's remove this asymmetry.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-29 08:34:09 -08:00
Berthold Stoeger
e80c0d2c60 filter: reset shown_dives in filter
The shown_dives variable was reset by the dive_list code. Arguably,
the filter should keep track of the number of shown dives, so move
the resetting there. This means adding a new "reset()" member function
to the filter and call that instead of "updateAll()" when the core
data is reset.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-29 08:34:09 -08:00
Berthold Stoeger
79f95b7f7d core: remove DiveObjectHelper
Since switching to the mobile-models and removing grantlee,
DiveObjectHelper was demoted to a thin wrapper around string
formatting functions. The last user was removed in a previous
commit.

It was never a good idea, given QML's strange memory-management.
Let's remove it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-17 13:03:56 -08:00
Berthold Stoeger
1037c15b98 mobile: remove DiveObjectHelper code
When editing a dive, a DiveObjectHelper of the unmodified dive
was created to compare the edited with the old values. Since
the DiveObjectHelper is used here only as a pointless wrapper
around the formatting functions, call these functions directly.

However, note that the code is in principle wrong since the
change to the mobile-models, which do not use the DiveObjectHelper.
The real fix would be to reload the data from the model to prevent
going out-of-sync with respect to the formatting routines!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-17 13:03:56 -08:00
Berthold Stoeger
cc5ebd7414 printing: remove CylinderObjectHelper
With the removal of grantlee, this became pointless glue
code. Call the formatting functions directly.

Since the printing code was the only user of CylinderObjectHelper,
remove the whole thing.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-17 13:03:56 -08:00
Berthold Stoeger
ae182c386b printing: remove DiveObjectHelper from printing code
At this point (post grantlee), DiveObjectHelper is just pointless
glue code. Let's remove it from the printing code and call the
formatting functions directly. If necessary, move these functions
to core/string-format.cpp.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-17 13:03:56 -08:00
Berthold Stoeger
d9942269a9 printing: remove DiveObjectHelperGrantlee
This was a weird helper object, needed for grantlee. Instead
of storing this object, loop over cylinders and dives directly.

The actual accessor function is unchanged and now generates
a DiveObjectHelper or DiveCylinderHelper for every variable
access. Obviously, this is very inefficient. However, this
will be replaced in future commits by direct calls to formatting
functions.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-17 13:03:56 -08:00
Berthold Stoeger
bf8261c001 core: create string-format.cpp source file
The mobile version of the list used string formatting functions
defined in DiveObjectHelper and declared in mobilelistmodels.h.
Very confusing. Move them to a separate source file where - in
the long run - all the string-formatting functions, which
are scattered all over the place, can be collected.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-12-17 13:03:56 -08:00
Berthold Stoeger
daebd0ad0e core: correct AL* tankinfo sizes.
Recently (d16a9f118a) the tankinfo table was made dynamic, which
means that the default tankinfos are added programatically.
Thereby, the wrong function was used for AL* type of cylinders:
metric instead of imperial. Fix those.

Reported-by: Michael Andreen <harv@ruin.nu>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-17 08:10:56 -08:00
Berthold Stoeger
296a391faa prefs: add option to display only actually used tanks
A user complained about the default cylinders list. Provide
a preferences option to turn this off.

When changing the preferences, the tank-info model will be
completely rebuilt. Currently, this is a bit crude as this
will be done for any preferences change.

Suggested-by: Adolph Weidanz <weidanz.adolph@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-13 11:49:59 -08:00
Berthold Stoeger
11e576ffbf core: remove the "no-name" tank info
There was a tank info with an empty name. According to a comment,
this is needed for the "no cylinder" case. However, we now support
empty cylinder tables, so this is not needed anymore. Therefore,
remove it.

Make sure that the user can still enter the empty name, just in
case. But don't save the size and pressure in that case.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-13 11:49:59 -08:00
Berthold Stoeger
d16a9f118a core: free tank info table on exit
This is obviously a pure code-hygiene thing. But with the new
dynamic tank info table, this becomes trivial, so let's do it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-13 11:49:59 -08:00
Berthold Stoeger
50b11024d6 core: keep tank infos in a dynamic table
The list of known tank types were kept in a fixed size table.
Instead, use a dynamic table with our horrendous table macros.
This is more flexible and sensible.

While doing this, clean up the TankInfoModel, which was leaking
memory.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-13 11:49:59 -08:00
Berthold Stoeger
2d7be7a0e3 preferences: create global settingsChanged signal
So far, the PreferencesDialog emitted a settingsChanged signal.
This meant that models that listened to that signal had to
conditionally compile out the code for mobile or the connection
had to be made in MainWindow.

Instead, introduce a global signal that does this and move
the connects to the listeners to remove inter-dependencies.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-12 15:52:40 -08:00
Robert C. Helling
e7a18456c9 Add surge etc to printing template variables
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-12-12 16:37:29 +01:00
Robert C. Helling
df9a52d857 downloader: filter possible devices and add mounts, remember last choices
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-12-03 13:26:55 -08:00