aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlpropertyresolver.cpp
blob: 0217f7b7b5d330ef27a706e4c9f140bce470ad98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include "qqmlpropertyresolver_p.h"
#include <private/qqmlcontextdata_p.h>
#include <private/qqmlsignalnames_p.h>

QT_BEGIN_NAMESPACE

const QQmlPropertyData *QQmlPropertyResolver::property(const QString &name, bool *notInRevision,
                                                 RevisionCheck check) const
{
    if (notInRevision) *notInRevision = false;

    const QQmlPropertyData *d = cache->property(name, nullptr, nullptr);

    // Find the first property
    while (d && d->isFunction())
        d = cache->overrideData(d);

    if (check != IgnoreRevision && d && !cache->isAllowedInRevision(d)) {
        if (notInRevision) *notInRevision = true;
        return nullptr;
    } else {
        return d;
    }
}


const QQmlPropertyData *QQmlPropertyResolver::signal(const QString &name, bool *notInRevision) const
{
    if (notInRevision) *notInRevision = false;

    const QQmlPropertyData *d = cache->property(name, nullptr, nullptr);
    if (notInRevision) *notInRevision = false;

    while (d && !(d->isFunction()))
        d = cache->overrideData(d);

    if (d && !cache->isAllowedInRevision(d)) {
        if (notInRevision) *notInRevision = true;
        return nullptr;
    } else if (d && d->isSignal()) {
        return d;
    }

    if (auto propName = QQmlSignalNames::changedSignalNameToPropertyName(name)) {
        d = property(*propName, notInRevision);
        if (d)
            return cache->signal(d->notifyIndex());
    }

    return nullptr;
}

QT_END_NAMESPACE