Commit graph

18782 commits

Author SHA1 Message Date
Berthold Stoeger
646aead629 desktop: disable animation when selecting multiple dives
Selecting many dives when the animation was active
was increadibly slow, so disable it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-10 14:33:15 -08:00
Berthold Stoeger
b3e4c9c8da desktop: cache photo and geo icons
The icons shown in the dive list were rendered for every single
access. Render them only once. This supposes that the
defaultIconMetrics structure does not change once the icons are
rendered!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-10 14:33:15 -08:00
Dirk Hohndel
41df39fdbe user manual: make the style more personal
Style is always tricky. This is really complex material. This attempts
to slightly personalize the language and make it less academic sounding,
while not removing any of the attention to detail and actual content of
this manual section.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-02-09 08:10:47 -08:00
Dirk Hohndel
b923526f04 user manual: fix typo in manual text
This isn't about 'depth variables', but about continuous vs categorical variables.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-02-09 08:10:47 -08:00
Dirk Hohndel
7a188cf7fe user manual: introduce the two variables as 'base' and 'data'
Instead of adding these names later, use them right from the start.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-02-09 08:10:47 -08:00
Dirk Hohndel
9ab481e927 user manual: get ready for 5.0
While version numbers are really rather random, we decided that with the
new statistics feature we will change the version number to 5.0.
Reflect that in the manual.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-02-09 08:10:47 -08:00
willemferguson
a0f740763b Subsurface Desktop user manual: Statistics panel
Update the user manual to take into account the statistics tool.
This is a first attempt.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2021-02-08 08:23:01 -08:00
Berthold Stoeger
60a6b61fb6 statistics: fix placement of horizontal labels in bar charts
The subtraction of half the label width, needed for centered
labels, must have been lost somewhere.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-08 08:19:48 -08:00
Berthold Stoeger
5b6f468547 statistics: don't place labels at half-integer values
Placing labels at half-integer values gives horrible
rendering artifacts. Therefore, always round to integer
values. The easiest way to do this is right before setting
the position. Introduce a helper function to round QPointF
in such scenarios.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-06 10:05:41 -08:00
Berthold Stoeger
f1203d365a desktop: improve splitter defaults
On first startup, use the splitter values suggested by Dirk:
Top/Bottom: 60/40
Info/Profile: 50/50
List/Map: 60/40

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-06 10:00:39 -08:00
Berthold Stoeger
0b0e6672d5 profile: detect dive-mode change in profile
The profile must be replotted when the dive mode changes.
Weirdly, this was routed via the dive-information tab
(making it inherently non-mobile compatible). Detect
such a change directly in the profile.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-06 10:00:39 -08:00
Berthold Stoeger
aefbde93ce desktop: be smarter about filling splitters
On state change, the splitters were completely emptied and
refilled. Instead try to reuse already existing splitter
slots. This reduces annoying flickering.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-06 10:00:39 -08:00
Berthold Stoeger
c584e28f2e desktop: don't access profile directly to redraw it
The MainWindow has a function to replot the profile. Use that
instead of accessing the profile directly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-06 10:00:39 -08:00
Berthold Stoeger
64dae43bdd desktop: do own memory management of quadrant widgets
The memory management of the quadrant widgets is a total mess:
When setting the widget, the QSplitters take ownership, which
means that they will delete the widget in their destructor.

This is inherently incompatible with singletons, which must
not be deleted.

To avoid all these troubles, remove the widgets from the
QSplitters in the desctructor of the MainWindow. This of
course means that we now have to take care about deletion
of the widgets.

For local widgets use std::unique_ptr, for singletons use
a static variable that is deleted on application exit.

Sadly, for the map widget we can't use a normal singleton,
because the QML MapWidget's memory management is buggy.
Add a comment in the source code explaining this.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-06 10:00:39 -08:00
Berthold Stoeger
8a36a100ce desktop: don't allow view change in planner
When in planner mode, don't allow the user to change the application
state. This brought us nothing but troubles and inconsistencies.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-06 10:00:39 -08:00
Berthold Stoeger
1ed2f1681a desktop: remove the view-state
There was the "application state", which decided what to show
in the "quadrants" and the "view state" which decided which
quadrant to show. These interacted in a hard-to-grasp way.

