Commit graph

1312 commits

Author SHA1 Message Date
jan Iversen
af22015452 core: activate qPrefGeocoding
remove Geocoding from SettingsObjectWrapper and reference qPrefFacebook

update files using SettingsObjectWrapper/Geocoding to use qPrefFacebook

this activated qPrefGeocoding and removed the similar class from
SettingsObjectWrapper.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-13 15:04:50 -07:00
jan Iversen
3cd698361c core: create qPrefGeocoding from SettingsObjectWrapper
Update set/get functions to follow common name scheme:
- get function have same name as in struct preferences
- 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-13 15:04:50 -07:00
jan Iversen
72d87364c0 core: activate qPrefLanguage
remove Language from SettingsObjectWrapper and reference qPrefLanguage

update files using SettingsObjectWrapper/Language to use qPrefLanguage

this activated qPrefLanguage and removed the similar class from
SettingsObjectWrapper.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-13 11:49:32 -07:00
jan Iversen
63fa532b15 core: create qPrefLanguage from SettingsObjectWrapper
Update set/get functions to follow common name scheme:
- get function have same name as in struct preferences
- 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-13 11:49:32 -07:00
Dirk Hohndel
ce4e0d3276 Use hex USB VID/PID
Except of course that the Android intent does give us these values in
decimal.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-12 15:37:21 -07:00
jan Iversen
75ce813a27 core: activate qPrefLocationService
remove LocationService from SettingsObjectWrapper and reference qPrefLocationService

update files using SettingsObjectWrapper/LocationService to use qPrefLocationService

this activated qPrefLocationService and removed the similar class from
SettingsObjectWrapper.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-12 11:30:19 -07:00
jan Iversen
2b11fd4cc8 core: create qPrefLocationService from SettingsObjectWrapper
Update set/get functions to follow common name scheme:
- get function have same name as in struct prefs
- 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-12 11:30:19 -07:00
jan Iversen
cb2dc7515b core: activate qPrefTechnicalDetails
remove TechnicalDetails from SettingsObjectWrapper and reference qPrefTechnicalDetails

update files using SettingsObjectWrapper/TechnicalDetails to use qPrefTechnicalDetails

this activated qPrefTechnicalDetails and removed the similar class from
SettingsObjectWrapper.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-12 07:36:10 -07:00
jan Iversen
b98ba9ba94 core: create qPrefTechnicalDetails 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-12 07:36:10 -07:00
jan Iversen
3c69c8299b core: SettingsObjectWrapper remove buehlmann property
remove buehlmann(), setBuehlmann(bool)

buehlmann() is really planner_deco_mode == BUEHLMANN, so no need for a function
setBuehlmann is dangerous, because buehlmann is saved on disk, but not in prefs.* and thus can lead to inconsistency between bool buehlmann and planner_deco_moce.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-12 07:36:10 -07:00
jan Iversen
e2374e2f81 core: qPrefDivePlanner, cleanup SettingsObjectWrapper
Remove individual store to disk for divePlanner in SettingsObjectWrapper

The save was double effect, qPrefDivePlanner::instance()->sync(), which
was preciding already do this.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-12 07:36:10 -07:00
Jocke
c33a952582 Mobile: return pressures for all used cylinders
Return all pressure values for all used cylinders as a list.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-08-11 11:19:07 -07:00
Jocke
f9e81c7326 Mobile: return all used gasmixes as a list
Planning ahead for full edit capabilities of dives that uses multiple cylinders.  

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-08-11 11:19:07 -07:00
Jocke
80df7dd441 Mobile: return all used cylinders as a list
Planning ahead for full edit capabilities of dives that uses multiple cylinders.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-08-11 11:19:07 -07:00
Dirk Hohndel
a85d4a6447 FTDI support: list PIDs in decimal everywhere
This makes it easier if we ever add one to make sure we find
all the places those need to be changed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-11 11:14:22 -07:00
Dirk Hohndel
9f94aaf450 Whitespace cleanup, extra braces, and null checks
Thanks to Lubomir for the review.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-11 11:14:22 -07:00
Dirk Hohndel
b85098d401 Android: add callback to Java code to check pending Intents
If we get launched by an intent, we need to delay processing that Intent
until after the app is initialized. This is the helper function we'll use
for that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-11 11:14:22 -07:00
Dirk Hohndel
ae6756e7f1 Android: don't assume that non-BT means FTDI on Android
We do support download from USB devices like the Atomic Aquatics Cobalt.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-11 11:14:22 -07:00
Dirk Hohndel
23bde692fa core: remove confusing information from debug message
This always looked like a thread number and really made no sense since
we had a much more informative debug message just a couple lines above.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-11 11:14:22 -07:00
Dirk Hohndel
1bbbc07dd5 core: add indexOf member to ConnectionListModel
This will allow us to programatically set the connection in the QML UI.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-11 11:14:22 -07:00
Dirk Hohndel
0b242bcaca Android: notify the UI a dive computer was plugged in
And try to guess which one from the device string we get from the Intent.

The function is named to indicate its future use (because once the user
plugs in such a device, we should show the download page).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-11 11:14:22 -07:00
Dirk Hohndel
7cc9da6347 Android: more FTDI debugging
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-11 11:14:22 -07:00
Dirk Hohndel
8b37e3f10e Android: add more verbose logging when trying to open USB
The goal is to be able to tell what's actually going wrong.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-11 11:14:22 -07:00
Dirk Hohndel
2ca8b98091 Android: log both for mobile and full app
We don't usually build the full app on Android, but it's still possible.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-11 11:14:22 -07:00
Dirk Hohndel
aed7528443 Android: add callback from Intent
Right now all this does is add the device string to the log.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-11 11:14:22 -07:00
Robert C. Helling
b9fcc9543d Allow zero length segments in planner
Those are needed to indicate bailout or set point switches
at the beginning of  the ascend.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-08-09 08:46:57 -07:00
jan Iversen
e33545afd0 core: activate qPrefUpdateManager
remove UpdateManager from SettingsObjectWrapper and reference qPrefUpdateManager

