35 lines
1.3 KiB
C++
35 lines
1.3 KiB
C++
#ifndef TEMPLATEENGINE_H
|
|
#define TEMPLATEENGINE_H
|
|
|
|
#include <QObject>
|
|
#include <QString>
|
|
#include <QJsonDocument>
|
|
#include <QJsonObject>
|
|
#include <QJsonArray>
|
|
#include <QPrinter>
|
|
#include <QPainter>
|
|
#include "templatedao.h"
|
|
|
|
class TemplateEngine : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit TemplateEngine(QObject *parent = nullptr) : QObject(parent) {}
|
|
|
|
static QString exportToPDF(const Template &tpl, const QJsonObject &data);
|
|
static QString exportToXLSX(const Template &tpl, const QJsonObject &data);
|
|
static QString exportToDOCX(const Template &tpl, const QJsonObject &data);
|
|
|
|
private:
|
|
static void drawJsonElements(QPainter *painter, const QJsonArray &elements, const QJsonObject &data);
|
|
static void drawLabel(QPainter *painter, const QJsonObject &elem, const QJsonObject &data);
|
|
static void drawTable(QPainter *painter, const QJsonObject &elem, const QJsonObject &data);
|
|
static void drawQRCode(QPainter *painter, const QJsonObject &elem, const QJsonObject &data);
|
|
static void drawImage(QPainter *painter, const QJsonObject &elem);
|
|
static void drawLine(QPainter *painter, const QJsonObject &elem);
|
|
static QString resolveValue(const QString &text, const QJsonObject &data);
|
|
static QString exportDir();
|
|
};
|
|
|
|
#endif // TEMPLATEENGINE_H
|