Commit graph

18411 commits

Author SHA1 Message Date
Dirk Hohndel
0de26e44a5 mobile/UI: rewrite screen size logic
This has been a thorn in my side for a long time. The old code was
terrible and insanely fragile. The new code is really dumb and quite
fragile. So definitely an improvement?

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-10 15:16:52 -08:00
Dirk Hohndel
b40354c7f2 build-system: compile stats code on mobile OSs
Android and iOS use qmake, so add the code to the .pro file.
This also removes all remnants of QCharts includes and uses and all the
references to QCharts in our various build systems.

That was a brief but extremely useful detour.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-10 15:16:52 -08:00
Dirk Hohndel
eb2b0f0a3e mobile/statistics: add a statistics page on mobile
This adds a reasonably flexibile mobile page that tries to do the right
thing for both portrait and landscape mode. In order to get the most out
of a mobile screen, it's implemented in a way that always gives it the
full screen (it does so by emptying out the page stack and being the
only page shown - brutal, but effective).

This commit also contains a bunch of other random cleanups that didn't
really justify being in separate commits.

Parts of this was written by Berthold, hence the double SOB.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10 15:16:52 -08:00
Berthold Stoeger
d77f254328 statistics: add a skeleton StatsManager class
In analogy to "QMLManager", add a "StatsManager" class,
which manages the statistics module on mobile.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10 15:16:52 -08:00
Berthold Stoeger
e7907c494f statistics: convert chart to QQuickItem
It turns out that the wrong base class was used for the chart.
QQuickWidget can only be used on desktop, not in a mobile UI.

Therefore, turn this into a QQuickItem and move the container
QQuickWidget into desktop-only code.

Currently, this code is insane: The chart is rendered onto a
QGraphicsScene (as it was before), which is then rendered into
a QImage, which is transformed into a QSGTexture, which is then
projected onto the device. This is performed on every mouse
move event, since these events in general change the position
of the info-box.

The plan is to slowly convert elements such as the info-box into
QQuickItems. Browsing the QtQuick documentation, this will
not be much fun.

Also note that the rendering currently tears, flickers and has
antialiasing artifacts, most likely owing to integer (QImage)
to floating point (QGraphicsScene, QQuickItem) conversion
problems. The data flow is
QGraphicsScene (float) -> QImage (int) -> QQuickItem (float).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10 15:16:52 -08:00
Berthold Stoeger
f6b857b8fe statistics: fix 20 m binner
Copy&paste error: the 20 m binner binned to 10 m.

Reported-by: Peter Zaal <peter.zaal@gmail.com>
Reported-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10 14:45:12 -08:00
Berthold Stoeger
bbdd34d069 statistics: add count to box and whisker plots
When calculating the quartiles, we need the count of dives
anyway, which makes it trivial to export this value to
the frontend.

Fixes an erroneous "mean", which should be "median".

Suggested-by: Peter Zaal <peter.zaal@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10 14:45:12 -08:00
Linus Torvalds
1808804bab Make sure to sanitize the gasmix after editing it
Otherwise we end up showing the gasmix in a different form after editing
for the usual air percentages, because we haven't normalized the gasmix
values and store them back in the dive in the non-normalized format.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-01-10 13:44:43 -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
Berthold Stoeger
de62638b73 statistics: add tags variable
Trivially a copy of the "buddies" code.

Suggested-by: Peter Zaal <peter.zaal@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10 13:42:48 -08:00
Berthold Stoeger
2d864c3e9d statistics: sort dive sites
The dive sites where sorted by location in RAM, which is just
silly. Add a DiveSiteWrapper that sorts by name, though that
should probably be improved.

Suggested-by: Peter Zaal <peter.zaal@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10 13:42:48 -08:00
Berthold Stoeger
0efcbb0eb6 statistics: add min and max operations for numerical types
This makes sense and is easy to implement.

Suggested-by: Peter Zaal <peter.zaal@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10 13:42:48 -08:00
Dirk Hohndel
bd26d8407f build.sh: recreate previous behavior with no args
When calling build.sh with no args asking for a specific build type, that
should be equivalent with calling it with the -desktop arg.

Reported-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-09 19:29:50 -08:00
Berthold Stoeger
b5c8d0dbb4 statistics: fix range in categorical axes
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-09 14:25:02 -08:00
Berthold Stoeger
83848fb2a8 statistics: add a dive-# variable
This was requested on the mailing list and it makes sense to
have it. Of course, not all charts make sense: e.g. a plot dive-#
vs. count is a bit redundant...

