Commit graph

15316 commits

Author SHA1 Message Date
Berthold Stoeger
1cd0863cca Import: add add_to_new_trip flag to process_imported_dives()
If this flag is set, dives that are not assigned to a trip will
be assigned to a new trip. This flag is set if the user checked
"add to new trip" in the download dialog of the desktop version.

Currently this is a no-op as the dives will already have been
added to a new trip by the downloading code. This will be removed
in a subsequent commit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-19 13:48:17 -08:00
Berthold Stoeger
31eb86c733 Dive import: fix logic of process_imported_dives()
The logic in process_imported_dives() was faulty: Dives are merged
trip-wise in a loop. But if only autogenerated trips were supposed
to be merged, the trip would not be added.

Change the logic to always add the trip if it is not merged. To make
the loop easier to read, factor out the merge-trip-into-existing-trips
logic into a separate function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-19 13:48:17 -08:00
Berthold Stoeger
11d19abc74 Dive download: add trip_table to device_data_t
Since recent commits, dive-trips are not added directly to the core,
but into separate trip tables (see ec37c71f5e).
These commits did not finish the work for the download-from-dc
case.

Add an extra trip_table field to device_data_t. If trips are created
(user selected "Download into new trip"), the trip will be created
in that table.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-19 13:48:17 -08:00
Berthold Stoeger
239e6f237f Cleanup: remove unused variables
Commit 4d06ddd723 removed deletion of
unused dive sites on save. The corresponding variables were not
removed leading to compiler warnings. Remove the variables too.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-19 13:48:17 -08:00
Robert C. Helling
5f04fecd00 Don't allow empty username for git
When no real name is set in /etc/passwd the username ends
up being ",,,". Git does not like that. Actually, only the
part before the first comma is the name, the rest is office
and phone number. We don't want those.

Before we only testing for the username being a NULL pointer.

Reported-by: Keith Grimes
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-01-16 02:38:30 +01:00
Robert C. Helling
2c794348c1 Planner: Add checkbox to force OC bailout
This adds a checkbox for rebreather modes of the planner
that force the ascent to be in OC mode. Before, one had
to add a one minute last segment with the mode change but
this is not practical when manually searching for the
maximal bottom time given gas reserves.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-01-13 15:02:07 -08:00
Berthold Stoeger
7f2c7aa7de Download: don't refresh display if thread finished
After the downloading finished, the mainwindow-display is reset
via a signal. This is probably an artifact of old times, when
downloading was done into the main dive-list. Nowadays, this seems
to make little sense, as the main dive-list is not changed by download.

Remove the signal.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-13 15:01:42 -08:00
Jan Mulder
9a26225558 Travis: OpenSUSE 42.3 / Qt5.6 build issue, use openssl and no libressl
... and remove install of the default (old) libgit2 from OS. That old
(0.24.0) libgit2 will be replaced by a newer anyway, so useless to
install.

But the real change to get this Travis build running again is using
the well known openssl instead of libressl.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2019-01-10 08:19:07 -08:00
Dirk Hohndel
c7e3e4146e Travis: OpenSUSE 42.3 / Qt5.6, add missing curl
The install was missing curl.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl> Removed upgrade to newer libgit2.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-01-10 08:19:07 -08:00
Jan Mulder
cfc22d0702 Build: build libgit2 from source when less than 0.26.0
We currently require a minimal version of libgit2 of 0.24.0. From
issue #1926 it seems that this version is too old. So, a simple test on
Linux to see the behaviour with such an old libgit2, I tried that.
Interestingly, with the current version of openssl that old libgit2
version does not even compile from source (known error in libgit2).

So, bump our minimal version of libgit2 to 0.26.0. That is also the
version we currently use on the Travis and official builds, so well
tested.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2019-01-10 08:19:07 -08:00
Berthold Stoeger
7bf055bb42 CHANGELOG.md update
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
ea40370389 Cleanup: remove explicit constructor of DiveListBase
DiveListBase had an explicit constructor that initialized the
"firstExecution" member variable. The latter was a development-
artifact that was never used. Remove the member and the constructor.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
82c47bdd79 Undo: make dive-import undoable
On desktop, replace all add_imported_dives() calls by a new undo-command.
This was rather straight forward, as all the preparation work was done
in previous commits.

