aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/templatelayout.cpp
AgeCommit message (Collapse)Author
2018-10-07Statistics: only consider selected dives in HTML export statisticsGravatar Berthold Stoeger
If only selected dives were exported into HTML, the statistics would nevertheless cover all dives. A counter-intuitive behavior. Fix by adding a selected_only flag to calculate_stats_summary(). Reported-by: Jan Mulder <jlmulder@xs4all.nl> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-07Statistics: remove global state / calculate only when neededGravatar Berthold Stoeger
Statistics were calculated into global variables every time the current dive was changed. Calculate statistics only when needed and into a structure provided by the caller. 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-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>
2017-12-29cleanup: Uninitialized pointer fieldGravatar Jan Mulder
CID 208320 Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
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: only load *.html files in the UIGravatar Lubomir I. Ivanov
The function find_all_templates() thus far handled all files in the user template directory. This patch makes it so that only files with the .html extension are loaded. Also remove brackets for single lined `if` statement. 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-09-20Add a checkbox to turn off plan variationsGravatar Robert C. Helling
... as those come with a performance penalty Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-04-29Add SPDX header to desktop widgetsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-03-24Fix double to int truncation in C++ codeGravatar Jeremie Guichard
Wfloat-conversion enabled for C++ part of the code Fix warnings raised by the flag using lrint Original issue reported on the mailing list: The ascent/descent rates are sometimes not what is expected. E.g. setting the ascent rate to 10m/min results in an actual ascent rate of 9m/min. This is due to truncating the ascent rate preference, then effectively rounding up the time to reach each stop to 2s intervals. The result being that setting the ascent rate to 10m/min results in 20s to ascend 3m (9m/min), when it should be exactly 18s. Reported-by: John Smith <noseygit@hotmail.com> Reported-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
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-02-29templatelayout.cpp: fix potential issue in preprocessTemplate()Gravatar Lubomir I. Ivanov
The function preprocessTemplate(), did not account well for indexes in Grantlee variables, such as: dive.weight# (where # is the index) dive.cylinder# To solve the issue the list (QList<QPair<QString, QString> >) for variables to be replaced is populated will all possible indexes: 0 - MAX_WEIGHTSYSTEM for weights 0 - MAX_CYLINDERS for cylinders Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-29templatelayout.cpp: add a HTML preprocessor stageGravatar Lubomir I. Ivanov
The current Grantlee template loading scheme does not allow a preprocessing layer. With the recent DiveObjectHelper changes the layer is required if we don't want to add a set of dummy methods and Q_PROPERTIES which will only inflate the DiveObjectHelper class. Use the already present helper readTemplate() to load the raw HTML template and pass it to a static function which does some variable replacement to accomudate DiveObjectHelper. This change is done for the sake of not breaking the Grantlee HTML variables on the user side! Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-08Fix memory leak on the printing systemGravatar Tomaz Canabrava
We forgot to delete the Grantlee object before creating a new one Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-08Simplify Finding the TemplatesGravatar Tomaz Canabrava
We don't need a list of QFileInfo if we are not using it much better to have a list of the files directly Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-08Don't iterate over the dive_table to discover the number of divesGravatar Tomaz Canabrava
dive_table.nr is exactly that. 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-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>