Commit graph

1999 commits

Author SHA1 Message Date
Berthold Stoeger
f299fa37f9 stats: fix visibility check of the statistics tab on desktop
Apparently, the visibility flag of the view is not inherited
from the statistics widget. Therefore, the statistics is
redrawn on every action even if not visible.

Set the visibility explicitly in the show- and hide-events.

This is crazy.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-03-31 13:41:39 +02:00
Berthold Stoeger
5b3cb5898f desktop: fold ApplicationState into MainWindow
The application state is a desktop-only thing. The mobile UI
also has its application state, but that is something completely
different.

The last remaining user of the application state was to flag
whether the planner is active. Since this has all been
unglobalized, the ApplicationState structure can be moved
from core to the desktop UI. And there it can be made local
to the MainWindow class.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-17 07:26:55 -08:00
Berthold Stoeger
42cff9b3a5 planner: pass in_planner down to TemplateLayout
The TemplateLayout prints different dives depending on
whether the planner is active. Instead of accessing a
global variable, pass the status down from the MainWindow.
That's all quite convoluted, since there are multiple
layers involved.

On the positive side, the in_planner() function has now
no users an can be removed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-17 07:26:55 -08:00
Berthold Stoeger
18049bc8d0 cleanup: remove unused includes in mainwindow.cpp
The printing code moved elsewhere, so these includes are not
needed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-17 07:26:55 -08:00
Berthold Stoeger
5a8d7617ce statistics: implement primitive "restrict to selection" feature
Allow the user to restrict the analyzed dives based on the
current selection. One button restricts to the current selection
and one button resets the restriction.

Thus, the user can for example select bars in the bar chart
or a range in the scatter plot and perform statistics on
these sets.

The restriction works on top of the filter.

The UI can certainly be improved, but it is a start.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-13 13:02:54 -08:00
Berthold Stoeger
622e9ba373 printing: "fix" progress indicator
In TemplateLayout, there was a progress indication, which reported
the progress - not of the actual rendering - but of adding the
dives to the "to render" list. Which is of course done in less than
a ms, making the whole thing completely pointless.

Instead, emit progress when actually looping over the dives or
statistics.

Nobody ever noticed the problem because even rendering is done in
fractions of a second and indeed is accounted to only one fifth
of the total progress.

The real purpose of this "fix" is to get rid of the getTotalWork()
function, which was just insane. Instead of asking the TemplateLayout
how many dives it rendered, this number was extracted from
global state. Simply store the number of dives in the TemplateLayout
object instead.

Moreover, fix two coding style issues:
 - "Page" variable identifier starting with a capital
 - The Printer::render() being defined (as opposed to declared) with
   a default parameter. This is not how C++'s default parameters work,
   sorry.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-13 12:20:25 -08:00
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
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
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
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
9b7565e81a statistics: turn ChartGrid into QSGNodes
Turn the background grid into QSGNodes. Each grid line is
represented by a QSG line item. An alternative would be
drawing the grid into a QImage and blasting that onto the
screen. It is unclear which one is preferred.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-20 08:47:18 +01:00
Doug Junkins
31e26fd144 mobile: add GF fields for ceiling calculation
Adds fields to the advanced preferences page to modify GFLow and GFHigh for
the Buhlmann decompression model for calculating ceilings. Updated preferences
code to set the Buhlmann parameters in core/deco.c when the GF prefs are
updated.

Signed-off-by: Doug Junkins <douglas.junkins@gmail.com>
2021-01-19 12:34:46 -08:00
Berthold Stoeger
32ec9a8726 undo: remove invalidate_dive_cache call from MainTab
When creating the RenumberDive undo command, the MainTab
would manually call invalidate_dive_cache(). However, this
is done on undo/redo, therefore the call can (should) be
removed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-11 08:42:17 -08:00
Berthold Stoeger
7819683990 profile: remove ProfileWidget2::dateTimeChanged()
This function sent a signal and the only listener was removed
in the previous commit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10 15:57:39 -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
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
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
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
e943065977 cleanup: remove "GpsLocation *locationProvider" from MainWindow
This is mobile only and not used on desktop.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01 12:38:50 -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
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
dc37ba7758 cleanup: remove QPointer instances
QPointer is a strange "smart" pointer class, which resets itself
when the pointed-to QObject is deleted. It does this by listening
to the corresponding signal and therefore is surprisingly heavy
for a plain pointer. A cynic would say that the existence of
QPointer is an expression of Qt's broken ownership model.

In any case, QPointer was only used at two places, were it was
100% useless: As a parameter to a function and as a locally scoped
pointer. It only makes sense if
a) there is a chance that the object disappears during the pointer's
   lifetime and
b) it is actually checked for null before use
None of which was the case here. Remove.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-17 13:03:56 -08:00
Berthold Stoeger
fa6eb6144b printing: move #includes from headers to source files
To decrease include-file interdependencies.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-17 13:03:56 -08:00
Berthold Stoeger
2239ffe13c printing: remove YearInfo structure
This is a wrapper around "stats *" used to pass statistics
through Qt's weird metatype system. Not needed anymore.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-17 13:03:56 -08:00
Berthold Stoeger
0310eb31da printing: refactor if and loop code
The loop code was buggy: the current position was only increased
inside when executing the loop once. This would obviously fail
for empty lists. Moreover, the whole thing was quite difficult
to reason about, since a reference to the current position was
passed down in the call hierarchy.

Instead, pass from and to values to the parse function and
create a generic function that can search for the end of
loop and if blocks. This function handles nested if and for
loops.

The if-code now formats the block only if the condition is true.
The old code would format the block and throw it away if not
needed.

This should now provide better diagnostics for mismatched tags.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-17 13:03:56 -08:00
Berthold Stoeger
f42a70586b printing: remove objects QVariant map
An artifact from the old grantlee code: the whole parser state
was kept in an untyped QVariant map. One case was particularly
bizarre: the options were a class member and yet added to the
weird map.

Replace this by a strongly typed state structure. Ultimately,
this will allow us to replace the "dive object helper".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-17 13:03:56 -08:00
Berthold Stoeger
0cbb448740 cleanup: make templateOptions and printOptions reference types
These two structs describe options used during printing.
They are passed through numerous classes as pointer. In this
case, reference semantics are preferred, as references:
 - can never be null
 - can not change during their lifetime
This not only helps the compiler, as it can optimize away null
checks, but also your fellow coder. Moreover, it prevents
unintentional creation of uninitialized references: one can't
create an instance of a class without initializing a reference
member. It does not prevent references from going dangling.
However, pointers have the same disadvantage.

Contains a few whitespace cleanups.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-17 13:03:56 -08:00
Berthold Stoeger
8d93192537 cleanup: remove MainWindow::stateBeforeEdit member
The last user was removed in accf1fcc8f.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-13 11:50:56 -08:00
Berthold Stoeger
53c2f34930 cleanup: remove unused typedefs
Last users removed in ca6aa38139.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-13 11:50: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
a55c7ff079 desktop: don't save data to the "no-name" tank
There seems to be no point to saving data to the tank with
the empty name. Don't save tank-pressure and size to that
tank info.

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
2e328c7633 cleanup: remove unused #undefs in mainwindow.cpp
These macros were removed 2016-ish.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-12 15:52:40 -08:00
Berthold Stoeger
0ea5374f62 profile: move connect() calls to profile
The mainwindow was connecting preferences changes to the profile.
Do this directly in the profile.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-12 15:52:40 -08:00
Berthold Stoeger
41751a5899 cleanup: remove unused signal ProfileWidget2::updateDiveInfo
Last user was remove in 0bd821183d.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-12 15:52:40 -08:00
Berthold Stoeger
3b2ae46eb8 profile: move DiveHandler to profile-widget folder
These are the small dots that describe dragable points on
the profile when in the planner. It makes no sense to have
them in desktop's planner-widget code. They belong to the
profile.

Therefore, move the code there and compile on mobile.

Not everything can be compiled on mobile for now, but it
is a start.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-12 15:52:40 -08:00
Berthold Stoeger
cd33d88768 cleanup: remove unused macros in diveplanner.cpp
Clearly, these are artifacts.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-12 15:52:40 -08:00
Berthold Stoeger
674c20227b profile: call clearHandlers() in setPlanState()
This function, which removes the handlers from the profile, was called
in setAddState() but not in setPlanState(). In the latter case it was
called explicitly by the caller.

Move the call from the caller into the function. This allows us to
make clearHandlers() private in to the profile widget.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-12 15:52:40 -08:00
Berthold Stoeger
bb76cb56d4 desktop: move planner-code to diveplanner.cpp
Around 2015 there was a push to move planner UI code from
mainwindow.cpp to diveplanner.cpp. That never was completed,
presumably because the planner is actually three widgets.

Collect these widgets in one PlannerWidgets class and move
the code there.

