aboutsummaryrefslogtreecommitdiffstats
path: root/core/subsurface-qt/DiveObjectHelper.cpp
AgeCommit message (Collapse)Author
2018-07-04Translations: unify gettextFromC::tr() and QObject::tr()Gravatar Berthold Stoeger
There were two catch-all classes for translations outside of class context. gettextFromC was used exclusively from C, but C++ used both, gettextFromC and QObject. Some of the string were even present in both. Therefore, unify to gettextFromC throughout the code base. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-04Cleanup: fold core/helpers.h into core/qthelper.hGravatar Berthold Stoeger
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>
2018-05-14Core: introduce new subsurface-string headerGravatar Dirk Hohndel
First small step to shrinking dive.h. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-14DiveObjectHelper: expose number of dives in a tripGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-09Change taglist_get_tagstring to support 'unlimited' tag list sizeGravatar Jeremie Guichard
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>
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-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-01-31mobile cleanup: restyle construction of locationlistGravatar Jan Mulder
See also e6e1473e6. The construction of the locationlist was not the same as the 3 previous lists, and it needs the inclusion of a new model file (divelocationmodel.cpp) in the mobile app. In addition, as the mobile app is mainly interested in a simple stringList (model) to populate a HintsText field (or maybe later a combobox), this stringlist is added to the model, to easy interfacing with QML. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-31mobile cleanup: unduplicate code and do not loop over dives (3)Gravatar Jan Mulder
See e6e1473e6. Exact same commit but here for the list of divemaster. The careful reader will spot a small addition to the clearDetailsEdit() QML function. Two more field are cleared. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-31mobile cleanup: unduplicate code and do not loop over dives (2)Gravatar Jan Mulder
See e6e1473e6. Exact same commit but here for the list of buddies. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-31mobile cleanup: unduplicate code and do not loop over dives (1)Gravatar Jan Mulder
This is the first of a set of commits that are (very) similar. It appeared that a number of more or less static lists, which are constructed by a loop over all dives in the logbook, were executed when changing focus to a next dive. For example, the in this commit addressed list of used dive suits. What was wrong was that the suitList was linked to a dive. There is only a need to construct the list of used suits when data is changed (and obviously, once on startup of the app). Further, it appeared that a lot of code was duplicated and that we can use (in this case) the same code from the desktop completionmodels.cpp. Basically, this commit involves the following changes: - include completionmodels.cpp in mobile and desktop (so move it from the desktop only category to the generic category). - remove double code from DiveObjectHelper.cpp - Do not differentiate in the init phase and the normal refresh of the list - the per dive logic is now only the getting of a previously constructed list (in init or update of the divelist). There are no visible changes in the UI, other than a better performance when scrolling over dive details. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-26Cleanup: avoid out of bounds accessGravatar Dirk Hohndel
sizeof() is clearly the wrong way to get to the size of that array... Coverity CID 208290 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-11-25Fix crash when dives have no dive siteGravatar Dirk Hohndel
get_dive_site_by_uuid() returns a NULL pointer in that case. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-11-25mobile: autocomplete location namesGravatar Jan Mulder
Add the capability to select the location name from a list, constructed from the known dive sites in the logbook. Fixes: #546 Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-06-24QML UI: DiveList: add date box to trip headerGravatar Dirk Hohndel
This way you can tell when a trip happened. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-22QML UI: correctly build plural translationGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-18QML UI: use the short date formatGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-26Creation of dive duration string and surface interval stringGravatar Stefan Fuchs
Update the function to create the dive duration string in a way that it can be used also in info and stats tab and added some more flexibility. Changed layout for <1h freedives to "0:05:35" (w/o units) or "5:35min" (with units and :) or "5min 35sec" (with units with space). Add a new function to create the surface interval string. Completely remove old function get_time_string() and get_time_string_s(). Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-04-29Add SPDX header to remaining core filesGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-03-24Subsurface-mobile: do send decimal GPS to GoogleGravatar Jan Mulder
Sending nicely readable formatted coordinates to Google Maps does not result in a correctly positioned map. Google likes unreadable decimal format. Little hacky solution. Added a gps_decimal attribute, populate that with the standard function for format a coordinate to string, but reset the preferences value temporarly so that it always converts it to decimal style. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-02-03Revert "In statistics, ignore gas use of planned dives"Gravatar Dirk Hohndel
This reverts commit 1d8662006cbb5edae941315e30ede381c23a817b. Mistakenly pushed to master Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-02In statistics, ignore gas use of planned divesGravatar Robert C. Helling
When merged with real dives, those would double count otherwise. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-01-22QML UI: allow magic phrase for multiple buddies to be localizedGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-17QML UI: deal with multiple buddies correctlyGravatar Joakim Bygdell
When editing adive in Subsurface-mobile we can only handle one buddy due to the limitations of the combobox. To prevent loss of data when editing a dive with more than one buddy we display "Multiple Buddies" in the buddy field. This creates a special case where no changes are written to the buddy field unless the user changes buddy for that dive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-04Fix some warningsGravatar Dirk Hohndel
At least the warnings about size potentially being uninitialized seem correct and valid. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-04Remove hacks regarding multiple gasmixes and cylindersGravatar Joakim Bygdell
Enabling cylinder edit in Subsurface-mobile our previous hacks regarding multiple cylinders and gasmixes must be removed. Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-04QML UI: Enable cylinder editGravatar Joakim Bygdell
This adds the option to select a cylinder when adding or editing a dive. Due to limited screen size we restrict the editing to the first cylinder only. Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-10Adds Cylinder helper class for cylinder info access in grantlee templatesGravatar Tim Wootton
to allow grantlee to access individual fields of the cylinder_t struct rather than a string representation of the whole cylinder info using a grantlee structure like this one: <table class="table_class"> <tr> <td>Cylinder</td> <td>Start press.</td> <td>End press.</td> <td>Gas mix</td> </tr> {% for cylinderObject in dive.cylinderObjects %} <tr> <td>{{ cylinderObject.description }}</td> <td>{{ cylinderObject.startPressure }}</td> <td>{{ cylinderObject.endPressure }}</td> <td>{{ cylinderObject.gasMix }}</td> </tr> {% endfor %} </table> Signed-off-by: Tim Wootton <tim@tee-jay.org.uk> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23Only add non-blank cylinder strings to the cylinder listGravatar Tim Wootton
Signed-off-by: Tim Wootton <tim@tee-jay.org.uk> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23Only add non-blank weights to the weight listGravatar Tim Wootton
Signed-off-by: Tim Wootton <tim@tee-jay.org.uk> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23Let cns and otu return ints rather than QStringsGravatar Tim Wootton
This way they display correctly when accessed from grantlee template Fixes #1085 Signed-off-by: Tim Wootton <tim@tee-jay.org.uk> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23Adds missing visibility to DiveObjectHelper, so it too can be used in print ↵Gravatar Tim Wootton
templates. Signed-off-by: Tim Wootton <tim@tee-jay.org.uk> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-16QML UI: add comboboxes to DiveDetailsEditGravatar Joakim Bygdell
This adds autocompleting text input fields for suit, buddy and divemaster. [Dirk Hohndel: some whitespace cleanup] Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-16Add functions to DiveObjectsHelperGravatar Joakim Bygdell
This generated the QStringLists needed to populate the combobxes in DiveDetailsEdit. Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-29Fix Qt date interfaces for times before 1970Gravatar Linus Torvalds
This seems to work around the crazy QDateTime::fromTime_t() problem in Qt. It is *very* lightly tested. In fact, the only test is that "test0.xml" change that is part of this patch. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-15QML UI: stop using "--" for empty stringsGravatar Dirk Hohndel
I can't remember why we started doing this, but at this point I find it just weird. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05QML UI: better trip headerGravatar Dirk Hohndel
This tries to give the best information about the trip that we have. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04Move subsurface-core to core and qt-mobile to mobile-widgetsGravatar Dirk Hohndel
Having subsurface-core as a directory name really messes with autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an autocomplete conflict and also was inconsistent with the desktop-widget name for the directory containing the "other" UI. And while cleaning up the resulting change in the path name for include files, I decided to clean up those even more to make them consistent overall. This could have been handled in more commits, but since this requires a make clean before the build, it seemed more sensible to do it all in one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>