50IfChangedNode::IfChangedNode(
const QList<FilterExpression> &feList,
70 if (c->
lookup(QStringLiteral(
"forloop")).isValid()
71 && (!c->
lookup(QStringLiteral(
"forloop"))
72 .value<QVariantHash>()
75 auto hash = c->
lookup(QStringLiteral(
"forloop")).value<QVariantHash>();
77 c->
insert(QStringLiteral(
"forloop"), hash);
81 QTextStream watchedTextStream(&watchedString);
82 auto watchedStream = stream->
clone(&watchedTextStream);
83 if (m_filterExpressions.isEmpty()) {
84 m_trueList.render(watchedStream.get(), c);
86 QVariantList watchedVars;
87 for (
auto &i : m_filterExpressions) {
88 auto var = i.resolve(c);
93 watchedVars.append(var);
99 QVariantList lastSeenVarList;
100 if (m_lastSeen.userType() != qMetaTypeId<QString>()) {
101 lastSeenVarList = m_lastSeen.value<QVariantList>();
107 if ((watchedVars != lastSeenVarList)
108 || (!watchedString.isEmpty()
109 && (watchedString != m_lastSeen.value<
QString>()))) {
110 auto firstLoop = !m_lastSeen.isValid();
111 if (!watchedString.isEmpty())
112 m_lastSeen = watchedString;
114 m_lastSeen = watchedVars;
118 hash.insert(QStringLiteral(
"firstloop"), firstLoop);
119 c->
insert(QStringLiteral(
"ifchanged"), hash);
120 m_trueList.render(stream, c);
122 }
else if (!m_falseList.isEmpty()) {
123 m_falseList.render(stream, c);
The Context class holds the context to render a Template with.
void insert(const QString &name, QObject *object)
virtual QVariant lookup(const QString &str) const