Cutelee 6.1.0
scriptabletemplate.cpp
1/*
2 This file is part of the Cutelee template system.
3
4 Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either version
9 2.1 of the Licence, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library. If not, see <http://www.gnu.org/licenses/>.
18
19*/
20
21#include "scriptabletemplate.h"
22
23#include "context.h"
24#include "engine.h"
25#include "node.h"
26
27ScriptableTemplate::ScriptableTemplate(Cutelee::Template t, QObject *parent)
28 : QObject(parent), m_template(t)
29{
30}
31
32QString ScriptableTemplate::render(ScriptableContext *c) const
33{
34 return m_template->render(c->context());
35}
36
37QList<QObject *> ScriptableTemplate::nodeList() const
38{
39 auto nodeList = m_template->nodeList();
40 QList<QObject *> objList;
41
42 for (auto n : nodeList) {
43 objList << n;
44 }
45 return objList;
46}
47
48void ScriptableTemplate::setNodeList(const QList<QObject *> &list)
49{
50 NodeList nodeList;
51
52 for (auto obj : list) {
53 auto n = qobject_cast<Node *>(obj);
54 if (n) {
55 nodeList << n;
56 }
57 }
58 m_template->setNodeList(nodeList);
59}
A list of Nodes with some convenience API for rendering them.
Definition node.h:148
The Template class is a tree of nodes which may be rendered.
Definition template.h:95
QString render(Context *c) const
Definition template.cpp:74