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 QQMLCONNECTIONS_H
5#define QQMLCONNECTIONS_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <private/qqmlcustomparser_p.h>
19
20#include <QtQmlMeta/qtqmlmetaexports.h>
21#include <QtQml/qqml.h>
22
23#include <QtCore/qobject.h>
24#include <QtCore/qstring.h>
25
26QT_BEGIN_NAMESPACE
27
28class QQmlBoundSignal;
29class QQmlContext;
30class QQmlConnectionsPrivate;
31class Q_QMLMETA_EXPORT QQmlConnections : public QObject, public QQmlParserStatus
32{
33 Q_OBJECT
34 Q_DECLARE_PRIVATE(QQmlConnections)
35
36 Q_INTERFACES(QQmlParserStatus)
37 Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
38 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged REVISION(2, 3))
39 Q_PROPERTY(bool ignoreUnknownSignals READ ignoreUnknownSignals WRITE setIgnoreUnknownSignals)
40 QML_NAMED_ELEMENT(Connections)
41 QML_ADDED_IN_VERSION(2, 0)
42 QML_CUSTOMPARSER
43
44public:
45 QQmlConnections(QObject *parent = nullptr);
46 ~QQmlConnections();
47
48 QObject *target() const;
49 void setTarget(QObject *);
50
51 bool isEnabled() const;
52 void setEnabled(bool enabled);
53
54 bool ignoreUnknownSignals() const;
55 void setIgnoreUnknownSignals(bool ignore);
56
57protected:
58 void classBegin() override;
59 void componentComplete() override;
60
61Q_SIGNALS:
62 void targetChanged();
63 Q_REVISION(2, 3) void enabledChanged();
64
65private:
66 void connectSignals();
67 void connectSignalsToMethods();
68 void connectSignalsToBindings();
69};
70
71// TODO: Drop this class as soon as we can
72class QQmlConnectionsParser : public QQmlCustomParser
73{
74public:
75 void verifyBindings(
76 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit,
77 const QList<const QV4::CompiledData::Binding *> &props) override;
78 void applyBindings(QObject *object, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;
79};
80
81// TODO: We won't need Connections to be a custom type anymore once we can drop the
82// automatic signal handler inference from undeclared properties.
83template<>
84inline QQmlCustomParser *qmlCreateCustomParser<QQmlConnections>()
85{
86 return new QQmlConnectionsParser;
87}
88
89QT_END_NAMESPACE
90
91#endif
92

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

source code of qtdeclarative/src/qmlmeta/types/qqmlconnections_p.h