This is not a full dis-entanglement, as the plannerwidgets
have to access the profile via the mainwindow. But at least
it collects the planner UI code at a single place.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-12 15:52:40 -08:00
Berthold Stoeger
16f86f2f65 desktop: use getDiveSelection to access selected dives
In the list view two functions were still manually collecting
the selected dives. Use getDiveSelection() there as well.

Careful: that means that the check for dives that are already
outside of a trip now has to be done in the RemoveDivesFromTrip
command.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-12 15:52:40 -08:00
Berthold Stoeger
369c5b0dc6 desktop: init dive list header actions in constructor
The main window called a function to init the header actions
(i.e. the context menu) of the dive-list. There is no reason why
this shouldn't be done in the constructor of the dive list, since
it only accesses the QSettings, which are available at application
startup. This improves modularity of the code (by a tiny, tiny bit).

Moreover, the initialization function was at the same time the
header-reloading function. That function can now be folded
into the settings-changed function, since that is the only
remaining user.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-12 15:52:40 -08:00
Berthold Stoeger
712e4680ca preferences: connect() dialog page only once
Weirdly, the settingsChanged() signal of the dialog-pages was
connected() to the settingsChanged() signal of the dialog
every time the settings were accepted. Do it only once
in the constructor.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-12 15:52:40 -08:00
Berthold Stoeger
0fab09a990 preferences: don't remove/add pages in refreshPages()
This function was called when opening the preferences dialog
to update all the pages with the current preferences.

For unknown reasons it also removed / readded all the pages.
Remove that code and use the now leaner function when refreshing
the pages.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-12 15:52:40 -08:00
Berthold Stoeger
f3a2ee8082 preferences: sort pages only once
After each addition of a page in the constructor, the list was
resorted. This appears pointless. Instead, sort the list only
after all pages were added.

Since the add-page function is now a single line, remove it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-12 15:52:40 -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
Berthold Stoeger
8bbd778c28 cleanup: remove unused PreferencesDialog::emitSettingsChanged()
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
11eec0a503 Fix cylinders in printing templates
These did not appear in our templates. With this commit,
there are two lists to iterate over, cylinders and
cylinderObjects:

cylinders has just one property: description which is a string
summarizing cylinder information

cylinderObjects has the individual properties addresable

This also fixes a bug when the iterator variable did not
have the singular name of the list it iterates over.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-12-08 21:46:10 -08:00
Berthold Stoeger
a23c3d0bb1 cleanup: remove unnecessary includes from divepicturewidget.cpp
Also, use finer-grained Qt includes instead of the full QtWidgets
include.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-03 10:32:20 -08:00
Berthold Stoeger
7e8636d7be cleanup: remove unused function in templatelayout.cpp
This was removed with grantlee.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-26 21:45:17 +01:00
Berthold Stoeger
71389cfa92 cleanup: remove empty function MainTab::reload()
This used to reload the completion models. Moreover, remove two
obsolete member-function declarations.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-14 10:01:50 -08:00
Berthold Stoeger
38a784f5af desktop: automatically reload completion-models
Instead of programatically reload the completion models, listen
to the relevant signals in the models. To that goal, derive all
the models from a base class.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-14 10:01:50 -08:00
Berthold Stoeger
b390fb368d desktop: update completion models if dive was edited
In the main-tab, when changing tag, buddy or divemaster,
update the corresponding completion model.
This is a quick-fix and the wrong thing to do. It works only
if the currently shown dive is changed, which is not a given.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-12 11:22:12 -08:00
Berthold Stoeger
0272f118ae printing: properly initialize DPI value
The DPI value in the print_options structure was never initialized.
This could lead to random DPI values and crashes. How this ever
worked is a mystery.

Therefore, read and write the DPI value from the settings just
as the other print-options. And initialize the corresponding dialog
widget to this value.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-12 11:20:54 -08:00
Dirk Hohndel
58ea215881 desktop: minor tweak for dark modes
This ensures that the BT/BLE devices are legible, regardless of light or dark
mode.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-11-07 15:23:53 -08:00
Berthold Stoeger
41c0fb4039 filter: don't escape '&' in filter-preset menu
When constructing an action, '&' is used as the keyboard shortcut
marker. Since this mangles preset names, use the setIconText()
function of the action instead.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-07 14:08:39 -08:00
Berthold Stoeger
5caac4c480 filter: don't render filter preset name as HTML text
QLabels must be explicitly set to not accept HTML input.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-07 11:37:51 -08:00
Berthold Stoeger
396598430b desktop: fix saving of column-widths of device and site tables
Qt's memory management scheme is completely broken and messes
with common expectations.

QObjects are organized as a tree. The children are destroyed
in the destructor of QObject. This means that they are destructed
after the destructor of the parent object has run and its
sub-object were destructed. Obviously, this makes no sense as
the child objects should be able to access their parent at
any time.

To restore the commonly expected deterministic order of
construction and destruction, one might simply do away with
Qt's silly object tree and organise things using classical
subobjects. However, that breaks with the Qt-generated UI
classes: The objects generated by these classes are *not*
destructed with the UI class. Instead, they are attached
to the widget's QObject tree. Thus these are again destructed
*after* the widget! Who comes up with such a scheme?

In our case this means that we cannot have models used for
TableViews as subobjects, because the TableView needs the
model to save the column widths in the destructor. Which,
as detailed above is called *after* the desctructor of the
widget! Thus, turn these models into heap-allocated objects
and add them to the QObject tree.

Funilly, this exposes another insanity of Qt's QObject tree:
Children are destructed in order of construction! One would
expect that if objects are constructed in the sequence
A, B, C one can expect that C can, at any time, access B and A.
Not so in Qt: The destruction order is likewise A, B, C!

Thus, take care to init the widgets before the model. Jeez.

