diff options
author | 2015-07-28 07:27:30 -0700 | |
---|---|---|
committer | 2015-07-28 07:27:30 -0700 | |
commit | f2e2be0f67146941d9a05815db2d1335a975765e (patch) | |
tree | 31813fc61ad44048baf72cd71e016b521bd6afbe /templatelayout.cpp | |
parent | 7d0c6f895d813b366a3c9ff5b26ed3db1b2fba02 (diff) | |
parent | 01645d64b91b29878d6927dcf7cd5c2381e0bfaa (diff) | |
download | subsurface-f2e2be0f67146941d9a05815db2d1335a975765e.tar.gz |
Merge branch 'custom-print' of github.com:neolit123/subsurface
Diffstat (limited to 'templatelayout.cpp')
-rw-r--r-- | templatelayout.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/templatelayout.cpp b/templatelayout.cpp index fec57cb2a..30919891a 100644 --- a/templatelayout.cpp +++ b/templatelayout.cpp @@ -4,6 +4,8 @@ #include "helpers.h" #include "display.h" +QList<QString> grantlee_templates; + int getTotalWork(print_options *printOptions) { if (printOptions->print_selected) { @@ -19,6 +21,19 @@ int getTotalWork(print_options *printOptions) return dives; } +void find_all_templates() +{ + grantlee_templates.clear(); + QDir dir(getSubsurfaceDataPath("printing_templates")); + QFileInfoList list = dir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot); + foreach (QFileInfo finfo, list) { + QString filename = finfo.fileName(); + if (filename.at(filename.size() - 1) != '~') { + grantlee_templates.append(finfo.fileName()); + } + } +} + TemplateLayout::TemplateLayout(print_options *PrintOptions, template_options *templateOptions) : m_engine(NULL) { @@ -35,7 +50,6 @@ QString TemplateLayout::generate() { int progress = 0; int totalWork = getTotalWork(PrintOptions); - QString templateName; QString htmlContent; m_engine = new Grantlee::Engine(this); @@ -69,14 +83,7 @@ QString TemplateLayout::generate() Grantlee::Context c(mapping); - if (PrintOptions->p_template == print_options::ONE_DIVE) { - templateName = "one_dive.html"; - } else if (PrintOptions->p_template == print_options::TWO_DIVE) { - templateName = "two_dives.html"; - } else if (PrintOptions->p_template == print_options::CUSTOM) { - templateName = "custom.html"; - } - Grantlee::Template t = m_engine->loadByName(templateName); + Grantlee::Template t = m_engine->loadByName(PrintOptions->p_template); if (!t || t->error()) { qDebug() << "Can't load template"; return htmlContent; |