2017-04-27 20:26:05 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-04-21 17:23:13 +02:00
|
|
|
#ifndef TEMPLATELAYOUT_H
|
|
|
|
#define TEMPLATELAYOUT_H
|
|
|
|
|
2017-11-24 22:54:54 +02:00
|
|
|
#include <QStringList>
|
2015-04-21 17:23:13 +02:00
|
|
|
#include "mainwindow.h"
|
2015-06-14 06:25:35 +02:00
|
|
|
#include "printoptions.h"
|
2016-04-05 09:40:03 -07:00
|
|
|
#include "core/statistics.h"
|
|
|
|
#include "core/qthelper.h"
|
2020-02-03 19:33:06 +01:00
|
|
|
#include "core/subsurface-qt/diveobjecthelper.h"
|
|
|
|
#include "core/subsurface-qt/cylinderobjecthelper.h" // TODO: remove once grantlee supports Q_GADGET objects
|
2015-04-21 17:23:13 +02:00
|
|
|
|
2015-06-21 06:13:22 +02:00
|
|
|
int getTotalWork(print_options *printOptions);
|
2015-07-24 09:26:25 +02:00
|
|
|
void find_all_templates();
|
2017-11-23 01:59:26 +02:00
|
|
|
void set_bundled_templates_as_read_only();
|
2017-11-24 22:54:54 +02:00
|
|
|
void copy_bundled_templates(QString src, QString dst, QStringList *templateBackupList);
|
2015-07-24 09:26:25 +02:00
|
|
|
|
2020-08-21 13:24:10 +02:00
|
|
|
enum token_t {LITERAL, FORSTART, FORSTOP, BLOCKSTART, BLOCKSTOP, IFSTART, IFSTOP, PARSERERROR};
|
|
|
|
|
|
|
|
struct token {
|
|
|
|
enum token_t type;
|
|
|
|
QString contents;
|
|
|
|
};
|
|
|
|
|
2015-08-21 19:03:42 +02:00
|
|
|
extern QList<QString> grantlee_templates, grantlee_statistics_templates;
|
2015-06-10 13:39:15 +02:00
|
|
|
|
2015-04-21 17:23:13 +02:00
|
|
|
class TemplateLayout : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2019-04-26 17:51:25 +02:00
|
|
|
TemplateLayout(print_options *printOptions, template_options *templateOptions);
|
2015-04-21 17:23:13 +02:00
|
|
|
QString generate();
|
2015-08-21 19:03:42 +02:00
|
|
|
QString generateStatistics();
|
2015-07-05 06:21:39 +02:00
|
|
|
static QString readTemplate(QString template_name);
|
|
|
|
static void writeTemplate(QString template_name, QString grantlee_template);
|
2015-04-21 17:23:13 +02:00
|
|
|
|
|
|
|
private:
|
2019-04-26 17:51:25 +02:00
|
|
|
print_options *printOptions;
|
2015-07-02 22:26:31 +02:00
|
|
|
template_options *templateOptions;
|
2020-08-21 13:24:10 +02:00
|
|
|
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);
|
|
|
|
|
|
|
|
|
2015-05-30 15:32:15 +02:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void progressUpdated(int value);
|
2015-04-21 17:23:13 +02:00
|
|
|
};
|
|
|
|
|
2019-04-26 18:16:02 +02:00
|
|
|
struct YearInfo {
|
2015-08-21 19:00:46 +02:00
|
|
|
stats_t *year;
|
|
|
|
};
|
|
|
|
|
2015-07-02 22:26:31 +02:00
|
|
|
Q_DECLARE_METATYPE(template_options)
|
2015-07-16 11:39:27 +02:00
|
|
|
Q_DECLARE_METATYPE(print_options)
|
2015-08-21 19:00:46 +02:00
|
|
|
Q_DECLARE_METATYPE(YearInfo)
|
2015-04-21 17:23:13 +02:00
|
|
|
|
|
|
|
#endif
|