Commit graph

16485 commits

Author SHA1 Message Date
Berthold Stoeger
a9da44b402 Cleanup: remove MainWindow::recreateDiveList() function
The function had only one line and had only one caller.
We might just as well fold that line into the caller.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-19 21:13:40 -08:00
Berthold Stoeger
958032b21c Desktop: don't reload dive list model after clearing the model
By clearing the model, its contents are removed. There is no
point in reloading the model.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-19 21:13:40 -08:00
Berthold Stoeger
635d67ee7f Dive list: clear internal data when clearing model
The DiveListModelBase::clear() implementation was flawed: It cleared
the data in the core, but left the data in the model untouched.
The code was relying on the fact that the caller would reset the
model manually. Not a good idea.

Therefore, clear the internal data to keep the model consistent at
all times.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-19 21:13:40 -08:00
Berthold Stoeger
9f573df971 Dive list: update selection after clearing model
When clearing the model the selection is cleared. Send the according
signal.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-19 21:13:40 -08:00
Berthold Stoeger
ecb517d496 Cleanup: remove ProfileWidget2::refreshDisplay signal
It was not used anywhere.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-19 21:13:40 -08:00
Berthold Stoeger
78d4a4ce36 Filter: don't reload filter after reloading dive list
The hidden_by_filter items are set on reload of the dive list.
No point in reloading the filter again.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-19 21:13:40 -08:00
Berthold Stoeger
3003c6e1ee Filter: move recalculation of filter from FilterModel to TripModel
The way this was accessed via Qt's model semantics was horrible.
This gives arguably more readable code, since we don't have to
shoehorn things through QVariants.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-19 21:13:40 -08:00
Berthold Stoeger
9ffafbc326 Filter: move num_shown logic from model to core
Since the number of shown dives is stored in the core, let's also
keep it updated there.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-19 21:13:40 -08:00
Berthold Stoeger
b76f207158 Filter: split out filter from model
Split out the actual filtering from the MultiFilterSortModel.
Create a DiveFilter class that does the actual filtering.
Currently, mobile and desktop have their own version of this
class, though ultimately we may want to merge them.

The idea here is that the trip-model and undo-commands have
direct access to the filter-function and thus can take care
of keeping track of the number of shown dives, etc.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-19 21:13:40 -08:00
Berthold Stoeger
6d6d10f03a Filter: move calculation of shown dives to undo command
The filter-model was catching dives-added / dives-deleted signals
from the models to keep track of the number of shown dives.

To simplify the data flow, do this directly in the undo-command.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-19 21:13:40 -08:00
Berthold Stoeger
2d09819ddf Filter: move number of shown dives to core
We mark hidden/shown dives in the core but store the number
of shown dives in the MultiFilterSortModel. Move this datum
to the core for improved locality.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-19 21:13:40 -08:00
Berthold Stoeger
cbd98edb73 Cleanup: remove MultiFilterSortModel::filterChanged()
Nobody was calling this function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-19 21:13:40 -08:00
Berthold Stoeger
669ca76b08 Cleanup: remove MultiFilterSortModel::clearFilter
Nobody was using that function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-19 21:13:40 -08:00
Berthold Stoeger
e66f2aed6a CHANGELOG.md update
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-19 06:35:59 -08:00
Dirk Hohndel
e9a9bc1282 GitHub actions: fix macOS artifact upload
Previously this created a bogus Subsurface.app.zip.zip file and then
failed to upload it to the release.

The upload / download pair of default actions is happier with just the folder.
And then the creation of the zip file needs the '-r' switch. Oops.
Finally, the pull-request specific uploads as build artifact are completely
redundant since we already do this to move the data from the macOS build to the
container that runs our own publish action in the first place.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-18 11:16:35 -08:00
Robert C. Helling
c2d5de207d Check if all required bytes were read
Fixes CID 350077

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-11-16 12:34:30 -08:00
Robert C. Helling
08cb521cf2 Initialize modified member
Fixes CID 350111

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-11-16 12:34:30 -08:00
Robert C. Helling
dbb504429d Don't acces null dive computer
Fixes CID 350111

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-11-16 12:34:30 -08:00
Robert C. Helling
143da031ce Use the actual error number
According to the man page, fopen and fclose return
the error number in the global variable errno.