Finally, print a warning in the column-saving code of
TableWidget, so that these kind of subtleties are caught
in the future.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-07 11:37:51 -08:00
Berthold Stoeger
291768b63c desktop: rename table widget in DiveComputerTab to "devices"
The custom TableView widget saves the table width on destruction.
For that, it uses the "objectName()". Since the table of the
DiveComputerTab was simply called "table" in the UI file, the
widths were saved in that generic section. To avoid future
name-conflicts, rename the widget to "devices".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-07 11:37:51 -08:00
Berthold Stoeger
68b63534a3 desktop: maximize size of last column in filter-preset table
This was just ugly: the column with the "trash" symbol and the
name had the same size. On creation of the object, make the last
column expand and adapt the size of the "trash" column according
to its content.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-07 11:37:51 -08:00
Dirk Hohndel
be3190db8a revert preference settings for title color
Because of subsequent changes there is no clean way to just revert the changes
introduced in commit 8b36cf1051 ("desktop: offer different colors for info tab
titles"), so this manually removes the parts we don't need anymore.

This also restores a tooltip value that was inadvertantly removed in that
commit.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-11-04 14:51:55 -08:00
Dirk Hohndel
6201ac34b4 desktop: automatically pick a good theme title color
The preference setting seemed far too strange to do this. And not very user
friendly. So instead we figure out if this is a dark theme or not by looking at
text and background colors in the palette, and make sure we get notified if
that changes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-11-04 14:47:10 -08:00
willemferguson
335d3f9c07 Reorganise the current statistics tab
As the title above says....

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2020-11-04 11:34:26 -08:00
Dirk Hohndel
814cda7183 desktop: generalize the colorization of the tab widget
Instead of doing it just for the Information tab, do it for all of the tabs.
There's still room for improvement. But this certainly feels more consistent.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-11-03 23:08:39 -08:00
Dirk Hohndel
7d18a525f1 desktop: allow update of tab widget colors at run time
Adding a new virtual function to all of these classes may seem like overkill,
but of course the idea is that likely we'd allow similar changes to all of
them.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-11-03 23:08:39 -08:00
willemferguson
8b36cf1051 desktop: offer different colors for info tab titles
Add a preference option to set the color of the text on the information tab to
either MediumBlue, LightBlue or Black. The last two of these colors are meant
to enable areadable font contrast on displays with dark mode.
The choice is saved with the other preferences.

[Dirk Hohndel: this isn't really about dark mode, so changed many of the types
	       and variable names, changed the user visible texts, and
               addressed some whitespace issues]

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-11-03 23:08:39 -08:00
Doug Junkins
e6956b9d57 desktop: add label to dive computer table
There was no "title" property on the dive computer table which
was causing an default label of "GroupBox" to appear above the
table. Added a title property to clean up the UI.

Signed-off-by: Doug Junkins <junkins@foghead.com>
2020-10-29 15:00:20 -07:00
Doug Junkins
6dccce21da desktop: use default colors for dive info labels
Removed the style change to force a style change for the labels on
the dive information page to Medium Blue. This makes labels more
readable in MacOSX dark mode since the default style changes colors
when the mode is shifted from light to dark or vice versa.

Signed-off-by: Doug Junkins <junkins@foghead.com>
2020-10-29 15:00:20 -07:00
Berthold Stoeger
7c70459f6c cleanup: remove unnecessary includes from maintab
These are artifacts from when the maintab contained more stuff.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-28 11:27:58 +01:00
Berthold Stoeger
49fc05de7e desktop: move MinMaxAvgWidget to TabDiveStatistics
This is its only user and the widget is scheduled for removal.
Let's move it there temporarilly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-26 20:56:56 -07:00
Berthold Stoeger
ab94956759 cleanup: remove dive.h include in simplewidgets.h
Let's simply forward declare the needed structures.
Also removes removes two more unnecessary includes.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-26 20:56:56 -07:00
Dirk Hohndel
f193c2ef08 cleanup: fix deprecated QVector constructor
Annoyingly, the replacement has only been available since Qt 5.14.
To make the code less messy, implement our own stdToQt conversion helper.

Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26 19:27:03 -07:00
Dirk Hohndel
c5eaac122e cleanup: remove reference to deprecated enum value
This had been deprecated for quite a while.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26 19:27:03 -07:00
Dirk Hohndel
bbf76f9ee7 cleanup: don't initialize flags with just an integer
This is slightly different from the previous cleanup around QFlag use as this
one is related to QtWebKit flags. But the logic is the same.
Just syntax to avoid a warning.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26 19:27:03 -07:00
Dirk Hohndel
d58c962bdb cleanup: replace deprecated signal
Again, the replacement was only implemented in Qt 5.14, so more conditional
code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26 19:27:03 -07:00
Dirk Hohndel
ffecc00f42 cleanup: SkipEmptyParts syntax has changed
Sadly, the new enum has only been available since Qt 5.14, so this is a rather
ugly replacement.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26 19:27:03 -07:00
Dirk Hohndel
f8f83a9986 cleanup: model isn't used in the lambda
Simply cleaning up a warning.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26 19:27:03 -07:00
Dirk Hohndel
c5fcdfae30 cleanup: remove obsolete connections
Not sure how this even ended up in this .ui file.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26 19:27:03 -07:00
Dirk Hohndel
ea4e83fead cleanup: fix deprecated role
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26 19:27:03 -07:00
Dirk Hohndel
5aaff77b9e cleanup: replace deprecated use of child member
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26 19:27:03 -07:00
Dirk Hohndel
87563eb404 cleanup: fix deprecated form of QProcess::start
You are now required to always provide a list of arguments.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26 19:27:03 -07:00
Dirk Hohndel
f871b8dfac cleanup: fix deprecated QFlags use
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26 19:27:03 -07:00
Berthold Stoeger
e7b56c2d31 filter: use 64-bit integer literal for generating bit fields
For multiple-choice constraints we use a bit field of type
uint64_t. This means we theoretically support up to 64 items.
Currently use at most seven.

Coverity complained (correctly) that we use the expression
"1 << x" to generate the bitfields. However 1 is a 32-bit
literal on most platforms, which makes this undefined
behavior for x >= 32. Change the integer literal to 64-bit
1ULL.

Moreover, when detecting items with an index >= 64, don't
even attempt to set the according bit, since this is
undefined behavior and the compiler is free to do as it
pleases in such a case.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25 16:23:46 -07:00
Berthold Stoeger
4aa571d5a0 cleanup: remove get_times() functions
The function
1) was misnamed: it determined the time of the first selcted dive.
2) had only one caller.
3) would crash if there was no selected dive.

Let's just fold the functionality into the caller. It's a one-liner
anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25 13:59:52 -07:00
Berthold Stoeger
c263487e7c cleanup: remove MainWindow::setFileClean()
This function was used to unify both methods of tracking unsaved
changes. Since desktop now only uses the undo system, it can
be replaced by a single call to "Command::setClean()".

Arguably, the UI is the wrong place to do this and the appropriate
calls should be done by the core. However, let's play it safe
for now and avoid any breaking change.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25 13:59:04 -07:00
Berthold Stoeger
fa6235d035 cleanup: remove MainWindow::unsavedChanges() function
This function was used to unify both methods of checking for
unsaved changes: the global unsaved_changes() flag and the
Command::clean() function of the undo-system.

However, all desktop functions are now undoable and therefore
the function is not needed and can be replaced by calls
to !Command::clean().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25 13:59:04 -07:00
Berthold Stoeger
8a20d019c2 desktop: remove DiveComputerManagementDialog
This is now done in a TabWidget with undo-support.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25 13:59:04 -07:00
Berthold Stoeger
c6188bbe47 devices: connect DiveComputerModel to undo-command
Instead of modifying the device table directly, call the undo
commands. Moreover, don't keep our own copy in the mode - show
the original version. Connect to the appropriate signals.

This means that the calls from the DiveComputerManagement
dialog have to be removed, since this mode of editing is
not supported. The whole dialog will be removed in a future
commit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25 13:59:04 -07:00
Berthold Stoeger
fa7dfa3710 desktop: add tab-widget for dive computer names
If we want to include dive computer names in the undo system,
there should be visual feedback on undo/redo.

This would mean opening the divecomputer dialog, which would
appear quite strange. Therefore, add a tab. This is not ideal,
but consistent with the dive site tab, which probably shouldn't
be there either. In the future, the UI needs some rethinking.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25 13:59:04 -07:00
Berthold Stoeger
39a4090c0a devices: add devices in Command::importTable()
Add a device_table parameters to Command::importTable() and
add_imported_dives(). The content of this table will be added
to the global device list (respectively removed on undo).

This is currently a no-op, as the parser doesn't yet fill
out the device table, but adds devices directly to the global
device table.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24 09:51:37 -07:00
Berthold Stoeger
a261466594 parser: add device_table to parser state
If we want to avoid the parsers to directly modify global data,
we have to provide a device_table to parse into. This adds such
a state and the corresponding function parameters. However,
for now this is unused.

Adding new parameters is very painful and this commit shows that
we urgently need a "struct divelog" collecting all those tables!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24 09:51:37 -07:00
Berthold Stoeger
41975435a2 cleanup: remove TagWidget::fixPopupPosition()
No user of that member function!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24 09:50:39 -07:00
Berthold Stoeger
d543196059 desktop: overwrite drag & drop in TagWidget
The interaction of Qt's drag & drop with GroupedLineEdit was
exceedingly weird. The user was able to scroll the viewport
making the text invisible.

This implements a very primitive alternative drag & drop
functionality: dropped text is regarged as a distinct tag.
This means that it is not possible to modify existing tags
by dropping in the middle of them. Arguably, this might even
be better than arbitrary drag & drop. But even if not perfect,
this fixes a very nasty UI behavior.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24 09:49:36 -07:00
Berthold Stoeger
a9a4249b23 desktop: avoid crashes on drag&drop in GroupedLineEdit
If the user manages to "scroll" through the QPlainTextEdit by
a drag&drop action, the state of the widget becomes inconsistent.
On the one hand, the text-block says that it has one line.
On the other hand, its layout says that it has no line.
When trying to fetch the line, a crash occurs.

Try to detect such a strange state and return early in
GroupedLineEdit::paintEvent().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24 09:49:36 -07:00
Berthold Stoeger
d508a16aca parser: replace params[] code by new xml_params struct
This fixes a load of memory holes, and makes the code
(hopefully) more readable.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-23 18:17:02 -07:00
Berthold Stoeger
ad608e48f5 filter: don't add to filter presets when importing dive sites
When importing dive-sites we would add to the global filter-preset
table. This data should be thrown away, just like the other tables
that might be imported.

This shows that we really should introduce a "struct divelog",
which collects all those tables into a single structure.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-17 09:04:20 -07:00
Berthold Stoeger
a7bbb6c1cc filter: remove filter_preset_table_t
We used a typedef "filter_preset_table_t" for the filter preset table,
because it is a "std::vector<filter_preset>". However, that is in
contrast to all the other global tables (dives, trips, sites) that we
have.

Therefore, turn this into a standard struct, which simply inherits
from "std::vector<filter_preset>". Note that while inheriting from
std::vector<> is generally not recommended, it is not a problem
here, because we don't modify it in any shape or form.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-17 09:04:20 -07:00
Berthold Stoeger
215e5a4544 desktop: make divecomputer table sortable
Add a small proxy-model on top of DiveComputerModel so that clicking
on table headers makes the table sortable.

The UI feature here is not as important as the fact that the UI does
its own sorting and we can keep the device-table in the core sorted
differently.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-11 08:35:20 -07:00
Dirk Hohndel
7f896ee8d5 build-system: remove building Grantlee cmake
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-08 12:19:39 -07:00
Robert C. Helling
51c84b3c44 Remove code references to Grantlee
These are no longer needed. What is still missing is removing Grantlee from the
various build systems.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-08 12:19:39 -07:00
Robert C. Helling
c9106b9dbe Interpret divelist printing templates
This is a first step of an efford to get rid of the Grantlee dependency. This
implements template processing for those constructs used in our divelist and
statistics printing templates.

