| 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 | #include <private/qqmlsignalnames_p.h> |
| 7 | |
| 8 | QT_BEGIN_NAMESPACE |
| 9 | |
| 10 | const QQmlPropertyData *QQmlPropertyResolver::property( |
| 11 | const QString &name, bool *notInRevision, RevisionCheck check) const |
| 12 | { |
| 13 | if (notInRevision) |
| 14 | *notInRevision = false; |
| 15 | |
| 16 | const QQmlPropertyData *d = cache->property(key: name, object: nullptr, context: nullptr); |
| 17 | |
| 18 | // Find the first property |
| 19 | while (d && d->isFunction()) |
| 20 | d = cache->overrideData(data: d); |
| 21 | |
| 22 | if (check != IgnoreRevision && d && !cache->isAllowedInRevision(data: d)) { |
| 23 | if (notInRevision) |
| 24 | *notInRevision = true; |
| 25 | return nullptr; |
| 26 | } |
| 27 | |
| 28 | return d; |
| 29 | } |
| 30 | |
| 31 | const QQmlPropertyData *QQmlPropertyResolver::signal( |
| 32 | const QString &name, bool *notInRevision, RevisionCheck check) const |
| 33 | { |
| 34 | if (notInRevision) |
| 35 | *notInRevision = false; |
| 36 | |
| 37 | const QQmlPropertyData *d = cache->property(key: name, object: nullptr, context: nullptr); |
| 38 | |
| 39 | while (d && !d->isFunction()) |
| 40 | d = cache->overrideData(data: d); |
| 41 | |
| 42 | if (check != IgnoreRevision && d && !cache->isAllowedInRevision(data: d)) { |
| 43 | if (notInRevision) |
| 44 | *notInRevision = true; |
| 45 | return nullptr; |
| 46 | } |
| 47 | |
| 48 | if (d && d->isSignal()) |
| 49 | return d; |
| 50 | |
| 51 | if (const auto propName = QQmlSignalNames::changedSignalNameToPropertyName(changeSignal: name)) { |
| 52 | if (d = property(name: *propName, notInRevision, check); d) |
| 53 | return cache->signal(index: d->notifyIndex()); |
| 54 | } |
| 55 | |
| 56 | return nullptr; |
| 57 | } |
| 58 | |
| 59 | QT_END_NAMESPACE |
| 60 | |