Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | class QActionGroupPrivate : public QObjectPrivate | - |
8 | { | - |
9 | inline QActionGroup* q_func() { return static_cast<QActionGroup *>(q_ptr); } inline const QActionGroup* q_func() const { return static_cast<const QActionGroup *>(q_ptr); } friend class QActionGroup; | - |
10 | public: | - |
11 | QActionGroupPrivate() : exclusive(1), enabled(1), visible(1) { } | - |
12 | QList<QAction *> actions; | - |
13 | QPointer<QAction> current; | - |
14 | uint exclusive : 1; | - |
15 | uint enabled : 1; | - |
16 | uint visible : 1; | - |
17 | | - |
18 | private: | - |
19 | void _q_actionTriggered(); | - |
20 | void _q_actionChanged(); | - |
21 | void _q_actionHovered(); | - |
22 | }; | - |
23 | | - |
24 | void QActionGroupPrivate::_q_actionChanged() | - |
25 | { | - |
26 | QActionGroup * const q = q_func(); | - |
27 | QAction *action = qobject_cast<QAction*>(q->sender()); | - |
28 | ((!(action != 0)) ? qt_assert_x("QWidgetGroup::_q_actionChanged", "internal error",__FILE__,6672) : qt_noop()); | - |
29 | if(exclusive) { | - |
30 | if (action->isChecked()) { | - |
31 | if (action != current) { | - |
32 | if(current) | - |
33 | current->setChecked(false); | - |
34 | current = action; | - |
35 | } | - |
36 | } else if (action == current) { | - |
37 | current = 0; | - |
38 | } | - |
39 | } | - |
40 | } | - |
41 | | - |
42 | void QActionGroupPrivate::_q_actionTriggered() | - |
43 | { | - |
44 | QActionGroup * const q = q_func(); | - |
45 | QAction *action = qobject_cast<QAction*>(q->sender()); | - |
46 | ((!(action != 0)) ? qt_assert_x("QWidgetGroup::_q_actionTriggered", "internal error",__FILE__,8490) : qt_noop()); | - |
47 | q->triggered(action); | - |
48 | } | - |
49 | | - |
50 | void QActionGroupPrivate::_q_actionHovered() | - |
51 | { | - |
52 | QActionGroup * const q = q_func(); | - |
53 | QAction *action = qobject_cast<QAction*>(q->sender()); | - |
54 | ((!(action != 0)) ? qt_assert_x("QWidgetGroup::_q_actionHovered", "internal error",__FILE__,9298) : qt_noop()); | - |
55 | q->hovered(action); | - |
56 | } | - |
57 | QActionGroup::QActionGroup(QObject* parent) : QObject(*new QActionGroupPrivate, parent) | - |
58 | { | - |
59 | } | - |
60 | | - |
61 | | - |
62 | | - |
63 | | - |
64 | QActionGroup::~QActionGroup() | - |
65 | { | - |
66 | } | - |
67 | QAction *QActionGroup::addAction(QAction* a) | - |
68 | { | - |
69 | QActionGroupPrivate * const d = d_func(); | - |
70 | if(!d->actions.contains(a)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
71 | d->actions.append(a); | - |
72 | QObject::connect(a, qFlagLocation("2""triggered()" "\0" __FILE__ ":" "174""180"), this, qFlagLocation("1""_q_actionTriggered()" "\0" __FILE__ ":" "174""180")); | - |
73 | QObject::connect(a, qFlagLocation("2""changed()" "\0" __FILE__ ":" "175""181"), this, qFlagLocation("1""_q_actionChanged()" "\0" __FILE__ ":" "175""181")); | - |
74 | QObject::connect(a, qFlagLocation("2""hovered()" "\0" __FILE__ ":" "176""182"), this, qFlagLocation("1""_q_actionHovered()" "\0" __FILE__ ":" "176""182")); | - |
75 | } never executed: end of block | 0 |
76 | if(!a->d_func()->forceDisabledTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
77 | a->setEnabled(d->enabled); | - |
78 | a->d_func()->forceDisabled = false; | - |
79 | } never executed: end of block | 0 |
80 | if(!a->d_func()->forceInvisibleTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
81 | a->setVisible(d->visible); | - |
82 | a->d_func()->forceInvisible = false; | - |
83 | } never executed: end of block | 0 |
84 | if(a->isChecked()TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
85 | d->current = a; never executed: d->current = a; | 0 |
86 | QActionGroup *oldGroup = a->d_func()->group; | - |
87 | if(oldGroup != thisTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
88 | if (oldGroupTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
89 | oldGroup->removeAction(a); never executed: oldGroup->removeAction(a); | 0 |
90 | a->d_func()->group = this; | - |
91 | a->d_func()->sendDataChanged(); | - |
92 | } never executed: end of block | 0 |
93 | return never executed: return a; a;never executed: return a; | 0 |
94 | } | - |
95 | QAction *QActionGroup::addAction(const QString &text) | - |
96 | { | - |
97 | return new QAction(text, this); | - |
98 | } | - |
99 | QAction *QActionGroup::addAction(const QIcon &icon, const QString &text) | - |
100 | { | - |
101 | return new QAction(icon, text, this); | - |
102 | } | - |
103 | | - |
104 | | - |
105 | | - |
106 | | - |
107 | | - |
108 | | - |
109 | | - |
110 | void QActionGroup::removeAction(QAction *action) | - |
111 | { | - |
112 | QActionGroupPrivate * const d = d_func(); | - |
113 | if (d->actions.removeAll(action)) { | - |
114 | if (action == d->current) | - |
115 | d->current = 0; | - |
116 | QObject::disconnect(action, qFlagLocation("2""triggered()" "\0" __FILE__ ":" "237""244"), this, qFlagLocation("1""_q_actionTriggered()" "\0" __FILE__ ":" "237""244")); | - |
117 | QObject::disconnect(action, qFlagLocation("2""changed()" "\0" __FILE__ ":" "238""245"), this, qFlagLocation("1""_q_actionChanged()" "\0" __FILE__ ":" "238""245")); | - |
118 | QObject::disconnect(action, qFlagLocation("2""hovered()" "\0" __FILE__ ":" "239""246"), this, qFlagLocation("1""_q_actionHovered()" "\0" __FILE__ ":" "239""246")); | - |
119 | action->d_func()->group = 0; | - |
120 | } | - |
121 | } | - |
122 | | - |
123 | | - |
124 | | - |
125 | | - |
126 | QList<QAction*> QActionGroup::actions() const | - |
127 | { | - |
128 | const QActionGroupPrivate * const d = d_func(); | - |
129 | return d->actions; | - |
130 | } | - |
131 | void QActionGroup::setExclusive(bool b) | - |
132 | { | - |
133 | QActionGroupPrivate * const d = d_func(); | - |
134 | d->exclusive = b; | - |
135 | } | - |
136 | | - |
137 | bool QActionGroup::isExclusive() const | - |
138 | { | - |
139 | const QActionGroupPrivate * const d = d_func(); | - |
140 | return d->exclusive; | - |
141 | } | - |
142 | void QActionGroup::setEnabled(bool b) | - |
143 | { | - |
144 | QActionGroupPrivate * const d = d_func(); | - |
145 | d->enabled = b; | - |
146 | for(QList<QAction*>::const_iterator it = d->actions.constBegin(); it != d->actions.constEnd(); ++it) { | - |
147 | if(!(*it)->d_func()->forceDisabled) { | - |
148 | (*it)->setEnabled(b); | - |
149 | (*it)->d_func()->forceDisabled = false; | - |
150 | } | - |
151 | } | - |
152 | } | - |
153 | | - |
154 | bool QActionGroup::isEnabled() const | - |
155 | { | - |
156 | const QActionGroupPrivate * const d = d_func(); | - |
157 | return d->enabled; | - |
158 | } | - |
159 | | - |
160 | | - |
161 | | - |
162 | | - |
163 | | - |
164 | QAction *QActionGroup::checkedAction() const | - |
165 | { | - |
166 | const QActionGroupPrivate * const d = d_func(); | - |
167 | return d->current; | - |
168 | } | - |
169 | void QActionGroup::setVisible(bool b) | - |
170 | { | - |
171 | QActionGroupPrivate * const d = d_func(); | - |
172 | d->visible = b; | - |
173 | for(QList<QAction*>::Iterator it = d->actions.begin(); it != d->actions.end(); ++it) { | - |
174 | if(!(*it)->d_func()->forceInvisible) { | - |
175 | (*it)->setVisible(b); | - |
176 | (*it)->d_func()->forceInvisible = false; | - |
177 | } | - |
178 | } | - |
179 | } | - |
180 | | - |
181 | bool QActionGroup::isVisible() const | - |
182 | { | - |
183 | const QActionGroupPrivate * const d = d_func(); | - |
184 | return d->visible; | - |
185 | } | - |
186 | | - |
187 | | - |
| | |