Commit graph

15340 commits

Author SHA1 Message Date
Dirk Hohndel
fd31dfe40d Mobile/filtering: use margins instead of rectangles to create space
I'm not sure why this had initially failed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
c797038bd8 Mobile/filtering: only filter when editing is finished
This is a usability / performance tradeoff. I like it better when it filters as
I type, but on mobile this may make things feel sluggish.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
f965492241 Mobile/filtering: reset the filter text when toggled
This seemed less UI clutter than adding a clear button.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
cadb072a0c Mobile/filtering: improve code readability
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:29 +01:00
Dirk Hohndel
e5ee895793 Mobile/filtering: animate the filter header
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:29 +01:00
Dirk Hohndel
2fe1750bf8 Mobile/filter: add marker between entries in full text search
Otherwise we could match the end of one string and the beginning of the next,
so having a buddy name Linus and a dive master named Alvin would be matched
by USA.

Also add Notes to the full text search (I had forgotten those earlier).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:29 +01:00
Dirk Hohndel
90d321f0ff Mobile/filtering: add count of filtered dives to search bar
The count in the trip headers is still that for the complete trip and therefore
misleading.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:29 +01:00
Dirk Hohndel
65aa6bc43b Mobile/filtering: make the search box an overlay
This way it stays at the top of the dive list.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:29 +01:00
Dirk Hohndel
8f7633eff8 Mobile/filtering: full text filter, instead of just dive site
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:29 +01:00
Jan Mulder
0bc0b6bfe8 Mobile/filtering: first attempt to filter on dive site
[Dirk Hohndel: this is the starting point of my following commits, I decided to
	       leave it in place to give Jan credit for the work he did on
               figuring out some of the plumbing needed to get things to work]

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:29 +01:00
Jan Mulder
f1bb2c8478 Mobile/filtering: add icons for filter and sort
Add 2 icons for filter and sort capabilities. And as before, these
icons are coming from the Google Material design set.

[Dirk Hohndel: Jan's commit forgot to add the actual icons, I added
               those so the commit matched its message]

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:29 +01:00
Berthold Stoeger
ca211c03e0 Dive site: remove webservice code in MainTab::updateDiveSite()
There was still code in MainTab::updateDiveSite() related to
dive-sites obtained from the obsolete web-service. Remove.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-23 22:07:42 +01:00
Berthold Stoeger
954553b878 Parser: remove static variable location in import-cobalt.c
A static variable was used to collect two parts of the location
string. Instead, explicitly store these two parts in two different
strings and concetenate them. One fewer variable and the program
flow is thus hopefully more clear.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-23 08:06:28 +01:00
Berthold Stoeger
138f27f65d Parser: make parser (mostly) reentrant
Introduce a parser_state structure, which describes (most) of the
global parser state. Create such a structure in the entry routines
to the parser and pass it down to the individual functions. The
parser state is initialized and freed with the init_parser_state()
and free_parser_state() functions.

The main benefits are:
1) Isolation of parser state.
2) Keeping the global name space tidy.
3) Prevent memory leaks which could happen in truncated files by
   freeing all the parser state after parse.

A somewhat controversial point might be that the individual
parsing functions are split in those that need parser-state and
those that don't. This means that there are now two versions of
the MATCH macro, viz. one for the former and one for the latter.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-23 08:06:17 +01:00
Berthold Stoeger
343808271c Core: accept NULL-pointer in free_trip() and free_divesite()
This is consistent with most other free_*() functions in the core
code and will make cleanup of parser state less verbose.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-23 08:06:17 +01:00
Berthold Stoeger
46bf8bf2fa Core: export free_picture()
Export the free_picture() function from dive.c. The parser may need
this in case of truncated files to free its temporary resources.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-23 08:06:17 +01:00
Stefan Fuchs
45f4dac70a mxe-based-build.sh comments: Also build libftdi1
Add libftdi1 in comments in MXE build script.

