2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2010-06-30 17:51:21 +02:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2010-06-30 17:51:21 +02:00
|
|
|
|
2010-07-15 14:12:27 +02:00
|
|
|
#include <qmljs/qmljsdocument.h>
|
2010-06-30 17:51:21 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QHash>
|
|
|
|
|
#include <QVariant>
|
|
|
|
|
#include <QStringList>
|
2011-01-20 14:03:07 +01:00
|
|
|
|
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QLinearGradient)
|
2010-06-30 17:51:21 +02:00
|
|
|
|
|
|
|
|
namespace QmlJS {
|
|
|
|
|
|
|
|
|
|
class Document;
|
|
|
|
|
|
|
|
|
|
class QMLJS_EXPORT PropertyReader
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
2010-07-15 14:12:27 +02:00
|
|
|
PropertyReader(Document::Ptr doc, AST::UiObjectInitializer *ast);
|
2010-06-30 17:51:21 +02:00
|
|
|
|
|
|
|
|
bool hasProperty(const QString &propertyName) const
|
|
|
|
|
{ return m_properties.contains(propertyName); }
|
|
|
|
|
|
|
|
|
|
QVariant readProperty(const QString &propertyName) const
|
|
|
|
|
{
|
|
|
|
|
if (hasProperty(propertyName))
|
|
|
|
|
return m_properties.value(propertyName);
|
|
|
|
|
else
|
|
|
|
|
return QVariant();
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-28 14:39:54 +02:00
|
|
|
QString readAstValue(const QString &propertyName) const
|
|
|
|
|
{
|
|
|
|
|
if (hasProperty(propertyName))
|
|
|
|
|
return m_astPropertyValues.value(propertyName);
|
|
|
|
|
else
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 12:57:11 +02:00
|
|
|
QLinearGradient parseGradient(const QString &propertyName, bool *isBound) const;
|
2010-07-15 14:12:27 +02:00
|
|
|
|
2010-06-30 17:51:21 +02:00
|
|
|
QStringList properties() const
|
|
|
|
|
{ return m_properties.keys(); }
|
|
|
|
|
|
2010-07-15 14:12:27 +02:00
|
|
|
bool isBindingOrEnum(const QString &propertyName) const
|
|
|
|
|
{ return m_bindingOrEnum.contains(propertyName); }
|
|
|
|
|
|
2010-06-30 17:51:21 +02:00
|
|
|
private:
|
|
|
|
|
QHash<QString, QVariant> m_properties;
|
2016-04-28 14:39:54 +02:00
|
|
|
QHash<QString, QString> m_astPropertyValues;
|
2010-07-15 14:12:27 +02:00
|
|
|
QList<QString> m_bindingOrEnum;
|
|
|
|
|
AST::UiObjectInitializer *m_ast;
|
|
|
|
|
Document::Ptr m_doc;
|
2010-06-30 17:51:21 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} //QmlJS
|