summaryrefslogtreecommitdiffstats
path: root/core
AgeCommit message (Collapse)Author
2018-03-14Cleanup: consistently use qPrintable()Gravatar Berthold Stoeger
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>
2018-03-14Cleanup: constify string arguments in core/dive.cGravatar Berthold Stoeger
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>
2018-03-14Cleanup: Set text encoding to UTF-8 for all platforms.Gravatar Berthold Stoeger
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>
2018-03-14Subsurface-mobile: Add OSTC 2 TR as support dive computerGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-03-13Subsurface update for upstream libdivecomputer changesGravatar Linus Torvalds
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>
2018-03-13Treat a PSCR dive with sensors more like a CCR diveGravatar Anton Lundin
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>
2018-03-13Fix up CCR/PSCR dives with sensors values without no_o2sensorsGravatar Anton Lundin
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>
2018-03-13Use the current dive mode instead of constantGravatar Anton Lundin
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>
2018-03-11DiveObjectHelper: add dive_site_uuid()Gravatar Lubomir I. Ivanov
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>
2018-03-06Cosmetic modifications in profile delta sample stringGravatar Stefan Fuchs
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>
2018-03-05Cleanup: Remove hash field from picture-structureGravatar Berthold Stoeger
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>
2018-03-05Cleanup: pass QString and QByteArray const-refs to qthelper functionsGravatar Berthold Stoeger
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>
2018-03-05Cleanup: Fold add_hash() call into learnHash() functionGravatar Berthold Stoeger
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>
2018-03-05Cleanup: Don't store hash in picture struct in learnHash()Gravatar Berthold Stoeger
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>
2018-03-05Cleanup: Don't call learnHash() in hashPicture()Gravatar Berthold Stoeger
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>
2018-03-05Cleanup: remove updateHash() functionGravatar Berthold Stoeger
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>
2018-03-05Cleanup: Make helper function haveHash() of static linkageGravatar Berthold Stoeger
The function is only used in the qthelper.cpp translation unit. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05core/imagedownloader.cpp: Use signal to exit eventloopGravatar Berthold Stoeger
Don't do busy-waiting. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05core/imagedownloader.cpp: Use implicit default constructor of QImageGravatar Berthold Stoeger
No point in move-constructing from a different default constructed QImage. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05core/imagedownloader.cpp: remove recursionGravatar Berthold Stoeger
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>
2018-03-05core/imagedownloader.cpp: Make the manager object local to load()Gravatar Berthold Stoeger
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>
2018-03-05core/imagedownloader.cpp: Simplify deletion of objectsGravatar Berthold Stoeger
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>
2018-03-05core/imagedownloader.cpp: Fix memory leakGravatar Berthold Stoeger
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>
2018-03-05Use correct numeric format based on selected locale (Qt domain part)Gravatar Stefan Fuchs
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>
2018-03-05Localization: implement *_loc() functions in plannernotes.cGravatar Berthold Stoeger
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>
2018-03-05Localization: implement *_loc() functions in profile.cGravatar Berthold Stoeger
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>
2018-03-05Localization: Make Qt's locale-aware formatting accessible from CGravatar Berthold Stoeger
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>
2018-03-05Configure DC dialog: Add a few missing translationsGravatar Stefan Fuchs
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-03-02Choose water presets from a qcombobox in planner, custom value possibleGravatar Oliver Schwaneberg
Add a combo box for water types with defaults for fresh water, sea water and the EN 13319. All values taken from units.h, where EN 13319 was added beforehand. Custom values can be entered through a spinbox. Also changed "Salinity" in TapDiveInformation.ui to "Water type". Translation required! Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-03-02Warning Fix: add missing include to core/parse-xml.cGravatar Berthold Stoeger
Fallout from commit #cd5e17cf79c2f1eb896efd0436c103221de446ae Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-27Updated strategy for removing cylindersGravatar Stefan Fuchs
Change the strategy when to allow cylinder removal from a dive: - Not remove when cylinder has gas switch events, in any other cases allow removal - Remove this whole "cylinder with same gas" thing being a criteria for cylinder removal When removing a cylinder which has corresponding pressure info in samples, also remove this pressure info from the samples. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-26Cleanup: Unify qthelper.h and qthelperfromc.hGravatar Berthold Stoeger
Since all qt-helpers are defined in qthelper.cpp, there seems to be no reason to have two include files. By unifying the two files, duplication and inconsistencies are removed. The C++-only part is simply compiled away with #ifdefs. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-26Cleanup: Use QString as parameter for [get|save]BtDeviceInfo()Gravatar Berthold Stoeger
Each callsite of saveBtDeviceInfo() has a QString, which is converted to a C-string, passed and immediately converted back. Remove these conversions by taking a reference to QString directly. getBtDeviceInfo() is not as clear. Here, the callsite has a C-string handed down from libdivecomputer. Nevertheless, pass a reference of QString here as well. Firstly, for reasons of symmetry. Secondly, to avoid multiple conversions in the getBtDeviceInfo() functions. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-25Correctly suppress display of ICD table if prefs.show_icd is falseGravatar Stefan Fuchs
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-25For prefs option show_icd add missing call for loadingGravatar Stefan Fuchs
Add the missing call to load the prefs option show_icd in function SettingsObjectWrapper::load() Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-24Whitespace cleanup in core/divelogexportlogic.cppGravatar Stefan Fuchs
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-24Correct comments for struct temperature_t value rangeGravatar Stefan Fuchs
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-24Use duration_t for total_sac_time in struct stats_tGravatar Stefan Fuchs
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-24Use temperature_t for temperatures in struct stats_tGravatar Stefan Fuchs
Use struct temperature_t for temperatures in struct stats_t and use get_temperature_string() when printing these temperatures for statistics and HTML export. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-22Exit add_plan_to_notes() in plannernotes.c always via label finishedGravatar Stefan Fuchs
Replace an early "return" in add_plan_to_notes() with a "goto finished;" This was the initial idea of doing it plus it fixes a potential memory leak (missing free for icdbuffer). Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-20Indicate direction of transition in verbatim planGravatar Robert C. Helling
Replace "Transition to" by "Ascent to" or "Descend to" Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-02-17Coding-style: remove superfluous parenthesesGravatar Berthold Stoeger
Mostly replace "return (expression);" by "return expression;" and one case of "function((parameter))" by "function(parameter)". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-17Cleanup: Save hash from filename-to-hash map to git repositoryGravatar Berthold Stoeger
This unifies behavior of XML & git saving. Now, in both cases, the picture hash is extracted from the filename-to-hash map instead of using the picture structure. This seems more robust, because the picture structure is not necessarily updated by learnHash(). The latter may operate on a copy of the picture structure. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-17Cleanup: return copied string from hashstring()Gravatar Berthold Stoeger
The following statement in the hashstring() function: return hashOf[QString(filename)].toHex().data(); returns data of the temporary QByteArray generated by toHex(). Thus, the caller will access released memory, which could lead to data corruption. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-12Cleanup: remove outdated TODO itemGravatar Berthold Stoeger
report_error() automatically pushes error messages. No need for a separate signal. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-12Cleanup: remove declaration of get_error_string()Gravatar Berthold Stoeger
This function was removed in #8f81a22e7f26729cc2f4902ba7db8f696314539f. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-12dump_tissues: fix missing 'struct deco_state' argumentGravatar Lubomir I. Ivanov
With DECO_CALC_DEBUG != 0, divelist.c and profile.c have calls to dump_tissues() without passing a 'struct deco_state' argument. Fixes #1105 Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-02-10Add a preference to turn on ICD warningsGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-02-07Cleanup: unserialize loading of picturesGravatar Berthold Stoeger
The images to load are kept in a set to avoid multiple loading of the same picture. The set was protected with a mutex. Problem: the mutex was not released before loading the picture, effectively serializing the loading of pictures. Therefore unlock the mutex once the set is updated. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-07Cleanup: remove unused typedefGravatar Berthold Stoeger
The type SHashedFilename defined in core/imagedownloader.h was not used anywhere. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>