Sadly, this can't use the generic IntRangeBinner, because dive-#s
start at 1, not 0.

Suggested-by: Christof Arnosti <charno@charno.ch>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-09 14:17:56 -08:00
Berthold Stoeger
b00009ef4e statistics: add a mean depth variable
This was requested on the mailing list. Reduce code size somewhat
by deriving the binner and the variable classes from common
base classes with a mean-vs-max flag.

Suggested-by: Christof Arnosti <charno@charno.ch>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-09 14:17:56 -08:00
Michał Sawicz
4ecb8ba0cc [snap] enable ccache in Linux Snap workflow
Also adding `push` to triggering events to populate the cache.

Signed-off-by: Michał Sawicz <michal@sawicz.net>
2021-01-07 17:26:25 -08:00
Michał Sawicz
d2bbe36572 [snap] add missing Qt5Charts dependency
Signed-off-by: Michał Sawicz <michal@sawicz.net>
2021-01-07 17:26:25 -08:00
Michał Sawicz
a5e25c8e7d [snap] add Linux Snap workflow
This will build and verify the snap on pull requests to `master`.

Signed-off-by: Michał Sawicz <michal@sawicz.net>
2021-01-07 17:26:25 -08:00
Michał Sawicz
25d0fb7157 [snap] add daily USN check
This workflow will download the current snaps published in the `candidate`
channel for all architectures and check them for packages with published
Ubuntu Security Notices. If it finds one, it will trigger a build of the
snap recipe:

https://code.launchpad.net/~subsurface/+snap/subsurface-stable

This will rebuild the snap with patched packages and publish it to the
`candidate` channel.

Signed-off-by: Michał Sawicz <michal@sawicz.net>
2021-01-07 12:44:36 -08:00
Berthold Stoeger
2a850025b2 statistics: add ticks at beginning and end of the axis
The grid is based on the axis ticks. If labels in histogram
axes were skipped (because there are too many bins), it could
happen that the grid was incomplete, because the first and/or
last tick were missing. Add these explicitly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-07 10:39:52 -08:00
Berthold Stoeger
cad00032fc statistics: improve placement of info-box
The info box was placed either above or below the mouse-pointer.
If the pointer is at the center and the infobox higher than
half the chart, it would cross the border. Detect this case
and place the info box at the center.

Same logic for right/left, though that should typically not
happen.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-06 12:31:22 -08:00
Berthold Stoeger
405e6b6b69 statistics: fix chart features: regression line and median/mean
The coordinates of these were calculated when creating the feature.
This is wrong, because the min/max values of the axes can change
on resize to get "nice" number. Therefore, recalculate after resizing.
This means that the general "LineMarker" class has to be split into
two classes, one for regression lines and one for median/mean
markers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-06 12:31:22 -08:00
Berthold Stoeger
ab324ed769 statistics: paint custom grid
With removal of QtCharts' axes, the grid was lost. Readd it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-06 12:31:22 -08:00
Berthold Stoeger
8dfa3f6db3 statistics: draw title of axes
Easy enough to implement, but one weirdness:
To get the height of the rotated text, one has to access the
width() member of the boundingRect. I'm not sure if that makes
sense, but so be it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-06 12:31:22 -08:00
Berthold Stoeger
4ab9f1c6b0 statistics: replace QtCharts' axes
Replace by custom implementation, with the ultimate goal to
remove the QtCharts module. This doesn't yet display axis
titles or a grid.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-06 12:31:22 -08:00
Berthold Stoeger
598058e21e statistics: set correct z-value for bars
The bars were set to the z-value of the labels. Not an issue,
since the labels are generated after the bars and therefore
plot later. Still, do the right thing.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-06 12:31:22 -08:00
Berthold Stoeger
90129aa26f statistics: render title
Since we want to get rid of QtCharts, we have to render our own
title. Simply keep around a QGraphicsSimpleTextItem and put in
the center of the chart. Define the borders to the scene as
constants.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-06 12:31:22 -08:00
Berthold Stoeger
ccc95f938a statistics: save axis with series
In the future we want to use our own axis implementation to
convert from/to screen coordinates. For this purpose, we
need to save the axes with the series. Especially if we want
to support multiple series on different axes.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-06 12:31:22 -08:00
Berthold Stoeger
23d781deba statistics: save chart in axis class
The chart was passed as argument to the function recalculating
the axis labels. Instead, pass the chart in the constructor of
the axes and save it. This gains us flexibility for the future:
There will be more functions that need to access the chart (e.g.
resizing of the axes).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-06 12:31:22 -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
Dirk Hohndel
d63910caa3 desktop/update-check: fix logic when to ask about update check
Checking a field that we intentionally don't store to disk is obviously
wrong. It's been this way for a long time and it has annoyed me many
times, but somehow I never spent the time to track down why this was
happening.