update files using SettingsObjectWrapper/UpdateManager to use qPrefUpdateManager

this activated qPrefUpdateManager and removed the similar class from
SettingsObjectWrapper.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-09 08:45:02 -07:00
jan Iversen
e673a3558e core: create qPrefUpdateManager 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-09 08:45:02 -07:00
jan Iversen
21243ec4f7 core: activate qPrefDivePlanner
remove DivePlanner from SettingsObjectWrapper and reference qPrefDivePlanner

update files using SettingsObjectWrapper/DivePlanner to use qPrefDivePlanner

this activated qPrefDivePlanner and removed the similar class from
SettingsObjectWrapper.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-08 14:29:50 +02:00
jan Iversen
357510b9cd core: create qPrefDivePlanner 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-08 14:29:50 +02:00
jan Iversen
334099951a core: qPref add STRUCT macro
In order to solve use of e.g. depth_t a new macro is added

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-08 14:29:50 +02:00
Dirk Hohndel
46e2e4badf Android: remove unused define
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-05 20:39:34 -07:00
jan Iversen
264aa883b2 core: qPref, remove inline and ; for inline functions
Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-02 13:31:08 -07:00
jan Iversen
affdc9d394 core: activate qPrefUnits
remove Units from SettingsObjectWrapper and reference qPrefUnits

update files using SettingsObjectWrapper/Units to use qPrefUnits

this activated qPrefUnits and removed the similar class from
SettingsObjectWrapper.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-02 08:59:56 -07:00
jan Iversen
54335e1ec6 core: create qPrefUnit 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-02 08:59:56 -07:00
jan Iversen
470b41e595 core: change type of unit_system to enum
unit_system is an enum, but was declared as short, correct declaration.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-02 08:59:56 -07:00
Berthold Stoeger
90c7be0772 Cleanup: shrink size of three-letter month name strings to 4
There was a comment reading

/*++GETTEXT: these are three letter months - we allow up to six code bytes*/

but this is not valid (anymore), since the array contains only
untranslated strings, which will be translated on-the-fly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-02 08:55:08 -07:00
Berthold Stoeger
8c036234e2 Cleanup: move sort_table() from subsurface_startup.c to divelist.c
The function is not only used at startup and arguably belongs
the the file with the rest of the low-level divelist functions.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-02 08:55:08 -07:00
Berthold Stoeger
1c4a859c8d Cleanup: remove all override modifiers
Commit df156a56c0 replaced "virtual"
by "override" where appropriate. Unfortunately, this had the
unintended consequence of producing numerous clang warnings. If
clang finds a override-modified function in a class definition,
it warns for *all* overriden virtual functions without the override
modifier.

To solve this, go the easy route and remove all overrides. At least
it is consistent.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-01 06:30:00 -07:00
Berthold Stoeger
42aae8196f Cleanup: remove silly " != 0" expression
In metadata.cpp, replace a silly
 "if (!memcmp(...) != 0)"
by the intended
 "if (!memcmp(...))"

Obviously, both have the same effect. Fixes a warning.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-01 15:30:54 +03:00
Berthold Stoeger
df156a56c0 Cleanup: replace virtual by override where appropriate
The keyword "virtual" signalizes that the function is virtual,
i.e. the function of the derived class is called, even if the
call is on the parent class.

It is not necessary to repeat the "virtual" keyword in derived
classes. To highlight derived virtual functions, the keyword
"override" should be used instead. It results in a hard compile-
error, if no function is overridden, thus avoiding subtle bugs.

Replace "virtual" by "override" where appropriate. Moreover,
replace Q_DECL_OVERRIDE by override, since we require reasonably
recent compilers anyway. Likewise, replace /* reimp */ by
"override" for consistency and compiler support.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-31 11:02:34 +02:00
Berthold Stoeger
7fe76a5dbd Cleanup: Make WindowsTitleUpdate a global object
WindowsTitleUpdate is such a trivial object (a QObject with a single
signal and no own state), that it's not really understandable why
it would need all that "singleton" boiler-plate. Just make it
a default constructed/destructed global object.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-30 13:55:23 -07:00
jan Iversen
181d2cf364 core: activate qPrefProxy
remove Proxy from SettingsObjectWrapper and reference qPrefProxy

update files using SettingsObjectWrapper/Proxy to use qPrefProxy

this activated qPrefProxy and removed the similar class from
SettingsObjectWrapper.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-30 07:43:22 -07:00
jan Iversen
f4f798f8dd core: create qPrefProxy from SettingsObjectWrapper
Update set/get functions to follow common name scheme:
- get function have same name as in struct prefs
- 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-07-30 07:43:22 -07:00
jan Iversen
311b2672da core: qPrefPrivate.h added HANDLE_PREFERENCE_INT_DEF_EXT
Add missing type macro, needed for qPrefProxy

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-30 07:43:22 -07:00
Kristaps Dz
02e76be96a BT support: disable BT download when compiling without BT
When BT_SUPPORT is not enabled, don't default to "true" for using bluetooth for downloading dives.
Otherwise, bluetooth will be forced since the bluetooth button has been removed and is never overridden.

Fixes #1541