The "view state" is used to show the map or dive list in
full screen.

I simply couldn't get these two orthogonal states to interact
properly. Moreover the thing was buggy: If a quadrant was hidden,
the user could still show it, by dragging from the side of the
window, at least under KDE.

To solve these woes, merge the two states into a single
application state. If the widget of a quadrant is set to null,
don't show it. So the four "view states" are now "application
states" where three of the four quadrants are not shown.

This also changes the memory management of the widgets:
widgets that are not shown are now removed from the QSplitter
objects. This makes it possible that the same widget is
shown in *different* quadrants.

While writing this, I stumbled upon a Qt bug, which is known
since 2014:
https://forum.qt.io/topic/43176/qsplitter-sizes-return-0

When restoring the quadrant sizes there was a test whether
the quadrant size is 0. If that was the case, a default size
was set. This seems not to work if the widgets were recently
added. Since this test now always fails, make the quadrants
non-collapsible and thus guarantee that 0 is never saved as
a size.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-06 10:00:39 -08:00
Berthold Stoeger
122092707c statistics: delete chart items when root node is deleted
When reparenting the statistics widget, QtQuick deletes
the rootNode and all the child nodes. It is unclear whether
this is a bug or intended behavior. In any case, it means
that the pointers to QSG nodes in the chart items become
stale.

To avoid this, delete all chart items in the root node's
destructor, before QtQuick can do anything. It is unclear
from which context this is called (render or UI) and whether
this is even valid. In some tests, it seemed to work.