Fixes CID 350115

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-11-16 12:34:30 -08:00
Robert C. Helling
f370446236 Initialize cylider field properly
This fixes another thing Coverty found. I am not 100% sure
I understand the semantics of cylinder_t.manually_added
but looking at other instance I guess true is the correct
value for a cylinder from a csv file for a Poseidon
rebreather.

Fixes CID 350734

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-11-16 12:34:30 -08:00
Robert C. Helling
28db9ede41 Don't access uninitialized deco_structure
Coverty found that in the export functions, we initialize
the planner deco state with NULL and then possibly later
access its content. This makes sure, we don't do that.

Let's see if this makes Coverty happy or I missed somehting
else.

Fixes CID 350736
Fixes CID 350735

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-11-16 12:34:30 -08:00
Stefan Fuchs
1a2c42cebc Remove setStyleSheet for "Dive mode" box
Remove modification of style sheet for "Dive mode" box in info tab.
This fixes a broken UI layout under Windows.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2019-11-16 08:32:07 -08:00
Stefan Fuchs
e70cf24950 Fixes in tab widget UI layout
Three minor changes in tab widget UI layout and txt:
- Remove leading space in string "Gas name"
- Remove duplicate <item> entry
- Correct "leftMargin" and "rightMargin" to 0 everywhere

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2019-11-16 08:32:07 -08:00
Berthold Stoeger
8a33c04894 Cleanup: use DiveTripModelBase::clear() to reset the log
Introduce a DiveTripModelBase::clear() function that cleanly
clears all dive data inside a beginResetModel()/endResetModel()
pair. Thus, the UI will be cleanly reset and we can remove
explicit calls to
 - graphics->setEmptyState()
 - mainTab->clearTabs()
 - mainTab->clearTabs()
 - diveList->reload()
from MainWindow::closeCurrentFile().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-16 08:29:53 -08:00
Berthold Stoeger
f0a89759bf Profile: clear tooltip's plotInfo in ProfileWidget2::setEmptyState
The tooltip's plotInfo was not cleared when clearing the profile.
With the new cylinder code, this lead to crashes, because the
displayed_dive's cylinder array is now cleared. The old code would
happily read stale data from the fixed-size cylinders array.

Clear the plotInfo explicitly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-16 08:29:53 -08:00
Berthold Stoeger
12c7c5ea96 Cleanup: move clearing of current_dive into clear_dive_file_data()
It makes no sense to have a non-NULL current_dive once all dives
have been deleted. Therefore, clear current_dive implicitly in
clear_dive_file_data() and don't depend on the caller performing
this.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-16 08:29:53 -08:00
Berthold Stoeger
808316f434 Cleanup: fold cleanUpEmpty() into closeCurrentFile()
The latter was the only caller of the former and there seems
to be no clear separation between the two. By making a single
function out of this the code is easier to follow and duplicate
code can be more easily detected. Matter of fact, the profile
was cleared twice.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-16 08:29:53 -08:00
Berthold Stoeger
36094e4a18 Partially revert 3025e0630d
This commit did the "right" thing by implementing Qt mode semantics
as intended, but for unknown reasons the profile is not properly
cleared on close-file anymore. This code is so convoluted that there
is not point in fighting it at the moment. Revert to remove-rows
instead of reset-model.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-16 08:29:53 -08:00
Berthold Stoeger
065559c3d8 Core: set gas use to zero if no values are given
In get_gas_used() the use was left uninitialized if there are neither
user- nor computer-supplied values. This gives random SACs in the UI.
Initialize to 0.

Fixes #2376.