Signed-off-by: Kristaps Dzonsons <kristaps@bsd.lv>
2018-07-29 10:55:25 -07:00
Berthold Stoeger
fce42d4858 Dive media: Extract thumbnails from videos with ffmpeg
Extract thumbnails using ffmpeg.
Behavior is controlled by three new preferences fields:
 - extract_video_thumbnails (bool): if true, thumbnails are calculated.
 - extract_video_thumbnail_position (int 0..100): position in video
   where thumbnail is fetched.
 - ffmpeg_executable (string): path of ffmpeg executable.

If ffmpeg refuses to start, extract_video_thumbnails is set to false
to avoid unnecessary churn.

Video thumbnails are marked by an overlay.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-28 15:31:25 -07:00
Kristaps Dz
51066e5478 Build-system: add OpenBSD support
Rename linux.c to unix.c and add OpenBSD support as well. Conditionally compile based on OS.

Signed-off-by: Kristaps Dzonsons <kristaps@bsd.lv>
2018-07-28 14:08:06 -07:00
jan Iversen
f175890632 core: activate qPrefFacebook
remove Facebook from SettingsObjectWrapper and reference qPrefFacebook

update files using SettingsObjectWrapper/Facebook to use qPrefFacebook

this activated qPrefFacebook and removed the similar class from
SettingsObjectWrapper.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-27 12:36:20 -07:00
jan Iversen
e0f1817fdc core: create qPrefFacebook 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-07-27 12:36:20 -07:00
jan Iversen
037ee9994d core: fix qPrefCloudStorage to derive git_url
remove set_git_url and git_url_changed, because it is not possible
to set git_url, this is done inderectly through set_base_url

Update disk_base_url to generated git_url for both load/sync

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-27 12:23:09 -07:00
Dirk Hohndel
c7f0e65b12 Whitespace cleanup core divecomputer handling
Not entirely script based because of two odd issues where the script creates
bogus indentation.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-26 16:32:51 +03:00
Dirk Hohndel
128fc5f4b8 Whitespace cleanup core/settings
We can argue about any of the changes here, but they are the result of our
whitespace.pl script - so if any of this is offensive to you, part of the
resolution will be fixing the script...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-26 16:32:51 +03:00
jan Iversen
19871a6ab2 core: qPrefCloudStorage save userid to new location
userid was saved outside all groups, even though it belongs to cloudStorage

Add code to save in new location and read from new/old location

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
3d6848b22c core: activate qPrefDiveComputer
remove DiveComputer from SettingsObjectWrapper and reference qPrefDiveComputer

update files using SettingsObjectWrapper/DiveComputer to use qPrefDiveComputer

this activated qPrefDiveComputer and removed the similar class from
SettingsObjectWrapper.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
98820cf970 core: update qPrefDisplay to new consensus
add inline to load/sync
remove const from QString getters

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
8cfe048150 core: update qPrefCloudStorage to new consensus
make load/sync inline
remove const from QString getters

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
5f3471bf86 core: make load/sync inline in qPref
Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
254ba61fd9 core: make load/sync inline in qPrefAnimations
Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
0002cd2d20 core: create qPrefDiveComputer 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-07-25 08:35:04 -07:00
jan Iversen
69c7ed676a core: add qPrefAnimations to SettingsObjectWrapper/qPref load
correct missng qPrefAnimations in global load functions

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
ead05c8e17 core: expand qPref macros to handle sub structure
Expand SET_, DISK_ and HANDLE_ macros with field for substructure

Structure prefs contains e.g. prefs.dive_computer.vendor an extra field
are added to the macros to allow this.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
92ade62260 core: remove LOADSYNC* macros
expend LOADSYNC* into DISK_* macros
remove LOADSYNC* from qPrefPrivate.h
update qPrefDisplay to not use LOADSYNC*

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
3eae683b57 core: make qPrefAnimations/CloudStorage getters static and inline
Add static and inline to getter in all qPref header files
Remove call to GET_PREFERENCE_* in qPrefDisplay.cpp
Remove GET_PREFERENCE_* from qPrefPrivate.h

static inline is slightly faster than a function call, but it saves
a lot of coding lines (no lines in qPref*.cpp). Getters are a direct
reference to struct preferences, so they will normally only be used
from QML.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
87d8963c78 core: make qPrefDisplay getters static and inline
Add static and inline to getter in all qPref header files
Remove call to GET_PREFERENCE_* in qPrefDisplay.cpp

static inline is slightly faster than a function call, but it saves
a lot of coding lines (no lines in qPref*.cpp). Getters are a direct
reference to struct preferences, so they will normally only be used
from QML.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
7f4123d0d1 core: isolate qPrefPrivate to qPref* classes
Make functions in qPrefPrivate private and add
qPref* as friends

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
jan Iversen
f1648d297b core: qPref replace COPY_TXT with copy_txt in qPrefPrivate
Add copy_txt function to qPrefPrivate class
Remove macro COPY_TXT from qPrefPrivate.h
Replace use of COPY_TXT with copy_txt in qPref classes

copy_txt is only once, COPY_TXT was expanded approx. 160 times, so
this commit saves space (and removes a macro).

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
Berthold Stoeger
b3feaa80e2 Dive video: paint duration-bar above thumbnail in profile plot
Paint a rectangle on top of thumbnails indicating the run-time
of the video.

Use the z=100.0-101.0 range for painting the thumbnails, whereby
the z-value increases uniformly from first to last thumbnail
(sorted by timestamp). The duration-bars are placed at z-values
midway between those of the thumbnails.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-23 15:58:55 -07:00
Berthold Stoeger
c742885984 Dive media: prepare for video-thumbnails
Video thumbnails are more complex than simple picture thumbnails.
We store a duration and might want to store multiple images.

