Commit graph

15381 commits

Author SHA1 Message Date
Miika Turkia
6000d3c502 Merge branch 'willemferguson-mobilemanual3'
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-23 07:36:03 +02:00
John Plaxco
53e31c48ee Improve error reporting when exporting a selection of 0 dives.
If no dives are selected when trying to export a selection, a message
is shown that no dives were selected, but it's immediately hidden
behind a message saying that a temporary file could not be created.
In fact, the creation of the temporary file wasn't never attempted,
so the message that the user actually sees is misleading.

The solution chosen here is to duplicate the check that at least some
dives are selected, and abort early if that case is detected, rather
than continuing on to show the additional misleading message. Not
elegant, but it gets the job done.

Better solutions to this include refactoring prepare_dives_for_divelogs
to return something more descriptive than a bool, remove that check
from prepare_dives_for_divelogs entirely since it doesn't seem to be
a good fit there, or switch to exceptions for handling these problems
rather than return values. I don't have sufficient familiarity with
the codebase to attempt these more invasive changes, but they
should be considered in the future.

On a final note, some of the other error messages in this file start
with a capital letter, but the one relevant to this particular PR
does not. Again, I'm not familiar enough with the codebase (or
translations) to know if that's safe to change, so I'll leave that
for another time or another developer.

Reported-by: John Plaxco
Signed-off-by: John Plaxco <john@johnplaxco.com>
2018-12-23 04:55:28 +01:00
willemferguson
98b685286e Subsurface-mobile user manual V2.1.5
Updates to the user manual for Subsurface-mobile. Many new
figures have been brought in. The text has been overhauled
to include latest features and some features that do not
exist any more have been removed. Text has been added,
explaining the copy-and-paste operation (Thanks, Miika).

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2018-12-22 12:16:22 +02:00
Dirk Hohndel
c38215dfa7 Mobile: deal with BT name and address when tapping Download
Instead of trying to update this whenever the connection text changes,
instead deal with it right before it actually gets used.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-12-21 14:53:45 -08:00
Dirk Hohndel
ef8656998a Mobile: add helper function to fill in the BT name
For some devices the BT device name is different from the product name.
Make sure that name is available to the mobile UI. This helper fills it
in from the scan data (based on the device address).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-12-21 14:52:02 -08:00
Dirk Hohndel
6ba1cf8cf7 core: recognize Oceanic Pro Plus X over BLE
Just like with the Aqualung i770R in 7697003498 this name follows the
pattern of a model number in ASCII encoding, followed by the serial
number of the device.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-12-21 12:41:43 -08:00
Miika Turkia
10a0393b1b Mobile: force update of ui on paste
Apparently this does the trick of updating the dive list when pasting
data on mobile. Tnx janmulder.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-21 09:13:37 +02:00
Miika Turkia
3f8583de36 Mobile: initialize copy variables
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-21 09:13:37 +02:00
Miika Turkia
8203fa884e Add UI info to mobile documentation
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-21 09:13:37 +02:00
Miika Turkia
53ba950c8f Mobile: copy the dive data when configuring settings
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-21 09:13:37 +02:00
Miika Turkia
8e7a9a4f4c Mobile: UI for selecting what to copy-paste
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-21 09:13:37 +02:00
Jan Mulder
de813c27ce CHANGELOG
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-12-21 08:08:02 +01:00
Jan Mulder
73213d3c79 core: shift dive time in correct direction
Unsure where this bug got introduced, but when asking for the dive
time to be shifted 1 hour later, the divelist and the dive details
showed 1 our earlier.

Fixes: #1893

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-12-21 08:08:02 +01:00
Dirk Hohndel
9f417cacaa Update libdivecomputer
Catch up with Jef's upstream
Fix Oceanic pattern matching for BLE versions

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-12-19 07:36:40 -08:00
Berthold Stoeger
bfe69239df Import: unglobalize downloadTable
To make data flow more clear, unglobalize the downloadTable object.
Make it a subobject of DownloadThread. The difficult part was making
this compatible with QML, because somehow the pointer to the
download-table has to be passed to the DiveImportedModel. Desktop would
simply pass it to the constructor. But with objects generated in QML
this is not possible. Instead, pass the table in the repopulate()
function. This seems to make sense, but for this to work, we have to
declare pointer-to-dive-table as a Q_METATYPE. And this only works
if we use a typedef, because MOC removes the "struct" from "struct
dive_table". This leads to compilation errors, because dive_table is
the symbol-name of the global dive table! Sigh.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-17 07:37:32 -08:00
Berthold Stoeger
a6a5cf61e2 Cleanup: make DiveImportedModel::checkStates a std::vector
To not have to bother with memory-management. Moreover, the
old code was in principle wrong, since it assumed that
sizeof(bool) == 1. Of course, this is true for all supported
platforms, but let's not depend on such implementation-defined
behavior anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-17 07:37:32 -08:00
Berthold Stoeger
6febe22b6b Cleanup: remove DiveImportedModel::setImportedDivesIndexes()
This function resets the DiveImportedModel. It takes two
arguments: first and last index. All callers passed in 0
and number-of dives anyway, so remove the arguments.
Since this now does the same as repopulate(), merge the
two functions.

