1// Copyright (C) 2019 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#include "qqmlpropertyresolver_p.h"
5#include <private/qqmlcontextdata_p.h>
6
7QT_BEGIN_NAMESPACE
8
9const QQmlPropertyData *QQmlPropertyResolver::property(const QString &name, bool *notInRevision,
10 RevisionCheck check) const
11{
12 if (notInRevision) *notInRevision = false;
13
14 const QQmlPropertyData *d = cache->property(key: name, object: nullptr, context: nullptr);
15
16 // Find the first property
17 while (d && d->isFunction())
18 d = cache->overrideData(data: d);
19
20 if (check != IgnoreRevision && d && !cache->isAllowedInRevision(data: d)) {
21 if (notInRevision) *notInRevision = true;
22 return nullptr;
23 } else {
24 return d;
25 }
26}
27
28
29const QQmlPropertyData *QQmlPropertyResolver::signal(const QString &name, bool *notInRevision) const
30{
31 if (notInRevision) *notInRevision = false;
32
33 const QQmlPropertyData *d = cache->property(key: name, object: nullptr, context: nullptr);
34 if (notInRevision) *notInRevision = false;
35
36 while (d && !(d->isFunction()))
37 d = cache->overrideData(data: d);
38
39 if (d && !cache->isAllowedInRevision(data: d)) {
40 if (notInRevision) *notInRevision = true;
41 return nullptr;
42 } else if (d && d->isSignal()) {
43 return d;
44 }
45
46 if (name.endsWith(s: QLatin1String("Changed"))) {
47 QString propName = name.mid(position: 0, n: name.size() - static_cast<int>(strlen(s: "Changed")));
48
49 d = property(name: propName, notInRevision);
50 if (d)
51 return cache->signal(index: d->notifyIndex());
52 }
53
54 return nullptr;
55}
56
57QT_END_NAMESPACE
58

source code of qtdeclarative/src/qml/qml/qqmlpropertyresolver.cpp