Commit graph

16401 commits

Author SHA1 Message Date
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
Berthold Stoeger
52d8d89f73 Mobile: optimize cylinderList() function
The cylinderList() function collects all cylinder descriptions.
Instead of adding all cylinders, then sort, then removed duplicates,
keep a sorted list and only add non-existing elements. Find
existing elements by a binary search.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
eaf8a59edf CHANGELOG.md update
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
6a1e2cd8c2 Desktop: support no-cylinders in dive information tab
The tab was crashing if there were no cylinders because
1) per_cylinder_mean_depth() would access non-existing cylinders.
2) TabDiveInformation::updateProfile() would access a non-existing
   mean.

Fix both of these crash conditions by checking whether the dive
actually has cylinders.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
fd23c3d908 Profile: don't crash when there are no cylinders
TankItem would happily access a non-existing cylinder and crash.
But freedives for example have no cylinders. Thus, handle that
situation gracefully by exiting early if there is no cylinder.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
2d637f2528 Cleanup: replace unsigned by signed parameter in two helper functions
In getFormattedWeight() and getFormattedCylinder(), the indexes
were passed as unsigned ints. This makes no sense as the only
callers were using signed ints. Change the parameters to signed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
c26e922802 Cleanup: return cylinder from add_empty_cylinder()
As a convenience, return the cylinder from add_empty_cylinder()
to spare the caller from the nasty expression to fetch the
last cylinder.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
8df3705152 Cleanup: return cylinder from cylinder_start() in parser
Most callers of this function accessed the newly generated cylinder
immediately after calling this function. Thus, for convenience,
return the added cylinder. This avoids a number of verbose expressions.

On the flip side, cylinder_start() now has to be cast to
function returning void in a the "nesting" function table.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
7c9f46acd2 Core: remove MAX_CYLINDERS restriction
Instead of using fixed size arrays, use a new cylinder_table structure.
The code copies the weightsystem code, but is significantly more complex
because cylinders are such an integral part of the core.

Two functions to access the cylinders were added:
get_cylinder() and get_or_create_cylinder()
The former does a simple array access and supposes that the cylinder
exists. The latter is used by the parser(s) and if a cylinder with
the given id does not exist, cylinders up to that id are generated.

One point will make C programmers cringe: the cylinder structure is
passed by value. This is due to the way the table-macros work. A
refactoring of the table macros is planned. It has to be noted that
the size of a cylinder_t is 64 bytes, i.e. 8 long words on a 64-bit
architecture, so passing on the stack is probably not even significantly
slower than passing as reference.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
cd4f66014f Cleanup: Make cylinder formatting functions const-clean
In qt-models/cylindermodel.cpp the various formatting functions
can take a pointer-to-const cylinder. Thus, the data() function
can likewise treat the cylinder as const - as it should.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
4355ce3924 Cleanup: move copy_cylinder_types() from dive.c to equipment.c
Thus, future callers will not have to include the monster dive.h
include if they just want to copy cylinders.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
860807bf92 Core: create copy_cylinder_type() function
Move the loop body of copy_cylinder_types() into its own function.
When using variable sized arrays, this loop will have to treat two
cases (overwrite cylinder and add new cylinder), so that makes things
more clear.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
f2bcc240c4 Core: dynamically allocate cylinder maps in merge_cylinders()
merge_cylinders() used three bitmaps to identify cylinders used in
the first and second dive and matched cylinders. Even though nobody
will use more than 32 (or 64!) cylinders, replace these with
dynamically allocated bool-arrays for consistency with the rest
of the code.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
371a5fd66b Core: dynamically allocate gases array
When calculating per-cylinder mean depths, bitfields were used to
keep track of "used" and "known" cylinders. Even though no sane
person will use more than 32 cylinders, turn this into dynamically
allocated arrays of bool for consistency with the rest of the code.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
4e86d99714 Cleanup: free plot data on exit
Some widgets copy the full plot info. Free these data on exit to
prevent monstrous valgrind reports.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
05a5a06fd3 Profile: dynamically allocate gases array
To calculate sac rates, an array of used gases for every point on the
profile was used. This was implemented using unsigned int bitfields.

While nobody sane will ever use 32 or even 64 cylinders, for consistency
with the rest of the code, also change this to use dynamically
allocated arrays.

But allocate only once per shown profile, not once per sample.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
00289cd222 Profile: dynamically allocate plot pressure data
All accesses to the pressure data were converted to use functions.
Therefore it is now rather trivial to dynamically allocate the
pressure array and just change the functions.