By using an undo-command, a full UI-reset can be avoided, making the UI
react smoother.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
0249e12589 Import: split process_imported_dives() function
Split the process_imported_dives() function in two:
1) process_imported_dives() processes the dives and generates
   a list of dives and trips to be added and removed.
2) add_imported_dives() calls process_imported_dives() and
   does the actual removal / addition of dives and trips.

The goal is to split preparation and actual work, to
make dive import undo-able.

The code adds extra checks to never merge into the same
dive twice, as this would lead to a double-free() bug.
This should in principle never happen, as dives that
compare equal according to is_same_dive() are merged
in the imported-dives list, but perhaps in some pathologival
corner-cases is_same_dive() turns out to be non-transitive.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
fd196f143a Core: don't copy dive-id on merge dive
The installment of the divelist-undo system has made it unnecessary
to adopt the uniq-id of the merged-into dive. On the contrary, we
want to avoid two dives with the same dive-id in the divelist at
all costs, since get_divenr() still uses the id and thus may fetch
the wrong dive.

Therefore, don't copy the dive-id on merge.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
0dfc59f38c Import: add merge_all_trips parameter to process_imported_dives()
When importing log-files we generally want to merge trips. But
when downloading and the user chose "generate new trip", that
new trip should not be merged into existing trips.

Therefore, add a "merge_all_trips" parameter to process_imported_dives().
If false only autogenerated trips [via autogroup] will be merged.
In the future we might want to let the user choose if trips
should be merged when importing log-files.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
1593f2ebad Import: merge dives trip-wise
The old way of merging log-files was not well defined: Trips
were recognized as the same if and only if the first dives
started at the same instant. Later dives did not matter.

Change this to merge dives if they are overlapping.
Moreover, on parsing and download generate trips in a separate
trip-table.

This will be fundamental for undo of dive-import: Firstly, we
don't want to mix trips of imported and not-yet imported dives.
Secondly, by merging trip-wise, we can autogroup the dives
in the import-data to trips and merge these at once. This will
simplify the code to decide to which trip dives should be
autogrouped.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
f542dc4030 Import: add trip_table argument to DiveImportedModel::repopulate()
In the future we want to download trips into a distinct trip-table
instead of the global trip-table to allow for undo of import.

Therefore add a trip_table argument to DiveImportedModel::repopulate()
and a trip_table member to DiveImportedModel. To correctly set these,
add a DownloadThread::trips() function, which currently simply returns
the global trip table.

Finally, make "struct trip_table *" a Q_METATYPE, so that the corresponding
arguments can be passed from QML.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
7e33369dc8 Parser: add trip_table parameter to parsing functions
To allow parsing into arbitrary trip_tables, add the corresponding
parameter to the parsing functions and the parser state. Currently,
all callers pass the global trip_table so there should be no change
in functionality. These arguments will be replaced in subsequent commits.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
ec37c71f5e Core: add trip_table parameter to trip-functions
Currently trips are added to the global trip table. If we want to
make dive-import undoable, we should be able to parse trips of a
log-file into a distinct table. Therefore, add a trip_table
parameter to
	- insert_trip()
	- create_and_hookup_trip_from_dive()
	- autogroup_dives()
	- unregister_trip()
	- remove_dive_from_trip()

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
7df8d8c888 Undo commands: refactor dive-trip handling
Trips were added to the core with the first dive of that trip.
With the recent changes that keep trips ordered by first dive,
this became counter-productive. Keeping a consistent state at
all times would mean resorting the trip table for every dive
that is added.