It makes much more sense to use the presence of either the don't check
flag or a next check date as an indication that we have already asked
this question.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-06 10:18:23 -08:00
Dirk Hohndel
fabeb71ade desktop/UI: move statistics to View menu
It seems to make more sense to have it there with the 'Yearly Statistics'
and not in the Log menu. Interestingly enough, both locations were clearly
considered when first adding this in commit 106f7a8e0e ("desktop: add
statistics widget dummy and application state") as you can tell by the
never implemented actionViewStats.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-06 10:11:31 -08:00
Dirk Hohndel
2305ecc877 dekstop/UI: remove duplicate resource
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-06 10:11:31 -08:00
Dirk Hohndel
19828510d9 desktop/UI: add shortcut for 'Open cloud storage'
This seems like a logical extension of the shortcuts we already have.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-06 10:11:31 -08:00
Robert C. Helling
b181c011cc Add dive rating and visibility to statistics variables
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2021-01-05 00:34:14 +01:00
Dirk Hohndel
ce0f64df2e stats: fix line segment intersection math
Linear algebra class was a while ago, but somehow this does look more
logical to me.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-04 11:20:51 -08:00
Dirk Hohndel
c63994f775 build-system/AppImage: ensure stats dependencies get bundled
This will make sure QtCharts is part of the AppImage.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-03 17:11:54 -08:00
Dirk Hohndel
1f1d82b1b3 statistics: don't crash if the QCharts QML modules aren't found
We don't really give a user visible error message which is kind of a problem,
but at least we don't crash anymore.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-03 16:58:01 -08:00
Berthold Stoeger
6a6dd0888a statistics: don't reset binner if binner is set
Recently code was added to reset variable 1 binner if the second
variable does not support an unbinned first variable.

It forgot to check whether a binner was already set. Do this.
But validate the old binner first!

This code is extremely fragile and will have to be redone.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03 15:41:36 -08:00
Dirk Hohndel
77bc0c7c93 desktop: rename Statistics tab to Summary
We now have three different things that are kinda like statistics:
- the summary tab (reasonably useful when looking at selected dives)
- the yearly statistics (Ctrl/CMD-Y)
- the full statistics (Ctrl/CMD-T)

I'd argue that's at least one too many. But I'm sure some people will disagree.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-03 13:56:25 -08:00
Dirk Hohndel
68dd039a81 statistics: add CHANGELOG
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-03 13:56:18 -08:00
Dirk Hohndel
814b2dd65f build-system/Windows: package the QtCharts QML resources
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-03 13:56:05 -08:00
Berthold Stoeger
bea289e314 statistics: clip regression line
A steep regression line would shoot out of the chart. Therefore,
clip to the y = minY and y = maxY lines.

QtGraphicsScene has its own clipping routines, but they are
very general, so let's do this trivial case by hand.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03 13:56:05 -08:00
Berthold Stoeger
9beec46e22 statistics: use RoundRectItem for legend and info-box
Dirk says rounded corners look better. This now looks a bit
extreme to me and probably the border size should be increased.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03 13:56:05 -08:00
Berthold Stoeger
b188560ae5 ui: create a RoundRectItem class
Factor out code from ProfileWidget's ToolTipItem, but make
the radius of the corners dynamic. Move into backend-shared,
though a new ui-shared might be preferred.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03 13:56:05 -08:00
Berthold Stoeger
9759d5b21a statistics: add parentheses around percentage in horizontal bars
For better visual guidance, format labels as "count (percentage)"
in horizontal bar charts. In vertical bar charts two lines are used
anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03 13:56:05 -08:00
Dirk Hohndel
e47878cbce statistics: charts drop down looks better with smaller icons
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-03 13:56:01 -08:00
Dirk Hohndel
5ab8c8308b statistics: chart icons look better with rounded corners
This is certainly a ridiculous bike shedding effort, but I do like this better.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-03 13:55:57 -08:00
Berthold Stoeger
9c4157ca35 statistics: fix silly typo in legend code
After each column, instead of setting the new x-variable, the
new value was added to the old value. This led to ever increasing
gaps.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03 13:41:15 -08:00