aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/templatelayout.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-12-12 13:28:36 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-12-17 13:03:56 -0800
commit0cbb4487401b749476e939db20b842e04099bfa8 (patch)
tree2627229973b9d9cbb25c83953231e29fe0f1cd91 /desktop-widgets/templatelayout.h
parent7bdd968e05a3ec11ab9f207e7bd32ff7bffc34a8 (diff)
downloadsubsurface-0cbb4487401b749476e939db20b842e04099bfa8.tar.gz
cleanup: make templateOptions and printOptions reference types
These two structs describe options used during printing. They are passed through numerous classes as pointer. In this case, reference semantics are preferred, as references: - can never be null - can not change during their lifetime This not only helps the compiler, as it can optimize away null checks, but also your fellow coder. Moreover, it prevents unintentional creation of uninitialized references: one can't create an instance of a class without initializing a reference member. It does not prevent references from going dangling. However, pointers have the same disadvantage. Contains a few whitespace cleanups. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/templatelayout.h')
-rw-r--r--desktop-widgets/templatelayout.h10
1 files changed, 4 insertions, 6 deletions
diff --git a/desktop-widgets/templatelayout.h b/desktop-widgets/templatelayout.h
index cf295e5ed..b59679285 100644
--- a/desktop-widgets/templatelayout.h
+++ b/desktop-widgets/templatelayout.h
@@ -10,7 +10,7 @@
#include "core/subsurface-qt/diveobjecthelper.h"
#include "core/subsurface-qt/cylinderobjecthelper.h" // TODO: remove once grantlee supports Q_GADGET objects
-int getTotalWork(print_options *printOptions);
+int getTotalWork(const print_options &printOptions);
void find_all_templates();
void set_bundled_templates_as_read_only();
void copy_bundled_templates(QString src, QString dst, QStringList *templateBackupList);
@@ -27,22 +27,20 @@ extern QList<QString> grantlee_templates, grantlee_statistics_templates;
class TemplateLayout : public QObject {
Q_OBJECT
public:
- TemplateLayout(print_options *printOptions, template_options *templateOptions);
+ TemplateLayout(const print_options &printOptions, const template_options &templateOptions);
QString generate();
QString generateStatistics();
static QString readTemplate(QString template_name);
static void writeTemplate(QString template_name, QString grantlee_template);
private:
- print_options *printOptions;
- template_options *templateOptions;
+ const print_options &printOptions;
+ const template_options &templateOptions;
QList<token> lexer(QString input);
void parser(QList<token> tokenList, int &pos, QTextStream &out, QHash<QString, QVariant> options);
QVariant getValue(QString list, QString property, QVariant option);
QString translate(QString s, QHash<QString, QVariant> options);
-
-
signals:
void progressUpdated(int value);
};