It implements a template parser for loops over dives, cylinders and year and
variable replacement. As the previous Grantlee code, it does not really use
Qt's QObject introspection capabilities but reuses the old long chain of
if-else-statements.

The grantlee code is not yet removed.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-08 12:19:39 -07:00
Berthold Stoeger
6e6705fb6e cleanup: use safe connect() in ConfigureDiveComputerDialog
The pointer-to-member-function version is compile-time checked
and therefore less risky with respect to refactoring.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-06 10:38:45 -07:00
willemferguson
a3e990dfd5 Remove empty vertical space from filter QListWidget
In the filter the dropdown lists for selecting dive mode or day-of-week
has a lot of white space at the bottom. This PR removes that white space.
Actually the white space at the bottom of a QListWidget appears to
be a known bug (actually an omission) for the current Qt V15. The above
solution is a brute-force workaround to achieve the same end result.
The active line is actually the setFixedSize(). The other line, however,
comprises good QT layout policy to minimise widget size.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2020-10-05 13:36:29 -07:00
Berthold Stoeger
468eb7ef33 clenup: remove bogus connect statement.
In OstcFirmwareCheck::saveOstcFirmware() we find the connect() call
    connect(dialog, SIGNAL(finished(int)), config, SLOT(dc_close()));
whereby "config" is of the type "ConfigureDiveComputer".
However, the function signature of ConfigureDiveComputer::dc_close
reads as
    void dc_close(device_data_t *data);
and indeed "data" is accessed inside the function. I don't understand
how this doesn't crash, but clearly something is amiss.

Let's remove that connect statement.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-05 12:39:16 -07:00
Berthold Stoeger
61f8b8c002 planner: limit depth and time of segments to sane values
Using non-sensical depth and times for segments in the planner may
lead to an unresponsive UI. Therefore limit depth to 1000 m/3300 ft
and time to 100 h. Limiting of depth is done in settingsChanged()
since it has to adapt to the user changig their preferred units.

Fixes #2762.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-03 16:19:04 -07:00
Berthold Stoeger
00abc04913 cleanup: use getDiveSelection() to loop over selected dives
getDiveSelection() returns a vector of the selected dives.
Use that instead of looping over the dive table and checking
manually.

This removes a few lines of code.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-03 10:01:13 -07:00
Berthold Stoeger
7b196a5ef9 desktop: allow moving dives to arbitrary trips
The UI only allowed adding dives to trips above or below the
current dive (and even that is buggy). This is a strange
restriction, since trips are designed to be non-contiguous.

Allow adding dives to any trip using the new trip selection
dialog. The undo-command is already there, so only little
code to write.

This feature was requested on the mailing list.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-03 10:01:13 -07:00
Berthold Stoeger
f5fe6839c7 desktop: add trip selection dialog
A simple dialog to select a trip. Simply fill a QListWidget without
the model/view rigmarole. So much less painful! Of course that means
that the dialog has to be regenerated everytime it is used.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-03 10:01:13 -07:00
Berthold Stoeger
06c35026d6 desktop: fix paging through dive list with page-up key, etc
In the dive list we have horrible code, which intercepts all events
to save the selection before/after the event. This was necessary
because we couldn't get Qt's selection data flow under control.

This means intercepting all events that can change the selection.
The page-up, page-down, home and end keys were forgotten. Add these
cases.

Fixes #2957.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-02 11:10:28 -07:00
Berthold Stoeger
7337ff386b cleanup: rename FilterWidget2 to FilterWidget
The name "FilterWidget2" is historical and has no meaning anymore,
since the current version has little to nothing to do with the
"second" version of the widget.

Rename the class and source files accordingly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:14:31 -07:00
Berthold Stoeger
76cf251e59 filter: avoid unnecessary filter recalculations when loading set
When loading a stored filter set, we would get numerous
constraintChanged signals, which caused filter recalculations.
Use the ignoreSignal flag to prevent these.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Berthold Stoeger
cd27e36b8f filter: add modified flag
When editing the filter, the modified flag is set and shown to the
user. After saving / loading / clearing the filter, the flag is
reset. This simulates (probably badly) a usual load/save interface.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Berthold Stoeger
1ed61aeabf filter: show currently selected preset in a text field
This provides some visual feedback on the currently selected preset.
Update when changing selection or clearing the filter.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Berthold Stoeger
cccd242a36 filter: when clearing the filter unselect the current filter preset
It makes no sense to have the a filter preset selected after
clearing the filter.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Berthold Stoeger
d064f78608 filter: when a filter preset is selected, suggest its name on save
The goal here is to let the user edit already existing sets and
save them using their old name. This is a stop-gap measure until
we get a proper filter-set editing interface.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Berthold Stoeger
f9721fce4b filter: implement importing of filter presets
When importing a divelog, import filter presets. If there are
equal names, import only if the presets differ. In that case,
disambiguate the name. This made things a bit more complicated,
as comparison of filter presets had to be implemented.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Berthold Stoeger
631be569fe cleanup: forward declare QHideEvent and QShowEvent
Don't include the respective header files in filterwidget2.h

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Berthold Stoeger
38b686687f cleanup: move shown-text calculation from filter widget to core
The filter widget was caching whether the filter was active and
used that flag to calculate the "# dives shown" string. Move this
directly to the DiveFilter class to remove interdependencies and
to unify with mobile.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Berthold Stoeger
68fffc2672 filter: add completer for save-filter-preset dialog
Thus, the user can easily overwrite already existing settings.
Not perfect, but the easy solution for now.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Berthold Stoeger
41cf83583d filter: load filter presets from XML files
This is a bit painful: since we don't want to modify the filter
presets when the user imports (as opposed to opens) a log,
we have to provide a table where the parser stores the presets.
Calling the parser is getting quite unwieldy, since many tables
are passed. We probably should introduce a structure representing
a full log-book at one point, which collects all the things that
are saved to the log.

Apart from that, this is simply the counterpart to saving to XML.
The interpretation of the string data is performed by core
functions, not the parser itself to avoid code duplication with
the git parser.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Berthold Stoeger
142f76374c filter: add filter preset table
Add a table view that shows all presets and a button to delete
old presets. When clicking on an item, load the preset.
When the filter is reset, deselect any item.

Change the preset-loading code: instead of simply loading the
preset, select the preset in the table. Thus, it will be loaded
implicitly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Berthold Stoeger
c6bd2a7ffb filter: connect load filter preset functionality to ui
Add a button to the filter preset widget that allows the
user to load a previously saved filter preset.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Berthold Stoeger
581eb1f563 filter: create a primitive "create filter preset" dialog
The dialog asks the user for a name and warns if the name
already exists, i.e. an old filter preset will be overwritten.
Possibly, this should contain an auto-completion facility in
the case that the user wants to overwrite old presets.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Berthold Stoeger
6c443ba841 filter: connect new filtercode to filterwidget2
Replace the static filterwidget with a list of filterconstraints.
The first attempt of using a table widget failed, because Qt's
table delegates are dysfunctional. It's not that they are bad, they
just don't work at all.

Therefore, this code "simulates" a table in that on addition / deletion
of constraints it keeps track of the rows of all constraints so
that each constraint-widget can be associated with a row of the
constraint model.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Berthold Stoeger
c0af74ba88 filter: add a filter constraint widget
This add a widget that represents a single filter constraint. Since
filter constraints are very general, the widget has to consider a
number of cases:
- numerical ranges
- star-widget ranges
- string lists
- multiple choice lists
Moreover, it supports units, which must be updated when the preferences
change.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Berthold Stoeger
eb22c0205e cleanup: remove unnecessary includes in divelistview.cpp
Most of these became unnecessary when including media in the
undo system.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 14:12:56 -07:00
Berthold Stoeger
9d3b15bf9c translations: initialize water type strings at run time
The water type strings were static and therefore passed through
gettextFromC::tr() before main(). One would hope to get a warning
in such a case, but this is not the case.

Therefore, use the QT_TRANSLATE_NOOP macro to register the strings
in Qt's translation system and translate the list when needed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-21 13:42:00 -07:00
Dirk Hohndel
efdff9fd87 desktop: fix TableView for Qt 5.15
If we set the size on the QPushButton, the button no longer receives any input
(tested on macOS). With this change we get an odd visual artifact when clicking
on the 'add' button, but it least it works, so this is good enough for the next
release.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-09-13 13:55:46 -07:00
Robert C. Helling
3426c6440c Disable SAC factor setting for CCR dives
The SAC factor is only used for minimal gas calculations which
don't make sense in the CCR context.