Moreover, implement Qt-model semantics by using a
beginResetModel()/endResetModel() pair. This simplifies the
code.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-17 07:37:32 -08:00
Berthold Stoeger
abf942f303 Cleanup: make DCDeviceData a "normal" singleton
DCDeviceData was using that weird pattern where the instance
variable was set in the constructor. There is no apparent
reason to do so, therefore convert to a "normal" singleton.

Access that directly in QMLManager instead of saving it in
a member variable first.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-17 07:37:32 -08:00
Berthold Stoeger
6184f5d276 Core: remove count_dives_with_*() functions
The simplified filter-widget doesn't present lists of existing values
with counts. Thus, a whole slew of count_dives_with_*() functions
can be removed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-17 07:33:45 -08:00
Robert C. Helling
f0164e97a2 Show average max depth in statistics tab
This makes more sense than average depth. The min entry is also
about max depth for a dive.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-12-17 12:18:26 +01:00
Robert C. Helling
ac8db01873 Show average max depth in yearly statistics
this was requested in #1854 and I think this suggestion makes sense

Fixes #1854

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-12-17 12:18:26 +01:00
Dirk Hohndel
99561484ad Update libdivecomputer
- Enable BLE support for the Oceanic Pro Plus X
- Add support for the Aqualung i300C
- Fix the Pro Plus X gas mixes
- Add a workaround for invalid ringbuffer begin pointers

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-12-14 16:36:22 -08:00
Tomaz Canabrava
705e61b62c Hide unimplemented components from search
Those fields are not ready yet, hide them.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2018-12-14 01:05:18 +08:00
Tomaz Canabrava
201f0c8f89 Filter the data
Wire up the needed code to filter the data in the myInvalidate
call. The data comes from the Struct FilterData and if any
of the test conditions on the filter function are false, the
filter will assume that the specific dive shouldn't be shown

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2018-12-14 01:05:18 +08:00
Tomaz Canabrava
e0f473fcb4 Drop old filter code
Drop tons of now-unused-code.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2018-12-14 01:05:18 +08:00
Tomaz Canabrava
43178be1f2 Handle Show / Close of the Filter Box
when you close, remove filter. when you open again, restore.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2018-12-14 01:05:18 +08:00
Tomaz Canabrava
81bb6086c0 Struct FilterData
The idea is that this struct will have all the needed data
that will be passed to the filter model. Everything that happens
on the filterwidget will fill out this struct, then forward it
to the model, that in turn will activate the filter hiding
some of the dives that matches on your divelist.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2018-12-14 01:05:18 +08:00
Tomaz Canabrava
89413c5f07 Replace the old filter widget for a new one
Wires the code to display the filter widget on the mainwindow.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2018-12-14 01:05:18 +08:00
Tomaz Canabrava
8378695d7f Start the FilterDive state
Register the new FilterDive widget on the mainwindow
so we can trigger a shortcut to display it.
The shortcut currently doesn't exists.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2018-12-14 01:05:18 +08:00
Tomaz Canabrava
19f6e8810c Start to implement a simplified version of the filter widget
The idea of this new widget is to be able to filter more
types of data, while keeping it simple and extending the
feature set to something that was impossible with the old
implementation.

While the old implementation had 4 panels that you could
use to filter specific tags / people / types of dives
the new one will let you filter by visibility, temperature
people, name, equipment, etc, in a more natural way
than the old one.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2018-12-14 01:05:18 +08:00
Berthold Stoeger
c64c9c923b Cleanup: detangle unregister_dive() and delete_single_dive()
These two functions were called in different contexts:
- unregister_dive(): from the undo-commands to remove the dive
  from the global dive table, but not delete it. The dive was
  already removed from its trip.
- delete_single_dive(): from non-undo code. Most of it not in
  use and removed in a sibling-commit. Here, the dive is supposed
  to be removed from its trip and a new selection is calculated.

