/*
* Copyright 2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Author: Zsombor Egri
*/
#ifndef UCSTYLEHINTS_P_H
#define UCSTYLEHINTS_P_H
#include
#define foreach Q_FOREACH
#include
#include
#include
#undef foreach
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include
#else
#include
#endif
class QQuickItem;
UT_NAMESPACE_BEGIN
class UCStyleHintsParser;
class UCStyledItemBase;
class PropertyChange;
class LOMIRITOOLKIT_EXPORT UCStyleHints : public QObject, public QQmlParserStatus
{
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(bool ignoreUnknownProperties MEMBER m_ignoreUnknownProperties)
public:
explicit UCStyleHints(QObject *parent = 0);
~UCStyleHints();
private Q_SLOTS:
void _q_applyStyleHints();
protected:
void classBegin() override;
void componentComplete() override;
private:
class Expression {
public:
Expression(const QString &name, QQmlBinding::Identifier id, const QString& expr,
const QUrl &url, int line, int column)
: name(name), id(id), expression(expr), url(url), line(line), column(column) {}
QString name;
QQmlBinding::Identifier id;
QString expression;
QUrl url;
int line;
int column;
};
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool m_decoded;
bool m_completed;
bool m_ignoreUnknownProperties;
#else
bool m_decoded:1;
bool m_completed:1;
bool m_ignoreUnknownProperties:1;
#endif
QPointer m_styledItem;
QList m_expressions;
QList< QPair > m_values;
QList< PropertyChange* > m_propertyBackup;
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QQmlRefPointer m_cdata;
#else
QQmlRefPointer m_cdata;
#endif
friend class UCStyleHintsParser;
void propertyNotFound(const QString &styleName, const QString &property);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
void decodeBinding(const QString &propertyPrefix, const QQmlRefPointer &compilationUnit, const QV4::CompiledData::Binding *binding);
#elif QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
void decodeBinding(const QString &propertyPrefix, const QQmlRefPointer &compilationUnit, const QV4::CompiledData::Binding *binding);
#else
void decodeBinding(const QString &propertyPrefix, const QV4::CompiledData::CompilationUnit *compilationUnit, const QV4::CompiledData::Binding *binding);
#endif
};
class LOMIRITOOLKIT_EXPORT UCStyleHintsParser : public QQmlCustomParser
{
public:
UCStyleHintsParser() : QQmlCustomParser(QQmlCustomParser::AcceptsSignalHandlers) {}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void verifyBindings(const QQmlRefPointer &compilationUnit, const QList &bindings) override;
void applyBindings(QObject *obj, const QQmlRefPointer &compilationUnit, const QList &bindings) override;
#else
void verifyBindings(const QQmlRefPointer &compilationUnit, const QList &bindings) override;
void applyBindings(QObject *obj, const QQmlRefPointer &compilationUnit, const QList &bindings) override;
#endif
private:
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void verifyProperty(const QQmlRefPointer &compilationUnit, const QV4::CompiledData::Binding *binding);
#else
void verifyProperty(const QQmlRefPointer &compilationUnit, const QV4::CompiledData::Binding *binding);
#endif
};
UT_NAMESPACE_END
#endif // UCSTYLEHINTS_P_H