Additionally, make bailout stop for at least minimum switch
time or problem solving time.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-09-13 13:51:07 -07:00
Berthold Stoeger
762c5276fd cleanup: remove empty files in desktop-widgets/statistics
This functionality never came to be and there are fundamentally
different plans floating around. Therefore, remove these empty
files.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-12 08:36:10 -07:00
Berthold Stoeger
fbd2160af2 desktop: make completion of equipment types substring search
User request: when entering a cylinder type, do a substring
search. For example, when entering "100" also find "AL100".
Currently, a starts-with search was used.

This is simply done by setting the "filterMode" of the
ComboBoxDelegate to "Qt::MatchContains".

Suggested-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-10 08:58:03 -07:00
Berthold Stoeger
0424ee8996 cleanup: when planning a dive, set dive computer to first dc
When planning a dive, dc_number was set to 1, which actually is
the second dc! The code seems to handle this gracefully, however
it appears weird. Let's set dc_number to 0 instead.

Originally, the assignment was introduced in a422957cd6
and moved later in 4f5621c4c6.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-08 17:20:09 -07:00
Berthold Stoeger
ee2f466470 cleanup: use taxonomy_get_value() instead of taxonomy_get_index()
Instead of getting the index and using that to access values, use
the taxonomy_get_value() helper function. Two places are affected:
1) reverse geo-lookup
2) location filter delegate

The behavior of reverse geo-lookup is changed slightly: now an
empty string is likewise recognized as missing "TC_ADMIN_L3".
Before, only a missing category was interpreted as such.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-06 12:59:54 -07:00
Michael Werle
d404aa767f [Bug #2934] Geo Lookup - support for remote dive sites
Some remote dive sites have no populated places (towns, cities)
nearby. For such sites, we now fall back to looking up
unpopulated place names, such as the reef or island name.

Also some code refactorisation:
the actual network access is now encapsulated in its own
function removing some duplicated code handling in the
reverseGeoLookup function and making it more readable.

Furthermore, reverseGeoLookup() was completely refactored as
most of its functionality was due to legacy requirements; the
current code-base only calls this function from a single
location and only with an empty taxonomy_data object. This
makes the function more focussed and much simpler and more
readable.

Finally, a resource leak in reverseGeocde introduced in
4f3b26f9b6 was fixed.

Signed-off-by: Michael Werle <micha@michaelwerle.com>
2020-09-05 17:34:15 +02:00
Robert C. Helling
52aa7d83b6 Increase event icon size in print mode
When plotting the profile in higher resolution for export,
increase the icon size in the same way.

This is commented out for the mobile version as that
uses printMode for profile display.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-09-03 11:46:18 -07:00
Robert C. Helling
c6fa415880 Improve resolution of profile export
The way we export the profile image (as direct export but
also used for printing) is that we render the profile
from the screen to a Pixmap and save that to a file. Unfortunately
this results in very bad resultion and a blurred image.

This is an attempt to improve that situation but it's still far
from perfect: Rather than a QPixmap and grab, I now use a QImage
(where I can set the size) and render, and indeed the picture resolution
(when vied at fixed size) get's better this way. The disadvantage
is that icons get smaller at the same rate und so
there is a natural limit on how big we can get. Maybe somebody
with better Qt knowledge can take off from here. In my opinion
this is already a step in the right direction.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-09-03 11:46:17 -07:00
Robert C. Helling
8f6d054140 Set printer resolution
You need a better resolution to plot a picture with high resolution...

Connection done with a lambda expression thanks to @dirkhh.

Signed-off-by: Robert C. Helling <helling@atdotde.de> (+1 squashed commit)
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-09-03 11:46:16 -07:00
Michael Werle
37ae5a7d83 [Bug #2930] Fix crash bug in LocationInformationWidget
If a user exits the LocationInformationWidget (Edit  Dive Site)
while a reverseGeocode lookup is in progress, the object's
diveSite variable is set to null.

When the reverseGeocode lookup completes, this variable is
dereferenced causing an application crash.

Signed-off-by: Michael Werle <micha@michaelwerle.com>
2020-09-03 08:59:08 +02:00
Robert C. Helling
7e82205e9b Planner: Properly initialize salinity
When the dive has no explicity salinity, our conversion
between pressure and depth assumed salt water. Make this
explicity by using the corresponding macro.

When the planner starts and no salinity is set explicity,
set the water type chooser to salt water to reflect
our default assumption.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-09-02 09:43:38 -07:00
Robert C. Helling
6ad55cd63b cleanup: fix compiler warning
... at least for llvm.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-24 08:31:38 -07:00
Dirk Hohndel
c5b1fd9f53 core/BLE: don't insist on pairing of pure BLE devices
Most (all?) BLE dive computers actually don't need to be paired, and some
apparently can't be paired. So let's not enforce that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-22 19:35:58 -07:00
Gaetan Bisson
56c6cd06c9 Fix includes for building against Qt-5.15
Signed-off-by: Gaetan Bisson <bisson@archlinux.org>
2020-06-13 14:00:05 +02:00
Berthold Stoeger
bed64f20ba cleanup: remove QCalendarWidget forward declaration and include
This is an artifact of code that never came to be.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-27 13:55:08 -07:00
Berthold Stoeger
330b300f22 cleanup: unglobalize grayImage()
This function was globalized in be462ae1a6 to be used for the calender
widget, but that never came to be. Therefore, for now unglobalize it
until it is needed. That said, there probably is a helper function to
turn pictures into gray-scale.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-27 13:55:08 -07:00
Berthold Stoeger
7417f865cd cleanup: un-singletonize ShiftTimesDialog
There is no reason that this dialog is a singleton. Since it is modal,
it can be created on demand. Apart from removing superfluous global state,
this simplifies code, because preparing the widget can now be done in
the constructor instead of overriding the showEvent() function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-27 09:47:35 -07:00
Berthold Stoeger
25f1bc488f cleanup: un-singletonize RenumberDialog
There is no reason that this dialog is a singleton. Since it is modal,
it can be created on demand. This simplifies code, because the mode
(selected-only or all-dives) can be set in the constructor.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-27 09:47:35 -07:00
Berthold Stoeger
891c0e7ec6 cleanup: whitespace fixes in TabDiveInformation
Use C-style function definitions (squirly brackets on new lines) and
remove empty lines at end of file.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-25 08:33:08 -07:00
Berthold Stoeger
2d17edeb40 desktop: localize salinity value
The salinity value was not displayed with localized thousands separators.
E.g. to a user of a German locale the density read as slightly over
1 g/l, when it should be approximately 1000 g/l. For consistency, also
localize that value.

Also localize the CNS and OTU numbers, even though these should
(hopefully!) never come with thousands separators.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-25 08:33:08 -07:00
Berthold Stoeger
8f80129bac cleanup: create common QDateTime -> timestamp conversion function
In analogy to the timestamp -> QDateTime conversion, create a
common function.
1) For symmetry with the opposite conversion.
2) To remove numerous inconsistencies.
3) To remove use of the deprecated QDateTime::toTime_t() function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-22 12:31:06 -07:00
Berthold Stoeger
f63485b444 cleanup: move timestampToDateTime() to qthelper.cpp
Move this function from maintab.cpp to qthelper.cpp. Since the
functionality was used in numerous places, use the helper function
there as well. This removes a number of inconsistencies. For example,
sometime setTimeSpec(Qt::UTC) was called, even though the
QDateTime object was already created with that time spec.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-22 12:31:06 -07:00
Berthold Stoeger
00ff63f186 desktop: update date and time fields if user changes format
This was more painful than expected, because we get the "preferences"
changed signal too early when the user switches to system format.
The correct format is set by the preferences-widget, not the preferences
subsystem.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-22 10:00:43 -07:00
Berthold Stoeger
fb1cf8d0e5 desktop: refresh date/time format when switching to system defaults
When switching to system defaults, refresh the fields in the preferences
UI so that the user can tell how the fields will be formatted.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-22 10:00:43 -07:00
Berthold Stoeger
1777df405f desktop: don't call plotDive with doClearPictures = true
This was an old "optimization" to avoid double plotting of the
pictures, first by the profile itself, then by the picture tab.
Since the profile now updates the pictures itself, this must
be removed: The picture tab doesn't do it anymore.

Fixes #2833

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-16 10:10:30 -07:00
Berthold Stoeger
27505aedfb cleanup: use pointer-to-member style connect for ComboBoxDelegate
This was still using the archaic macro version, because Qt decided
to parameter-overload the signals (which turned out to be a horrible
idea). However, since we switched to fairly recent Qt this can be
solved using the qOverload template.

In this case things are a bit more complicated because we overload
the corresponding slots. Since we have control over that, let's
just disambiguate their names instead of using the cryptic qOverload.