[Dirk Hohndel: and mention that it is possible to build without it]

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 07:43:16 +01:00
Berthold Stoeger
ee0fc25cf3 Parser: remove webservice related code
Recently, the subsurface webservice was removed. Remove the corresponding
code in the parser. This removes a static variable, which was used
to generate unique dive-site ids.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-22 09:07:27 -04:00
Jocke
9c6d24e50e Mobile UI: make SsrfSwitch resizable
Back in 8ab8a67f the checkbox where made resizable.
This applies the same functionality to the selector switch and makes the
two objects match in vertical size.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-10-21 14:43:41 -04:00
Berthold Stoeger
6ed5db4d51 Dive list: remove three unnecessary instances of qobject_cast<>.
In DiveListView, the result of model() was dynamically cast to
QSortFilterProxyModel. But then, only the virtual match() function
was used. The whole point of virtual functions is that you can
cast them on the base-class and it will execute the function of
the derived class. Thus, remove these casts and operate directly
on the QAbstractItemModel base class.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-21 19:57:49 +03:00
Berthold Stoeger
9829e49815 Dive list: move dive-selection code from filter to list
After invalidating the filter, the dive-selection was modified to
ensure that at least one dive is selected. This was done in the
filter code, but it seems preferrable to do this in the dive-list
code, which has direct access to the selection-model.

Therefore, move the code from MultiFilterSortModel to DiveListView.
While doing so, split the code in DiveListView into more functions to:
1) Get the index of the first dive (if any).
2) Select the first dive (if any).

This allows a distinct size reduction of conditional compilation
in MultiFilterSortModel (accesses to MainWindow are not possible
in mobile code).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-21 19:57:49 +03:00
Berthold Stoeger
2f81890f49 Dive list: update trip headers on filter-finish
On change of the filter, the headers of non-extended trips were not
updated. Therefore, on filter-finish-event loop over all trips
in DiveTripModel and signal data-changed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-21 19:57:49 +03:00
Berthold Stoeger
bca9c8f88c Parser: free city and country after use
The variables country and city used in divinglog_place()
were never freed. Free them when the pointers are reset.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-21 19:56:02 +03:00
Berthold Stoeger
9025694d12 Parser: free old string in utf8_string
The utf8_string() function is used to extract whitespace-trimmed
strings. The function would happily overwrite the pointer to
the old string, which could therefore leak (suppose an XML has
redundant attributes).

Therefore preemtively free the string output parameter. This makes
it of course necessary to only pass in NULL-initialized pointers
or pointers to owned string.

The code survives the current set of parser-tests.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-21 19:56:02 +03:00
Linus Torvalds
28e3413ff6 Add 'location_t' data structure
Instead of having people treat latitude and longitude as separate
things, just add a 'location_t' data structure that contains both.

Almost all cases want to always act on them together.

This is really just prep-work for adding a few more locations that we
track: I want to add a entry/exit location to each dive (independent of
the dive site) because of how the Garmin Descent gives us the
information (and hopefully, some day, other dive computers too).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-10-21 19:55:09 +03:00
Jan Mulder
c986940630 Profile: show correct info box for multiple DCs
Update the dive info box when toggling the chosen DC using the
keyboard. The keyboard toggle does not generate a mouse move
event, so this data was not repainted. For this, a
sub-optimization of not repainting when not moving the mouse
had to be removed. This does not impact ant performance
as 99.9999% of the calls of the repaint are caused by mouse
movement anyway.

Fixes: #1802

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-20 06:50:52 -04:00
Jan Mulder
cc225a44f2 Preferences: set deco parameters correctly enabled
And fix another bug in this area of the code. It appeared that
the gflow/gfhigh and conservatism deco parameters where not
enabled at startup, but after toggling the VPM vs BUEHLMANN setting
they were.