Therefore, refactor the thumbnailing in imagedownloader.cpp. Move
the thumbnail-writing down in the call chain to where the thumbnails
are created, since we have more information there (i.e. whether we
could parse the file but not extract an image, etc.).

Split the write-to-cache function into three versions:
  - pictures
  - videos
  - unknown

Define the video-thumbnail on-disk format as
  - uint32  MEDIATYPE_VIDEO
  - uint32  duration of video in seconds
  - uint32  number of pictures
  for each picture:
	- uint32  offset in msec from begining of video
	- QImage  frame

Currently, we write 0 pictures. This will be filled in subsequent commits.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-23 15:58:55 -07:00
jan Iversen
b9b1f03f0d core: activate qPrefCloudStorage
remove CloudStorage from SettingsObjectWrapper and reference qPrefCloudStorage

update files using SettingsObjectWrapper/CloudStorage to use qPrefCloudStorage

this activated qPrefCloudStorage and removed the similar class from
SettingsObjectWrapper.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-21 07:49:25 -07:00
jan Iversen
4b68329c9d core: create qPrefCloudStorage from SettingsObjectWrapper
Update set/get functions to follow common name scheme:
- get function have same name as in struct preferences
- set function have set_<name> (from struct preferences>)
- signal function have <name>_changed (from struct preferences>)

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-07-21 07:49:25 -07:00
Berthold Stoeger
f23425c558 Uninline functions in dive.h
There were numerous inlined functions in dive.h. For many of them
inlining is dubious. Let's uninline most of them, with the exception
of trivial accessors and interpolate().

On current master, this gave a size reduction of 5 pages:

-rwxrwxr-x 1 bs bs 5863656 Jul 18 20:57 subsurface-inline
-rwxrwxr-x 1 bs bs 5843176 Jul 18 20:48 subsurface-noinline
-----------------------------------------------------------
                     20480

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-21 07:46:44 -07:00
Berthold Stoeger
325b8bba35 Undo: remember deleted trip in UndoRemoveDivesFromTrip::undo()
If the last dive of a trip is removed, the trip is deleted.
On redo the dive is added to a non existing trip, leading to a
segfault.

Therefore, keep a copy of the trip to reinstate it on redo.
Note: this cannot work for a sequence of multiple commands.
One would have to rewrite the whole undo-history. Nevertheless,
let's do this as a stop-gap measure.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-19 02:43:08 +03:00
jan Iversen
3c3729711c core: remove QSettings in qPref* and use a shared variable
Add qPrefPrivate class which contains one QSettings variable,
delete QSettings from qPref* class definitions

this secures there are only instance of QSettings
(QSettings needs to be in a QObject class to work)

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-18 10:40:08 -07:00
jan Iversen
c0e9e978a1 core: remove include QSettings from QPref
remove QSettings header file from qPref.h (which is included in many files)
to isolate the use of QSettings in the total system.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-18 10:40:08 -07:00
Berthold Stoeger
8ff7314b21 Cleanup: rename trip->index to trip->saved
The index-field was misused by the IO routines to mark which dives
had been saved. Somewhat questionable, but let's at least name the
field accordingly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-18 09:04:47 -07:00
Berthold Stoeger
3a933637da Cleanup: removed unused functions in divelist.h
find_trip_by_idx() and find_matching_trip() weren't used anywhere.
The trip index actually is only misused as a "trip saved"-flag.

trip_has_selected_dives() only existed as a comment.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-18 09:04:47 -07:00
Berthold Stoeger
6d72871942 Cleanups to core/color.[c|hpp]
A number of small cleanups to the color-table:

1) Make the profile_color map of static linkage - it is not
used outside of this file.

2) Remove the third color, which originally was planned for
printing. It was not accessed anywhere.

3) Replace QVector<QColor> by std::array<QColor, 2>. Using a
reference-counted, copy-on-write, dynamic container for static
data seems like overkill. std::array<QColor, 2> has exactly the
same run-time impact as QColor[2], but allows for assignment.

4) Use brace-initialization and remove the unneeded COLOR macro.

5) Remove the fill_profile_color function. Simply use static
initialization.

6) Move #includes from .h to .cpp file.

7) Remove text_render_options(_t), which were not used anywhere.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-18 02:09:15 +03:00
Berthold Stoeger
2c6b1a99af Cleanup: simplify dive_getUniqID()
dive_getUniqID() is used to create unique dive ids, which are
stable during application lifetime. It was passed a dive, checked
that the id was not set (if it was that it is know to the application)
and set a new id (in contradiction to its name!) if it hadn't any.

There were three callers:

alloc_dive(): called the function on a zeroed dive struct.
fixup_dive(): called the function only if the dive had a 0 id.
MainWindow::setupForAddAndPlan(): called the function on a zeroed dive
struct.

Thus, in all three callers the id is guaranteed to be zero and
the whole keeping-track-of-ids logic is moot. Remove the logic,
don't pass a dive struct to dive_getUniqID() and move the function
to the C-backend.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-17 15:20:52 -07:00
Stefan Fuchs
bb2dfdfe54 For media file open dialog add different file filters
On top of the file filter for all media files add a file filter
for images only, one for videos only and one for all files.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-07-15 09:38:12 -07:00
jan Iversen
80761beb93 core: solve copy/paste error in qPref_private
DISK_LOADSYNC_INT used double correct to int

DISK_LOADSYNC_INT used double correct to int

Signed-off-by: Jan Iversen <jani@apache.org>Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-15 14:35:31 +02:00
jan Iversen
8d857a650d core: qPrefDisplay correct font setting.
SettingsObjectWrapper contained some delicate font handling mixing font and
font_size, breaking that into 2 parts broke font handling on some platforms

