mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
0cbb448740
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>
56 lines
1.7 KiB
C++
56 lines
1.7 KiB
C++
// SPDX-License-Identifier: GPL-2.0
|
|
#ifndef TEMPLATELAYOUT_H
|
|
#define TEMPLATELAYOUT_H
|
|
|
|
#include <QStringList>
|
|
#include "mainwindow.h"
|
|
#include "printoptions.h"
|
|
#include "core/statistics.h"
|
|
#include "core/qthelper.h"
|
|
#include "core/subsurface-qt/diveobjecthelper.h"
|
|
#include "core/subsurface-qt/cylinderobjecthelper.h" // TODO: remove once grantlee supports Q_GADGET objects
|
|
|
|
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);
|
|
|
|
enum token_t {LITERAL, FORSTART, FORSTOP, BLOCKSTART, BLOCKSTOP, IFSTART, IFSTOP, PARSERERROR};
|
|
|
|
struct token {
|
|
enum token_t type;
|
|
QString contents;
|
|
};
|
|
|
|
extern QList<QString> grantlee_templates, grantlee_statistics_templates;
|
|
|
|
class TemplateLayout : public QObject {
|
|
Q_OBJECT
|
|
public:
|
|
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:
|
|
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);
|
|
};
|
|
|
|
struct YearInfo {
|
|
stats_t *year;
|
|
};
|
|
|
|
Q_DECLARE_METATYPE(template_options)
|
|
Q_DECLARE_METATYPE(print_options)
|
|
Q_DECLARE_METATYPE(YearInfo)
|
|
|
|
#endif
|