While doing this, tighten the access specifiers of the slots. Turn
public into private and protected as appropriate.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-16 10:09:35 -07:00
Berthold Stoeger
fc6d99eb93 cleanup: make overridden functions in model delegates private
There is no point in calling these functions directly, so we can
just make them private. Morover, add override specifiers were they
were missing and remove a pointless default parameter to the
testActivation() function. It was not used anywhere.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-16 10:09:35 -07:00
Berthold Stoeger
d85f92c5df cleanup: whitespace fixes in modeldelegates.[cpp|h]
We put the pointer and reference modifier to the variable, not the
type. Some people don't like this, but
1) This is consistent with the rest of the code base.
2) This is how C and C++ parse, love it or hate it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-16 10:09:35 -07:00
Dirk Hohndel
658089d763 core/bt: match DC descriptor in lower case
This fixes a rather subtle bug.

In btdiscovery.cpp we are detecting dive computers based on their BT name and
are setting up product+vendor as the key for that lookup. QMap always uses case
sensitive comparisons and a tiny inconsistency snuck into our code.
libdivecomputer names for the Aqualung dive computers i200C / i300C / i550C end
in an upper case C (as matches the official branding), but in btdiscovery.cpp
we have those names with lower case c. And therefore didn't recognize these
dive computers.

Obviously this is easy to fix by fixing those three strings, but I decided that
it was silly to set ourselves up for similar oversights in the future. So
instead I switched the matching of the descriptor to simply be allways all
lower case.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-15 02:49:46 +03:00
Dirk Hohndel
9815024199 add Berthold to the list of explicitly mentioned developers
Number 3 overall committer with currently 9% of total commits and 27% of all
commits in the last three years.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-09 17:21:43 -07:00
Berthold Stoeger
ce7cc79705 desktop: hide/unhide tags if dive site was edited
The tags of the dive site were shown/hidden when changing the
current dive.

Thus the following could happen:
1) User changes to dive with no tags. Tags are hidden.
2) User add image, which creates GPS tag
3) Tag is updated but not shown.

Fix this by showing/hiding tags when they are calculated not
when switching the dive.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-08 08:51:37 -07:00
Berthold Stoeger
1c590783e0 cleanup: free tab-widgets when exiting the application
This is completely irrelevant, however out of principle,
let's free the tab-widgets at the end of the application.
To do so, use Qt's object hierarchy. I'm not a fan of this
kind of memory management, but it is how it is.

Moreover, remove the explicit constructor of MainTab, since
it doesn't differ from the default constructor anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-07 08:56:59 -07:00
Berthold Stoeger
c139c16c03 cleanup: remove clearing of displayed_dive in MainTab constructor
Clearing displayed_dive here makes no sense for two reasons:
1) This is only called on startup, when displayed_dive is not
   yet initialized.
2) The tab-widgets don't use displayed_dive anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-07 08:56:59 -07:00
Berthold Stoeger
4ca2b8daea desktop: use current_dive to save subtitles
The old code used displayed_dive. However, virtually all the
displayed data is now derived from current_dive.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-07 08:56:58 -07:00
Berthold Stoeger
3b8b328639 desktop: use current_dive instead of displayed_dive on equipment tab
Since the displayed data is extracted from current_dive it makes no
sense to query displayed_dive for the dive mode.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-07 08:56:57 -07:00
Berthold Stoeger
532449644e desktop: update tab info only if current_dive is set
If current_dive was not set, the code would clear the tabs
right after updating the data. We might just as well set the
data only if current_dive is set.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-07 08:56:57 -07:00
Berthold Stoeger
326772cbdb statistics tab: use current_dive to decide whether user is freediving
This used the displayed_dive object. However, we now use current_dive
to designate the currently displayed dive. Thus, use this instead.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-07 08:56:56 -07:00
Berthold Stoeger
5febb534b8 DiveComponentSelection: use current_dive instead of displayed_dive
This should have been converted a long time ago.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-07 08:56:48 -07:00
Berthold Stoeger
7a443423bc cleanup: generalize ExtraDataModel to display data of any dc
The goal here is to remove a dependency on displayed_dive.
While doing so, make the model more general and display any dc.
Pass in the dc of the current dive instead of displayed dive,
since all other tabs are already converted to show data of
the current dive. The QStrings are cached since we generate
them anyway, so we may just keep them. Thus, there is no
danger of the dc becoming invalid.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-07 08:46:15 -07:00
Berthold Stoeger
1cd9229ae0 desktop: don't update models in MainWindow::refreshDisplay()
The models should now properly reset themselves if data in
the core changes.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-07 08:43:27 -07:00
Berthold Stoeger
fb6210a99a cleanup: invert control-flow when resetting the core structures
To reset the core data structures, the mobile and desktop UIs
were calling into the dive-list models, which then reset the
core data structures, themselves and the unrelated
locationinformation model. The UI code then reset various other
things, such as the TankInformation model or the map. . This was
unsatisfying from a control-flow perspective, as the models should
display the core data, not act on it. Moreover, this meant lots
of intricate intermodule-dependencies.

Thus, straighten up the control flow: give the C core the
possibility to send a "all data reset" event. And do that
in those functions that reset the core data structures.
Let each module react to this event by itself. This removes
inter-module dependencies. For example, the MainWindow now
doesn't have to reset the TankInfoModel or the MapWidget.

Then, to reset the core data structures, let the UI code
simply directly call the respective core functions.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-07 08:43:27 -07:00
Berthold Stoeger
4374605c12 undo: make adding of pictures undoable
This one is a bit hairy, because two things might happen if the
picture has a geo location:
- A dive gets a newly generated dive site set.
- The dive site of a dive is edited.
Therefore the undo command has to store keep track of that.
Oh my.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06 13:58:09 -07:00
Berthold Stoeger
74f03e3537 media: move addition of pictures out of create_picture()
If we want to make addition of pictures undoable, then create_picture()
must not add directly to the dive. Instead, return the dive to which the
picture should be added and let the caller perform the addition.

This means that the picture-test has to be adapted.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06 13:58:09 -07:00
Berthold Stoeger
434644b381 undo: make picture (media) deletion undoable
The code is rather complex. Firstly, we have different representations
of pictures throughout the code. Secondly, this tries to do add the
pictures in batches to the divepicture model and that is always rather
tricky.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06 13:58:09 -07:00
Berthold Stoeger
6f8cc5aafe Cleanup: remove DivePictureThumbnailThread
An empty class that was not used anywhere. This allows us to
remove a few include files as well.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06 13:58:09 -07:00
Berthold Stoeger
418b160731 media: remove unused local variable
TabDivePhotos::saveSubtitles() had an unused local variable.
Clearly a copy&paste oversight.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06 13:58:09 -07:00
Berthold Stoeger
91e81879a5 media: put photo-view in row-selection mode
It makes no sense to have the view in item-selection mode, since
each picture represents a row. Thus we can remove a few lines
of code.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06 13:58:09 -07:00
Berthold Stoeger
0d06eb83d8 media: don't send dive-id in drag&drop event
The profile-widget doesn't use that information anymore.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06 13:58:09 -07:00
Berthold Stoeger
4e25912fd3 cleanup: don't call updateDivePictures in MainWindow
That is already properly done by the photo-tabwidget, which displays
the pictures.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06 13:58:09 -07:00
Berthold Stoeger
c50e58d761 desktop: avoid spurious undo commands for date/time editing
The date and time fields of the main tab posted undo events
for every date/timeChanged signal. Thus, when changing the
day of the month to e.g. 21, this would result in two date
change events: one to the 2nd and one to the 21st. This is
very irritating.

Instead listen to editingFinished() events, which thankfully
exist for these widgets.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06 13:19:57 -07:00
Berthold Stoeger
9298466037 desktop: update statistics tab when cylinders changed
The cylinder-based statistics where not updated when an undo
command edited cylinder data. Do so.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06 11:44:22 -07:00
Berthold Stoeger
16a35a8bbe desktop: update information tab when cylinders change
The SAC rate, etc were only updated when switching between dives.
They should always be updated when an undo command changes (adds,
edits, removes) the cylinders of a dive.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06 11:44:22 -07:00
Monty Taylor
f37f428762 cleanup: capitalize use dc
It was suggested in a review of a previous patchset that we should
capitalize the use of "use dc" to "Use DC" - but if we were going
to do that we should do it everywhere, not just in the one place.

This is the followup to do that.

Signed-off-by: Monty Taylor <mordred@inaugust.com>
2020-05-05 10:23:18 -07:00
Monty Taylor
7a9214575e cleanup: Change Salty to Brackish
In the code, the difference between SALTYWATER and SALTWATER is hard
to see. More importantly, in the UI - Brackish is the word for water
that has more salt that freshwater but less salt that seawater. The
docs already use the word to clarify what is meant.
2020-05-05 08:25:21 -07:00
Monty Taylor
95e6792c4f Grantlee: Add salinity and water type to grantlee variables
These can be useful in a printed divelog, especially if the
log entry is also showing weight and exposure suit.