Copy font + font_size handling 1-1 from SettingsObjectWrapper

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-15 14:35:31 +02:00
Dirk Hohndel
55336bd7ad Merge branch 'metadata' of https://github.com/bstoeger/subsurface 2018-07-14 08:20:47 -07:00
Dirk Hohndel
dc22747cb0 Merge branch 'qPrefAnimations' of https://github.com/janiversen/subsurface
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-14 08:16:14 -07:00
Dirk Hohndel
e834874a7a Merge branch 'qPrefDisplay' of https://github.com/janiversen/subsurface 2018-07-14 08:14:31 -07:00
Berthold Stoeger
772935b596 Metadata: Parse ASFs (=WMVs)
The simplest video-formats to parse so far.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-14 08:32:30 +02:00
Berthold Stoeger
4de0b7dd3d Metadata: Parse AVIs
Whereas extraction of the dive-duration is trivial, AVIs don't seem
to have a standardized way of saving the creation time. This commit
implements support for two versions randomly found on the internet.
Additional version will follow if need arises. AVI seems not to be
a particular popular format for either vacation or professional
videographers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-14 08:32:30 +02:00
Berthold Stoeger
02ad18d4d8 Metadata: extract duration fom QuickTime/MP4-style containers
We want the duration of videos for two reasons:
 - To display the duration of the video in the profile plot.
 - To be able to determine which dive a video is closer to if the
   start is not during a dive.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-14 08:32:30 +02:00
Berthold Stoeger
9efb56e2d4 Dive pictures: don't update all images on drag&drop to profile
Gracefully handle drag & drop to the profile, which changes the
offset of the pictures. To do this, keep the pictures in the
DivePictureModel and the ProfileWidget2 sorted by offset and
re-arrange if needed to keep the list sorted. This needs some
code reshuffling.

Introduce a helper-function that moves ranges in arrays.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-13 17:07:42 -07:00
Stefan Fuchs
63e63ee07d Disable the WindowContextHelpButtonHint for Qt >=5.10
Disables the WindowContextHelpButtonHint by default on Qt::Sheet and
Qt::Dialog widgets. This hides the ? button on Windows, which only
makes sense if you use QWhatsThis functionality.
This value has been added in Qt 5.10.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-07-13 14:46:10 -07:00
Stefan Fuchs
24c915e97c In planner notes don't show dive mode for first data point
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-07-13 11:26:28 -07:00
Stefan Fuchs
9883b9f10e Add three missing translations for divemode_text_ui in plannernotes.c
Added three missing translations which were forgotten here:
fcf6b819d9

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-07-13 11:26:28 -07:00
Linus Torvalds
b34a4063be Make sure our libdivecomputer custom IO interfaces have sleep functions
When I switched over from our own custom IO implementation to the new
upstream custom IO model in libdivecomputer, I completely missed the
fact that the libdivecomputer custom IO model also does a custom _sleep_
function.

I'm not entirely sure what the point was, and it broke things even in
libdivecopmputer itself when some of the new sleep functions were
broken.

Anyway, we didn't export any sleep functions at all for the bluetooth,
BLE and FTDI cases, the the libdivecomputer code didn't fall back to any
sane default sleep implementation either, so the end result was no
sleeping at all.

Which didn't matter for most divecomputers.

But it seems like at least some OSTC dive computers did care, at least
in certain situations, and both Miika and Anton had trouble downloading
with their OSTC Sport dive computers.  Using the serial line protocol
and the legacy /dev/rfcomm model worked fine, because then it used the
sleeping functions in the POSIX serial code inside libdivecomputer.

This just adds trivial sleeping functions for the affected download
protocols.  Maybe I should have just made libdivecomputer have a sane
default instead, but this wasn't hard either (the hard part was trying
to figure out why the downloads worked for some people and not for
others).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-07-13 11:25:38 -07:00
jan Iversen
d4e76dac9e core: remove Animations from SettingsObjectWrapper and activate qPrefAnimations
remove Animations from SettingsObjectWrapper and reference qPrefAnimations
update files using SettingsObjectWrapper/Animations to user qPrefAnimations

this activated qPrefAnimations

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-12 22:34:35 +02:00
jan Iversen
3a314c3dec core: copy Animations from SettingsObjectWrapper to qPref as its own class
Update set/get functions to follow common name scheme:
- get function have same name as in struct preferences
- set function have set_<name in struct preferences>
- signal function have <name in struct preferences>_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-07-12 19:07:49 +02:00
jan Iversen
928fc1ee79 core: move load of display variables to qPrefDisplay from SettingsObjectWrapper
ensure SettingsObjectWrapper load() loads all display variables.

Copy font setting code from SettingsObjectWrapper to qPrefDisplay

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-12 18:44:31 +02:00
jan Iversen
9732194bf8 core: sync display variables from struct preferences when ssrf terminates
Add qPrefDisplay sync to sync in SettingsObjectWrapper.

If a program part change display variables in struct preferences, they would
not be saved on disk.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-12 18:44:31 +02:00
jan Iversen
da61c1714f core: activate qPrefDisplay in SettingsObjectWrapper
add the prepared class qPrefDisplay to SettingsObjectWrapper and thereby making it active.

As a consequence of the uniform naming standard desktop-widgets/preferences_defaults.cpp and
tests/testpreferences.cpp have been updated.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-12 18:44:31 +02:00
jan Iversen
8cc0b6dbc1 ssrf: add shared helper file
add subsurface-helper.cpp to share functions between mobile and desktop

move mobile qml registrations to a shared function (avoiding differences in registrations)

