summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Gehad elrobey <gehadelrobey@gmail.com>2015-07-24 09:26:25 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2015-07-28 11:37:23 +0300
commitf76ebe3b9d2e7e4dcd2de3b3bab6994bfa254c44 (patch)
treeae8dba2d5af225ccc5df6216cdca358892375272
parent0b085f79b12ee2ca60278c324e419f47f47ae100 (diff)
downloadsubsurface-f76ebe3b9d2e7e4dcd2de3b3bab6994bfa254c44.tar.gz
Printing: search for grantlee templates in the templates directory
We need to dynamically look up for all the existing templates in the template directory. A grantlee template can be named any name but we ignore files ending with '~'. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
-rw-r--r--qt-ui/mainwindow.cpp3
-rw-r--r--templatelayout.cpp14
-rw-r--r--templatelayout.h3
3 files changed, 20 insertions, 0 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index ed7c62c62..b6459d3c2 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -199,6 +199,9 @@ MainWindow::MainWindow() : QMainWindow(),
ReverseGeoLookupThread *geoLookup = ReverseGeoLookupThread::instance();
connect(geoLookup, SIGNAL(started()),information(), SLOT(disableGeoLookupEdition()));
connect(geoLookup, SIGNAL(finished()), information(), SLOT(enableGeoLookupEdition()));
+#ifndef NO_PRINTING
+ find_all_templates();
+#endif
}
MainWindow::~MainWindow()
diff --git a/templatelayout.cpp b/templatelayout.cpp
index fec57cb2a..9caf773d0 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,18 @@ int getTotalWork(print_options *printOptions)
return dives;
}
+void find_all_templates()
+{
+ 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)
{
diff --git a/templatelayout.h b/templatelayout.h
index e37e9e868..5f4678923 100644
--- a/templatelayout.h
+++ b/templatelayout.h
@@ -6,6 +6,9 @@
#include "printoptions.h"
int getTotalWork(print_options *printOptions);
+void find_all_templates();
+
+extern QList<QString> grantlee_templates;
class TemplateLayout : public QObject {
Q_OBJECT