Signed-off-by: Monty Taylor <mordred@inaugust.com>
2020-05-05 17:31:47 +03:00
Robert C. Helling
36748fef0d Add conneciton for display variations checkbox
...this gat lost at some point.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-05-04 13:22:08 +02:00
Miika Turkia
05177cfc14 CSV export: include dive mode field
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2020-05-04 10:43:40 +02:00
Berthold Stoeger
4d0a200cfd planner: on printing, restore textual plan using a saved string
When printing, the dive plan was prepended with a logo, a disclaimer
and the profile. Then it was restored by setting the plan of
displayed_dive.

Instead, simply save the original plan in a QString and restore that.
This removes a further dependency on displayed_dive, which I'd like
to make local to the planner.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-04 10:42:07 +02:00
Berthold Stoeger
9bbd8b8169 desktop: remove unused if-branch in MainWindow::editCurrentDive()
MainWindow::editCurrentDive() used to be a general function to enter
edit mode. Nowadays, this is only called for one very specific case,
namely editing the profile of a manually added dive. Therefore, we
can remove the if-branch that dealt with planned dives.

Moreover, we can do the test right at the beginning and remove
a warning message for duplicate "edition", as this is not
possible anymore.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-04 10:42:07 +02:00
Berthold Stoeger
4f5621c4c6 Planner: fold MainWindow::setupForAddAndPlan into createSimpleDive()
There was only one caller of MainWindow::setupForAddAndPlan() left
and that caller immediately called DivePlannerPointsModel::createSimpleDive().
Thus, we might just as fold the former in the latter and thus
concentrate all the prepare-dive-for-plan business in one place.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-04 10:42:07 +02:00
Berthold Stoeger
62cbf26cc8 planner: send plan in calculatedPlanNotes
Thus, the MainWindow doesn't have to extract the plan from
displayed_dive. This is a tiny step in an attempt to detangle
the interfaces. The bigger goal will be to make displayed_dive
local to the planner.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-04 10:42:07 +02:00
Berthold Stoeger
f123972dbf planner: update variations in planner not mainwindow
When calculating variations, they were sent to the mainwindow,
which updated displayed_dive accordingly. Do this directly
in the planner-model.

The idea is to detangle interdependencies and to make the
code reusable (planner on mobile?).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-04 10:42:07 +02:00
Berthold Stoeger
769915f3fe selection: create global single_selected_trip() function
The DiveListView had a singleSelectedTrip function that
returns the selected trip if exactly one trip is selected.
This could be very slow if numerous non-trip items were
selected, because all the selection indices were back-
translated by the proxy model.

This could make selection changes very slow, because the
MainTab used said function to determine whether it should
show trip or dive data.. Indeed, with a 3500 dive test log,
when selecting all dives in tree mode, the updating of the
TabWidgets is sped up from 130 ms to 5 ms this commit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-03 15:02:21 -07:00
Berthold Stoeger
5147131701 selection: inform core of trip selection in DiveListView
When selecting / deselecting trips, keep the core updated.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-03 15:02:21 -07:00
Berthold Stoeger
f961ec7a8b selection: introduce clear_selection() function
The DiveListView would touch the selection-innards directly.
Let's encapsulate that. Moreover, take care to reset the trip
selection when resetting the core data.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-03 15:02:21 -07:00
Berthold Stoeger
649b2f2a9e cleanup: don't explicitly clear tabs in MainWindow::selectionChanged()
When there is no current dive, mainTab->updateDiveInfo() implicitly
clears the tabs. There is no need to call this explicitly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-03 14:47:49 -07:00
Berthold Stoeger
17556cc66c profile: don't interpret NULL as current_dive in plotDive()
ProfileWidget2::plotDive() had this weird interface, where passing
in NULL as dive would mean "show current_dive". However, most callers
would already pass in current_dive. Therefore, unify and always pass
in current_dive if the caller wants to draw the current dive.

This allows us to interpret NULL as "show empty profile". Thus,
passing in current_dive when there is no current_dive simply shows
an empty profile. This makes the calling code in
MainWindow::selectionChanged() simpler.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-03 14:47:49 -07:00
Berthold Stoeger
2829909376 profile: remove outside callers of ProfileWidget2::replot()
There was a mix of ProfileWidget2::replot() and
ProfileWidget2::plotDive(current_dive, true), which is equivalent.
Since there was more of the latter and it is more flexible, unify on
that.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-03 14:47:49 -07:00
Berthold Stoeger
d520ac2286 cleanup: remove parameter to ProfleWidget2::replot()
Firstly, the parameter appears conceptually wrong, as replot suggests
that the currently shown dive is replot. Secondly, the only caller that
passed a parameter was passing in current_dive, which is just what happens
if one doesn't pass a parameter. Therefore, change that caller (call
plotDive directly) and remove the parameter.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-03 14:47:49 -07:00
Berthold Stoeger
8f8457ebe4 desktop: ask user when quitting application while planning
We used to cancel a plan (or profile edit) when the user quit
the application while planning. This is inconsistent with
respect to closing or opening a different log, where the user
was asked for confirmation.

Thus, for consistency and to avoid loss of a planned dive,
use the okToClose() function in on_actionClose_triggered() of
MainWindow. As an added bonus, this saves a few SLOC.

Fixes #1078

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-03 14:17:47 -07:00
Berthold Stoeger
a8130f0fa1 desktop: fix editing of trips
In 2021035cfc a bug was introduced:
currentTrip of MainTab was not set in trip mode. Thus, when editing
the trip notes, the notes of all selected dives were edited instead.

Set the member variable and not a local variable.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-02 14:52:51 +02:00
Berthold Stoeger
9c70261c0e cleanup: move declaration of utc_mk* functions to new subsurface-time.h header
No point in slurping in all of dive.h for translation units that only
want to do some time manipulation without ever touching a dive.

Don't call the header "time.h", because we don't want to end up in a
confusion with the system header of the same name.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01 09:42:31 -07:00
Berthold Stoeger
50b195142b cleanup: remove includes from desktop-widgets/locationinformation.h
Notably, there was a circular include

locationinformation.h <-> importgps.h

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01 09:42:31 -07:00
Berthold Stoeger
95284c026e cleanup: move dive_table from dive.h to divelist.h
This allows us to decouple dive.h and divelist.h, a small step in
include disentangling.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01 09:42:31 -07:00
Berthold Stoeger
60b00162a9 desktop: don't replot profile when populating dive information tab
When the dive mode is changed, the profile has to be replot. This
is by a function of the TabDiveInformation. However, that function
was also executed when populating the tab. Thus, when changing dive,
the profile was plot twice.

Move the profile plotting out of the function. Ultimately, the profile
should listen to the appropriate signals itself.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-30 14:14:13 -07:00
Berthold Stoeger
2021035cfc selection: replace selectedTrips() by singleSelectedTrip() function
To check wether the tab widgets should show the trip view, they called
the selectedTrips() function. The trip view was shown if that contained
only one trip. However, the selectedTrips() function was very slow,
because it has to query to core models.

Change the function to singleSelectedTrip(), which returns a trip
if there is exactly one trip selected. The function returns early
if there is more than one trip selected. This makes the select-all
case much faster.

There are two cases which are still very slow:
- List mode, because here all top-level items are queried.
- Dive log with many only top-level items.

Ultimately, we will have to cache the trip selection because
querying the model is too slow.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-26 13:54:59 -07:00
Berthold Stoeger
6e83135fba desktop: select dives at once
The old code would call QItemSelectionModel::select() once for every dive.
Instead collect the selection in a QItemSelection and only call
QItemSelectionModel::select() once. This makes selecting multiple dives
significantly faster.

The loop also expanded the trips with selections. This has now to be
done in an extra loop.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-26 13:54:59 -07:00
Berthold Stoeger
4f438d1e32 dive list: don't access selected dives via indices
When determining the selected dive sites to highlight them on the
map, the DiveListView code used the local indices of the selected
dives. However, that was unreasonably slow. Even though a layering
violation, let's access the core data structures directly. In my
tests this improved from 700 ms to 0 ms!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-26 13:54:59 -07:00
Berthold Stoeger
2ad3696230 cleanup: make DiveListView slots private
It makes reasoning about code so much easier when one knows that
functions cannot be accessed from the outside. Therefore, make
a number of DiveListView slots private. Moreover, unslotize
functions that never were used in connect calls.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-26 13:54:59 -07:00
Berthold Stoeger
5d49da5d6b selection: move test for programmatical selection changes to widget
The DiveListView widget has to differentiate between programmatical
und user-initiated selection changes. It did so by using the
DiveListNotifier::inCommand() flag.

However,
1) There is only one point of entry for such selection changes,
   viz. the MultiFilterSortModel::selectionChanged() signal