Target is to replace current subsurface-desktop-main + subsurface-desktop-helper and
subsurface-mobile-main + subsurface-mobile-helper with
subsurface-*-main + subsurface-helper

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-12 08:08:00 -07:00
Jocke
59465b85f6 Don't show decimals on pressures
As per discussion in #1460 there is no point in showing decimal values
for pressures in the equipment tab on desktop or in the dive edit view on 
mobile.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-07-12 17:15:05 +03:00
Berthold Stoeger
a8bfa5f053 Dive media: add ".mov" to list of known video extensions
This was an oversight in b28dba6087.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-12 02:18:09 +03:00
jan Iversen
b15f6f3d4a core: remove clang warning in divesite.c
Add () in complex condition to avoid clang warning.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-11 12:59:33 +02:00
jan Iversen
4a4bc1c8f3 core: add version variables to qPref and make it qml loadable
add canonical_version and mobile_version to qPref

Having a property in qPref, allows the use in qml, and prepare the
interface for qml testing.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-10 10:30:50 -07:00
jan Iversen
8d66633fe7 core: make qPref::cloud_status the only version of the enum
add enum to qPref and remove elsewhere
update source core to reference qPref.

the enum cannot be in pref.h because it is to be used in qml and Q_ENUM
need the enum to be defined as part of the class

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-10 10:30:50 -07:00
Berthold Stoeger
a741f505ca Dive pictures: differentiate between IO-error and unknown format
Show different images for IO-error and unknow file format.

Use file-extensions to recognize video files if we couldn't
parse them.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-09 09:12:58 -07:00
Berthold Stoeger
3d7865cf26 Dive pictures: detach ProfileWidget2 from DivePictureModel
As long as ProfileWidget2 and DivePictureModel showed the same set of
pictures and any change would lead to a full recalculation of the set,
it made sense to let ProfileWidget2 use DivePictureModel's data.

Recently, keeping the two lists in sync become more and more of a
burden. Therefore, disconnect ProfileWidget2 and DivePictureModel. This
will lead to some code-duplication and perhaps a temporary drop in
UI-performance, but in the end the code is distinctly simpler and also
more flexible.

Thus, for example the DivePhotoTab could be changed to support headings
without having to touch ProfileWidget2 at all.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-08 11:00:44 -07:00
Berthold Stoeger
b28dba6087 Dive pictures: Recognize video files
When generating thumbnails, test for video files. If it is, use
a dummy-thumbnail. Write only the type (video), but no image to
the thumbnail cache, for forward-compatibility.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-08 07:41:15 -07:00
Lubomir I. Ivanov
94d6e5d851 save-git: allocate user_info members on the heap
subsurface_user_info() only works on Linux (linux.c),
but it doesn't allocate values on the heap.

Solve this ownership problem by always allocating
.name and .email on the heap in subsurface_user_info()
and freeing in the caller.

If subsurface_user_info() did not modify any of the
values from NULL, use default ones, but allocate them
on the heap too.

Ref #1346

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-07-07 17:42:10 -07:00
jan Iversen
516e3421b1 core: update qPrefDisplay.cpp to use all qPref macros.
change qPrefDisplay.cpp to use qPref_private macros, for each variable. The macros
used depend on how standard the variable is handled.

Remark: this commit is production code, but qPrefDisplay is NOT integrated into
SettingsObjectWrapper and thus not active in the live system

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-07 09:44:06 -07:00
jan Iversen
2971984687 core: add macros to handle get/set/loadsync functions
Add macros to handle get/set/loadsync function set functions in qPref

These macros are only convinience functions to write less for all those
variables who are traited standardized.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-07 09:44:06 -07:00
jan Iversen
e3767fdc43 core: add macros to handle setter functions
Add macros to handle full function set functions in qPref

Remark: the function name is fixed to be "set_<name>" where name is
identical to the variable in struct preferences

This is not our standard naming, but is consistent with struct
preferences (that also use different name schemes).

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-07 09:44:06 -07:00
jan Iversen
7ee1aab728 core: add macros to replace getter functions
Add macros to handle full getter functions

Remark: it is assumed the name of getter function is identical to
the name in struct preferences.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-07 09:44:06 -07:00
jan Iversen
ce358fdb68 core: qPref private add macros to replace disk* functions
Use a private QSettings variable, instead of declaring it each time

Add macros to handle full disk* functions

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-07 09:44:06 -07:00
jan Iversen
e5dace2233 core: copy Display from SettingsObjectWrapper to qPref as its own class
copy Display from SettingsObjectWrapper to qPref as its own class
file. Update Display to use a common load/sync scheme.

Update set/get functions to follow common name scheme:
- get function have same name as in struct preferences
- set function have set_<name in struct preferences>
- signal function have <name in struct preferences>_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 are made to show the use of the low level LOADSYNC macros, which will
be used for special cases. This class is NOT linked into the live system.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-07 09:44:06 -07:00
jan Iversen
55c3afc075 core: pref.h rename showDeveloper to show_developer
change to use same name pattern as other variables.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-07 09:44:06 -07:00
Dirk Hohndel
cd5eed4605 git storage: avoid warning about "Unmatched action 'hash'"
In commit f3ef38ca0d ("Dive pictures: remove hashes") we removed picture
hashes, but removing them from the git parser causes an ugly red warning when
opening an existing cloud storage repo. With this patch we just silently ignore
the hash.

Fixes #1473

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-07 07:35:45 -07:00
Dirk Hohndel
03bc40194d core: don't crash on merge of non-existing dive site
While we shouldn't have a dive that references a dive site that doesn't exist,
if we do, we shouldn't crash. And a dive site that doesn't exist is most
definitely 'empty'.

