Commit graph

14524 commits

Author SHA1 Message Date
jan Iversen
1bc361b2ea core/tests: add uuidString to qPrefUpdateManager
add static class variable uuidString to qPrefUpdateManager
correct test cases

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-25 11:49:47 -07:00
jan Iversen
be9c47954c core: qPrivate add handle macros for class variables
Some variables are not in structure prefs, but are static class
variables, these will not be synced on exit, because they can only
be changed through the setter, but loaded on startup.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-25 11:49:47 -07:00
jan Iversen
69f21d9aed core: make methods in qPrefPrivate static
Small cleanup, using static methods is simpler and faster

Added propSetValue and propValue instead of exposing setting
variable.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-25 11:49:47 -07:00
jan Iversen
c3a54826a2 core: qPrefPrivate.h correct spaces before \ in macros
the ending \ in macros have been expanded to many spaces, correct back to
1 space

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-25 11:49:47 -07:00
Salvador Cuñat
b87cbddfc1 smtk-import: Apply lists to main smartrak_import() function
Previously we built arrays for the tables each time we parsed a dive.
Now we simply build the lists once, and use them in each dive parsing.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2018-08-25 11:11:51 -07:00
Salvador Cuñat
272dcf9514 smtk-import: move from arrys to lists while parsing tables
In most cases we can not foresee the maximum number of data of a given
type. It can be quite low or really big (a concerned diver can store
thousands of different fishes in Fish table).
Moving from arrays, where size has to be preset, to linked lists seems
the more logical option.
Here we set a (very limited) data structure, just an index and a text
fields following the format of most SmartTrak tables. Some special
table, like Buddy, needs a bit of processing before placing the data in
the list.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2018-08-25 11:11:51 -07:00
Salvador Cuñat
25491cf077 smtk-import: Do not set build type in CMakeLists.txt
We set the build type from the building script. Setting this in
CMakeLists.txt make the script setting useless and always build Release
type.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2018-08-25 11:11:51 -07:00
Jocke
84eb2e377e Update Changelog
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-08-25 07:01:42 -07:00
Jocke
02af3463d0 Mobile: add default cylinder UI
Add the UI components to let the user set the default cylinder and select
the chosen cylinder when adding a new dive.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-08-25 07:01:42 -07:00
Berthold Stoeger
011158b25c Cleanup: const-ify functions taking dives and divecomputers
Another small step in making things const-clean.
See also commit 605e1e19ed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-23 14:41:01 -07:00
Dirk Hohndel
b352eaae12 Latest translations
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-23 10:22:39 -07:00
Berthold Stoeger
d815e0c947 Parse: pass dive_table argument to parse_file()
To enable undo of divelog-importing it is crucial that parse_file()
can parse into arbitrary dive tables.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-23 10:17:12 -07:00
Berthold Stoeger
ecb64d7e3e Cleanup: user properly typed pointers
A trivial cleanup: replace void by properly typed pointers in
cylinder_none() and weightsystem_none(). Moreover, remove the
unused function no_weightsystems().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-23 05:21:08 -07:00
jan Iversen
62672276d0 core: correct error in qPrefUpdateManager
make next_check (in qPrefUpdateManager) long instead of string

Correct test cases (compare time_t not strings)
Add test case to check time_t works as expected

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-23 05:19:16 -07:00
jan Iversen
fa62ffdbf0 core: correct error in qPrefLanguage
Correct mangled disk names

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-23 05:19:16 -07:00
Berthold Stoeger
605e1e19ed Cleanup: const-ify functions taking pointers to events
This is another entry in the series to make more things
"const-clean" with the ultimate goal of merge_dive() take
const pointers.

This concerns functions taking pointers to events and
the fallout from making these const.

The somewhat debatable part of this commit might be
that get_next_event() is split in a two distinct
(const and non-const) versions with different names,
since C doesn't allow overloading. The linker should
recognize that these functions are identical and remove
one of them.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-23 05:16:38 -07:00
Berthold Stoeger
44f34d8cd7 Cleanup: const-ify parameters to trivial accessor functions
Accessor-functions without noticeable logic, such as depth_to_bar()
can trivially be made "const-clean".

Moreover, let get_dive_location() return a "const char *". The
non-const version must have been an oversight, as the caller
must not free() or overwrite the string.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-23 05:16:38 -07:00
Berthold Stoeger
360f07e453 Cleanup: pass gasmix by value
In a previous commit, the get_gasmix_* functions were changed to
return by value. For consistency, also pass gasmix by value.

Note that on common 64-bit platforms struct gasmix is the size
of a pointer [2 * 32 bit vs. 64 bit] and therefore uses the
same space on the stack. On 32-bit platforms, the stack use
is probably doubled, but in return a dereference is avoided.

Supporting arbitrary gas-mixes (H2, Ar, ...) will be such an
invasive change that going back to pointers is probably the
least of our worries.

