diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-12-12 13:28:36 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-12-17 13:03:56 -0800 |
commit | 0cbb4487401b749476e939db20b842e04099bfa8 (patch) | |
tree | 2627229973b9d9cbb25c83953231e29fe0f1cd91 /desktop-widgets/templateedit.h | |
parent | 7bdd968e05a3ec11ab9f207e7bd32ff7bffc34a8 (diff) | |
download | subsurface-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/templateedit.h')
-rw-r--r-- | desktop-widgets/templateedit.h | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/desktop-widgets/templateedit.h b/desktop-widgets/templateedit.h index 5ed416a61..5c4c7cd96 100644 --- a/desktop-widgets/templateedit.h +++ b/desktop-widgets/templateedit.h @@ -14,30 +14,24 @@ class TemplateEdit : public QDialog Q_OBJECT public: - explicit TemplateEdit(QWidget *parent, struct print_options *printOptions, struct template_options *templateOptions); + explicit TemplateEdit(QWidget *parent, const print_options &printOptions, template_options &templateOptions); ~TemplateEdit(); private slots: void on_fontsize_valueChanged(int font_size); - void on_linespacing_valueChanged(double line_spacing); - void on_borderwidth_valueChanged(double border_width); - void on_fontSelection_currentIndexChanged(int index); - void on_colorpalette_currentIndexChanged(int index); - void on_buttonBox_clicked(QAbstractButton *button); - void colorSelect(QAbstractButton *button); private: Ui::TemplateEdit *ui; QButtonGroup *btnGroup; bool editingCustomColors; - struct template_options *templateOptions; + const print_options &printOptions; + template_options &templateOptions; struct template_options newTemplateOptions; - struct print_options *printOptions; QString grantlee_template; void saveSettings(); void updatePreview(); |