mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Printing: add functions that read/write a template
Read/write templates from files. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
parent
c35092f5c9
commit
605e1e2d93
2 changed files with 21 additions and 0 deletions
|
@ -89,6 +89,25 @@ QString TemplateLayout::generate()
|
||||||
return htmlContent;
|
return htmlContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString TemplateLayout::readTemplate(QString template_name)
|
||||||
|
{
|
||||||
|
QFile qfile(getSubsurfaceDataPath("printing_templates") + QDir::separator() + template_name);
|
||||||
|
if (qfile.open(QFile::ReadOnly | QFile::Text)) {
|
||||||
|
QTextStream in(&qfile);
|
||||||
|
return in.readAll();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
void TemplateLayout::writeTemplate(QString template_name, QString grantlee_template)
|
||||||
|
{
|
||||||
|
QFile qfile(getSubsurfaceDataPath("printing_templates") + QDir::separator() + template_name);
|
||||||
|
if (qfile.open(QFile::ReadWrite | QFile::Text)) {
|
||||||
|
qfile.write(grantlee_template.toUtf8().data());
|
||||||
|
qfile.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Dive::Dive() :
|
Dive::Dive() :
|
||||||
m_number(-1),
|
m_number(-1),
|
||||||
dive(NULL)
|
dive(NULL)
|
||||||
|
|
|
@ -14,6 +14,8 @@ public:
|
||||||
TemplateLayout(print_options *PrintOptions, template_options *templateOptions);
|
TemplateLayout(print_options *PrintOptions, template_options *templateOptions);
|
||||||
~TemplateLayout();
|
~TemplateLayout();
|
||||||
QString generate();
|
QString generate();
|
||||||
|
static QString readTemplate(QString template_name);
|
||||||
|
static void writeTemplate(QString template_name, QString grantlee_template);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Grantlee::Engine *m_engine;
|
Grantlee::Engine *m_engine;
|
||||||
|
|
Loading…
Reference in a new issue