This commit is a step in const-ifying input parameters (passing
by value is the ultimate way of signaling that the input parameter
will not be changed [unless there are references to said parameter]).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-23 05:16:38 -07:00
Berthold Stoeger
5c4569247a Cleanup: unify get_gas_at_time() and get_gasmix()
There were two functions for getting gas-mixes at a certain timestamp:
- get_gasmix() for repeated queries.
- get_gas_at_time() for a single query.
Since the latter is a special case of the former, simply call
the former in the latter. Moreover, rename to get_gasmix_at_time()
for consistency.

Replace on get_gasmix() call, which was outside of a loop by the
corresponding get_gasmix_at_time() call.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-23 05:16:38 -07:00
Berthold Stoeger
f5b11daffd Cleanup: return gasmix by value
Currently, get_gasmix_from_event() and get_gasmix() return pointers
to either static or to (possibly changing) dive data. This seems like
a dangerous practice and the returned data should be used immediately.

Instead, return the gasmix by value. This is in preparation of
const-ifying input parameters of a number of core functions, which
will ultimately let the merge() function take const-arguments in
preparation of undo of dive-merging.

On common 64-bit systems gasmix (two "int"s) is the size of a pointer
and can be returned in a register.

On 32-bit systems a pointer to the struct to be filled out will be
passed.

Since get_gasmix() now returns a value, the first invocation is
tested by a NULL-initialized "struct event *". Document this in
a comment.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-23 05:16:38 -07:00
Berthold Stoeger
b6187f73aa Cleanup: fix memory leak on failed DLF import
In the case of a failed dlf import, the memory of the read-in
file was not freed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-23 05:07:58 -07:00
Berthold Stoeger
7ae1b8cb11 Cleanup: fix memory leak in OSTC import
The OSTC branch forgot to release the memory of the file.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-23 05:07:58 -07:00
Lubomir I. Ivanov
c354abfe7c CHANGELOG.md: add note about html-export bugfix
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-08-23 05:01:32 -07:00
Lubomir I. Ivanov
d2dfc922f3 save-html: make sure that some strings are quoted
- filenames for pictures
- trip locations
- event names (not really needed)

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-08-23 05:01:32 -07:00
Lubomir I. Ivanov
38f09cbd16 CHANGELOG.md: update with the latest map-widget fix
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-08-18 18:50:26 +02:00
Lubomir I. Ivanov
b4f10553cc map-widget: add support for filtering of map locations
If the dive list is filtered the map should hide dive locations
that do not match the dive list filter.

To achieve that, loop over dives instead of dive sites in
MapWidgetHelper::reloadMapLocations() and discard
dives that are hidden by the filter. Then check if a dive
has a dive site attached to it and re-use the old functionality.