Reported-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-16 09:23:39 +01:00
Berthold Stoeger
2f77716e8f Dive list: signal correct trip in DiveTripModelTree::topLevelChanged
DiveTripModelTree::topLevelChanged() has pretty complex code, as
it has to handle the fact that when adding/removing a dive from
a trip, the trip can change its position.

The code did not account for the fact that when moving an object
back in the top level list, one has to subtract one from the new
index, because the object was removed somewhere in the front of
the list.

To make matters worse, when an entry stayed where it was, this
was realized by moving the entry right behind itself, which of
course means that it stays where it is. But this meant that in
the by far most common case (no moving) the wrong entry was
updated.

Fix this by subtracting 1 from the new index when moving an
entry to the back.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-15 13:50:35 -08:00
Berthold Stoeger
5e29245e68 Refactoring: move undo commands to top level
In the future we might want to use undo-commands for mobile as
well (even if not implementing undo).

Therefore, move the undo-command source from desktop-widgets
to their own commands top-level folder.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-14 21:02:07 +01:00
jan Iversen
685b92b9c2 /: Corrected wrong Qt dependency from Kirigami
Kirigami 5.62 uses QtQuick.Controls 2.5, which were introduced in
Qt 5.12 (see https://doc.qt.io/qt-5/qtquickcontrols-index.html)

update CMakeList.txt to demand min. 5.12 when building SUBSURFACE-MOBILE
update INSTALL text

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-11-14 09:28:25 -08:00
Berthold Stoeger
b43ecdad4e Undo: don't delete dive sites when pasting dives
We used to only keep sites with dives around. This changed when
implementing the dive site tab. The paste-dive code was written
using the old semantics and thus, when overwriting dive sites,
it deleted unused dive sites.

To make things consistent, remove that code. It would be very
weird when dive sites are deleted by pasting, but not by setting
a different dive site manually.

Bonus: no more dependencies on desktop-includes in the undo code.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-14 09:37:27 +01:00
Berthold Stoeger
8db3e5cd59 Undo: remove unrelated include in command_divelist.cpp
This file included "desktop-widgets/divelistview.h" without needing
it. If we want to use the undo commands on mobile we shouldn't
include desktop headers. Therefore, remove the include.

This has the unintended side-effect that the Qt debug headers are
not included indirectly anymore. Thus, change a few
"qWarning() << ..." instances to "qWarning(...)".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-14 09:37:27 +01:00
Berthold Stoeger
1163fd18c4 Undo: remove superfluous dive replot in DiveComputerBase::redoit()
Removing / moving a dive computer needs a profile replot. This
was done explicitly in DiveComputerBase::redoit(). This is
unnecessary, as a profile replot is performed implicitly by the
setSelection() call.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-14 09:37:27 +01:00
Berthold Stoeger
ef2f682c67 Undo: remove superfluous refreshDisplay() in AddDive::(un)doit()
Dives used to be added from a special dive-edit screen. Thus, the
undo command had to close that screen. This is no longer the case.
Remove the calls.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-14 09:37:27 +01:00
Berthold Stoeger
f6d3efc6f8 Cleanup: don't std::move() temporaries
clang correctly warns about std::move()ing objects returned from
functions. This is a pessimization, because the compiler can't
copy elide the object. Remove.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-14 09:36:39 +01:00
jan Iversen
46088e63fd /: update INSTALL to reflect correct Qt version.
commit 5ce4b3d5e set minimum Qt level to 5.11 for Subsurface-mobile
commit 3df2be5c1 set minimum Qt level to 5.9.1 for Subsurface

update INSTALL to reflect to new Qt versions

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-11-13 08:29:48 -08:00
Berthold Stoeger
b850384100 Profile: fix pressure scale
The determination of minimum pressure in calculate_max_limits_new()
in profile.c was wrong for a long time. Since the loop went over all
cylinders (even unused ones), the minimum pressure was always zero.

Since we loop only over used cylinders, the minimum pressure was
initialized to the lowest starting pressure of any cylinder.

If there were no events with pressure change, the minimum pressure
stayed unchanged, resulting in a funky scaling.

Instead, let's initialize the minimum pressure to the lowest ending
pressure.

Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-12 07:00:37 +01:00
willemferguson
ebaac21ef5 Show altitude corresponding to surface pressure
In the information tab, presenting atmospheric pressure is a bit
unintuitive because the diver cannot easily relate that to altitude.

For the Atm. Pressure widget in the Information tab this code does:
If the atmospheric pressure for a dive exists and the user selects
the 'm' or 'ft' option from the combobox, then the estimated altitude
is shown in the text box.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2019-11-11 22:57:48 +01:00
Berthold Stoeger
e434b5aa40 Cleanup: introduce DiveTripModelBase::IS_TRIP_ROLE
To test whether an entry is a trip, we passed a pointer to the
trip through a QVariant and tested that for null-ity.

Passing pointers through QVariants has given us myriads of
problems in QML, therefore introduce a bool IS_TRIP_ROLE

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-11 22:44:58 +01:00
Berthold Stoeger
a474264cc8 Cleanup: fix typos in comment
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-11 22:44:58 +01:00
jan Iversen
bd7357238f mobile-widget/qml: correct syntax error introduced in e63257f0e
default parameter values is not supported as this syntax was introduced
in ECMA-262 6th edition while QML only implements the fifth edition
(as of Qt 5.11).

remove default parameter and check for undefined instead.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-11-11 20:44:35 +01:00
willemferguson
08db77333b Notes tab: Use top RH for depth and duretion fields
Currently the top righthand part of the notes tab is used for
    showing and editing air teperature and water temperature. But
    these fields were moved over to the Information tab and are not
    required in the Notes tab any more. Rather use this space for the
    depth and duration data for manually-entered dives. Currently
    extra vertical space is created in the Notes tab for showing this
    field, resulting in inefficient use of screen space and
    inelegant layout. This code moves the Duration and Depth fields
    into the top righthand of the Notes tab.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2019-11-11 20:19:22 +01:00
willemferguson
2fe1121b1c Information tab: Make air and water tempertatures editable
The undo stack is preserved.
This is in preparation of removing temperatures from the Notes tab.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2019-11-11 20:18:41 +01:00
Willem Ferguson
7a4abd7477 Reorganise the Information tab of the Info panel
1)  Reorganise the existing widgets in the Information tab
2)  Move divemode widget and visibility widget from Notes tab to
    Information tab
