Commit graph

18392 commits

Author SHA1 Message Date
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
Berthold Stoeger
7b0455b4d8 statistics: reverse chart selection logic
The old ways was to select the chart first, then depending on
the chart choose the binning.

Willem says that it should work the other way round: select
the binning (or operation) and make the charts depend on
that.

I'm not arguing one way or the other, just note that the new
way is much more tricky, because it is easy to get unsupported
combinations. For example, there is no chart where the
first variable is unbinned, but the second axis is binned
or has an operation. This makes things distinctly more tricky
and this code still needs a thorough audit.

Since this is all more tricky, implement a "invalid" chart
state. Ideally that should be never shown to the user, but
let's try to be defensive.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03 13:41:15 -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
Berthold Stoeger
165dce4a0e statistics: implement a statistics widget on desktop
Implement a widget that shows the statistics state as comboboxes
and the statistics chart. Calls into the statistics code if any
of the comboboxes changes.

The hardest part here is the formatting of the charts list with
its icons and with headings. Sadly, it is not trivial to arrange
icons horizontally. Therefore we would have to fully reimplement
the ComboBox view, which is probably not fun.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03 13:41:15 -08:00
Berthold Stoeger
319a7af31a statistics: add a model that describes a list of charts
Qt's comboboxes are controlled by models, there's no way around
that. To customize the chart-selection widget this must therefore
be abstracted into a model. On the upside, this hopefully can
be used for desktop and mobile.

The model provides icons and paints a warning-symbol on it
if the statistics core code deems the chart to be not recommended.
Notably, when plotting a categorical bar chart against a
numerical value (in such a case histograms are preferred).

Includes a fix for a silly oversight in CMakelist.txt: add the
statstranslations.h header.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03 13:41:15 -08:00
Berthold Stoeger
fbb17871c9 statistics: add SVG icons representing chart-types
Add a few icons representing chart type (in internal terms:
chart subtypes): bar (grouped, stacked, single), box-and-whisker,
data points, pie. These should be shown in the chart selection
box.

Yes, the "artwork" is not pretty, so see these as a placeholder.

Morover, add a "warning" icon. This icon already existed as SVG,
but was not references (its png render was).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03 13:41:15 -08:00
Berthold Stoeger
76d94eda23 statistics: silence two Coverity warnings
Two warnings concerning division by zero and non-initialization
of a member variable, respectively.

Both are false positives. However, Coverity is excused because
it probably doesn't understand std::vector<> and also can't
know whether the object in question is generated in a different
source file.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03 13:41:15 -08:00
Dirk Hohndel
402e7eaf97 cleanup: get the Ubuntu names right
Kinda silly, but it bugged me.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-03 13:39:20 -08:00
Dirk Hohndel
c6f134a9b1 mobile: replace locationProvider with calls to GpsLocation::instance()
This makes it more obvious what we are doing. And won't make any difference
from a performance perspective.

Also converted the last call to connect using the old syntax to the new syntax.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-02 12:47: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
Dirk Hohndel
53b572f987 mobile: don't connect to applicationStateChanged signal early
We don't want to connect to this until all parts of the QMLManager object are set up.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-02 12:47:15 -08:00
Berthold Stoeger
995100a540 statistics: implement StatsView
The StatsView shows the chart described by the StatsState structure.
It is based on a QML ChartView. This should make it possible to
easily port to mobile. It does not include any of the UI around
the chart, viz. the variable and chart selection, etc.

The code checking for the statistical significance of the regression
line was written by Willem.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2021-01-02 11:04:03 -08:00
Berthold Stoeger
a034014a6a statistics: implement a structure representing the chart state
The StatsState structure fully describes the current state of
the chart: the selected axes, operations and additional chart
features, such as legend or labels.

The code implements sanity checks and reacts accordingly,
if an invalid combination of variables and charts is chosen.

The chart and variable lists to be displayed can be queried
and are encapsulated in the StatsState::UIState structure.

Some variable / chart combinations are possible, but not
recommended, which is represented by a warning flag.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02 11:04:03 -08:00
Berthold Stoeger
cccc0abc0c statistics: implement scatter series
Implement a simple scatter series for plotting two numerical variables
agains each other. Since the scatter symbols may overlap, on hover
multiple dives are shown in the information box. If the box
would become too large, only the first few dives are shown followed
by "and X more".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02 11:04:03 -08:00
Berthold Stoeger
ad7872424b statistics: implement pie series
Implement a simple count-based pie chart. Percentage labels
are shown in the pie slices, the names outside the pie slices.
On hovering over a slice, the actual counts are shown.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02 11:04:03 -08:00
Berthold Stoeger
b0bdef469e statistics: implement a box-and-whisker series
Implements a simple box-and-whisker series to display
quartile based data. When hovering over a box-and-whiskers
item the precise data of the quartiles is shown.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02 11:04:03 -08:00
Berthold Stoeger
ca572acb0d statistics: implement a bar series
Implement a bar series, which can plot stacked, grouped and single
bar charts in horizontal or vertical ways. On hovering over a
bar, an information is shown. The shown information depends on
whether the chart is count or value based, or is a multi-bin
chart.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02 11:04:03 -08:00
Berthold Stoeger
99f98ea6d4 statistics: implement a simple information box
When the user hovers over features in the chart, they should
be presented with more information. For example in bar charts
on the dives the bar represents and the exact value that the
bar represents, etc.

The InformationBox is a simple QGraphicsWidget, which can be
placed on top of QCharts and can show a number of arbitrary
text lines.

When placing the box on the chart, the code attempts to stay
inside the plot area of the chart.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02 11:04:03 -08:00
Berthold Stoeger
907e6ff05d statistics: add series interface class
Add a interface class for the chart series used by the statistics
module. Abstract virtual functions are declared for replotting
and selecting items.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02 11:04:03 -08:00
Berthold Stoeger
31da037701 statistics: implement axes
Implement five kinds of axes:
 - ValueAxis: a standard axis for plotting numerical linear data.
 - CountAxis: a ValueAxis for plotting counts of dives.
 - CategoryAxis: an axis for plotting discrete variables without
   any notion of distance.
 - HistogramAxis: an axis for plotting bins with a numeric value.
 - DateAxis: a HistogramAxis that formats dates.

The axes derive from a common virtual base class that defines
a small interface, notably, returning the minimum and maximum
displayed value and redrawing the axis.

The mapping and painting is performed by QtCharts' axes. On
the one hand, using QtCharts turned out to be too inflexible.
On the other hand it allowed us to quickly prototype the charts.
Ultimately, we should do our own drawing of the axis.

As a testament to the inflexibility, QtCharts' axes do not
allow for repeated labels is needed for quarter-based date
charts (year, Q2, Q3, Q4, year, Q2, Q3, ...). Therefore the
code disambiguates labels by adding unicode zero-width spaces.
Wonderful.

When omitting labels due to space reasons, the histogram
axis attempts to show "preferred" labels. In the quarter
example above, it tries to show full years.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02 11:04:03 -08:00