This is a user request: add local time of dive to the tooltip.
Showing a localized time was surprisingly complex. First I had
to add a function that decomposes a timestamp into h/m/s. Then
the QLocale time-string has to be stripped of the timezone.
Fixes#3469.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of rendering in a membuffer, directly format into the
QString. We have the qasprintf_loc() function, which is equivalent
to put_format_loc(). Thus, this is a manual search/replace job.
However, this means that the formatting is done in UTF-8 and
then piecewise transformed into QString's (inane) UTF-16.
In the future we might think about directly using QString's
formatting function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Format strings of the type "SAC: %.*f%s/min" were put through
the translation machinery. This seems like a bad idea, and indeed
we had crashes owing to translators messing these up.
Therefore, translate only actual words/abbreviations, in the
case above "SAC" and "min". This has one significant advantage:
compile-time checking of the parameters.
However, it also has one significant disadvantage: lack of support
of right-to-left languages (e.g. semitic languages). If these
should be supported, I would suggest to use QString-style format
strings, i.e. "SAC: %1%2/%3" with appropriate documentation strings.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Arguably, string handling in C is painful. Move the function
that formats the "tooltip" of the current spot on the profile
to the C++ string-format.cpp.
Note: the actual code stays C with a few necessary adaptions
concerning the translation machinery.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To enable grouping by trip in the statistics module, split
the get_trip_title() function in a version that appends
a "(n dive(s)" string an one that doesn't. The statistics
module doesn't want that added string, since it displays
the number of dives in a different way.
Also, move the functions to string-format.h, where these
are collected. And rename them to camelCase. Yes, it's
ugly, but consistent with most other C++ code in the code
base.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>
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>
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>
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>
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>