The difficulty is that all the stale pointers to chart items
have to be deleted as well. All in all, the QSG memory
management is a big nuisance and very brittle.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-06 10:00:39 -08:00
Dirk Hohndel
805a2388af core/BT: fix duplicate entries in BT detection
Somehow three identical lines snuck into commit 0a4e37ee8b ("core/BT: simplify
detection of bluetooth names").

Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-28 12:51:19 -08:00
Berthold Stoeger
a6cfd181e8 downloader: don't leak device name
For Uemis there was string-manipulation that leaked the
temporary string. Use QString instead in order not to have
to bother about such things.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-26 20:20:09 +01:00
Berthold Stoeger
dc887f6d0a downloader: don't leak DiveImportedModel
Not that it matters, but there seems to be no reason to allocate
DiveImportedModel on the heap and no reason to leak it after
the download has finished.

Removes a artifactuous comment and fixes a typo.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-26 20:20:09 +01:00
Berthold Stoeger
5c9f3742ec downloader: copy logfile name
At some places, this string is free()d, so it must not be
assigned a constant string.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-26 20:20:09 +01:00
Berthold Stoeger
b84baa8a0d downloader: remove unnecessary includes
Including <QObject> should only be necessary in very few
cases, because all widget classes have QObject as a base
class, which means that <QObject> already has to be included.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-26 20:20:09 +01:00
Dirk Hohndel
0a4e37ee8b core/BT: simplify detection of bluetooth names
Instead of that super long if-else if chain, have something more
structured using a table for the common case of prefix based names.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-23 14:35:32 -08:00
Dirk Hohndel
4a6ef023db core/BT: improve BT name detection for Pelagic dive computers
It would be so much nicer if we could just let libdivecomputer do this,
but the filter function there doesn't quite do things the way we need
them to be. Which is why we have our own function here.

This is a small attempt to rationalize the code that we have to make it
easier to maintain.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-23 14:35:32 -08:00
Dirk Hohndel
28f872040b Sync libdivecomputer with upstream
Merge with Jef's upstream libdivecomputer updates:
  - support new Ratio iX3M 2021 model IDs
  - support Mares Horizon, and fix the Mares Genius layout
  - add support for Shearwood Sage
  - various warning fixes, other minor details
Mark Aqualung i750TC as BLE capable

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-23 13:25:38 -08:00
Dirk Hohndel
1dffe08f17 mobile/UI: show result of manual sync
Since we no longer show the noisy git updates to the user, it has become
harder for them to know whether a sync to the cloud was successful.
Since a manual sync will never show the new 'what did you change and
here's how you undo it' notification, it seems easy enough to simply
show a status update.

This adds a passive notification with no action button after the user
either uses the main menu or pulling down on the dive list in order to
trigger a manual sync.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-23 13:19:11 -08:00
Dirk Hohndel
64dea827bd mobile/debugging: copy GPS fixes to clipboard
The goal is to enable a user experiencing crashes when applying GPS data
to their dive log to make all necessary data available to the
developers. Hopefully the clipboard is large enough to hold all the
data.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-23 13:19:11 -08:00
Robert C. Helling
faafcd0cfc Add Diviac conversion to smtk converter CGI script
Plus a little bit of error reporting.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2021-01-23 09:47:24 -08:00
Dirk Hohndel
7cc7feb8f0 Update translations from Transifex
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-21 18:04:39 -08:00
Berthold Stoeger
54ff31f5c1 statistics: do resizing in UI thread, not render thread
The updatePaintNode() function, which is run on the render
thread detected a geometry change and initiated recalculation
of the chart layout.

This means that plotAreaChanged() was called in two different
thread contexts, which is questionable. Instead, hook into
the geometryChanged() function and recalculate the chart items
there.

This fixes a rendering bug, because the old code would first
delete unneeded items and then rerender the chart. Thus, old
grid and tick items were still visible.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-21 13:42:14 -08:00
Dirk Hohndel
913bed19bb Update translation source strings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-20 10:03:29 -08:00
Berthold Stoeger
e79ac9c7ed cleanup: make a few DivePlannerModel functions private
It simplifies reasoning about control flow a lot if it is known
that functions can't be invoked from a different part of the code
base.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20 10:01:50 -08:00
Berthold Stoeger
98594c18d1 cleanup: constify TankItem::setData()
The TankItem only displays the data. Pass pointers as const.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20 10:01:50 -08:00
Berthold Stoeger
84f48b7290 cleanup: constify create_plot_info_new()
This only read accesses the dive and constructs a plot-info
structure. Make the dive parameter const.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20 10:01:50 -08:00
Berthold Stoeger
8d423359a5 cleanup: constify populate_pressure_information()
This has only read access on the dive. Make the parameter const.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20 10:01:50 -08:00
Berthold Stoeger
ad1e57dd67 cleanup: constify init_decompression()
This function initializes decompression data from a dive.
The dive is not modified, therefore make it const.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20 10:01:50 -08:00
Berthold Stoeger
5e1dcb0655 cleanup: remove dive parameter from DivePlotDataModel::setDive()
This was not used, probably an artifact from days long gone.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20 10:01:50 -08:00
Berthold Stoeger
5ddb5ada27 profile: don't "fake" dc in profile widget
There was code to create a fake dc in the profile widget in
the case that there are no samples. To my understanding, this
is obsolete, as such fake data is now generated automatically
when adding dives.

If for some reason there really are no samples, quit early
and go into the empty state.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20 10:01:50 -08:00
Berthold Stoeger
764aa6c512 planner: remove DivePlannerPointsModel::startTimeChanged signal
The way the starting time of a new plan was set was bonkers:

1) PlannerWidgets::planDive() invokes DivePlannerPointsModel::
   createSimpleDive().

2) createSimpleDive() calls DivePlannerPointsModel::
   setupStartTime()

3) setupStartTime() emits a signal startTimeChanged()

4) startTimeChanged is caught by PlannerWidget and sets
   the UI field

5) change of the UI field emits a timeChanged() signal which
   is connected to DivePlannerPointsModel::setStartTime()

6) setStartTime() sets the time of the plan and displayed_dive
   and emits dataChanged()

7) dataChanged() replots the dive()

8) Back in DivePlannerPointsModel::createSimpleDive() the diveplan
   start time is overwritten with displayed_dive (the value are
   equal owing to 6)

