1 | // Copyright (C) 2016 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QQMLEXPRESSION_H |
5 | #define QQMLEXPRESSION_H |
6 | |
7 | #include <QtQml/qqmlerror.h> |
8 | #include <QtQml/qqmlscriptstring.h> |
9 | |
10 | #include <QtCore/qobject.h> |
11 | #include <QtCore/qvariant.h> |
12 | |
13 | QT_BEGIN_NAMESPACE |
14 | |
15 | |
16 | class QString; |
17 | class QQmlEngine; |
18 | class QQmlContext; |
19 | class QQmlExpressionPrivate; |
20 | class QQmlContextData; |
21 | class Q_QML_EXPORT QQmlExpression : public QObject |
22 | { |
23 | Q_OBJECT |
24 | public: |
25 | QQmlExpression(); |
26 | QQmlExpression(QQmlContext *, QObject *, const QString &, QObject * = nullptr); |
27 | explicit QQmlExpression(const QQmlScriptString &, QQmlContext * = nullptr, QObject * = nullptr, QObject * = nullptr); |
28 | ~QQmlExpression() override; |
29 | |
30 | QQmlEngine *engine() const; |
31 | QQmlContext *context() const; |
32 | |
33 | QString expression() const; |
34 | void setExpression(const QString &); |
35 | |
36 | bool notifyOnValueChanged() const; |
37 | void setNotifyOnValueChanged(bool); |
38 | |
39 | QString sourceFile() const; |
40 | int lineNumber() const; |
41 | int columnNumber() const; |
42 | void setSourceLocation(const QString &fileName, int line, int column = 0); |
43 | |
44 | QObject *scopeObject() const; |
45 | |
46 | bool hasError() const; |
47 | void clearError(); |
48 | QQmlError error() const; |
49 | |
50 | QVariant evaluate(bool *valueIsUndefined = nullptr); |
51 | |
52 | Q_SIGNALS: |
53 | void valueChanged(); |
54 | |
55 | private: |
56 | QQmlExpression(QQmlExpressionPrivate &dd, QObject *parent); |
57 | |
58 | Q_DISABLE_COPY(QQmlExpression) |
59 | Q_DECLARE_PRIVATE(QQmlExpression) |
60 | friend class QQmlDebugger; |
61 | friend class QQmlContext; |
62 | }; |
63 | |
64 | QT_END_NAMESPACE |
65 | |
66 | #endif // QQMLEXPRESSION_H |
67 | |
68 |