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