Instead, add all dives to a trip and *then* add the trip to the
core. Change the data-structures to not register trips-to-be-added
with individual dives, but keep them in a separate vector for
each undo command.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
517fb7a462 Core: keep trips in table(s)
Currently, all trips are kept in a linked list. Replace the list
by a table in analogy to dive_table. Use this to keep the trip_table
sorted as suggested by dump_trip_list(). When inserting a trip into
the table do that after adding the dives, to avoid warnings coming
out of dump_trip_list().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
54fcda4c32 Core: fix dump_trip_list() function
In 64e6e435f8 the trip->when field
was replaced by a function. This forgot to adapt dump_trip_list(),
which is only compiled if DEBUG_TRIP is defined. Fix the function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
2c77142696 Core: macroize dive_table functions
Generate dive table functions by macros so that they can be reused
for trip tables.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
d1971a64f9 Core: Rename functions to more generic names
Rename
 - dive_get_insertion_index() -> dive_table_get_insertion_index()
 - unregister_dive_from_table() -> remove_from_dive_table()
 - get_idx_in_table() -> get_idx_in_dive_table()
 - sort_table() -> sort_dive_table()
This will make it more straight-forward to generate these functions
from macros.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
2802d42969 Cleanup: Make add_dive_to_table local to divelist.c
This function was not used outside of divelist.c, therefore make it
local. Moreover rename it to add_to_divetable so that the name
is generic and can be generated by a macro.

Moreover, remove the special case idx = -1, which would determine
the insertion index. Instead let the single caller who used this
feature do this.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
825fcc8547 Dive list: add table parameter to autogroup_dives()
Currently autogroup_dives() groups all dives in the global dive
list. Add a table parameter so that dives in any table can be
grouped. Thus it will be possible to pre-group dives on import,
which will be used for undo of import.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
f8327ed51b Core: move autogroup() into divelist.c
After loading or importing, the caller usually called autogroup()
to autogroup dives if so wished by the user. This has already led
to bugs, when autogroup() was forgotten.

Instead, call autogroup() directly in the process_loaded_dives()
and process_imported_dives() functions. Not only does this prevent
forgetting the call - it also means that autogrouping can be
changed without changing every caller.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Dirk Hohndel
7923507e76 build system: try harder to checkout the right version
And actually fail a build if that doesn't work.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-01-09 20:53:26 -08:00
Robert C. Helling
123f3ef7ec Filter for logged/planned dives
Add filter for dives having a planned dive computer or
a logged dive computer.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-01-08 10:39:06 +01:00
Robert C. Helling
c349692d98 Helper function to determined planned dives
... to reduce code duplication.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-01-08 10:39:06 +01:00
Berthold Stoeger
f1fc89b978 Dive list: split DiveTripModel into distinct models (tree and list)
The DiveTripModel was used to represent both, trip and list views.
Thus many functions had conditionals checking for the current mode
and both modes had to be represented by the same data structure.

Instead, split the model in two and derive them from a base class,
which implements common functions and defines an interface.

The model can be switched by a call to resetModel(), which invalidates
any pointer obtained by instance(). This is quite surprising
behavior. To handle it, straighten out the control flow:

DiveListView --> MultiFilterSortModel --> DiveTripModelBase

Before, DiveListView accessed DiveTripModelBase directly.

A goal of this commit is to enable usage of the same model by mobile
and desktop.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-07 09:33:52 -08:00
Berthold Stoeger
b5704ddb57 Cleanup: Remove MultiFilterSortModel::model
The source-model was cached in MultiFilterSortModel. For simplicity,
remove that and simply access via DiveTripModel::instance(). There
is only one instance where the cached model was used: when comparing
items for sorting. Thus, in indirection is added in a "hot" path.
Nevertheless, this will dwarf against the cost of string comparison.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-07 09:33:52 -08:00
Berthold Stoeger
4d06ddd723 Dive sites: don't delete unused dive sites on save
Unused dive sites were deleted on save. This clashed with the undo
system in the following scenario:

1) Delete single-use dive site.
2) Save (dive site deleted)
3) Undo (reference to freed dive site)

Therefore, as a quick-fix, keep the referenced dive site around.
Note that this also means that empty dive sites must not be
deleted, as it might refer to a dive in the undo system. Instead
only clear references to empty dive sites in the global dive
table. Factor this functionality out, as it was common to the
XML and git savers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-07 09:33:24 -08:00
Dirk Hohndel
da52440963 Merge branch 'shearwater_cloud' of https://github.com/mturkia/subsurface 2019-01-07 09:31:12 -08:00
Jan Mulder
4b7b0f2dec Build: remove --skip-googlemaps build option
The scripts/build.sh script has an option --skip-googlemaps. Introduced
in 2017 at a moment the Travis Mac build failed on this. Interestingly,
when Mac building of the maps plugin was possible again (commit 79e3f69f48)
the --skip-googlemaps stayed. Obviously, this hack was never intended
to be used for anything else then getting it passed Travis on
some point in time for a specific Mac build.

