Cutelee 6.1.0
rendercontext.cpp
1/*
2 This file is part of the Cutelee template system.
3
4 Copyright (c) 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 "rendercontext.h"
22
23#include "node.h"
24
25using namespace Cutelee;
26
27namespace Cutelee
28{
29
31{
32 RenderContextPrivate(RenderContext *qq) : q_ptr(qq) {}
33
34 Q_DECLARE_PUBLIC(RenderContext)
35 RenderContext *const q_ptr;
36
37 QList<QHash<const Node *, QVariant>> m_variantHashStack;
38};
39}
40
41RenderContext::RenderContext() : d_ptr(new RenderContextPrivate(this)) {}
42
44
45void RenderContext::push()
46{
47 Q_D(RenderContext);
48 d->m_variantHashStack.prepend({});
49}
50
51bool RenderContext::contains(Node *const scopeNode) const
52{
53 Q_D(const RenderContext);
54 Q_ASSERT(!d->m_variantHashStack.isEmpty());
55 return d->m_variantHashStack.last().contains(scopeNode);
56}
57
58QVariant &RenderContext::data(const Node *const scopeNode)
59{
60 Q_D(RenderContext);
61 Q_ASSERT(!d->m_variantHashStack.isEmpty());
62 return d->m_variantHashStack.last()[scopeNode];
63}
64
65void RenderContext::pop()
66{
67 Q_D(RenderContext);
68 d->m_variantHashStack.removeFirst();
69}
Base class for all nodes.
Definition node.h:78
Provides storage facility for state while rendering a template.
bool contains(Node *const scopeNode) const
QVariant & data(const Node *const scopeNode)
The Cutelee namespace holds all public Cutelee API.
Definition Mainpage.dox:8