1// Copyright (C) 2017 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#ifndef QQUICKBUTTONGROUP_P_H
5#define QQUICKBUTTONGROUP_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qobject.h>
19#include <QtQuickTemplates2/private/qtquicktemplates2global_p.h>
20#include <QtQml/qqml.h>
21#include <QtQml/qqmlparserstatus.h>
22
23QT_BEGIN_NAMESPACE
24
25class QQuickAbstractButton;
26class QQuickButtonGroupPrivate;
27class QQuickButtonGroupAttached;
28class QQuickButtonGroupAttachedPrivate;
29
30class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickButtonGroup : public QObject, public QQmlParserStatus
31{
32 Q_OBJECT
33 Q_PROPERTY(QQuickAbstractButton *checkedButton READ checkedButton WRITE setCheckedButton NOTIFY checkedButtonChanged FINAL)
34 Q_PROPERTY(QQmlListProperty<QQuickAbstractButton> buttons READ buttons NOTIFY buttonsChanged FINAL)
35 // 2.3 (Qt 5.10)
36 Q_PROPERTY(bool exclusive READ isExclusive WRITE setExclusive NOTIFY exclusiveChanged FINAL REVISION(2, 3))
37 // 2.4 (Qt 5.11)
38 Q_PROPERTY(Qt::CheckState checkState READ checkState WRITE setCheckState NOTIFY checkStateChanged FINAL REVISION(2, 4))
39 Q_INTERFACES(QQmlParserStatus)
40 QML_NAMED_ELEMENT(ButtonGroup)
41 QML_ATTACHED(QQuickButtonGroupAttached)
42 QML_ADDED_IN_VERSION(2, 0)
43
44public:
45 explicit QQuickButtonGroup(QObject *parent = nullptr);
46 ~QQuickButtonGroup();
47
48 static QQuickButtonGroupAttached *qmlAttachedProperties(QObject *object);
49
50 QQuickAbstractButton *checkedButton() const;
51 void setCheckedButton(QQuickAbstractButton *checkedButton);
52
53 QQmlListProperty<QQuickAbstractButton> buttons();
54
55 bool isExclusive() const;
56 void setExclusive(bool exclusive);
57
58 // 2.4 (Qt 5.11)
59 Qt::CheckState checkState() const;
60 void setCheckState(Qt::CheckState state);
61
62public Q_SLOTS:
63 void addButton(QQuickAbstractButton *button);
64 void removeButton(QQuickAbstractButton *button);
65
66Q_SIGNALS:
67 void checkedButtonChanged();
68 void buttonsChanged();
69 // 2.1 (Qt 5.8)
70 Q_REVISION(2, 1) void clicked(QQuickAbstractButton *button);
71 // 2.3 (Qt 5.10)
72 Q_REVISION(2, 3) void exclusiveChanged();
73 // 2.4 (Qt 5.11)
74 Q_REVISION(2, 4) void checkStateChanged();
75
76protected:
77 void classBegin() override;
78 void componentComplete() override;
79
80private:
81 Q_DISABLE_COPY(QQuickButtonGroup)
82 Q_DECLARE_PRIVATE(QQuickButtonGroup)
83
84 Q_PRIVATE_SLOT(d_func(), void _q_updateCurrent())
85};
86
87class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickButtonGroupAttached : public QObject
88{
89 Q_OBJECT
90 Q_PROPERTY(QQuickButtonGroup *group READ group WRITE setGroup NOTIFY groupChanged FINAL)
91
92public:
93 explicit QQuickButtonGroupAttached(QObject *parent = nullptr);
94
95 QQuickButtonGroup *group() const;
96 void setGroup(QQuickButtonGroup *group);
97
98Q_SIGNALS:
99 void groupChanged();
100
101private:
102 Q_DISABLE_COPY(QQuickButtonGroupAttached)
103 Q_DECLARE_PRIVATE(QQuickButtonGroupAttached)
104};
105
106QT_END_NAMESPACE
107
108QML_DECLARE_TYPE(QQuickButtonGroup)
109
110#endif // QQUICKBUTTONGROUP_P_H
111

source code of qtdeclarative/src/quicktemplates/qquickbuttongroup_p.h