Commit graph

17596 commits

Author SHA1 Message Date
Berthold Stoeger
9962d47b56 media: turn DivePictureModel::pictures into std::vector
QVector doesn't have a function to insert a range of pictures,
which we will need for undo of image adding/deletion.

Moreover, std::vector gives us stronger guarantees. For example,
if capacity is large enough, it guarantees that there will be
no reallocation and thus iterators stay valid. I have not found
such a guarantee in the Qt docs.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06 13:58:09 -07:00
Berthold Stoeger
fe82cb32b9 media: add small C++ helper describing a picture struct
By using a std::string instead of a C-string, memory management
becomes so much simpler! This class will be used for keeping track
of deleted/added pictures in the undo system.

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
bd960ea088 media: store dive instead of dive-id in DivePictureModel
dive-pointers are stable and the dive picture model is reset
if a selected dive is removed, so there is no risk in keeping
pointers.

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
e61641c79c undo: implement undo of setting a picture time by drag&drop
Even though the functionality is seemingly trivial, this is a bit
invasive, as the code has to be split into two distinct parts:
1) Post undo command
2) React to changes to the divelist

Don't compile that code on mobile.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06 13:58:09 -07:00
Berthold Stoeger
ebdb3e3c30 media: create sort_picture_table function via macro
This needs a slight change to the macro, because here we sort by
value type. Yes, from a C-programming point of view this is horrible,
however a decent compiler should just inline everything and not
pass around value types.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06 13:58:09 -07:00
Berthold Stoeger
db24f16686 core: add get_picture_idx() function
A function that gets the index of a picture in a picture table
given its filename. Since we are going to identify pictures by
their filename, we will need this function in the undo code.

Use the function in the remove_picture() function.

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
989d6a3f96 media: use table instead of linked list for media
For consistency with equipment, use our table macros for pictures.
Generally tables (arrays) are preferred over linked lists, because
they allow random access.

This is mostly copy & paste of the equipment code.

Sadly, our table macros are quite messy and need some revamping.
Therefore, the resulting code is likewise somewhat messy.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06 13:58:09 -07:00
Berthold Stoeger
282041e228 core: make picture.h compatible with C++
The "extern C {" guards were missing.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06 13:58:09 -07:00
Berthold Stoeger
2c4975f2ed cleanup: move copy_cylinders from dive.c to equipment.c
Since this doesn't touch struct dive, dive.c is not an appropriate
place for this function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06 13:58:09 -07:00
Berthold Stoeger
fdca130387 cleanup: make remove_from_*_table equipment functions static
These functions were not used outside their translation unit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06 13:58:09 -07:00
Berthold Stoeger
4d407dc666 pictures: turn QString into std::string for filenames
For undo of picture manipulation, it will be crucial that the
model and the core have the same order of pictures. The first
sort criterion will be time, the second filename in the case
that two pictures have, for whatever reason, the same timestamp.

However in the core we us C-strings and thus sort byte-wise
using strcmp. In the Qt-part we use QStrings, which sort according
to unicode encoding. To enable consistent sorting, change the
Qt-part to std::string, which uses a C-style 0-terminated string
as its backing store.

One might argue that in general filenames should use system-encoding
and therefore use std::string instead of QString. However, a
broader conversion to std::string turned out to be very painful,
since Qt is (deliberately?) difficult to use with std::string.
Notable all the file-manipulation functions don't take std::string
by default. Thus, this commit only converts the internal data
of DivePictureModel, but continues to use QString for the Qt-facing
interface.

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
Berthold Stoeger
30133946e0 models: emit dive changed signal when cylinders edited
To display changed SAC values it is necessary that the models
emit changed signals when cylinders are edited. An alternative
might be that the undo commands emit dive-changed signals themselves.