Reported-by: Benjamin Fogel <nystire@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-06 22:40:18 -07:00
Dirk Hohndel
63297562e6 iOS: find translations again
commit ec0511e824 ("ios: concentrate build dirs") moved the translations around
without updating the way they are accessed, causing our release 2.1.0 on iOS to
not be localized.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-03 14:58:00 -07:00
Robert C. Helling
072e404af5 Allow to split dives with more than one dive computer
Only the first computer is taken into account to find
surface intervals. All further dive computers are split
according to time.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-07-03 14:47:15 -07:00
Robert C. Helling
00f4fa0d1d Profile context menu entry to split a dive
Allow the user to manually split a dive in two.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-07-03 14:47:15 -07:00
Robert C. Helling
8697f7a84d Include cylinder pressures upon force_fixup()
Try to recompute cylinder start and end pressures from sample
data.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-07-03 14:47:15 -07:00
Berthold Stoeger
57c01f7a66 Translations: unify gettextFromC::tr() and QObject::tr()
There were two catch-all classes for translations outside of class
context. gettextFromC was used exclusively from C, but C++ used
both, gettextFromC and QObject. Some of the string were even present
in both. Therefore, unify to gettextFromC throughout the code base.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-04 05:33:31 +08:00
jan Iversen
2f95141330 core: remove double definition of enum cloud_storage_status
Remove cloud_storage_status from qmlprefs.h.
usage to qPref::

enum cloud_storage_status is not used from C, but only from C++, and
having the same structure defined multiple times is a maintenance
challenge.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-04 05:32:30 +08:00
jan Iversen
d02a03983d core: add qPref.h_and qPrefprivate.h
add 2 header files and 1 cpp file (qPrefPrivate does not have an implementation)

The rewrite/consoliadation of SettingsObjectWrapper, qmlmanager, qmlpref and planner
needs a place to put common private parts (qPrefPrivate) and 1 common class (qPref).

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-04 05:32:30 +08:00
jan Iversen
6c9c2168e1 core: sort CMakeLists.txt
sort .c and .cpp files in CMakeLists.txt

The .c and .cpp files in CMakeLists.txt had no obvious sequence,
sorting it at least gives one understandable sequence

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-04 05:32:30 +08:00
jan Iversen
889a0bb67a core/profile: move PP_GRAPHS_ENABLED from pref.h
PP_GRAPHS_ENABLED is only used in profilewidget2.cpp
make local to profilewidget.cpp

Signed-off-by: Jan Iversen <jani@apache.org>core/profile: move PP_GRAPHS_ENABLED from pref.h
2018-07-04 05:32:30 +08:00
jan Iversen
36d7f6eafb core: sort struct preferences
sort prefs, making it possible to find variables
add a few missing variables

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-04 05:32:30 +08:00
Berthold Stoeger
09fd5c40d1 Dive pictures: implement FindMovedImagesDialog
Move the find-moved-images functions into a new translation unit
and present the user with the identified matches before applying
them.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-04 02:27:36 +08:00
Berthold Stoeger
f3ef38ca0d Dive pictures: remove hashes
In the last commits, the canonical-to-local filename map was made
independent from the image hashes and the location of moved images
was based on filename not hashes. The hashes are now in principle
unused (except for conversion of old-style local filename lookups).

Therefore, remove the hashes in this commit. This makes addition
of images distinctly faster.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-04 02:27:36 +08:00
Berthold Stoeger
0646b41275 Dive pictures: find moved pictures based on filename
Users might have edited their pictures. Therefore, instead of identifying
pictures by the hash of the file-content, use the file path. The match
between original and new filename is graded by a score. Currently, this
is the number of path components that match, starting from the filename.
Camparison is case-insensitive.

After having identified the matching images, write the caches so that they
are saved even if the user doesn't cleanly quit the application.

Since the new code uses significantly less resources, it can be run in a
single background thread. Thus, the multi-threading can be simplified.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-04 02:27:36 +08:00
Berthold Stoeger
08962cb38d Dive pictures: index local file name by canonical filname
The connection canonical filename to local filename was done via
two maps:
  1) canonical filename -> hash
  2) hash -> local filename
But the local filename was always queried from the canonical filename.
Therefore, directly index the former with the latter.