The only thing to take care of is the idiosyncratic memory
management. Make sure to free and copy the buffer in the
appropriate places.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
bef1eac7fa Profile: use pressure data functions in DivePlotDataModel
The model was accessing the pressure data directly. Instead,
use the accessor functions so that the core structure can
be changed more easily.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
7c6a904bbf Profile: use pressure data functions in save_profiles_buffer
The save_profiles_buffer() function was accessing the pressure
data directly. Instead, use the already existing funcions to
make transition to dynamically allocated pressure data more
seamless.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
4c9532dc51 Profile: use pressure data functions in fill_missing_tank_pressures
The pressure data was directly accessed in fill_missing_tank_pressures().
Use the already existing functions so that the structures can be adapted
easily.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
7e1425796d Profile: turn INSERT_ENTRY macro into helper function
The only apparent reason that this was a macro is that it automatically
increased the "index" and "entry" counts. But incrementing these explicitly
seems reasonable.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
2fd4cb5fe1 Profile: pass index instead of pointer to set_plot_pressure_data
Another plot-pressure-related function whose argument is converted
to an index.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
fe6d3c8c38 Profile: switch pressure-accessing functions to indexes
Continue with replacing pointers to struct plot_data entries
by indexes. Thus the pressure data can be kept in its own
array and can by dynamically sized.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
459f9acc67 Cleanup: comment out function that is used by commented out code
The ProfileWidget2::getEntryFromPos() function was only used
by code that was commented out. Thus comment it out as well.

Moreover, turn the accompanying FIXME comments into TODO comments
to avoid a new LGTML alert.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
4724c88533 Profile: change get_plot_pressure to take index instead of pointer
The goal here is to make it possible to detach the pressure related
data from the plot_info structure. Thus, the pressure related data
can be allocated independently depending on the number of cylinders
per dive.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
fbd74c26d6 Profile: Change RulerItem2 to use index instead of pointer
To make the pressure data dynamic (size of the arrays depending
on the cylinders in the dive), it has to be separated from the
standard plot_data structure. To enable this, use indexes instead
of pointers to plot_data elements. This commit converts
the RulerItem2 to use an index.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
3025e0630d Cleanup: implement proper Qt-model semantics in DivePlotData model
User beginResetModel()/endResetModel() pairs to reset the model.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
77e5dbac73 Undo: Make PasteState cylinders list dynamically allocated
Instead of using a sub-array, use a std::vector<>. This is
a necessary step in removing the MAX_CYLINDERS restriction.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
16bdbc54b9 Cylinders: dynamically allocate cylinder arrays
Dynamically allocate cylinder arrays in C code. This is a tiny
step in removing the MAX_CYLINDERS limitation.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
ff653f721c Cylinders: dynamically allocate cylinder arrays
When keeping track of cylinder related data, the code was using
static arrays of MAX_CYLINDERS length. If we want to use dynamically
sized cylinder arrays, these have to be dynamically allocated.
In C++ code, this is trivial: simply replace the C-style arrays
by std::vector<>. Don't use QVector, as no reference counting or
COW semantics are needed here. These are purely local and unshared
arrays.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
Berthold Stoeger
11467fa326 Core: dynamically allocate the result of get_gas_used()
get_gas_used() returns the volume of used gases. Currently,
an array with MAX_CYLINDERS is passed in. If we want to make the
number of cylinders dynamic, the function must use an arbitrarilly
sized array.

Therefore, return a dynamically allocated array and free it
in the caller.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00
jan Iversen
f179ec033f scripts: update get-deps to allow clean build
libssh2 depends on openssl, therefore it is important that openssl is
build before libssh2.

The old get-deps would cause errors in 2 situations:
1) In a clean build, make of libssh2 would fail
2) In a normal build, where openssl changed version, make of libssh2 would
depend on old build.

Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-11-08 23:09:57 +01:00
Dirk Hohndel
2c11544d93 Mobile: correctly update filter text and update all three models
This is even harder because setActiveTrip is called from an action slot from
QML. If the C++ code called from that slot causes the object to which this slot
belongs to be destroyed, we get very strange crashes. The only workaround I
could come up with was to update the filter asynchronously.

This all seems very ugly and fragile.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08 20:50:05 +01:00
Dirk Hohndel
15674f1a71 Mobile: modify filter so that all models get notified
When we change the filter string, we need to make sure that the collapsed model is
also aware of the change.

Similarly, instead of just calling resetFilter and directly changing the core
data structures, we need to set the filter to the empty string which ensures
that all three models get notified and the view updates correctly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08 20:50:05 +01:00
Dirk Hohndel
20fda8afc3 Mobile: reconnect the correct model after changing filter
This caused a blank, unusable dive list.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-08 20:50:05 +01:00