3)  Translate water density to a word indicating water type
4)  Reorganise the Notes tab to compensate for the moving the
    divemode and visibility widgets to the Information tab
5)  Remove the problems in showing a QGroupBox in Qt Windows. I do
    this by removing the CSS specifying border characteristics

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-10 13:10:03 -08:00
Dirk Hohndel
dc95b077d9 Mobile: Add CHANGELOG and user manual update
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-10 21:59:32 +01:00
Dirk Hohndel
4f0d437f1e Mobile: add ability to directly open support email
This is even easier and more obvious than copying the logs on the About page
and then manually creating an email and pasting those logs.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-10 21:59:32 +01:00
Berthold Stoeger
80f123ce2a Parser: set timestamp to zero if parsing failed
When parsing of a timestamp failed (shouldn't happen) set the
timestamp to zero. This should give less unpredictable results
and silence a compiler warning.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
794066b236 Cylinders: access cylinders with get_cylinder()
Instead of accessing the cylinder table directly, use the get_cylinder()
function. This gives less unwieldy expressions. But more importantly,
the function does bound checking. This is crucial for now as the code
hasn't be properly audited since the change to arbitrarily sized
cylinder tables. Accesses of invalid cylinder indexes may lead to
silent data-corruption that is sometimes not even noticed by
valgrind. Returning NULL instead of an invalid pointer will make
debugging much easier.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00