Suggested-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-08-18 18:50:26 +02:00
Lubomir I. Ivanov
7cf05897a2 divelogexportlogic: show warning on missing 'theme' folder
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-08-17 00:58:01 +02:00
jan Iversen
da4ced9bdf core: remove SettingsObjectWrapper.*
remove unused files SettingsObjectWrapper.*

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-15 16:11:39 -07:00
jan Iversen
c579af0a19 ssrf: remove SettingsObjectWrapper and update qPref calls
remove use of SettingsObjectWrapper::
remove include of SettingsObjectWrapper.h
use qPrefFoo:: for setters and getters
replace prefs.foo with qPrefXYZ::foo() where feasible
(this expands to the same code, but gives us more control
over the variable).

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-15 16:11:39 -07:00
jan Iversen
0f68e0cc2e desktop-widget: remove SettingsObjectWrapper and update qPref calls
remove use of SettingsObjectWrapper::
remove include of SettingsObjectWrapper.h
use qPrefFoo:: for setters and getters
replace prefs.foo with qPrefXYZ::foo() where feasible
(this expands to the same code, but gives us more control
over the variable).

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-15 16:11:39 -07:00
jan Iversen
c6998ee926 desktop-widgets/facebook: remove SettingsObjectWrapper
remove use of SettingsObjectWrapper::
remove include of SettingsObjectWrapper.h
use qPrefFoo:: for setters and getters
replace prefs.foo with qPrefXYZ::foo() where feasible
(this expands to the same code, but gives us more control
over the variable).

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-15 16:11:39 -07:00
jan Iversen
4b2071728d core: remove SettingsObjectWrapper and update qPref calls
remove use of SettingsObjectWrapper::
remove include of SettingsObjectWrapper.h
use qPrefFoo:: for setters and getters
replace prefs.foo with qPrefXYZ::foo() where feasible
(this expands to the same code, but gives us more control
over the variable).

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-15 16:11:39 -07:00
jan Iversen
94fd758607 mobile-widgets: remove SettingsObjectWrapper and update qPref calls
remove use of SettingsObjectWrapper::
remove include of SettingsObjectWrapper.h
use qPrefFoo:: for setters and getters
replace prefs.foo with qPrefXYZ::foo() where feasible
(this expands to the same code, but gives us more control
over the variable).

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-15 16:11:39 -07:00
jan Iversen
1cc7c05170 profile-widget: remove SettingsObjectWrapper and update qPref calls
remove use of SettingsObjectWrapper::
remove include of SettingsObjectWrapper.h
use qPrefFoo:: for setters and getters
replace prefs.foo with qPrefXYZ::foo() where feasible
(this expands to the same code, but gives us more control
over the variable).

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-15 16:11:39 -07:00
jan Iversen
50c58b4065 qt-models: remove SettingsObjectWrapper and update qPref calls
remove use of SettingsObjectWrapper::
remove include of SettingsObjectWrapper.h
use qPrefFoo:: for setters and getters
replace prefs.foo with qPrefXYZ::foo() where feasible
(this expands to the same code, but gives us more control
over the variable).

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-15 16:11:39 -07:00
jan Iversen
6aee600aa7 desktop-widgets/preferences: reemove SettingsObjectWrapper
remove use of SettingsObjectWrapper::
remove include of SettingsObjectWrapper.h
use qPrefFoo:: for setters and getters
replace prefs.foo with qPrefXYZ::foo() where feasible
(this expands to the same code, but gives us more control
over the variable).

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-15 16:11:39 -07:00
jan Iversen
3b84dbe554 ssrf: call sync() when exiting appl.
In order to ensure preferences are saved, sync() is called
when leaving the program.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-15 16:11:39 -07:00
jan Iversen
f251faa501 core: use qPref::load/sync
use qPref instead of SettingsObjectWrapper for load/sync
(seems sync is only used for testing)

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-15 16:11:39 -07:00
jan Iversen
f2c302284b core: qPref limit header includes
replace qPref.h with qPrefFoo.h to limit header includes

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-15 16:11:39 -07:00
jan Iversen
9b8a6fa855 core: make methods in qPref* static
Make methods static to allow fast and esay access
use qPrefXYZ::foo() instead of qPrefXYZ::instance()->foo()

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-15 16:11:39 -07:00
jan Iversen
0825f644e0 core: make qPref.* use static
Prepare qPref.* to run load/sync
Make variables and methods static to give easy access
Make getter inline to give faster access

Signed-off-by: Jan Iversen <jani@apache.org>:wq
2018-08-15 16:11:39 -07:00
jan Iversen
253d868328 core: qPrefPrivate allow setters to be static
static setters are easier to reference
qPrefFoo::set_xyz() instead for qPrefFoo::instance()->set_xyz()

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-15 16:11:39 -07:00
jan Iversen
bac6456ee6 tests: remove testpreferences
remove the now empty testpreferences

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-15 16:11:39 -07:00
Berthold Stoeger
a781d3a44e Cleanup: fix warning in unix.c
The compiler complained about assigning the "const char *" returned by
mb_cstring() to a "char *". The warning is correct, as the returned
buffer still belongs to the membuffer. The code only worked because
destruction of the membuffer was "forgotten".

Fix this by using the "detach_buffer()" function, which passes ownership
to the caller and accordingly returns a "char *".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-14 14:13:52 -07:00
jan Iversen
f2c45c8187 tests: add General qml test cases
Add tst_qPrefGeneral qml file to test C++ qml connection

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-14 09:09:06 -07:00
jan Iversen
91ec0fe8d4 tests: move General test from testpreferences
Remove General test in testpreferences
add the same General tests to testqPrefGeneral

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-14 09:09:06 -07:00
jan Iversen
4ba458318c tests: add qPrefGeneral testcases
add test cases to secure struct preferences and qPrefGeneral work together

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-14 09:09:06 -07:00
jan Iversen
691025fa24 core: activate qPrefGeneral
remove General from SettingsObjectWrapper and reference qPrefGeneral

update files using SettingsObjectWrapper/General to use qPrefGeneral

this activated qPrefGeneral and removed the similar class from
SettingsObjectWrapper.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-14 09:09:06 -07:00
jan Iversen
4a7864444b core: create qPrefGeneral from SettingsObjectWrapper
Update set/get functions to follow common name scheme:
- get function have same name as in struct diveComputer
- set function have set_<name>
- signal function have <name>_changed

one class one .h/.cpp is the C++ idiom. Having load/sync of each
variable in 1 functions (in contrast to the distributed way
SettingsObjectWrapper handles it) secures the same storage name
is used. Having the set/get/load/sync functions grouped together
makes it easier to get an overview.

REMARK: this commit only defines the class, it is not active in production

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-14 09:09:06 -07:00
jan Iversen
d5b087f01f core: change default_file_behavior from short to enum
change to enum as it really is

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-14 09:09:06 -07:00