Wow!

But it gets worse:

9) The initial dive plan is set up in createSimpleDive().

Since the profile is drawn in 7) after clearing the displayed_dive
and before constructing the initial plan, the profile is shown
on a dive without samples. It therefore generates a dummy profile.

To make this somewhat less insane, remove the startTimeChanged()
signal in 3), explicitly set the start time of plan and dive to
the one calculated by setupStartTime() and explicitly set the UI
filed in the plannerWidget.

This still indirectly draws the profile via signals in a convoluted
way, but at it straightens out things somewhat. Most importantly,
the profile doesn't have to generate a fake DC.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20 10:01:50 -08:00
Berthold Stoeger
de220c2da0 profile: make three member functions const
These accessors do not change the ProfileWidget2 state, so
make them const.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20 10:01:50 -08:00
Dirk Hohndel
f4d806c77a Merge branch 'tvalue' 2021-01-20 09:54:03 -08:00
Dirk Hohndel
29060feaa8 statistics/legend: fix dragging legend on touch screen
While this didn't appear to be needed when dragging the legend with a
mouse, on a touch screen for some reason the drag ended after 30 pixels
either way horizontally (but no apparent limit vertically). By setting
this flag to true, drags on a tablet appear to work as expected.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-20 08:47:18 +01:00
Berthold Stoeger
4f58e9aa62 statistics: render bar and pie labels onto fill color
The labels in bar an pie charts are realized as individual
QSG pixmap nodes with an alpha channel. Sadly, rendering
bright labels onto a transparent background gives very
ugly artifacts.

As a stop gap measure, until the problem is understood,
render on a background with the color of the pie slice
or bar.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20 08:47:18 +01:00
Berthold Stoeger
2e2019dea7 statistics: move colors to statscolors.h
Most colors were already collected there, but a few were dispersed
throughout the source files.

For future themeability, move the remaining colors to this common
place.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20 08:47:18 +01:00
Berthold Stoeger
ba259fb1d6 statistics: make confidence area and regression line opt-in
This is not perfect - the polygon of the confidence area is
calculated even if it is not shown. Oh well.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20 08:47:18 +01:00
Berthold Stoeger
ff536e98fc statistics: don't replot chart when changing features
Up to now, when the user changed the visibility of chart features
(legend, quartiles, labels, etc.) the whole chart was replot.
Instead, only change the visibility status of these items.

After all, this modularity is one of the things the conversion
to QSG was all about.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20 08:47:18 +01:00
Berthold Stoeger
e32e6d63a7 statistics: leak textures on exit
The scatter plot items shared their textures. These were
std::unique_ptrs and cleaned up on exit. Owing to QSG's
broken memory model, freeing the textures after QApplication
terminated its threads led to crashes. Therefore, leak the
textures. Not satisfying, but ultimately harmless and better
than a crash.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20 08:47:18 +01:00
Berthold Stoeger
9e61a6372a statistics: fix range in categorical axes
Fix a bug that was fixed in b5c8d0dbb4 and reintroduced in
e7907c494f. Here is the original commit message:

The range for a one-bin chart is [-0.5,0.5], thus the range
in an n-bin chart is [-0.5,n-0.5], not [-0.5,n+0.5].

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20 08:47:18 +01:00
Berthold Stoeger
db69c38245 statistics: refactor QSG memory management
The code was wrong, because it deleted the ChartItems in the
main UI thread, not the render thread. This would delete the
QSG nodes in the UI thread and then crash on mobile.

Therefore refactor this part of the code by adding the
items to be deleted to a list that will be deleted by the
render thread.

As a drop in replacement of std::unique_ptr, implement
a silly ChartItemPtr class, which auto-initializes to null.

This turns the deterministic and easily controlled memory
management into a steaming pile of insanity. Obviously,
this can be made much more elegant, but this has to do for now.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20 08:47:18 +01:00
Berthold Stoeger
9d3de1801e statistics: remove QSceneGraph
All items are now painted with QSG.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20 08:47:18 +01:00