Debian Codegraph @

src/GUI/QmlRadioButtonHelper.hxx

raw symbols SCIP
1 // QmlRadioButtonHelper.hxx - helper for QtQuick radio button impl
2 //
3 // Written by James Turner, started April 2018.
4 //
5 // Copyright (C) 2015 James Turner <[email protected]>
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
21 #ifndef QMLRADIOBUTTONHELPER_HXX
22 #define QMLRADIOBUTTONHELPER_HXX
23
24 #include <QObject>
25 #include <QtQml>
26
27 class QmlRadioButtonGroup;
28
29 class QmlRadioButtonGroupAttached : public QObject
30 {
31 Q_OBJECT
32
33 Q_PROPERTY(QmlRadioButtonGroup* group READ group WRITE setGroup NOTIFY groupChanged)
34 Q_PROPERTY(bool isSelected READ isSelected NOTIFY isSelectedChanged)
35 public:
36 QmlRadioButtonGroupAttached(QObject* pr = nullptr);
37
38 QmlRadioButtonGroup* group() const;
39 bool isSelected() const;
40
41 public slots:
42 void setGroup(QmlRadioButtonGroup* group);
43
44 signals:
45 void groupChanged(QmlRadioButtonGroup* group);
46 void isSelectedChanged(bool isSelected);
47
48 private:
49 void onGroupSelectionChanged();
50
51 QmlRadioButtonGroup* m_group = nullptr;
52 };
53
54 class QmlRadioButtonGroup : public QObject
55 {
56 Q_OBJECT
57
58 Q_PROPERTY(QObject* selected READ selected WRITE setSelected NOTIFY selectedChanged)
59 public:
60 explicit QmlRadioButtonGroup(QObject *parent = nullptr);
61
62 static QmlRadioButtonGroupAttached *qmlAttachedProperties(QObject *);
63
64 QObject* selected() const;
65
66 signals:
67 void selectedChanged(QObject* selected);
68
69 public slots:
70 void setSelected(QObject* selected);
71
72 private:
73 QObject* m_selected = nullptr;
74 };
75
76 QML_DECLARE_TYPEINFO(QmlRadioButtonGroup, QML_HAS_ATTACHED_PROPERTIES)
77
78 #endif // QMLRADIOBUTTONHELPER_HXX