So, fix this as well.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-19 06:25:32 -04:00
Jan Mulder
66c4397efd Preferences: wire-up the deco parameters
The deco parameters need special treatment to wire them up to the
underlying deco model code. And with the new preferences setup this
is a lot of boilerplate.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-19 06:25:32 -04:00
Berthold Stoeger
0416e54049 Dive site: select dive site when entering edit mode
Commit 0aef04352a made it impossible
to move new dive sites on the map. When entering dive-site-edit mode,
the filter would be instructed to show only dives of the corresponding
dive site [which didn't yet exist] and therefore all dive sites
on the map were deselected.

Fix this by explicitly centering on the dive site to be edited in
MapWidgetHelper::enterEditMode().

Fixes #1809

Reported-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-19 06:20:07 -04:00
Berthold Stoeger
5a65bb75da Parser: don't leak extra data key/value pairs
On parsing of dive computer extra data, key/value pairs are stored
in global state. They are added to the dive computer with
add_extra_data(), which makes a copy of the string. The local
copies of the strings are never freed.

free() the strings after storing them. The data still leaks in case
of unfinished parsing of extra_data tags, but this will be
taken care of in a subsequent commit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-16 06:20:46 -04:00
Berthold Stoeger
6fd663f9b3 Core: use free_dc_contents() in delete_current_divecomputer()
delete_current_divecomputer() had some duplicate code to release
dive-computer resources. Use the free_dc_contents() function instead.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-16 06:20:33 -04:00
Berthold Stoeger
065c41b834 Core: copy / free serial and fw_version items of struct divecomputer
The serial and fw_version strings of struct divecomputer were copied
by pointer. This worked because they were never freed or modified.
Instead, do a deep copy of the strings and free them when appropriate.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-16 06:20:33 -04:00
Berthold Stoeger
c61cf991e0 Core: copy and free extra_data of dive computer structure
On dive computer copy, the extra data (a list of key/value pairs)
was simply copied as a pointer. This worked because the list was
never freed nor modified. Copy and free the list on dive computer
copy and free, respectively.

This made it necessary to move the STRUCTURE_LIST_* macros up in
the dive.c file.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-16 06:20:33 -04:00
Berthold Stoeger
763c3683e5 Core: fix broken commit e5dca8228e
In commit e5dca8228e a fixed order
of the arguments to merge_dives() was introduced: first dive old,
second dive downloaded. This made the dl variable, which pointed
to the downloaded dive useless. One instance was forgotten, which
led to a null-dereference.

Remove.

Reported-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-15 21:00:45 -04:00
Berthold Stoeger
7f49e43d76 Cleanup: make xml_parsing_units local to parse-xml.c
xml_parsing_units stores the units of the currently parsed XML
file. It is not used outside of parse-xml.c. Therefore, make
it of static linkage and remove the declaration from dive.h.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-15 21:00:17 -04:00
Berthold Stoeger
253510c555 Cleanup: remove apparently dead code in sanitize_cylinder_type()
sanitize_cylinder_type(), which is indirectly called from fixup_dive(),
had ft^3 -> mliter conversion code, which was executed on the
condition "xml_parsing_units.volume == CUFT".

But nowhere in the code base would xml_parsing_units.volume ever be
set to non-metric. Moreover, xml_parsing_units reflects the units
of the latest parsed XML file, but fixup_dive() is called in numerous
contexts not related to XML parsing. Therefore, the whole piece of
code seems highly questionable.

Remove this code.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-15 21:00:17 -04:00
Berthold Stoeger
08827cc5f6 Parser: fix leakage of dive-site and dive data
Dive site data was collected in "cur_dive_site", which was then
merged into an existing or a new dive site. But only the struct
dive_site pointed to by "cur_dive_site" and the taxonomy data
were freed, not the textual data such as name or description.
Therefore, split out the approrpriate free-ing from the
delete_dive_site() function and call that instead of a simple
free().

A similar situation occured for dives that would not be added
to the dive-table because they were deemed incomplete. Use
free_dive() here instead of a simple free() too.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-15 20:59:55 -04:00
Linus Torvalds
a2028cd6ef deco: _really_ make sure the deco state is fully initialized
I incorrectly thought that 'ci_pointing_to_guiding_tissue' was the only
missing initialization, because that is the only one valgrind pointed at.

... that is, until I started looking at a few more dives, which showed
that there were other parts tht weren't initialized either, like

        double tolerated_by_tissue[16];
        double tissue_inertgas_saturation[16];
        double crushing_onset_tension[16];            // total inert gas tension in the t* moment

so just make sure to clear the whole data structure, to avoid any random
behavior due to uninitialized deco state.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-10-15 20:57:25 -04:00
Berthold Stoeger
0e00d40ead Selection: always make newly selected dive the current dive
In select_dive(), the selected dive would only be made the
current dive, if it wasn't previously selected. If multiple
dives were selected and the user clicked on one of them which
is not the current dive, then the current dive would be
deselected and thus not be the current dive anymore. The
only remaining dive would not be made the current dive,
because it was already selected. End result: null dive shown.

Therefore, always make the selected dive the current dive,
even if it is already selected.

Fixes #1792

Reported-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-15 20:57:10 -04:00
Berthold Stoeger
3c1002d7ef Dowload: Deselect dives only if at least one dive was downloaded
On dive-download old dives are deselected and a new one is selected.
If no dives were downloaded, accordingly no dives were selected.
This deselect only dives if at least one dive was downloaded.

Fixes #1793

Reported-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-15 20:55:58 -04:00
Berthold Stoeger
813c570524 Core: copy whole list in copy_dc_renumber()
copy_dc_renumber() is an internal function to copy dive computers
and renumber the cylinders. Since only the structure was copied,
in the case of multi-dc dives, the merged dives shared the same
computer. If one of them was freed, use-after-free crashes would happen.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-15 20:55:03 -04:00
Miika Turkia
36043e8af2 Add new package to Ubuntu requirements
This package is needed for building the mobile (on desktop) version.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-10-15 16:37:40 -04:00
Linus Torvalds
193a7d3a56 deco: make sure deco state is fully initialized
This shouldn't have caused any issues, but it made for valgrind noise. So fix it.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-10-15 21:21:05 +02:00
Dirk Hohndel
a6e4de6b5e Tests: remove testing of download_mode
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-15 19:46:18 +02:00
Dirk Hohndel
a20626a874 Bluetooth cleanup: remove pointless download_mode
This was used to track whether we had selected the native BT mode in the
download dialog. But the information is redundant as we can tell from the
device name whether this is a BT/BLE download or not.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-15 19:46:18 +02:00
Dirk Hohndel
5b925d29af Desktop/trivial: fix misleading comment
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-15 19:46:18 +02:00
Berthold Stoeger
a58908df8e Dive import: reset current_dive in process_imported_dives()
process_imported_dives() might delete the currently selected
dives. This could lead to use-after-free problems. Therefore,
reset the currently selected dive to the last dive.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-15 12:50:44 -04:00
Berthold Stoeger
2775e7e991 Dive import: remove dive-to-be added from trip before deletion
On dive import, dives to be added may be merged into already
existing dives. In such a case, the dive to be added is deleted.
Before doing so, it must be removed from the trip is belongs to
to avoid corruption of the trip-list.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-15 12:50:44 -04:00
Berthold Stoeger
207ca0f94e Dive list: make deep copy of picture list on merge
On merging make a deep copy of the picture list, to avoid a use-after-free
crash after the orginal dive is deleted.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-15 12:50:44 -04:00
Berthold Stoeger
471fc1dfc8 Dive list: fix crash on dive import
In commit 8c2383b495 dive merging was
changed to not modify the original dive. On import, dives were then
merged and the original deleted. The merge_weightsystem_info() was
not adapted accordingly (deep copy of string instead of pointer),
leading to a use-after-free crash.

Resolve this by doing a deep copy.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-15 12:50:44 -04:00