2) This signal is not only emitted in command-context.
   Another source is for example dive-map selection changes.

Therefore, move the programmatical-selection-change status down
to the widget and set/reset it in the diveSelectionChanged() slot.
This makes "select all visible dive sites" somewhat faster. Sadly,
not as much as expected.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-26 13:54:59 -07:00
Berthold Stoeger
aaecc6e98e cleanup: make various functions in DiveListView private
Outside callers had no business calling these functions.
Especially some functions that were simply there to override
default DiveListView behavior. Mark these as overridden.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25 13:20:25 -07:00
Berthold Stoeger
b8e7a600d2 cleanup: remove DiveListView::selectDives()
This was used by the map to select dives. However, the map now calls
the core function directly, so this can be removed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25 13:20:25 -07:00
Berthold Stoeger
75ef8b68a1 map: call set_selection() core function to select dives
The map widget called the dive list to select dives. This is
inconsistent and complex. The dive list has to call down to
the core anyway. Therefore, change the code to call the common
core function.

This means that we have to transform integer ids into dive-pointers.
That is a bit sad, because the dives were just transformed into
indices. Let's address that in a future commit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25 13:20:25 -07:00
Berthold Stoeger
702d8c754d desktop: remove selectionChangeDone() from DiveListView::selectDive()
This was erroneous, as it should only be called at the end of
a selection change, not after every single dive. It made selection
of multiple dives extremely slow.

Reported-by: Jan Mulder <jlmulder@xs4all.nl>
Debugged-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25 10:23:05 -07:00
Berthold Stoeger
9fae262188 desktop: fold DiveListView::selectDive into DiveListView::selectDive
DiveListView::selectDive() is an overloaded function. The second
version was only called by the first version, so we can fold one
into the other.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25 10:23:05 -07:00
Berthold Stoeger
f8d3501c22 desktop: remove scrollto default parameter of DiveListView::selectDive()
No caller was using that parameter.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25 10:23:05 -07:00
Berthold Stoeger
e26ac9e58d desktop: remove selection-code to select a new current_dive
The undo-machinery makes sure that a current_dive always exists
after an undo command. This part of the code should never be
called.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25 10:23:05 -07:00
Berthold Stoeger
c00737eb23 desktop: don't select current dive after collapsing trips
This appears to be an artifact. Collapsing does not unselect
the current dive, so reselecting it appears pointless.
Also it is unclear why the selection should be restricted to
a single dive after collapsing.

Probably that was originally meant to expand only the trip
with the current dive in it?

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25 10:23:05 -07:00
Berthold Stoeger
b6aad78dab desktop: make DiveListView::selectDive() private
Thus, it is made clear that these member functions can only be
accessed from DiveListView itself. This should make debugging
easier.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25 10:23:05 -07:00
Berthold Stoeger
d8fabd241c cleanup: move clearing of event names to clear_dive_file_data()
Move this to the core so that desktop and mobile don't have
to call this explicitly. Matter of fact, mobile didn't call
this. It is unclear, whether that was even used on mobile,
though.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-24 10:40:12 -07:00
Berthold Stoeger
17526ded58 cleanup: move clearing of device nodes to clear_dive_file_data()
It makes no sense to keep the device nodes if all the other data
is cleared. Let's do this automatically and not explicitly.
This ensures that the function is also called on mobile.
Currently it was only called on desktop.

Weirdly, the parser-tests were expecting that the device nodes
were not reset by clear_dive_file_data() and therefore divecomputers
were accumulating in the test results. Thus, the additional
computers had to be removed from the expected test results.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-24 10:40:12 -07:00
Berthold Stoeger
89784a176e filter: implement filtering for divemode
This only checks the first divecomputer as the semantics for
multiple dive computers with different dive modes are not
clear. Should we check them all?

The implementation is a bit hackish: the indexes [0...n] of the
combobox are mapped onto [-1...n-1], where -1 means don't filter
and n-1 is the last valid dive mode.

Implements #2329

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-24 10:05:27 -07:00
Berthold Stoeger
9b8eed7821 cleanup: replace constructs of the type &vector[0] by vector.data()
It appears that some misguided compiler / library combinations crash
on &vector[0] for empty vectors. Even though very unfriendly, they are
technically correct, so let's remove these constructs.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-21 07:50:38 -07:00
Berthold Stoeger
a8aa897117 desktop: don't access first data element if no cylinders
TabDiveInformation::updateProfile() does some statistics via the
per_cylinder_mean_depth function. It passes down arrays with one
entry per cylinder, which are allocated by means std::vector.

To pass the array, the expression "&vector[0]" is used. It seems
like some compilers through an assertion violation if vector
has no elements. They are technically correct in that this is
undefined, but still this appears like very unfriendly behavior.
After all, std::vector should behave just like a dynamic C-array
that is automatically freed, when going out of scope.

Replace the "&vector[0]" by "vector.data()" and don't do the
call if there aren't any cylinders for good measure.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-21 07:50:38 -07:00
Berthold Stoeger
a3238020ee desktop: rearrange widgets on the dive site tab
Move the more commonly used filter to the left and the less
commonly used "purge unused sites" button to the right. Add
a spacer so that the filter-textbox doesn't extend over the
whole free space.

With apologies to sinistroverse users (is there an option to
make the layout direction depend on the locale?).

Suggested-by: Hartley Horwitz <hhrwtz@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-20 09:46:24 -07:00
Dirk Hohndel
ad66297cfd desktop: remove user survey
We have never made good use of the results. Let's just remove it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-19 14:27:54 -07:00
willemferguson
f690b8e90d Reorganise and reword divelog export panel
Perform slight reorganisation and rewording of the divelog export
panel. Specifically the wording is changed and expanded to make clear
the 2 types of export of profile data. All the CSV export options are
grouped together. With respect to profile export to CSV format, it is
made clear that one option concerns export of dive computer-related
profile data, whereas the other option involves export of computed
dive profile data from the Dive Profile panel.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2020-04-18 12:08:48 -07:00
Berthold Stoeger
b4e0968ed5 desktop: remove special QGroupBox stylesheet for non-Windows systems
That style-sheet made things look really ugly on most Linux themes.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-13 10:14:00 -07:00
Berthold Stoeger
9771c57a54 delegates: remove TankInfoDelegate::createEditor()
When creating a TankInfoDelegate editor, reploting of the profile
was disabled to avoid replotting when the user scrolls through
the tank-info list. Since the code was changed to only set the
tank-info when the editor is closed, this became unnecessary
(hopefully). Indeed the clearing of the flag was removed in a
previous commit. This means that we also have to remove the setting
of the flag. Since this is all the TankInfoDelegate::createEditor()
function was doing, we can remove the whole function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-12 10:32:58 -07:00
Berthold Stoeger
563263ab4f cleanup: remove unnecessary profile update after adding new dive
MainWindow::on_actionAddDive_triggered() updated the profile after
calling Command::addDive(). However, that is redundant because the
undo-machinery does the profile reload. Remove the call.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-12 09:20:17 -07:00
Dirk Hohndel
6d187b5f4a
Merge pull request #2643 from bstoeger/cylinder4
First steps of cylinder-editing undo
2020-04-11 11:03:05 -07:00
Berthold Stoeger
3f3869ff65 media: move picture function from dive.c to picture.c
Currently, move only those functions that do not access dive
structures.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-10 10:53:03 -07:00
Berthold Stoeger
7dc04b4437 delegates: remove ComboBoxTemplate::fixTabBehavior
The comment states that Qt treats TAB as cancel when in the combobox.
However, testing shows that this use-case works without this hack.
Since it caused weird behavior (the data was set *after* the editor
was closed, leading to inconsistent state), remove it.

Note: this overrides the previous commit, which is therefore redundant
from a history point of view. However, I'll leave the previous commit
in so that if something turns out to break, we can figure out which
of the two changes it was.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
e5c4dee7f6 delegates: call fixTabBehavior *before* closing the editor
fixTabBehavior() set the editor text *after* closing the editor.
This left us in an inconsistent state where we thought that the
editor is active. By reversing two connects, this problem is resolved.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
f9e246fed2 cleanup: make static fields local to ComboBoxDelegate
All combobox-delegates shared a number of static status fields.
In a quest to make the code more reentrant, move that to the
actual object. The fields have to be defined as mutable, since
they are set in const member functions.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
be7365755e cleanup: remove TankInfoDelegate::reenableReplot
Update of the profile is now done by the undo-commands. If the
planner needs this, it is probably better to connect directly
to the model, not the delegate.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
39bc6e3bdd cleanup: remove unneeded includes from TabDiveEquipment.cpp
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
63414fc823 undo: show multiple dive warning when editing equipment
When editing cylinders or weights directly in the table widgets,
no warning was shown if multiple dives were affected. To solve this,
emit signals from the respective models and catch them in dive
equipment tab. Not very nice, but it works for now.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00