On startup, convert the old map to the new one.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-04 02:27:36 +08:00
Dirk Hohndel
988d6682f2 Correctly recognize more OSTC variants as BLE
Some OSTC 2 and OSTC Plus variants show 'OSTC+ xxxxx' as BLE name and we
recognized this as OSTC 3 (but that one doesn't support BLE). With this
we recognize these models as OSTC 2 (which is identical from a download
perspective to the OSTC Plus) and both of those support BLE.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-02 09:24:30 -07:00
Linus Torvalds
90569e0ee6 Use (and update) dive computer times when merging and splitting dives
When we split a dive in two, we keep the dive computer ID for the dive,
but we should update the actual _time_ of the split dive to match the
split.

And when we look for "are these the exact same dives", we should check
not only that the dive computer dive ID matches, but also that the dive
computer time matches, so that we don't consider two parts of a dive
that has been split to be obviously the same dive.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-02 08:38:31 -07:00
Linus Torvalds
3209b490dd Use proper sample pointer when deciding to split dives
The dive splitting was completely wrong, because we checked the time of
the previous sample by doing

	sample[i - 1].time.seconds

which is entirely wrong.  The 'sample' variable is the *current* sample,
so the time of the previous sample is simply

	sample[-1].time.seconds

Alternatively, we could have started from the first sample, and done

	dc->sample[i - 1].time.seconds

but mixing the two concepts up just gets you a random sample pointer
that is likely not a valid sample at all, and obviously does not have
the right time at all.

As a result, dive splitting was pretty much random.  Sometimes it worked
purely by mistake, because the rest of the logic was right (ie we _had_
found the right point where we reached the surface in the dive etc, the
"previous sample time" was simply used to decide if the surface interval
was sufficient to split the dive up).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-02 08:36:53 -07:00
jan Iversen
f86dd889bf core: remove prefs-macros.h where unused
move #include prefs-macros from SettingsObjectWrapper.h to SettingsObjectWrapper.cpp
include dive.h directly (only part of prefs-macros.h used) in preference classes

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-01 22:06:28 +02:00
Berthold Stoeger
1a5e54e5eb Dive pictures: render icons with white instead of transparent background
The SVG icons for failed / still-loading pictures were rendered with an
alpha channel. This lead to strange behavior when hovering over the
icon in the profile plot: When hitting a "hole" the icon would be
minimized again.

Therefore, render the SVGs onto a white background.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-28 21:58:29 +08:00
Stephen Goodall
b492df6ffc Add Cressi Giotto, Newton and Drake to list of devices
Adding Cressi Giotto, Newton and Drake to the list of devices
that can be selected on Android devices.

Signed-off-by: Stephen Goodall <stephen.goodall88@googlemail.com>
2018-06-28 11:52:24 +08:00
Dirk Hohndel
314b08c78f QML UI: go back to always saving libdivecomputer logfile
This got disabled as unintended (I hope) side effect of commit
807571a588 ("core: update deviceData default from qml").

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-06-27 16:01:12 -07:00
Stephen Goodall
26871df84d Add Cressi Leonardo to list of devices
Adding Cressi Leonardo to the list of devices that can be selected
on Android devices.

Signed-off-by: Stephen Goodall <stephen.goodall88@googlemail.com>
2018-06-28 01:43:26 +08:00
Berthold Stoeger
db0dd54c37 Localization: make cache thread safe and robust against use-after-free
The old trGettext() was not thread-safe and the returned C-strings
could be freed in the case of empty translations strings. Therefore:

1) Introduce a mutex protecting access to the cache.

2) Never change existing entries, even if the translation string is empty.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-24 20:31:14 +02:00
Berthold Stoeger
879cb73b8b Localization: remove gettextFromC::instance()
There were a handfull instances of the kind
1) gettextFromC::instance()->tr(...)
2) gettextFromC::instance()->trGettext(...)

1) is pointless, as tr is a static function.

All instances of 2) were likewise pointless, because trGettext()
returns a C-string, which was then immediately converted to a
QString.

Thus, replace both constructs by gettextFromC::tr(...).

After this change there was only one user of gettextFromC::instance()
left, viz. the C-interface funtion trGettext(). Therefore, remove
gettextFromC::instance() and do all the caching / translating
directly in the global trGettext().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-24 20:31:14 +02:00
Berthold Stoeger
61b8add590 Localization: don't go via C-string in qthelper.cpp
The purpose of the gettextFromC class is twofold:
1) It provides a static storage of C strings if the C part needs
a translation and doesn't want to deal with memory-management.
2) It severs as a catch-all class for translations that do not come
from a proper class (i.e. from helper functions).

The second case was used a few times in qthelper.cpp. By using the
trGettext() function, a cached C-string was obtained. But in every
single instance, this C-string was then back-converted into a QString.
Therefore, use the gettextFromC::tr() function directly, which
returns a QString. Not only is the resulting code simpler - this also
avoids superfluous caching of translation strings.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-24 20:31:14 +02:00
Robert C. Helling
8406cbf187 Fix interpretation of dive mode changes upon replan
... by taking into acount that dive planner points refer
to the sement before the waypoint (while change mode
events are concerned with the future of a waypoint).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-06-24 09:35:55 +02:00
Robert C. Helling
4157365c96 Make planner notes divemode aware...
... and fix a problem with setpoint changes shown in the wrong line

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-06-24 09:35:55 +02:00
Berthold Stoeger
c65617661a Dive pictures: fix loading of remote images without local version
Owing to the recent churn in imagedownloader.cpp, some of the
code was bogus.

Notably, in f60343eebb the code
was changed such that always the local filename was used to access
the images. Yet, the old code remained, which after failure tried
again to access the local picture. This second access can obviously
be removed completely.

More seriously, after failing to load the local version, no
attempt was made to fetch the image via canonical filename. This
could produce the following sequence of events:
  - Import remote image
  - Delete thumbnail and local cache of image
  - Image loading would fail

Therefore, first try to load using local file-location. If
that fails, load using the canonical file-location. To do
so, split the file-access code in two functions. The code
should now be distinctly easier to follow.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-22 00:26:02 +03:00
Dirk Hohndel
5377706aca FTDI support: try ftdi_open first if the device name is 'ftdi'
It makes no sense to have the OS try (and fail) to open that device name.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-06-21 16:16:29 +09:00
Dirk Hohndel
b7619553fd core: print the correct message code for download failures
We filled in the missing information and then printed the wrong string.
This fixes that and also makes the strings slightly easier to understand.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-06-21 16:15:48 +09:00
Dirk Hohndel
05a00f31e9 mobile: better message regarding logfiles
On mobile those area always created and available for simple cut and paste.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-06-21 15:49:23 +09:00
Anton Lundin
dcb663e407 Revert "cleanup: remove empty function"
This broke our hook to plumb in our usb open function into libusb, so
this broke ftdi based downloads.

This reverts commit e4530cd5ef.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2018-06-21 06:28:39 +09:00
Linus Torvalds
98bd303d93 qt-ble: purge pending read data when writing
This should never happen, since our interface is bassically synchronous,
but it could happen with delayed replies that came in just after we
decided to re-transmit a command.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-06-20 16:38:04 +09:00