aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/templatelayout.h
AgeCommit message (Collapse)Author
2020-10-08Remove code references to GrantleeGravatar Robert C. Helling
These are no longer needed. What is still missing is removing Grantlee from the various build systems. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-08Interpret divelist printing templatesGravatar Robert C. Helling
This is a first step of an efford to get rid of the Grantlee dependency. This implements template processing for those constructs used in our divelist and statistics printing templates. It implements a template parser for loops over dives, cylinders and year and variable replacement. As the previous Grantlee code, it does not really use Qt's QObject introspection capabilities but reuses the old long chain of if-else-statements. The grantlee code is not yet removed. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-04Cleanup: lower-case filenames in core/subsurface-qt/Gravatar Berthold Stoeger
We tend to use lower-case filenames. Let's do it for these files as well. Simple search & replace. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Grantlee: split out grantlee-only property from DiveObjectHelperGravatar Berthold Stoeger
The cylindersObject list was only used by grantlee but not by the mobile code. Since it is quite heavy, split it out and thus don't generate it for every dive on mobile. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14Mobile: transform DiveObjectHelper into value-typeGravatar Berthold Stoeger
Instead of handing a reference-to-dive to QML, prerender all the needed properties and store them as values in DiveObjectHelper. Exception: - date(): generated from timestamp - time(): generated from timestamp - cylinderList(): does not depend on dive anyway and should be made static. This hopefully avoids the random mobile crashes that we are seeing. Clearly, this code needs to be optimized, but it is a start. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-14DiveObjectHelper: Turn DiveObjectHelper into Q_GADGET based objectGravatar Berthold Stoeger
DiveObjectHelper is a tiny wrapper around dive * to allow access to dive data from QML and grantlee. It doesn't have to be a full-fledged QObject with support for signals, etc. Therefore, turn it into a Q_GADGET based object. This allows us passing the object around as object, not as pointer to DiveObjectHelper. This makes memory-management distinctly easier. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-22Cleanup: turn CylinderObjectHelper into value typeGravatar Berthold Stoeger
CylinderObjectHelper is used for structured formatting of cylinder values in grantlee types. Instead of keeping a reference to a cylinder, turn it into a value type containing the formatted strings. This should be distinctly safer, as we don't risk having stale references flying around. Moreover, we don't have to use pointers but can use containers containing plain CylinderObjectHelper. Thus, no explicit memory management is needed, making the code distinctly easier to understand. Sadly, currently grantlee does not support Q_GADGET based Q_PROPERTY. Therefore a GRANTLEE_*_LOOKUP block has to be added. This can be removed in due course, as a patch to remedy this issue is in current grantlee master. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-29Cleanup: simplify YearInfo classGravatar Berthold Stoeger
YearInfo is a trivial wrapper around "stats_t *". All the constructor / destructor rigmarole seems completely unnecessary. Remove it. Probably the whole class could be removed, but for that I'd need more insight into Grantlee, which is low on my list of priorities for now. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-29Cleanup: rename variable PrintOptions to printOptionsGravatar Berthold Stoeger
We're quite inconsistent when it comes to variable naming. The general usage is camelCase for Qt parts and snake_case for core code. Virtually nowhere do we start variable names with a capital letter. Therefore, turn this one weird case into camelCase. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-29Cleanup: remove TemplateLayout::m_engine member variableGravatar Berthold Stoeger
TemplateLayout::m_engine is a Grantlee::Engine that is reallocated for every function call. Instead of the archaic memory-management, remove the member variable and make it a local variable of the two functions that need it. There seems to be no point in keeping the object alive beyond the function's scope. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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-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>
2017-11-24printing: update the coping of bundled templatesGravatar Lubomir I. Ivanov
This update includes: - Instead of copyPath() use a new specialized function: copy_bundled_templates() - The new function supports overwriting of templates in the user path, but only if a template file is read-only - If the file is RW create a backup of the file in the form of: <file-name>-User.html - Collect backup files and store them in a QStringList which is then shown in a QMessageBox from MainWindow to notifying the user about the backup This change allows moving the maintenance of the bundled templates back to the application developers and contributors as currently the only one who can edit the templates in the user path was the user. Suggested-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-24printing: add set_bundled_templates_as_read_only()Gravatar Lubomir I. Ivanov
Add the function set_bundled_templates_as_read_only() in templatelayout.cpp/h. The function is used to mark the bundled template files as read-only in the user folder. It is called in mainwindow.cpp, after the files are copied from the bundle. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
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 desktop widgetsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05Fix include pathsGravatar Linus Torvalds
As expected, commit 7be962bfc287 ("Move subsurface-core to core and qt-mobile to mobile-widgets") caused some breakage. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> 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>
2016-01-08Removed grantlee template code to deal with non-QobjectGravatar Tomaz Canabrava
Since we alreday have a Q_PROPERTY on the DiveObjectHelper, grantlee introspection can use that directly to access it's data, so there's no need for us to redeclare everything. More QObject Introspection, Less handmade boilerplate for Grantlee, QML, and a few other things. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-08Move Dive class from qthelper.h/cpp to it's own fileGravatar Tomaz Canabrava
and rename it to DiveObjectHelper, since it should be an QObject based class to make it easier on the QML, grantlee and widgets side to display the dive's internal data. each Q_PROPERTY defined in the DiveObjectHelper.h file can be acessed directly via it's name. So, if you are on a model that returns a dive, acess it's name by dive.name Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-16qthelper: also support "maxcns" and "otu" in Grantlee HTMLGravatar Lubomir I. Ivanov
Fixes #962 Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-16templatelayout.h: expose cylinders and weights in Grantlee HTMLGravatar Lubomir I. Ivanov
This patch adds the following HTML variables: "dive.cylinders" -> Dive::cylinders() "dive.cylinderX" -> Dive::cylinder(X) "dive.weights" -> Dive::weights() "dive.weightX" -> Dive::weight(X) The patch also creates some macros to ease the Dive variable lookup visually. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-16templatelayout.h: expose "dive.suit" as a Grantlee HTML variableGravatar Lubomir I. Ivanov
Having {{ dive.suit }} in the HTML will now return the suit as QString (from struct dive->suit). Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-30Move qt-ui to desktop-widgetsGravatar Tomaz Canabrava
Since we have now destkop and mobile versions, 'qt-ui' was a very poor name choice for a folder that contains only destkop-enabled widgets. Also, move the graphicsview-common.h/cpp to subsurface-core because it doesn't depend on qgraphicsview, it merely implements all the colors that we use throughout Subsurface, and we will use colors on both desktop and mobile versions Same thing applies for metrics.h/cpp Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>