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>
Thus, metadata has to be only read once and the picture_load_exif_data()
function can be removed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To ease trouble-shooting of the picture thumbnailer add a number
of debug- and info-messages.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Correct a bug in finding the minimum heartrate.
Use the minimum and maximum heartrate value to set min/max and
tic distance for the heartrate axis in the profile.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
This is a preparation for supporting videos. Some video formats may
not possess such meta data, or we may not yet be able to parse them.
In such a case, use the file creation date.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is a preparation for video support. We don't want to read a whole
potentially multi-GB file into memory just to detect that it isn't a
JPEG. Especially since at the moment EXIF metadata are parsed twice,
once for GPS, once for timestamp.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
strdup(qPrintable(s)) and copy_string(qPrintable(s)) were such common
occurrences that they seem worthy of a short helper-function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Replace constructs of the kind
s.toUtf8().data(),
s.toUtf8().constData(),
s.toLocal8Bit().data(),
s.toLocal8Bit.constData() or
qUtf8Printable(s)
by
qPrintable(s).
This is concise, consistent and - in principle - more performant than
the .data() versions.
Sadly, owing to a suboptimal implementation, qPrintable(s) currently
is a pessimization compared to s.toUtf8().data(). A fix is scheduled for
new Qt versions: https://codereview.qt-project.org/#/c/221331/
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Make arguments to set_informational_units(), set_git_prefs(),
set_userid(), dive_remove_picture() and update_event_name()
"const char *" for consistency with the rest of core/dive.c.
This will allow replacing toUtf8().data() with the constData()
version in a subsequent commit.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This was only done explicitly for Windows. Other platforms were
implicitly supposed to be UTF-8.
Suggested-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
So because I merged with upstream libdivecomputer, and it no longer does
the "halfduplex emulation" thing in the IO layer, and instead does it in
the only Suunto backend that needed it, that also affected our custom IO
layer in subsurface.
Sure, I could have left a dummy interface and left subsurface with some
ugly dead code, but it's really better to just get rid of the code.
So when Dirk pulls in the libdivecomputer updates from
https://github.com/torvalds/libdc-for-dirk.git Subsurface-branch
this patch to remove the halfduplex code in subsurface is also needed.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
PSCR dives with o2 sensors are more like CCR dives. The math is exactly
the same, its just a different diluent and a different po2.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
This introduces a fixup function that walks all the samples and
populates the no_o2sensors if its zero and supposed to be something
else.
There is a bug somewhere which Willem hit, causing this to never be set.
Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
In the if case above, we already conclude its a OC dive, but its cleaner
to actually pass the current mode instead of a hard coded value.
This also makes the code less prune to future bugs.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
The map widget on the mobile version requires that
a dive object from a model has a dive_site uuid.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Consistently do not use a space between value and unit.
Consistently do not use a space between "name:" and value.
Add "/min" for SAC rate.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
The hash field in the picture-structure was in principle non-operational.
It was set on loading, but never actually changed. The authoritative
hash comes from the filename->hash map.
Therefore, make this explicit by removing the hash field from the
picture structure.
Instead of filling the picture structure on loading, add the
hash directly to the filename->hash map. This is done in the
register_hash() function, which does not overwrite old entries.
I.e. the local hash has priority over the save-file. This
policy might be refined in the future.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Passing of QStrings and QByteArrays was inconsistent in qthelper.cpp.
Unify to passing const-references. Passing by value is no big deal, since
QString and QByteArray do copy-on-write "optimization". Nevertheless, let's
keep it as consistent and effective as possible.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
learnHash() was always called in conjunction with add_hash(). The
pattern was that a local filename and a hash were connected in
the hash-to-filename and the filename-to-hash maps. Then, the
original picture-filename or url were registered in the filename-to-hash
map.
This commit changes learnHash() to take three parameters (original-filename,
local-filename and hash) and do all of the above. The new code is
simpler because no dummy picture struct has to be generated in
DiveListView::loadImageFromURL().
The tests were extended to check for all hash<->filename associations.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
learnHash() is called either on a local picture structure
[DiveListView::loadImageFromURL()] or on a cloned picture structure
[ImageDownloader::saveImage()]. In neither case the picture structure
is passed to the frontend. Therefore, storing the new hash in the
picture struct is not necessary.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
hashPicture() calls hashFile(), which calls add_hash(). add_hash()
updates the filename-to-hash and hash-to-filename maps. Therefore,
there is no point in calling learnHash() in hashPicture(), which
updates the filename-to-hash map.
Note that learnHash() updates the picture-struct with the new hash,
but since hashPicture() works on a cloned picture-struct, which
is free()d in hashPicture(), these changes are lost anyway.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
updateHash() and hashPicture() did the same thing, with the exception
that hashPicture() marked the dive list as changed if a hash changed.
This seems like a good idea in any case, therefore always use
hashPicture().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
If loading from hash failed in the saveImage() slot(!) it would
recurse into loadFromUrl(), which would generate a new network
reply. Very scary and a (small) wonder that it worked.
Let's try to make this all more explicit.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The QNetworkAccessManager is only used in the load() function. No
point in it being a subobject.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
1) Destroying the QNetworkManager seems like a bug: this was a
subobject of ImageDonwloader. It's mysterious how this didn't
crash.
2) Instead of calling deleteLater() on the reply object, simply
delete it after completion.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
A cloned picture struct would not be freed if the filename was already
in the queued-for-download set.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This changes the numeric format of many values printed to the UI to
reflect the correct numeric format of the selected locale:
- dot or comma as decimal separator
- comma or dot as thousands separator
In the Qt domain the `L` flag is used case specific mostly
in qthelper.cpp.
Then the helper functions get_xxx_string() are used more consistently.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Replace snprintf() and put_format() by snprintf_loc() and
put_format_loc(), respectively to localize formatting of
integers and floats.
Acked-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Replace snprintf() and put_format() by snprintf_loc() and
put_format_loc(), respectively to localize formatting of
integers and floats.
Acked-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit introduces functions:
- QString asprintf_loc(const char *cformat, ...);
- int snprintf_loc(char *dst, size_t size, const char *cformat, ...);
- put_format_loc(struct membuffer *, const char *fmt, ...);
and their va_arg equivalents, which use Qt's QString::arg() formatting
options to render the strings.
The snprintf_loc() function takes care not to truncate multi-byte
UTF-8 encodings. Thus, on overflow, the resulting string might be
shorter than size-1.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>