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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
expend LOADSYNC* into DISK_* macros
remove LOADSYNC* from qPrefPrivate.h
update qPrefDisplay to not use LOADSYNC*
Signed-off-by: Jan Iversen <jani@apache.org>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
ensure SettingsObjectWrapper load() loads all display variables.
Copy font setting code from SettingsObjectWrapper to qPrefDisplay
Signed-off-by: Jan Iversen <jani@apache.org>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Adding Cressi Leonardo to the list of devices that can be selected
on Android devices.
Signed-off-by: Stephen Goodall <stephen.goodall88@googlemail.com>
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>
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>
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>
... 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>
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>
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>
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>
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>
Our model of waiting for 100ms before re-checking if we got a packet
over BLE resulted in potentially horrendously bad latency for received
packets.
That isn't just a possible performance issue, it actually seems to cause
IO errors with my Suunto EON Core. I'm not entirely sure why, but it
might simply be some timing interaction, particularly since the IO
errors seemed to primarily happen when the dive computer itself was also
busy updating the screen (ie if you pressed buttons on the dive computer
to switch to compass mode, for example).
So replace the silly hardcoded 100ms "waitFor()" function with a
WAITFOR() macro that checks the provided expression every time through
the loop, which gets us a much lower latency (we basically check every
ten milliseconds).
The macro is not beautiful, but it WorksForMe(tm).
This makes a huge difference to the reliability of the download for me,
and might matter for some other dive computers too.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
MAX_TANK_INFO is defined in dive.h but is not
used in add_cylinder_description() or when
allocating 'tank_info'.
Use MAX_TANK_INFO instead of the literal 100.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Instead of a constant or a macro for the maximum
number of 'ws_info' elements the 100 literal was used.
Define MAX_WS_INFO in dive.h and use it everywhere.
Also clamp loops that iterate `ws_info' to MAX_WS_INFO.
Prevents potential out-of-bounds reading, similarly to
the previous commit about 'tank_info'.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
In a number of places the global 'tank_info' array
is being iterated based on a 'tank_info[idx].name != NULL'
condition.
This is dangerous because if the user has added a lot of tanks,
such loops can reach 'tank_info[MAX_TANK_INFO]'. This is an
out of bounds read and if the 'name' pointer there happens to be
non-NULL, passing that address to a peace of code that tries
to read it (like strlen()) would either SIGSEGV or have undefined
behavior.
Clamp all loops that iterate 'tank_info' to MAX_TANK_INFO.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
The list of known dive computers was stored in a multi-map indexed
by the device name. Turn this into a sorted QVector. Thus, no
map-to-list conversion is needed in the device editing dialog,
which distinctly simplifies the code.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Remove the explicit constructor in DiveComputerNode: Just use
classical C-style struct initialization. Moreover, remove the
empty constructor and destructor of DiveComputerList.
The variable DiveComputerList::dcWorkingMap was unused. Remove.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Suunto has updated SampleBlob to use 30 byte blobs. This adds support
for the increased size. Note that this only parses the same fields we
have parsed before. (Currently I have no idea what the increased size is
used for.)
Note also that I do not currently have data with the new format so I
only tested this still works with old data.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
For debug reasons, failure to load the original image was spilled
to the console, even if the local file was then found.
Only print a message, when also the local image failed loading.
This needed a bit of code reshuffling. To know when to print a
failed-loading message, the URL is now checked at the Thumbnailer
level, not the ImageDownloader level. The ImageDownloader is
passed the URL and the original filename (if different). The
image is loaded from the URL, but the signals send the original
filename, so that the thumbnail can be associated to the proper
image.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Remove Q_OBJECT and qml properties from DCDeviceData class
Remove DCDeviceData register from mobile-helper.cpp
Change DCDeviceData constructor to be without parameters
Signed-off-by: Jan Iversen <jani@apache.org>
Calculate the correct cylinder pressures for rebreather dives with
bailout. Currently the cylinder pressures for a dive are calculated
assuming a single dive mode for that dive. Bailout indroduces more
than one dive mode for a single dive, i.e. transitions from
CCR or PSCR to OC and back. Currently the start and end pressures
for each cylinder are used to interpolate cylinder pressures while that
cylinder is used. However, the different gas consumption rates for
OC, PSCR and CCR are not taken into account in this interpolation
and the cylinder pressure is indicated by an averaged interpolation
accross the rebreather and OC legs of the dive. Consequently the
increased drop in cylinder pressure during OC is not shown. This
PR allows differentiation between CCR/PSCR legs of the dive and
the OC bailout segments, showing realistic interpolation that
indicate the increased rate of gas use during OC.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
When adding a picture to a dive, cache_picture() was called, which
calculated the hash of the picture in a background-thread.
This made tests occasionally fail, because the tests depended on
the filename-to-localfilename being overwritten in a call running
in a different thread. Depending on which thread finished first,
the test succeeded or failed.
The easiest way to circumvent this problem is to remove the cache_picture()
call. The hash will be calculated anyway with the thumbnails. And
the only function of the hash is the "find moved images" function. Which
is not an issue here, because the user just loaded the images from
disk.
Reported-by: Jan Iversen <jani@apache.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The code changes to standardise the named of divemodes and to
separate internal divemode names and UI divemode names introduced
a bug that caused non-backward compatability with existing
dive logs. The reason for this is the definition of the
divemode_text strings in dive.c
This change reverses that definition and brings about correct
loading of PSCR dive logs as well as correct parsing of bailout
events involving PSCR.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
helpers.h included qthelper.h and all functions declared in helpers.h
were defined in qthelper.h. Therefore fold the former into the latter,
since the split seems completely arbitrary.
While doing so, change the return-type of get_dc_nichname from
"const QString" to "QString".
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Subsurface-mobile has a long startup time; in order to isolate the problem(s) a
timer is added to see where time is "lost".
The collected startup times are added to the clipboard together with the other
logs, allowing test users to report back.
All this is only enabled when compiling with -DENABLE_STARTUP_TIMING
Closes#1340
[Dirk Hohndel: collapsed multiple commits and minor white space cleanups, added
missing QMutex variable]
Signed-off-by: Jan Iversen <jani@apache.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If we breathe from a cylinder with invalid start or
end pressures, we cannot reliably compute the total gas
use and thus the SAC. So we should not pretend to do so.
A better fix would compute the total SAC for only those
segements that have valid start and end pressures.
Reported-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
The former should be translated but not those that
go to xml/git.
... and fix capitalization of pSCR.
Suggested-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
This adds support for DC reported ceiling when importing the Shearwater
Desktop database. Both AI and non-AI versions are tested, but not all
possible paths. For non-AI the DC reported ceiling was from
firstStopDepth and for the AI version it was from the decoCeiling field.
I do not currently know when each of these fields are used, but at least
this works on my test data.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
If a thumbnail and the original picture can be accessed and the
modification date of the thumbnail is before the modification date
of the picture, recalculate the thumbnail.
This causes more disk access and might give strange effects for
picture files with messed up file timestamps (i.e. lying in the
future) or messed up computer clocks (i.e. running in the past).
Therefore, add a preference option to disable the new behavior.
Default is set to enabled.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Even though hashes of image contents are calculated, the hashes are
not compared to actual file contents in routine-operation. Therefore
give the user the option to recalculate thumbnails, should they have
edited the picture.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
the postEvent is only called when downloading from a dc
with bluetooth, so in most it does not have an effect
on the deleteLater() in the code.
there are no reason to do special cleanup while waiting
for bluetooth
QEvent::DeferredDelete is not supported on iOS.
Signed-off-by: Jan Iversen <jani@apache.org>
Since commit 6618c9ebfc, thumbnails
are saved in individual files. The filename was simply the picture-hash.
In a mailing-list discussion it turned out that in the future we might
not hash images or change the hash. Therefore, derive the thumbnail
filename from the image filename, using the SHA1 algorithm.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Add a #pragma to avoid getting warning when a struct is only initialized
with one 0 and not one pr struct member
Signed-off-by: Jan Iversen <jani@apache.org>
ssrf contains macros/includes etc. used in ssrf, but
not related to dives (mainly in dive.h)
currently the header is created to add the macro UNUSED
later it will be used to remove non-dive related items
from dive.h
Signed-off-by: Jan Iversen <jani@apache.org>
Saving of pictures to git repositories was disabled. Finally remove
this code and the corresponding load code.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
PictureEntry was defined as class in imagedownloader.h and
as struct in divepicturemodel.h
A class has a vptr in front, so the difference is real at least
for the clang compiler.
Signed-off-by: Jan Iversen <jani@apache.org>
interpolate, rel_mbar_to_depth, gas_mod and
gas_mnd returns int but uses
a function that returns long, causing clang to
warn about conversion loss due to implicit conversion.
Adding a cast, shows that it is correct.
Signed-off-by: Jan Iversen <jani@apache.org>
lbs_to_grams and to_feet returns int but uses
a function that returns long, causing clang to
warn about conversion loss due to implicit conversion.
Adding a cast, shows that it is correct.
Signed-off-by: Jan Iversen <jani@apache.org>
When creating the ICD-notes the membuffer was not '\0'-terminated,
leading to output of stale data.
Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There is a space character missing in the xml generated by the
present code. Insert a space character.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
If loading of an image failed, we tried to see if we find a
canonical filename in the cache. There's no point in rereading
the picture if the canonical and the original filename are
the same.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The recently committed refactoring of the dive-picture code introduced
a severe bug:
If an image couldn't be loaded from disk owing to an invalid file, the
filename was interpreted as an url and loaded in the background. This
succeeded, because the file actually exists. After download, the file
would then still be invalid and the whole thing restarted, leading to
an infinity loop.
To fix this, do two things:
1) Don't even try to download local files.
2) If interpreting a downloaded file fails, don't try the downloading
business again.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
...as the usuage is not anymore about a computer but
a momentary dive mode. Rename the end indicator as well.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
The bailout events in the planner are not saved correctly.
My oversight. This commits corrects the bug
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Ensure that calls to add_segment() all have a appropriate divemode
for that part of the dive plan. In the case of plan(), the existing
variable 'divemode' was directly passed to add_segment. For the
functions interpolate_transition() and trial_ascent(), the divemode
was obtained by including it in the parameter list of the function
and divemode supplied by the calling function.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Add a divemode column to the planner model and a
corresponding field to struct divepoint and fill it
in the corresponding functions.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Under some conditions get_current_divemode() (in dive.c) returns an
erroneous divemode. This happens when there are several events at
the very beginning of the dive, as can happen in some CCR dive logs.
This commit fixes that bug.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Replaced a rather cumbersome function that that did the above. Upon
the suggestion of Robert Helling who proposed a much shorter way,
this new function replaced the previous ones. This necessitated
changes to divelist.c, profile.c and plannernotes.c, as well as
dive.c/h.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Replaced a rather cumbersome function that that did the above. Upon
the suggestion of Robert Helling who proposed a much shorter way,
this new function replaced the previous ones. This necessitated
changes to divelist.c, profile.c and plannernotes.c, as well as
dive.c/h.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
This provides for reading of divemode change events from dive logs
and for writing them to dive logs. This applies to xml and git
divelogs. Divemode change events have the following structure:
event->name = "modechange"
event->value = integer corresponding to enum dive_comp_type (dive.c),
reflecting the type of divemode change (OC, CCR, PSCR, etc).
In the dive log file, the event value is written as a string that
corresponds to each of the enum values, e.g.
<event name='modechange' divemode='OC' />
This xml is also read from the dive log file and translated to an
appropriate value of event->value.
The file diveeventitem.cpp was udated to reflect this new way of
dealing with divemode change events.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Function peek_next_divemodechange() is redundant if get_next_divemodechange()
has one additional parameter. Calls to get_next_divemodechange() were
updated in divelist.c, plannernotes.c and profile.c.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
I removed the special event type that has been used for bailout events.
Bailout events are now just bookmarks with a specific name "e.g. OC,
CCR, PSCR). This removes a case where a segmentation error occurred
when trying to remove a bailout event from the dive profile.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
This is the second step for implementing bailout. The indirect
calls to fill_pressures through add_segment() (in deco.c) are
addressed. Bailout is now fully implemented in the dive log but
not in the dive planner.
1) The parameters to add_segment() are changed to take a
divemode as the second last parameter, and not a *dive.
2) Call to add_segment() in profile.c and in divelist.c are
adapted. In divelist.c some calls to add_segment were left
using dc-> divemode instead of possible bailout. This appears
tp be the most appropriate route.
3) The functions get_divemode_from_time() and get_next_divemodechange()
in dive.c have had some small changes.
4) The calls to get_segment(0 in planner.c were changed to reflect
the new parameter list, but not updated to reflect bailout. This
is the next step.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
This is a first step to interpret bailout events.
1) The event structures have a new attribute: divemode.
Currently interpreted dive modes are OC, CCR, PSCR.
2) When doing fill_pressures(), the calculation is aware
of divemode. When divemode is OC (==bailout), then
the appropriate calculations of gas pressures are done.
3) Two new functions get_next_divemodechange() and
get_divemode_at_time() are created to find divemode
changes in the events linked list and to determine
the dive mode at any point during the dive.
4) fill_pressures gets a small amendment to facilitate
the correct calculations, depending on divemode.
The cases where fill_pressures() is used *outside the planner*
are changed. The result is that, for dives with bailout, the
correct gas pressures are shown on the dive profile. The
deco for bailout dives is not yet correct. This is the
next step.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
This is only used by one caller and there doesn't appear to be a reason
to inline it in the first place.
Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead of generating one ImageDownloader object per image to be
downloaded and running every image download in a separate worker
thread, use one global ImageDownloader object owned by the UI thread.
The images are downloaded using event based IO (as probably was the
intention of the QNetworkManager class).
User-visible change: after download from the internet, the thumbnail
is shown without having to change dives.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Import a camera icon from the KDE breeze theme, which is licensed
under the LGPL. Use this icon to display not-yet-loaded images
in the photos tab and the profile.
Source: https://github.com/KDE/breeze-icons
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The size of the to-be-created thumbnails was passed from DivePictureModel
to Thumbnailer. This became more and more bothersome, because the size
had to be stored with the request. Calling from Thumbnailer into
DivePictureModel was not an option, since this is not linked to all tests.
Therefore, move these functions to the Thumbnailer class.
Since the maximum thumbnail size is now known to the thumbnailer, the
dummy and failure images can be precalculated, which makes switching
between dives faster.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Create a new class, which performs all thumbnailing code.
This is mostly code reshuffling. Thumbnails are extracted
either from a cache or thumbnail calculation is started in
a worker thread.
Since getHashedImage() is called from a worker thread it
makes no sense to call subfunctions in yet another worker
thread. Remove these calls.
In contrast to the previous code, on error the background
thread produces a failure image, but it is not yet shown.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In imagedownloader.cpp the only thing we need from the picture struct
is the filename. Therefore, use QStrings instead of the picture struct.
This simplifies memory management.
Remove the clone_picture() function, which is not needed anymore.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
SHashedImage was a subclass of QImage, which fetched the image according
to the filename hashes. Turn this into a function, as this is much more
idiomatic and flexible.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
On startup, convert an old-style thumbnailHash to individual
thumbnail files. Show a modal progress bar while doing so.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The old code loaded all thumbnails into memory at once. This does
not scale to logs with thousands of pictures. Therefore, save
the pictures to individual files and only load the currently
needed pictures.
Currently, this will make changing switching between dives slower,
because the thumbnails are loaded from disk. In the future, it
is planned to do this in a background thread without blocking
the user interface.
A notable difference to the old code: Thumbnails are now indexed
by the image-hash (i.e. the content of the raw image) and not
by the filename of the image. Thus, different paths to the same
image should only be saved once.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Detection isn't required, but it makes things easier. For the Mares dive
computers we only see the Bluelink, so we can't tell which dive computer is
connected to it. We guess "Quad", but the user can pick a different one.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When generating fake profiles for manually entered dives, fake_dc() and
plan() used different final ascent rates of 5 m/min and 4.5 m/min,
respectively. This led to dives that were 6 seconds longer than entered
by the user and to confusion. See #554.
Therefore, use the same ascent rate taken from the preferences field
flag.ascratelast6m in both cases.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
1) The connection for the display of CCR-setpoint o2SetpointGasItem
was erroneous, being connected to partialpressuregasSettings. It
is now correctly connected to technicalDetailsSettings.
2) The colour of the setpoint graph is changed from PO2_ALERT (red) to
an orange colour in order to show setpoint in red only when it
exceeds 1.6. This emphasises the visibility of red parts of the
gas pressure graphs whenever gas limits are exceeed.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
By not filling out this value, entering of manual dives was broken
for dive lengths starting with a digit 5 or higher.
Fixes#1211
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
fake_dc() used to return a statically allocated dc with statically
allocated samples. This is of course a questionable practice in
the light of multi-threading / resource ownership. Once these
problems were recognized, the parameter "alloc" was added. If set
to true, the function would still return a statically allocated
dc, but heap-allocated samples, which could then be copied in
a different dc.
All in all an ownership nightmare and a recipie for disaster.
The returned static dc was only used as a pointer to the samples
anyway. There are four callers of fake_dc() and they all have access
to a dc-structure without samples. Therefore, change the semantics
of fake_dc() to fill out the passed in dc. If the caller does
not care about the samples, it can simply reset the sample number
to zero after work.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This function looks for the last gas change before a
given time. We should initialize it with a gaschange
event as we might later use this event to read a
gasmix from it.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
This commit allows plotting the OC-equivalent pO2 graph for PSCR
dives. This happens in both the cases where there is no external
O2-monitoring AND when there is external pO2 monitoring. The
calculations are only done for PSCR dives and is achieved as
follows:
1) Within plot-info create a pressure-t called OC_pO2 in
profile.h and populate this variable with the open-circuit
pO2 values in profile.c.
2) Create a new partialPressureGasItem ocpo2GasItem in
profilewidget2.h and, in profilewidget2.cpp, initialise it
to read the plot-info OC_pO2 values and enable its
display by using the setVisible method. The
diveplotdatamodel was also touched in order to achieve
this.
3) Create a pref button that controls the display of OC-pO2 for SCR dives
4) Change the colour of the OC-pO2 grpah to orange
5) Change the connection of the crr_OC_pO2 signal to be appropriate
6) rename the OC_pO2 attribute to scr_OC-pO2
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
The previous code would not add the non-LE address for dual stack
devices. Unfortunately, even with this fix we still don't get the
correct result for the dual stack Shearwater Petrel 2 that I have
for testing as Android incorrectly reports it as a BLE-only device.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Only filter against the hard coded list if no other supported transports
are available for a dive computer.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
For example, even on platforms that support libusb, libdivecomputer
might be compiled without such support.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If the user specified bluetooth, we really should pick bluetooth, not
probe and possibly fall back to something else.
We should also honor the users choice of BLE vs classic BT.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
In firmware version 2.97 the setting 0x38, SETPOINT FALLBACK, has bin
obsoleted and we get a error when trying to write to it.
This removes this setting.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
On Android we still need to do more filtering as only some of the USB
divecomputers are supported. But on iOS this takes care of it without
the hard coded list.
Additionally, if built without BT or BLE support, the corresponding dive
computers are no longer shown (e.g. Perdix AI on Windows).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This opportunistically uses a cache of 'fingerprints' for already
downloaded dives.
As we download data from a dive computer, we save the fingerprint and
dive ID of the most recent dive in a per-divecopmputer fingerprint cache
file.
The next time we download from that dive computer, we will load the
cache file for that dive computer if it exists, verify that we still
have the dive that is referenced in that cachefile, and if so use the
fingerprint to let libdivecomputer potentially stop downloading dives
early.
This doesn't much matter for most dive computers, but some (like the
Scubapro G2) are not able to download one dive at a time, and need the
fingerprint to avoid doing a full dump. That is particularly noticeable
over bluetooth, where a full dump can be very slow.
NOTE! The fingerprint cache is a separate entity from the dive log
itself. Unlike the dive log, it doesn't synchronize over the cloud, so
if you download using different clients (say, your phone and your
laptop), the fingerprint cache entries are per device.
So you may still end up downloading dives you already have, because the
fingerprint code basically only works to avoid duplicate downloads on
the same installation.
Also, note that we only have a cache of one single entry per dive
computer and downloader, so if you download dives and then don't save
the end result, the fingerprint will now point to a dive that you don't
actually have in your dive list. As a result, next time you download,
the fingerprint won't match any existing dive, and we'll resort to the
old non-optimized behavior.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This creates a new libdivecomputer_device_open() helper, and makes
downloading and configuration use it to open the dive computer device
using the proper protocol.
The IRDA case was tested by Sébastien Dugué - I had initially left it
undone believing that "nobody uses IRDA".
Reported-and-tested-by: Sébastien Dugué <sebastien.dugue.subsurface@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This converts our old custom IO model to the new model that
libdivecomputer introduced. This is partly based on Jef's rough patch
to make things build, with further work by me.
The FTDI code is temporarily disabled here, because it will need to be
integrated with the new way of opening devices.
The ble_serial code goes away entirely, since now libdivecomputer knows
about BLE transport natively, and doesn't need to have any serial
wrapper around it.
Signed-off-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Remove a semicolon after Q_OBJECT and a few others after the closing
braces of while loops.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This should have been caught by our build check, but it turns out that
that one isn't correctly reflected in its Travis status.
Oops.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Up until now we just reused the macos.c file for convenience, hard coding a
specific file path that may or may not work on iOS. Instead get the preferred
path from Qt and for this we need to be able to call into Qt, so this needs to
be a C++ file.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Technically, these aren't BLE, these are just the three devices that
are supported by the Mares Bluelink Pro Bluetooth download dongle.
While we are at it, admit that this code is no longer automatically
created but instead maintained by hand.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Identify segements that fullfill the folllowing criteria for
the leading compartment:
He is off-gasing while N2 is on-gasing
Overall there is on-gasing
Add a line to the info box for those segments
Signed-off-by: Robert C. Helling <helling@atdotde.de>
The planner notes were constructed using a sequence of
len += snprintf(buf, buflen - len, ...);
calls. This will fail once len > buflen, because the second parameter
of snprintf is unsigned. Note that snprintf returns the number of
bytes that would have been written if it weren't truncated.
Fix this by using membuffer with put_format()/put_string() and
asprintf_loc().
Fixes#1155.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
get_dive_date_c_string() and get_current_date() return copied strings.
Make this explicit by returning non-const pointers.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Move duplicate code, which reads '*' arguments from va_list into
parse_fmt_int() function. To pass pointers-to-va_list, the va_list
has to be copied first.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
qthelper.cpp is already quite voluminous. Move the recently
introduced localized versions of (v)snprintf() and put_format()
into their own translation unit.
Moreover, adopt C-style semantics for asprintf_loc(). This function
will be used to remove fixed-size buffers in core/plannernotes.c.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Previous taglist_get_tagstring signature/implementation did not allow
handling of cases where inputted buffer could not contain all tags.
New implementation allocates buffer based on pre-computed size allowing to
insert all tags in the returned string.
Added get_taglist_string in qthelper to handle conversion to QString
Added TestTagList with tests for taglist_get_tagstring
Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
Same as default branch, but as 0x01 appears to be converted from DM4 to
DM5, let's just be explicit about it.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Currently the best guess of sampleBlob format. Unfortunately there seems
to be some version of DM that stores the temperature in different
location that I have not been able to figure out yet. Note that some
version of DM does not utilize sampleBlob but specific blobs for each
value (temperature, pressure, ...).
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Parse MP4s and related video files and extract the creation timestamp
from the "mdhd" (media header) atom.
Introduce helper function templates to extract arbitrary-length
unsigned integers in big-endian format from file or memory.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>