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