So, remove this option.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2019-01-07 09:27:38 -08:00
Miika Turkia
fd5aad7192 Use state structure for sample rate info
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2019-01-03 06:56:48 +02:00
Lubomir I. Ivanov
0903bef9db update year to 2019 in about screens
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2019-01-02 09:45:01 -08:00
Lubomir I. Ivanov
85fe844af4 desktop/preferences: rename the default file group
The original name was just "Dives" which is not
descriptive enough. Use "Default file".

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2019-01-02 09:43:34 -08:00
Miika Turkia
5ae54f481c Shearwater Cloud mentioned in changelog
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2019-01-01 15:38:32 +02:00
Miika Turkia
9c42345494 Use correct value for PO2
averagePPO2 appears to be correct value instead of currentPPO2SetPoint.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2019-01-01 15:32:27 +02:00
Dirk Hohndel
eea0cdee65 Desktop: change preferences dialog name to 'Preferences'
Fixes #1912

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-12-31 09:53:21 -08:00
Miika Turkia
5930cb52de Grab correct setpoint on Shearwater cloud import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-31 06:21:53 +02:00
Miika Turkia
bf925cd511 Describy configuring copy-paste on mobile
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-30 21:57:31 +02:00
Dirk Hohndel
bae683ad53 Travis: use 5.12.03 Docker image for Android
With this we have working arm and arm64 images (except that the arm64
image crashes when using Bluetooth).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-12-30 11:20:34 -08:00
Dirk Hohndel
ad84a96fdb Android Dockerfile: add latest cmake 3.13.2
cmake 3.10 (which comes with Ubuntu 18.04) in combination with Qt 5.12
and the current qt-android-cmake causes an odd bug. Paths are set with a
double slash at the start '//' and later in the process this causes
garbled path names for some of the objects which in return causes the
APKs built in the container to fail.

Upgrading the cmake inside the container to 3.13.2 fixes that problem.

All the credit for identifying the problem and figuring out a solution
goes to Jan Mulder.

The resulting container was pushed to Docker hub as version to 5.12.03.

Reported-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-12-30 11:20:34 -08:00
Jan Mulder
63498df1bc Android Docker: give the docker build its own output tree
Again, this is relevant for developers that do local docker android
builds, and normal android builds. A normal build uses the directory
subsurface-mobile-build-arm(64), and when doing a docker android build
this directory is shared between host and container. That sharing is
good, as it nicely exposes the build tree to the host (for easy compare,
inspection, etc.). But reusing the same tree as the local one is
inconvenient (and possibly dangerous due to all kinds of caching
issues).

So, give the docker build its own output tree for the shared
subsurface-mobile-build-arm(64) build output.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-12-30 11:20:34 -08:00
Jan Mulder
1e1457318c Android Docker: give the android builder its own name
Users that use docker locally for Windows style build and Android style
builds will (probably) not like that we use the same name for both
docker containers. So, give the android builder its own name.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-12-30 11:20:34 -08:00
Jan Mulder
20c40ea6b4 Android build: always reconfigure libdivecomputer
This fix makes no difference from usage of this script in Travis
context, as every build starts from a clean VM, but the very few
developers that build for Android locally, and that want to use the new
style docker container builds as well, things are broken.

libdivecomputer has build artifacts in its source tree (and that source
tree is shared between local and docker run). So it happens that
libdivecomputer is configured locally, and afterwards fails to build
in docker build as its already configured, but not for the docker
image its now running in.

The fix is simple. Always reconfigure libdivecomputer when using this
script.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-12-30 11:20:34 -08:00
Dirk Hohndel
6fb135eb46 Android: build both 32 and 64 bit binaries
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-12-30 11:20:34 -08:00