aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/common/qqmlsignalnames_p.h
blob: 9c3d192666d8297e51cf1c00288b91414e170b02 (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
57
58
59
// Copyright (C) 2023 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

#ifndef QQMLSIGNALANDPROPERTYNAMES_P_H
#define QQMLSIGNALANDPROPERTYNAMES_P_H

//
//  W A R N I N G
//  -------------
//
// This file is not part of the Qt API.  It exists purely as an
// implementation detail.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//

#include <cstddef>
#include <optional>

#include <QtQml/private/qtqmlglobal_p.h>
#include <QtCore/qstringview.h>
#include <QtCore/qstring.h>
#include <type_traits>

QT_BEGIN_NAMESPACE

class Q_QML_EXPORT QQmlSignalNames
{
public:
    static QString propertyNameToChangedSignalName(QStringView property);
    static QByteArray propertyNameToChangedSignalName(QUtf8StringView property);

    static QString propertyNameToChangedHandlerName(QStringView property);

    static QString signalNameToHandlerName(QAnyStringView signal);

    static std::optional<QString> changedSignalNameToPropertyName(QStringView changeSignal);
    static std::optional<QByteArray> changedSignalNameToPropertyName(QUtf8StringView changeSignal);

    static std::optional<QString> changedHandlerNameToPropertyName(QStringView handler);
    static std::optional<QByteArray> changedHandlerNameToPropertyName(QUtf8StringView handler);

    static std::optional<QString> handlerNameToSignalName(QStringView handler);
    static std::optional<QString> changedHandlerNameToSignalName(QStringView changedHandler);

    static bool isChangedHandlerName(QStringView signalName);
    static bool isChangedSignalName(QStringView signalName);
    static bool isHandlerName(QStringView signalName);

    static QString addPrefixToPropertyName(QStringView prefix, QStringView propertyName);

    // ### Qt7: remove this
    static std::optional<QString> badHandlerNameToSignalName(QStringView handler);
};

QT_END_NAMESPACE

#endif // QQMLSIGNALANDPROPERTYNAMES_P_H