Fixes #2814.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06 11:44:22 -07:00
Berthold Stoeger
beef8096f7 undo: update cylinder related info when editing cylinder data
We have to call update_cylinder_related_info() when adding /
editing / removing cylinders. This could be done in a common
base class of the commands. For simplicity, let's call
the function in the respective undo()/redo() functions.

Partially fixes #2814.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06 11:44:22 -07:00
Dirk Hohndel
862fcdf8ea documentation: remove two remaining references to the survey
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-05 18:48:46 -07:00
Dirk Hohndel
3be2455c7b documentation: revert switch to asciidoctor
While this worked well on Mac, it creates odd errors on Linux. This
doesn't seem worth spending too much effort on - so let's just go back
to asciidoc.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-05 18:48:36 -07:00
Dirk Hohndel
50a89eba66 documentation: fix makefile
This one was my fault, not Willems (since I edited his commit).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-05 18:25:57 -07:00
Willem Ferguson
70ebc2bee7 documentation/mobile-manual: create a merged v3 manual
Unintentionally two versions of the mobile manual were created. This brings all
of Willem's changes into the version for Subsurface-mobile v3, and restores the
last version of the v2 mobile manual.

This commit was manually created from a pull request that was signed off by
Willem, given that he wrote most of the text I am copying that SOB into this
commit and will assign authorship to him.

To avoid further confusion, we now have a v2 and a v3 manual, explicitly named.
The corresponding .html.git files were also updated (reflecting our switch to
asciidoctor).

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-05 17:55:02 -07:00
Berthold Stoeger
33b4ecf055 cleanup: move the inertgas enum from qthelper.hpp to deco.c
There are no outside users.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06 00:22:31 +02:00
Berthold Stoeger
123937901f planner: remove Bühlmann factor cache
The Bühlmann factors were cached in a thread-safe hashmap. It seemed
somewhat dubious that entering a critical section and doing a hash-lookup
would be significantly faster than a simple exp() call.

Indeed, in a very cache friendly test (16 entries, tight loop) calling the
factor() function 32 000 000 times from a different translation units we get:
  - with cache: 604 ms
  - without cache: 266 ms
Therefore, remove the cache. Given that 32 000 000 calls take only 266 ms,
it appears not sensible to try to optimize this function anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06 00:22:31 +02: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
Robert C. Helling
786963aba9 Changelog for variations checkbox
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-05-05 08:56:33 -07:00
Robert C. Helling
f55925db60 Explanatory comment in testprofile.cpp
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-05-05 08:56:33 -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
b3270222fd Add test for profile data
There was a TestProfile but that was a stub that did not test anything.

We have an export function that serialises the profile data
(including lots of derived data like deco information and
cylinder pressure interpolation). So here is now a simple
tests that can detect regressions in the profle.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-05-04 13:39:18 -07:00
willemferguson
6066ead0d5 Mobile user manual update
As the heading above says. two images changed.
Short table of contents added.
Add section on dive trip editing and dive list structure.
Added links to video tutorials.

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2020-05-04 13:38:31 -07:00
Dirk Hohndel
744bad833a update README to reflect discontinued ci-release on GitHub
The previous commit ended publishing current test binaries on GitHub.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-04 10:48:31 -07:00
Dirk Hohndel
d49647d288 GitHub Actions: stop creating CI releases
Net net this has caused more problems than it solved. Too often binaries
were missing or broken. Instead 'release equivalent' binaries are now
consistently posted to downloads/test via a Webhook.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-04 08:51:49 -07: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
977b50ba22 Update changelog
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2020-05-04 10:43:40 +02:00
Miika Turkia
435778b162 CSV import/export test: Add support for dive mode
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2020-05-04 10:43:40 +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
Miika Turkia
e1c3f29b88 CSV export: Add dive mode
Include dive mode to exported dive detail CSV

Closes #1588

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
acfcd866bd planner: remove conditional command-calls for mobile
In the planner the undo commands for adding / editing dives were
only called if not on mobile. This is from days were mobile didn't
have undo commands. We can remove these now.

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