aboutsummaryrefslogtreecommitdiffstats
path: root/core
AgeCommit message (Collapse)Author
2021-01-01core: add get_*_unit functions with explicit unit systemGravatar Berthold Stoeger
The get_*_unit() functions return the unit-name as set in the preferences. Add versions with a "metric" parameter. This will be used by the statistics code, which may in the future allow for binning with alternative units. All the unit-formatting functions should probably be moved away from qthelper to their own source file. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01core: move formatting of day-of-week to string-format.cppGravatar Berthold Stoeger
This was only used by the filter, but will also be used by the statistics module. To avoid duplicate translation strings, move to a common place. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01core: add "transparent" parameter to renderSVGIconGravatar Berthold Stoeger
The start-selection widget will need icons with a transparent background so that the icons don't stick out like a sore thumb. So far the icons rendered by this function were only used by the images on the profile and were perfectly rectangular. Therefore there was no need for this. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01core: make gasmix_is_invalid globally accessibleGravatar Berthold Stoeger
The statistics module will use that to bin dives by gasmix. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01core: add notion of gas-type to core/gas.cGravatar Berthold Stoeger
Create a gastype enum, which describes the type of a gas. For now: air, nitrox, normoxic, trimix and oxygen. This probably should be made configurable. The gas types will be used to bin gasses in the statistics module. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01core: move renderSVGIcon() to qthelper.cppGravatar Berthold Stoeger
The renderIcon() function was used by the thumbnailer to render SVG-based icons. Move it to the global qthelper.cpp so that it can also be used by the statistics module. Add "SVG" to the name to emphasize what it is used for. For consistency also move the renderSVGIconWidth() function, which renders to a fixed width, to qthelper.cpp Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-29cleanup: const-ify utc_mktime()Gravatar Berthold Stoeger
To make it clear that the struct tm is only used as an input parameter. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-29cleanup: move monthname to time.cGravatar Berthold Stoeger
Weirdly, this function was declared in dive.h and defined in subsurface-startup.c. Let's move declaration and definition to more appropriate places, viz. subsurface-time.h and time.c. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-29cleanup: remove getDivesInTrip() in qthelper.cppGravatar Berthold Stoeger
This function was not used anywhere. Moreover, remove a few unused includes from qthelper.h. Surprisingly, a number of users of qthelper.h depend on these, so readd them at the appropriate places. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-29filter: provide function that returns all shown divesGravatar Berthold Stoeger
This will be used by the statistics widget. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-29filter: internalize shown_dives in DiveFilter classGravatar Berthold Stoeger
one piece of global state removed! Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-29filter: move shown_dive from divelist.c to divefilter.cppGravatar Berthold Stoeger
Arguably, the number of filtered dives is a matter of the divefilter. Let's move it there. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-29filter: keep track on shown_dive on dive removal in DiveFilterGravatar Berthold Stoeger
When removing dives, the UndoCommands would keep track of the shown dives. When adding, they were calling into the filter instead. Let's remove this asymmetry. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-29filter: reset shown_dives in filterGravatar Berthold Stoeger
The shown_dives variable was reset by the dive_list code. Arguably, the filter should keep track of the number of shown dives, so move the resetting there. This means adding a new "reset()" member function to the filter and call that instead of "updateAll()" when the core data is reset. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-17core: remove DiveObjectHelperGravatar Berthold Stoeger
Since switching to the mobile-models and removing grantlee, DiveObjectHelper was demoted to a thin wrapper around string formatting functions. The last user was removed in a previous commit. It was never a good idea, given QML's strange memory-management. Let's remove it. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-17mobile: remove DiveObjectHelper codeGravatar Berthold Stoeger
When editing a dive, a DiveObjectHelper of the unmodified dive was created to compare the edited with the old values. Since the DiveObjectHelper is used here only as a pointless wrapper around the formatting functions, call these functions directly. However, note that the code is in principle wrong since the change to the mobile-models, which do not use the DiveObjectHelper. The real fix would be to reload the data from the model to prevent going out-of-sync with respect to the formatting routines! Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-17printing: remove CylinderObjectHelperGravatar Berthold Stoeger
With the removal of grantlee, this became pointless glue code. Call the formatting functions directly. Since the printing code was the only user of CylinderObjectHelper, remove the whole thing. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-17printing: remove DiveObjectHelper from printing codeGravatar Berthold Stoeger
At this point (post grantlee), DiveObjectHelper is just pointless glue code. Let's remove it from the printing code and call the formatting functions directly. If necessary, move these functions to core/string-format.cpp. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-17printing: remove DiveObjectHelperGrantleeGravatar Berthold Stoeger
This was a weird helper object, needed for grantlee. Instead of storing this object, loop over cylinders and dives directly. The actual accessor function is unchanged and now generates a DiveObjectHelper or DiveCylinderHelper for every variable access. Obviously, this is very inefficient. However, this will be replaced in future commits by direct calls to formatting functions. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-17core: create string-format.cpp source fileGravatar Berthold Stoeger
The mobile version of the list used string formatting functions defined in DiveObjectHelper and declared in mobilelistmodels.h. Very confusing. Move them to a separate source file where - in the long run - all the string-formatting functions, which are scattered all over the place, can be collected. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-12-17core: correct AL* tankinfo sizes.Gravatar Berthold Stoeger
Recently (d16a9f118a) the tankinfo table was made dynamic, which means that the default tankinfos are added programatically. Thereby, the wrong function was used for AL* type of cylinders: metric instead of imperial. Fix those. Reported-by: Michael Andreen <harv@ruin.nu> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-13prefs: add option to display only actually used tanksGravatar Berthold Stoeger
A user complained about the default cylinders list. Provide a preferences option to turn this off. When changing the preferences, the tank-info model will be completely rebuilt. Currently, this is a bit crude as this will be done for any preferences change. Suggested-by: Adolph Weidanz <weidanz.adolph@gmail.com> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-13core: remove the "no-name" tank infoGravatar Berthold Stoeger
There was a tank info with an empty name. According to a comment, this is needed for the "no cylinder" case. However, we now support empty cylinder tables, so this is not needed anymore. Therefore, remove it. Make sure that the user can still enter the empty name, just in case. But don't save the size and pressure in that case. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-13core: free tank info table on exitGravatar Berthold Stoeger
This is obviously a pure code-hygiene thing. But with the new dynamic tank info table, this becomes trivial, so let's do it. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-13core: keep tank infos in a dynamic tableGravatar Berthold Stoeger
The list of known tank types were kept in a fixed size table. Instead, use a dynamic table with our horrendous table macros. This is more flexible and sensible. While doing this, clean up the TankInfoModel, which was leaking memory. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-12preferences: create global settingsChanged signalGravatar Berthold Stoeger
So far, the PreferencesDialog emitted a settingsChanged signal. This meant that models that listened to that signal had to conditionally compile out the code for mobile or the connection had to be made in MainWindow. Instead, introduce a global signal that does this and move the connects to the listeners to remove inter-dependencies. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-12Add surge etc to printing template variablesGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-12-03downloader: filter possible devices and add mounts, remember last choicesGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-12-03build-system/downloader: cli-downloader isn't part of the coreGravatar Dirk Hohndel
It's part of the main excutable / helper and needs to be linked before all of our support libraries. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-12-03downloader: turn off bluetooth mode for nowGravatar Robert C. Helling
Eventually, this should also be set from the command line. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-12-03downloader: small improvementsGravatar Robert C. Helling
Provide supported dive computer list on the command line and actually call the cli download. Still not functional. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-12-03downloader: first outline of downloading dives from a deviceGravatar Dirk Hohndel
This is of course not functional at all, but it gives a first idea of what we will need to do in this code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-12-03downloader: first step to get instructions via CLIGravatar Dirk Hohndel
This still doesn't do a thing, but at least it seems to get the information closer to where we want it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-12-03build-system: start adding a headless buildGravatar Dirk Hohndel
Right now this doesn't do a thing, but it gives us a nice target that has far fewer dependencies and should contain enough parts to download stuff from a divecomputer and then sync that with cloud storage. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-11-24cylindermodel: remove in_planner() useGravatar Berthold Stoeger
in_planner() is problematic, since it is uses desktop-only application state. Since the cylinder-model already has an appropriate inPlanner flag, use this instead. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-23android: find the translationsv4.9.10Gravatar Dirk Hohndel
As we switched to the qmake based build we now bundle the translations via the Qt resource system instead of explicitly as Android assets. This adjusts the code that opens the translations accordingly. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-11-19core/picture: don't compile all on mobileGravatar Dirk Hohndel
We don't support adding pictures and videos on mobile, so let's not referernce the infrastrutcture that's needed for that. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-11-17core: fix incorrect QString::asprintf/vasprintf usageGravatar Dirk Hohndel
These are static functions, they cannot be used as a method on an object to construct that object. commit aa5f2e7c73 ("cleanup: replace deprecated sprintf()/vsprintf() calls") introduced this bug in an ill-advised attempt to deal with a deprecation warning. This caused us to not print GPS coordinates in the UI. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-11-14undo: add a general dives-imported signalGravatar Berthold Stoeger
Add a general dives-imported signal for those cases where we want to fully rebuild models, notably, the completion models. The divesAdded signals are too fine, because they are sent per trip and we don't want to reload these models multiple times per import. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-13Gracefully handle infinite MND for oxygenGravatar Robert C. Helling
When breathing pure oxygen and considering it not narcotic, there is not maximal narcotic depth and the formula divides by zero. So better, handle this case separately. Fixes #3080 Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-11-12filter: avoid Windows crashGravatar Dirk Hohndel
The scope confusion between s (the for loop variable) and s (the function argument) caused a crash in the s.split() on Windows. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-11-04core: don't construct std::string from null in device.cppGravatar Berthold Stoeger
Recently the QStrings were replaced by std::strings in device.cpp so that they can be accessed from C-code. However, libstd being modelled after C, constructing a std::string from a NULL pointer leads to a crash. Fix one case where this was overlooked. Moreover, replace a null-pointer check by empty_string(), to treat NULL and "" equally. Reported-by: Salvador Cuñat <salvador.cunat@gmail.com> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-04revert preference settings for title colorGravatar Dirk Hohndel
Because of subsequent changes there is no clean way to just revert the changes introduced in commit 8b36cf1051 ("desktop: offer different colors for info tab titles"), so this manually removes the parts we don't need anymore. This also restores a tooltip value that was inadvertantly removed in that commit. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-11-03cleanup: random small whitespace cleanupGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-11-03desktop: offer different colors for info tab titlesGravatar willemferguson
Add a preference option to set the color of the text on the information tab to either MediumBlue, LightBlue or Black. The last two of these colors are meant to enable areadable font contrast on displays with dark mode. The choice is saved with the other preferences. [Dirk Hohndel: this isn't really about dark mode, so changed many of the types and variable names, changed the user visible texts, and addressed some whitespace issues] Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-11-01parser: don't crash when parsing <weight> tagsGravatar Berthold Stoeger
When encountering a <weight> tag, we would parse into the last weightsystem. However, we only create weightsystems when encountering <weightsystem> tag. Therefore, this code would either crash or overwrite the previous weightsystem. Instead, create a new weightsystem for each <weight> tag. Moreover, make sure that inside a <weightsystem> tag a weightsystem actually exists. This should be the case, but who knows...? Reported-by: Nihal Gabr <gabr.nihal@gmail.com> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-31core: on import remove merged dives from trip/divesiteGravatar Berthold Stoeger
When dives were merged on import, they were not unregistered from their dive site and trip before being deleted. Thus, these tables had stale pointers, which would ultimate lead to crashes. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-27cleanup: refactor subsurfacesysinfo.cppGravatar Berthold Stoeger
This used to be a copy of QSysInfo. However, once the requirement was raised to Qt5.4, this was replaced by a subclass of the original QSysInfo - which made the whole file mostly obsolete. Just use QSysInfo directly where needed. Only for windows.c, which can't call directly into Qt, keep the isWin7Or8() helper function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-26cleanup: move variable declaration closer to useGravatar Dirk Hohndel
This way we avoid an unused variable warning on mobile builds. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26cleanup: remove unused function argumentGravatar Dirk Hohndel
Also, only compile the static function where it is used. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>