FlightGear next
QmlRadioButtonHelper.cxx
Go to the documentation of this file.
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 <james@flightgear.org>
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
22
23#include <QMetaObject>
24#include <QDebug>
25#include <QQmlEngine>
26
27QmlRadioButtonGroup::QmlRadioButtonGroup(QObject *parent) : QObject(parent)
28{
29
30}
31
32
37
39{
40 return m_selected;
41}
42
44{
45 if (m_selected == selected)
46 return;
47
48 m_selected = selected;
49 emit selectedChanged(m_selected);
50}
51
56
58{
59 return m_group;
60}
61
63{
64 if (!m_group)
65 return false;
66
67 return (m_group->selected() == this);
68}
69
71{
72 if (m_group == group)
73 return;
74
75 if (m_group) {
76 disconnect(m_group, &QmlRadioButtonGroup::selectedChanged,
77 this, &QmlRadioButtonGroupAttached::onGroupSelectionChanged);
78 }
79
80 m_group = group;
81
82 if (m_group) {
84 this, &QmlRadioButtonGroupAttached::onGroupSelectionChanged);
85 }
86
87 emit groupChanged(m_group);
89}
90
91void QmlRadioButtonGroupAttached::onGroupSelectionChanged()
92{
94}
void setGroup(QmlRadioButtonGroup *group)
void groupChanged(QmlRadioButtonGroup *group)
void isSelectedChanged(bool isSelected)
QmlRadioButtonGroupAttached(QObject *pr=nullptr)
void setSelected(QObject *selected)
static QmlRadioButtonGroupAttached * qmlAttachedProperties(QObject *)
QmlRadioButtonGroup(QObject *parent=nullptr)
void selectedChanged(QObject *selected)