delete_single_dive() calls unregister_dive(), which removes the
dive from its trip. Move remove_dive_from_trip() from the former
to the latter and make both functions independent. Instead
of deleting the dive explicitly in delete_single_dive(), call
the delete_dive_from_table() function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-14 00:29:31 +08:00
Berthold Stoeger
dfd7f98129 Core: don't remove dive from trip in add_dive_to_trip()
All callers of add_dive_to_trip() work on freshly generated dives,
with one exception, that was redundant anyway. Therefore it is not
necessary to remove the dive from a potential previous trip. Move the
responsibility of removing the dive from a trip to the caller,
respectively remove the redundant call. Add a warning message in the
case that trip is set.

Background: On import (either download or file-import) we might not
want to add trips to the global trip-list. For example to enable undo
of import but more generally to detangle that data flow. Thus,
add_dive_to_trip() should not mingle with the global trip-list,
which it has to do if a trip is deleted because the old dive was
removed.

Analysis of the add_dive_to_trip() callers:

1) core/dive.c

pick_trip():
    called on freshly generated merged dive.

finish_split():
    called on two freshly generated split dives.

2) core/divelist.c

create_and_hookup_trip_from_dive():
    called on freshly downloaded dive in dive_cb().
    called on freshly downloaded dive in record_uemis_dive().

autogroup_dives():
    called on dive from get_dives_to_autogroup(), which only
    finds dives that are outside of trips.

combine_trips():
    unused - removed in sibling commit.

try_to_merge_into():
    this call was actually erroneous - dive was already added
    to trip in try_to_merge(). Remove call.

3) core/libdivecomputer.c

dive_cb():
    called on freshly downloaded dive.

4) core/uemis_downloader.c

record_uemis_dive():
    called on freshly downloaded dive.

5) core/load_git.c

create_new_dive():
    called on freshly allocated dive.

6) core/parse.c

dive_end():
    called on freshly parsed dive.

7) desktop-widgets/command_divelist.cpp

DiveListBase::addDive():
    called on dive which is newly added to core.

moveDiveToTrip():
    called on dive that was removed from trip a few lines above.

8) mobile-widgets/qmlmanager.cpp

QMLManager::undoDelete():
    called on dive where divetrip was reset in the previous line.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-14 00:29:31 +08:00
Berthold Stoeger
662dd823fd Cleanup: remove split_dive_*() functions
In 302f6adb79 dive-splitting was made
undo-able. To this goal, the dive-splitting functions were split in
two types: Those that operate directly on the divelist and those that
only allocate the dives. The former are not in use anymore, therefore
remove them. Since only the latter remain, remove the "_dont_insert"
appendix of the name.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-14 00:25:07 +08:00
Berthold Stoeger
10c20babae Cleanup: remove merge_two_dives() function
In 014c04f8bd merging dives was included
in the undo-system. This made the merge_two_dives() function caller-less.
Remove it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-14 00:25:07 +08:00
Berthold Stoeger
a597929c10 Cleanup: remove remove_autogen_trips() function
In f427226b3b autogrouping / removal
of autogrouping was moved into the undo-machinery. This made the
remove_autogen_trips() function caller-less. Remove it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-14 00:25:07 +08:00
Berthold Stoeger
0a3d757aab Cleanup: remove combine_trips() function
In f427226b3b a combine_trips_create()
function was introduced that combined trips without deleting the old
trips. This was necessary for making combine-trips function undo-able.

The old combine_trips() function is not used anymore. Therefore remove
it. Rename the combine_trips_create() function to combine_trips() as
no differentiation is needed anymore.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-14 00:25:07 +08:00
Berthold Stoeger
2706fa7b8e Dive list: remove trip from model only once
In moveDivesBetweenTrips() a the model is informed of dives
that are moved between trips. A flag tells the model to delete
empty trips. If dives were removed in batches [use case: split
a big trip into multiple smaller trips] the flag would be sent
for every batch. This was handled gracefully by the model code,
but it gave a warning message.

Set the flag only for the last batch, when the trip is *really*
empty.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-14 00:09:05 +08:00
Berthold Stoeger
3cdc2661d2 Dive media: add media to closest dive
Currently, when selecting "Load media files even if time does not
match the dive time", the media are added to *all* selected dives.
Instead add it to the closest dive.

This seems like the less surprising behavior. Of course now if the
user really wants to add a media file to multiple dives, they will
have to do it manually.

To avoid a messy interface, this is solved by moving the iterate-
over-selected-dives loop to the core. Thus, a helper-function can
be made local to its translation unit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-13 08:11:22 +01:00
Jan Mulder
09a9fa1ae5 Android build: use our own gradle build spec
At this point in time there seems something wrong with jcenter that
is used to download all Android build artifacts from. It simply does
not find the needed stuff on there and our build fails. Its unclear
if this is a temporary issue at jcenter, or its just an intended change.

This fix is a bit of a hack. It provides our own gradle build spec
instead of the one that is provided from Qt (which is pulled in using
androiddeployqt). Added is a working download link to maven, and a
newer com.android.tools.build:gradle is used compared to Qt.

All this makes Travis happy again.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-12-12 12:25:35 +09:00
Dirk Hohndel
094ab67d23 Travis: fix the windows-container build
Call apt update before trying to install things.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-12-11 19:06:20 -08:00
Berthold Stoeger
779e33be5d Cleanup: don't leak filename on picture creation
dive_create_picture() is called from DiveListView::matchImagesToDives()
with a copy of the picture-filename. But:
  - On error the filename is not freed
  - On success the filename is strdup()ed
Thus, in all cases the memory is lost. Instead, pass in a temporary
buffer using qPrintable().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-11 23:59:30 +02:00
Robert C. Helling
b75081cc59 Invalidate git cache when removing dive from trip
... otherwise this change is not saved when saving to git.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-11 09:26:18 +01:00
Berthold Stoeger
99b2de85b5 Dive list: fix off-by-two bug in DiveTripModel
Commit 911edfca71 changed the dive list
on desktop to update positions of trips when adding/removing dives.
A very unlikely case, but necessary for consistency.

For a trip to be moveable down, its index has to be one-less than
the maximum index, which is "items - 1". The code was doubly wrong:
it forget the "1" and checked for less-or-equal instead less-than.
Thus this was effectively an off-by-two error. Fix it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-06 21:56:35 +01:00
Jan Mulder
b6d5dacd51 Android build: explicitly install using sdkmanager
Make sure all required Android SDK components are explicitly installed
before starting the actual build.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-12-06 21:53:02 +01:00
Jan Mulder
6c872931d5 Android build: buildtools version is automatically detected
With commit 0d8fc7ef970e of qt-android-cmake, the buildtools version
is automatically detected. So do not try to pass it any more, as
this breaks the build.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-12-06 21:53:02 +01:00
Berthold Stoeger
4bfcf12c17 Cleanup: remove EMPTY_DIVE_STRING
EMPTY_DIVE_STRING used to be a string-literal representing missing
information ("--"). In 6985c123d4 it
was replaced by the actual empty string. Using a literal to represent
the empty string seems a bit pointless, therefore remove it completely.

Notably:
	QString(EMPTY_DIVE_STRING) -> QString()
	if (temp.isEmpty()) temp = EMPTY_DIVE_STRING; -> noop
	if (s == EMPTY_DIVE_STRING) -> if (s.isEmpty())

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-11-24 11:01:20 -08:00
Berthold Stoeger
d67ecf8925 Cleanup: remove redundant 'extern "C"' in dive.h
In dive.h there was a redundant 'extern "C"' block defined inside
another 'extern "C"' block. Remove.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-11-23 13:24:00 -08:00
Berthold Stoeger
1ebf5a99ed Filter: use hidden_by_filter also on mobile
Desktop used the hidden_in_filter flag in struct dive, mobile
used its own vector plus a new showndives member in struct dive_trip.

Unifiy these to use the same core-facility, viz. hidden_by_filter.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-11-23 13:22:24 -08:00
Berthold Stoeger
70897dd1b7 Core: move is-single-day-trip and count-shown functions into core
These functionality was used by the desktop filter. To unify desktop
and mobile, move it into two new functions in divelist.c

Since one of them is the only caller of is_same_day() move that
likewise into divelist.c and make it of static linkage.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-11-23 13:22:24 -08:00
Berthold Stoeger
68414531ad Mobile: don't format trip heading for all dives
QML's ListView uses the "section" property to test if items belong to the
same section. Apparently, this must be a string and therefore we can't
pass e.g. a dive-trip object. Therefore a specially formatted string
was passed in, which was guaranteed to be unique (contained the dive-trip
pointer value) and the fully formatted trip-title and short-date.

The disadvantage of that approach is that the formatting is performed for
every dive and not every trip. Perhaps not a problem now, but it makes
it for example necessary to cache the number of filtered dives.

To be more flexible, pass in only the pointer value formatted as
hexadecimal string and provide a function to convert that string
back to a trip-pointer (in the form of a QVariant, so that it can
be passed to QML). Moreover provide two functions for formatting the
title and the short-date.

The three new functions are members of DiveListSortModel. This might not
be the perfect place, but it is easy to reach from the DiveListView.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-11-23 13:22:24 -08:00