qabstractbutton.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qabstractbutton.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12__attribute__((visibility("default"))) extern bool qt_tab_all_widgets();-
13QAbstractButtonPrivate::QAbstractButtonPrivate(QSizePolicy::ControlType type)-
14 :-
15-
16 shortcutId(0),-
17-
18 checkable(false), checked(false), autoRepeat(false), autoExclusive(false),-
19 down(false), blockRefresh(false), pressed(false),-
20-
21 group(0),-
22-
23 autoRepeatDelay(300),-
24 autoRepeatInterval(100),-
25 controlType(type)-
26{}
never executed: end of block
0
27-
28QList<QAbstractButton *>QAbstractButtonPrivate::queryButtonList() const-
29{-
30-
31 if (group
groupDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
32 return
never executed: return group->d_func()->buttonList;
group->d_func()->buttonList;
never executed: return group->d_func()->buttonList;
0
33-
34-
35 QList<QAbstractButton*>candidates = parent->findChildren<QAbstractButton *>();-
36 if (autoExclusive
autoExclusiveDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
37 auto isNoMemberOfMyAutoExclusiveGroup = [](QAbstractButton *candidate) {-
38 return
never executed: return !candidate->autoExclusive() || candidate->group() ;
!candidate->autoExclusive()
never executed: return !candidate->autoExclusive() || candidate->group() ;
0
390
40 || candidate->group()
never executed: return !candidate->autoExclusive() || candidate->group() ;
0
410
42 ;
never executed: return !candidate->autoExclusive() || candidate->group() ;
0
43 };-
44 candidates.erase(std::remove_if(candidates.begin(), candidates.end(),-
45 isNoMemberOfMyAutoExclusiveGroup),-
46 candidates.end());-
47 }
never executed: end of block
0
48 return
never executed: return candidates;
candidates;
never executed: return candidates;
0
49}-
50-
51QAbstractButton *QAbstractButtonPrivate::queryCheckedButton() const-
52{-
53-
54 if (group
groupDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
55 return
never executed: return group->d_func()->checkedButton;
group->d_func()->checkedButton;
never executed: return group->d_func()->checkedButton;
0
56-
57-
58 const QAbstractButton * const q = q_func();-
59 QList<QAbstractButton *> buttonList = queryButtonList();-
60 if (!autoExclusive
!autoExclusiveDescription
TRUEnever evaluated
FALSEnever evaluated
|| buttonList.count() == 1
buttonList.count() == 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
61 return
never executed: return 0;
0;
never executed: return 0;
0
62-
63 for (int i = 0; i < buttonList.count()
i < buttonList.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
64 QAbstractButton *b = buttonList.at(i);-
65 if (b->d_func()->checked
b->d_func()->checkedDescription
TRUEnever evaluated
FALSEnever evaluated
&& b != q
b != qDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
66 return
never executed: return b;
b;
never executed: return b;
0
67 }
never executed: end of block
0
68 return
never executed: return checked ? const_cast<QAbstractButton *>(q) : 0;
checked ? const_cast<QAbstractButton *>(q) : 0;
never executed: return checked ? const_cast<QAbstractButton *>(q) : 0;
0
69}-
70-
71void QAbstractButtonPrivate::notifyChecked()-
72{-
73-
74 QAbstractButton * const q = q_func();-
75 if (group
groupDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
76 QAbstractButton *previous = group->d_func()->checkedButton;-
77 group->d_func()->checkedButton = q;-
78 if (group->d_func()->exclusive
group->d_func()->exclusiveDescription
TRUEnever evaluated
FALSEnever evaluated
&& previous
previousDescription
TRUEnever evaluated
FALSEnever evaluated
&& previous != q
previous != qDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
79 previous->nextCheckState();
never executed: previous->nextCheckState();
0
80 }
never executed: end of block
else
0
81-
82 if (autoExclusive
autoExclusiveDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
83 if (QAbstractButton *b = queryCheckedButton()
QAbstractButto...heckedButton()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
84 b->setChecked(false);
never executed: b->setChecked(false);
0
85 }
never executed: end of block
0
86}
never executed: end of block
0
87-
88void QAbstractButtonPrivate::moveFocus(int key)-
89{-
90 QList<QAbstractButton *> buttonList = queryButtonList();;-
91-
92 bool exclusive = group
groupDescription
TRUEnever evaluated
FALSEnever evaluated
? group->d_func()->exclusive : autoExclusive;
0
93-
94-
95-
96 QWidget *f = QApplication::focusWidget();-
97 QAbstractButton *fb = qobject_cast<QAbstractButton *>(f);-
98 if (!fb
!fbDescription
TRUEnever evaluated
FALSEnever evaluated
|| !buttonList.contains(fb)
!buttonList.contains(fb)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
99 return;
never executed: return;
0
100-
101 QAbstractButton *candidate = 0;-
102 int bestScore = -1;-
103 QRect target = f->rect().translated(f->mapToGlobal(QPoint(0,0)));-
104 QPoint goal = target.center();-
105 uint focus_flag = qt_tab_all_widgets()
qt_tab_all_widgets()Description
TRUEnever evaluated
FALSEnever evaluated
? Qt::TabFocus : Qt::StrongFocus;
0
106-
107 for (int i = 0; i < buttonList.count()
i < buttonList.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
108 QAbstractButton *button = buttonList.at(i);-
109 if (button != f
button != fDescription
TRUEnever evaluated
FALSEnever evaluated
&& button->window() == f->window()
button->window...== f->window()Description
TRUEnever evaluated
FALSEnever evaluated
&& button->isEnabled()
button->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
&& !button->isHidden()
!button->isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
&&
0
110 (autoExclusive
autoExclusiveDescription
TRUEnever evaluated
FALSEnever evaluated
|| (
(button->focus... == focus_flagDescription
TRUEnever evaluated
FALSEnever evaluated
button->focusPolicy() & focus_flag) == focus_flag
(button->focus... == focus_flagDescription
TRUEnever evaluated
FALSEnever evaluated
)) {
0
111 QRect buttonRect = button->rect().translated(button->mapToGlobal(QPoint(0,0)));-
112 QPoint p = buttonRect.center();-
113-
114-
115-
116-
117 int score;-
118 if ((buttonRect.x() < target.right()
buttonRect.x()...target.right()Description
TRUEnever evaluated
FALSEnever evaluated
&& target.x() < buttonRect.right()
target.x() < b...onRect.right()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
119 && (key == Qt::Key_Up
key == Qt::Key_UpDescription
TRUEnever evaluated
FALSEnever evaluated
|| key == Qt::Key_Down
key == Qt::Key_DownDescription
TRUEnever evaluated
FALSEnever evaluated
)) {
0
120-
121 score = (qAbs(p.y() - goal.y()) << 16) + qAbs(p.x() - goal.x());-
122 }
never executed: end of block
else if ((buttonRect.y() < target.bottom()
buttonRect.y()...arget.bottom()Description
TRUEnever evaluated
FALSEnever evaluated
&& target.y() < buttonRect.bottom()
target.y() < b...nRect.bottom()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
123 && (key == Qt::Key_Left
key == Qt::Key_LeftDescription
TRUEnever evaluated
FALSEnever evaluated
|| key == Qt::Key_Right
key == Qt::Key_RightDescription
TRUEnever evaluated
FALSEnever evaluated
) ) {
0
124-
125 score = (qAbs(p.x() - goal.x()) << 16) + qAbs(p.y() - goal.y());-
126 }
never executed: end of block
else {
0
127 score = (1 << 30) + (p.y() - goal.y()) * (p.y() - goal.y()) + (p.x() - goal.x()) * (p.x() - goal.x());-
128 }
never executed: end of block
0
129-
130 if (score > bestScore
score > bestScoreDescription
TRUEnever evaluated
FALSEnever evaluated
&& candidate
candidateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
131 continue;
never executed: continue;
0
132-
133 switch(key) {-
134 case
never executed: case Qt::Key_Up:
Qt::Key_Up:
never executed: case Qt::Key_Up:
0
135 if (p.y() < goal.y()
p.y() < goal.y()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
136 candidate = button;-
137 bestScore = score;-
138 }
never executed: end of block
0
139 break;
never executed: break;
0
140 case
never executed: case Qt::Key_Down:
Qt::Key_Down:
never executed: case Qt::Key_Down:
0
141 if (p.y() > goal.y()
p.y() > goal.y()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
142 candidate = button;-
143 bestScore = score;-
144 }
never executed: end of block
0
145 break;
never executed: break;
0
146 case
never executed: case Qt::Key_Left:
Qt::Key_Left:
never executed: case Qt::Key_Left:
0
147 if (p.x() < goal.x()
p.x() < goal.x()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
148 candidate = button;-
149 bestScore = score;-
150 }
never executed: end of block
0
151 break;
never executed: break;
0
152 case
never executed: case Qt::Key_Right:
Qt::Key_Right:
never executed: case Qt::Key_Right:
0
153 if (p.x() > goal.x()
p.x() > goal.x()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
154 candidate = button;-
155 bestScore = score;-
156 }
never executed: end of block
0
157 break;
never executed: break;
0
158 }-
159 }
never executed: end of block
0
160 }
never executed: end of block
0
161-
162 if (exclusive
exclusiveDescription
TRUEnever evaluated
FALSEnever evaluated
0
163-
164-
165-
166 && candidate
candidateDescription
TRUEnever evaluated
FALSEnever evaluated
0
167 && fb->d_func()->checked
fb->d_func()->checkedDescription
TRUEnever evaluated
FALSEnever evaluated
0
168 && candidate->d_func()->checkable
candidate->d_func()->checkableDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
169 candidate->click();
never executed: candidate->click();
0
170-
171 if (candidate
candidateDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
172 if (key == Qt::Key_Up
key == Qt::Key_UpDescription
TRUEnever evaluated
FALSEnever evaluated
|| key == Qt::Key_Left
key == Qt::Key_LeftDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
173 candidate->setFocus(Qt::BacktabFocusReason);
never executed: candidate->setFocus(Qt::BacktabFocusReason);
0
174 else-
175 candidate->setFocus(Qt::TabFocusReason);
never executed: candidate->setFocus(Qt::TabFocusReason);
0
176 }-
177}
never executed: end of block
0
178-
179void QAbstractButtonPrivate::fixFocusPolicy()-
180{-
181 QAbstractButton * const q = q_func();-
182-
183 if (!group
!groupDescription
TRUEnever evaluated
FALSEnever evaluated
&& !autoExclusive
!autoExclusiveDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
184-
185-
186-
187 return;
never executed: return;
0
188-
189 QList<QAbstractButton *> buttonList = queryButtonList();-
190 for (int i = 0; i < buttonList.count()
i < buttonList.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
191 QAbstractButton *b = buttonList.at(i);-
192 if (!b->isCheckable()
!b->isCheckable()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
193 continue;
never executed: continue;
0
194 b->setFocusPolicy((Qt::FocusPolicy) ((b == q || !q->isCheckable())-
195 ? (b->focusPolicy() | Qt::TabFocus)-
196 : (b->focusPolicy() & ~Qt::TabFocus)));-
197 }
never executed: end of block
0
198}
never executed: end of block
0
199-
200void QAbstractButtonPrivate::init()-
201{-
202 QAbstractButton * const q = q_func();-
203-
204 q->setFocusPolicy(Qt::FocusPolicy(q->style()->styleHint(QStyle::SH_Button_FocusPolicy)));-
205 q->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed, controlType));-
206 q->setAttribute(Qt::WA_WState_OwnSizePolicy, false);-
207 q->setForegroundRole(QPalette::ButtonText);-
208 q->setBackgroundRole(QPalette::Button);-
209}
never executed: end of block
0
210-
211void QAbstractButtonPrivate::refresh()-
212{-
213 QAbstractButton * const q = q_func();-
214-
215 if (blockRefresh
blockRefreshDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
216 return;
never executed: return;
0
217 q->update();-
218}
never executed: end of block
0
219-
220void QAbstractButtonPrivate::click()-
221{-
222 QAbstractButton * const q = q_func();-
223-
224 down = false;-
225 blockRefresh = true;-
226 bool changeState = true;-
227 if (checked
checkedDescription
TRUEnever evaluated
FALSEnever evaluated
&& queryCheckedButton() == q
queryCheckedButton() == qDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
228-
229-
230 if (group
groupDescription
TRUEnever evaluated
FALSEnever evaluated
? group->d_func()->exclusive : autoExclusive
group ? group-... autoExclusiveDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
231-
232-
233-
234 changeState = false;
never executed: changeState = false;
0
235 }
never executed: end of block
0
236-
237 QPointer<QAbstractButton> guard(q);-
238 if (changeState
changeStateDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
239 q->nextCheckState();-
240 if (!guard
!guardDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
241 return;
never executed: return;
0
242 }
never executed: end of block
0
243 blockRefresh = false;-
244 refresh();-
245 q->repaint();-
246 QApplication::flush();-
247 if (guard
guardDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
248 emitReleased();
never executed: emitReleased();
0
249 if (guard
guardDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
250 emitClicked();
never executed: emitClicked();
0
251}
never executed: end of block
0
252-
253void QAbstractButtonPrivate::emitClicked()-
254{-
255 QAbstractButton * const q = q_func();-
256 QPointer<QAbstractButton> guard(q);-
257 q->clicked(checked);-
258-
259 if (guard
guardDescription
TRUEnever evaluated
FALSEnever evaluated
&& group
groupDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
260 group->buttonClicked(group->id(q));-
261 if (guard
guardDescription
TRUEnever evaluated
FALSEnever evaluated
&& group
groupDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
262 group->buttonClicked(q);
never executed: group->buttonClicked(q);
0
263 }
never executed: end of block
0
264-
265}
never executed: end of block
0
266-
267void QAbstractButtonPrivate::emitPressed()-
268{-
269 QAbstractButton * const q = q_func();-
270 QPointer<QAbstractButton> guard(q);-
271 q->pressed();-
272-
273 if (guard
guardDescription
TRUEnever evaluated
FALSEnever evaluated
&& group
groupDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
274 group->buttonPressed(group->id(q));-
275 if (guard
guardDescription
TRUEnever evaluated
FALSEnever evaluated
&& group
groupDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
276 group->buttonPressed(q);
never executed: group->buttonPressed(q);
0
277 }
never executed: end of block
0
278-
279}
never executed: end of block
0
280-
281void QAbstractButtonPrivate::emitReleased()-
282{-
283 QAbstractButton * const q = q_func();-
284 QPointer<QAbstractButton> guard(q);-
285 q->released();-
286-
287 if (guard
guardDescription
TRUEnever evaluated
FALSEnever evaluated
&& group
groupDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
288 group->buttonReleased(group->id(q));-
289 if (guard
guardDescription
TRUEnever evaluated
FALSEnever evaluated
&& group
groupDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
290 group->buttonReleased(q);
never executed: group->buttonReleased(q);
0
291 }
never executed: end of block
0
292-
293}
never executed: end of block
0
294-
295void QAbstractButtonPrivate::emitToggled(bool checked)-
296{-
297 QAbstractButton * const q = q_func();-
298 QPointer<QAbstractButton> guard(q);-
299 q->toggled(checked);-
300-
301 if (guard
guardDescription
TRUEnever evaluated
FALSEnever evaluated
&& group
groupDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
302 group->buttonToggled(group->id(q), checked);-
303 if (guard
guardDescription
TRUEnever evaluated
FALSEnever evaluated
&& group
groupDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
304 group->buttonToggled(q, checked);
never executed: group->buttonToggled(q, checked);
0
305 }
never executed: end of block
0
306-
307}
never executed: end of block
0
308-
309-
310-
311-
312QAbstractButton::QAbstractButton(QWidget *parent)-
313 : QWidget(*new QAbstractButtonPrivate, parent, 0)-
314{-
315 QAbstractButtonPrivate * const d = d_func();-
316 d->init();-
317}
never executed: end of block
0
318-
319-
320-
321-
322 QAbstractButton::~QAbstractButton()-
323{-
324-
325 QAbstractButtonPrivate * const d = d_func();-
326 if (d->group
d->groupDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
327 d->group->removeButton(this);
never executed: d->group->removeButton(this);
0
328-
329}
never executed: end of block
0
330-
331-
332-
333-
334QAbstractButton::QAbstractButton(QAbstractButtonPrivate &dd, QWidget *parent)-
335 : QWidget(dd, parent, 0)-
336{-
337 QAbstractButtonPrivate * const d = d_func();-
338 d->init();-
339}
never executed: end of block
0
340void QAbstractButton::setText(const QString &text)-
341{-
342 QAbstractButtonPrivate * const d = d_func();-
343 if (d->text == text
d->text == textDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
344 return;
never executed: return;
0
345 d->text = text;-
346-
347 QKeySequence newMnemonic = QKeySequence::mnemonic(text);-
348 setShortcut(newMnemonic);-
349-
350 d->sizeHint = QSize();-
351 update();-
352 updateGeometry();-
353-
354 QAccessibleEvent event(this, QAccessible::NameChanged);-
355 QAccessible::updateAccessibility(&event);-
356-
357}
never executed: end of block
0
358-
359QString QAbstractButton::text() const-
360{-
361 const QAbstractButtonPrivate * const d = d_func();-
362 return
never executed: return d->text;
d->text;
never executed: return d->text;
0
363}-
364void QAbstractButton::setIcon(const QIcon &icon)-
365{-
366 QAbstractButtonPrivate * const d = d_func();-
367 d->icon = icon;-
368 d->sizeHint = QSize();-
369 update();-
370 updateGeometry();-
371}
never executed: end of block
0
372-
373QIcon QAbstractButton::icon() const-
374{-
375 const QAbstractButtonPrivate * const d = d_func();-
376 return
never executed: return d->icon;
d->icon;
never executed: return d->icon;
0
377}-
378-
379-
380-
381-
382-
383-
384-
385void QAbstractButton::setShortcut(const QKeySequence &key)-
386{-
387 QAbstractButtonPrivate * const d = d_func();-
388 if (d->shortcutId != 0
d->shortcutId != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
389 releaseShortcut(d->shortcutId);
never executed: releaseShortcut(d->shortcutId);
0
390 d->shortcut = key;-
391 d->shortcutId = grabShortcut(key);-
392}
never executed: end of block
0
393-
394QKeySequence QAbstractButton::shortcut() const-
395{-
396 const QAbstractButtonPrivate * const d = d_func();-
397 return
never executed: return d->shortcut;
d->shortcut;
never executed: return d->shortcut;
0
398}-
399void QAbstractButton::setCheckable(bool checkable)-
400{-
401 QAbstractButtonPrivate * const d = d_func();-
402 if (d->checkable == checkable
d->checkable == checkableDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
403 return;
never executed: return;
0
404-
405 d->checkable = checkable;-
406 d->checked = false;-
407}
never executed: end of block
0
408-
409bool QAbstractButton::isCheckable() const-
410{-
411 const QAbstractButtonPrivate * const d = d_func();-
412 return
never executed: return d->checkable;
d->checkable;
never executed: return d->checkable;
0
413}-
414void QAbstractButton::setChecked(bool checked)-
415{-
416 QAbstractButtonPrivate * const d = d_func();-
417 if (!d->checkable
!d->checkableDescription
TRUEnever evaluated
FALSEnever evaluated
|| d->checked == checked
d->checked == checkedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
418 if (!d->blockRefresh
!d->blockRefreshDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
419 checkStateSet();
never executed: checkStateSet();
0
420 return;
never executed: return;
0
421 }-
422-
423 if (!checked
!checkedDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->queryCheckedButton() == this
d->queryChecke...tton() == thisDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
424-
425-
426 if (d->group
d->groupDescription
TRUEnever evaluated
FALSEnever evaluated
? d->group->d_func()->exclusive : d->autoExclusive
d->group ? d->...>autoExclusiveDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
427 return;
never executed: return;
0
428 if (d->group
d->groupDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
429 d->group->d_func()->detectCheckedButton();
never executed: d->group->d_func()->detectCheckedButton();
0
430-
431-
432-
433-
434 }
never executed: end of block
0
435-
436 QPointer<QAbstractButton> guard(this);-
437-
438 d->checked = checked;-
439 if (!d->blockRefresh
!d->blockRefreshDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
440 checkStateSet();
never executed: checkStateSet();
0
441 d->refresh();-
442-
443 if (guard
guardDescription
TRUEnever evaluated
FALSEnever evaluated
&& checked
checkedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
444 d->notifyChecked();
never executed: d->notifyChecked();
0
445 if (guard
guardDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
446 d->emitToggled(checked);
never executed: d->emitToggled(checked);
0
447-
448-
449-
450 QAccessible::State s;-
451 s.checked = true;-
452 QAccessibleStateChangeEvent event(this, s);-
453 QAccessible::updateAccessibility(&event);-
454-
455}
never executed: end of block
0
456-
457bool QAbstractButton::isChecked() const-
458{-
459 const QAbstractButtonPrivate * const d = d_func();-
460 return
never executed: return d->checked;
d->checked;
never executed: return d->checked;
0
461}-
462void QAbstractButton::setDown(bool down)-
463{-
464 QAbstractButtonPrivate * const d = d_func();-
465 if (d->down == down
d->down == downDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
466 return;
never executed: return;
0
467 d->down = down;-
468 d->refresh();-
469 if (d->autoRepeat
d->autoRepeatDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->down
d->downDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
470 d->repeatTimer.start(d->autoRepeatDelay, this);
never executed: d->repeatTimer.start(d->autoRepeatDelay, this);
0
471 else-
472 d->repeatTimer.stop();
never executed: d->repeatTimer.stop();
0
473}-
474-
475bool QAbstractButton::isDown() const-
476{-
477 const QAbstractButtonPrivate * const d = d_func();-
478 return
never executed: return d->down;
d->down;
never executed: return d->down;
0
479}-
480void QAbstractButton::setAutoRepeat(bool autoRepeat)-
481{-
482 QAbstractButtonPrivate * const d = d_func();-
483 if (d->autoRepeat == autoRepeat
d->autoRepeat == autoRepeatDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
484 return;
never executed: return;
0
485 d->autoRepeat = autoRepeat;-
486 if (d->autoRepeat
d->autoRepeatDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->down
d->downDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
487 d->repeatTimer.start(d->autoRepeatDelay, this);
never executed: d->repeatTimer.start(d->autoRepeatDelay, this);
0
488 else-
489 d->repeatTimer.stop();
never executed: d->repeatTimer.stop();
0
490}-
491-
492bool QAbstractButton::autoRepeat() const-
493{-
494 const QAbstractButtonPrivate * const d = d_func();-
495 return
never executed: return d->autoRepeat;
d->autoRepeat;
never executed: return d->autoRepeat;
0
496}-
497void QAbstractButton::setAutoRepeatDelay(int autoRepeatDelay)-
498{-
499 QAbstractButtonPrivate * const d = d_func();-
500 d->autoRepeatDelay = autoRepeatDelay;-
501}
never executed: end of block
0
502-
503int QAbstractButton::autoRepeatDelay() const-
504{-
505 const QAbstractButtonPrivate * const d = d_func();-
506 return
never executed: return d->autoRepeatDelay;
d->autoRepeatDelay;
never executed: return d->autoRepeatDelay;
0
507}-
508void QAbstractButton::setAutoRepeatInterval(int autoRepeatInterval)-
509{-
510 QAbstractButtonPrivate * const d = d_func();-
511 d->autoRepeatInterval = autoRepeatInterval;-
512}
never executed: end of block
0
513-
514int QAbstractButton::autoRepeatInterval() const-
515{-
516 const QAbstractButtonPrivate * const d = d_func();-
517 return
never executed: return d->autoRepeatInterval;
d->autoRepeatInterval;
never executed: return d->autoRepeatInterval;
0
518}-
519void QAbstractButton::setAutoExclusive(bool autoExclusive)-
520{-
521 QAbstractButtonPrivate * const d = d_func();-
522 d->autoExclusive = autoExclusive;-
523}
never executed: end of block
0
524-
525bool QAbstractButton::autoExclusive() const-
526{-
527 const QAbstractButtonPrivate * const d = d_func();-
528 return
never executed: return d->autoExclusive;
d->autoExclusive;
never executed: return d->autoExclusive;
0
529}-
530QButtonGroup *QAbstractButton::group() const-
531{-
532 const QAbstractButtonPrivate * const d = d_func();-
533 return
never executed: return d->group;
d->group;
never executed: return d->group;
0
534}-
535void QAbstractButton::animateClick(int msec)-
536{-
537 if (!isEnabled()
!isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
538 return;
never executed: return;
0
539 QAbstractButtonPrivate * const d = d_func();-
540 if (d->checkable
d->checkableDescription
TRUEnever evaluated
FALSEnever evaluated
&& focusPolicy() & Qt::ClickFocus
focusPolicy() & Qt::ClickFocusDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
541 setFocus();
never executed: setFocus();
0
542 setDown(true);-
543 repaint();-
544 QApplication::flush();-
545 if (!d->animateTimer.isActive()
!d->animateTimer.isActive()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
546 d->emitPressed();
never executed: d->emitPressed();
0
547 d->animateTimer.start(msec, this);-
548}
never executed: end of block
0
549void QAbstractButton::click()-
550{-
551 if (!isEnabled()
!isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
552 return;
never executed: return;
0
553 QAbstractButtonPrivate * const d = d_func();-
554 QPointer<QAbstractButton> guard(this);-
555 d->down = true;-
556 d->emitPressed();-
557 if (guard
guardDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
558 d->down = false;-
559 nextCheckState();-
560 if (guard
guardDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
561 d->emitReleased();
never executed: d->emitReleased();
0
562 if (guard
guardDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
563 d->emitClicked();
never executed: d->emitClicked();
0
564 }
never executed: end of block
0
565}
never executed: end of block
0
566-
567-
568-
569-
570-
571-
572-
573void QAbstractButton::toggle()-
574{-
575 QAbstractButtonPrivate * const d = d_func();-
576 setChecked(!d->checked);-
577}
never executed: end of block
0
578void QAbstractButton::checkStateSet()-
579{-
580}-
581void QAbstractButton::nextCheckState()-
582{-
583 if (isCheckable()
isCheckable()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
584 setChecked(!isChecked());
never executed: setChecked(!isChecked());
0
585}
never executed: end of block
0
586bool QAbstractButton::hitButton(const QPoint &pos) const-
587{-
588 return
never executed: return rect().contains(pos);
rect().contains(pos);
never executed: return rect().contains(pos);
0
589}-
590-
591-
592bool QAbstractButton::event(QEvent *e)-
593{-
594-
595-
596 if (!isEnabled()
!isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
597 switch(e->type()) {-
598 case
never executed: case QEvent::TabletPress:
QEvent::TabletPress:
never executed: case QEvent::TabletPress:
0
599 case
never executed: case QEvent::TabletRelease:
QEvent::TabletRelease:
never executed: case QEvent::TabletRelease:
0
600 case
never executed: case QEvent::TabletMove:
QEvent::TabletMove:
never executed: case QEvent::TabletMove:
0
601 case
never executed: case QEvent::MouseButtonPress:
QEvent::MouseButtonPress:
never executed: case QEvent::MouseButtonPress:
0
602 case
never executed: case QEvent::MouseButtonRelease:
QEvent::MouseButtonRelease:
never executed: case QEvent::MouseButtonRelease:
0
603 case
never executed: case QEvent::MouseButtonDblClick:
QEvent::MouseButtonDblClick:
never executed: case QEvent::MouseButtonDblClick:
0
604 case
never executed: case QEvent::MouseMove:
QEvent::MouseMove:
never executed: case QEvent::MouseMove:
0
605 case
never executed: case QEvent::HoverMove:
QEvent::HoverMove:
never executed: case QEvent::HoverMove:
0
606 case
never executed: case QEvent::HoverEnter:
QEvent::HoverEnter:
never executed: case QEvent::HoverEnter:
0
607 case
never executed: case QEvent::HoverLeave:
QEvent::HoverLeave:
never executed: case QEvent::HoverLeave:
0
608 case
never executed: case QEvent::ContextMenu:
QEvent::ContextMenu:
never executed: case QEvent::ContextMenu:
0
609-
610 case
never executed: case QEvent::Wheel:
QEvent::Wheel:
never executed: case QEvent::Wheel:
0
611-
612 return
never executed: return true;
true;
never executed: return true;
0
613 default
never executed: default:
:
never executed: default:
0
614 break;
never executed: break;
0
615 }-
616 }-
617-
618-
619 if (e->type() == QEvent::Shortcut
e->type() == QEvent::ShortcutDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
620 QAbstractButtonPrivate * const d = d_func();-
621 QShortcutEvent *se = static_cast<QShortcutEvent *>(e);-
622 if (d->shortcutId != se->shortcutId()
d->shortcutId ...->shortcutId()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
623 return
never executed: return false;
false;
never executed: return false;
0
624 if (!se->isAmbiguous()
!se->isAmbiguous()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
625 if (!d->animateTimer.isActive()
!d->animateTimer.isActive()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
626 animateClick();
never executed: animateClick();
0
627 }
never executed: end of block
else {
0
628 if (focusPolicy() != Qt::NoFocus
focusPolicy() != Qt::NoFocusDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
629 setFocus(Qt::ShortcutFocusReason);
never executed: setFocus(Qt::ShortcutFocusReason);
0
630 window()->setAttribute(Qt::WA_KeyboardFocusChange);-
631 }
never executed: end of block
0
632 return
never executed: return true;
true;
never executed: return true;
0
633 }-
634-
635 return
never executed: return QWidget::event(e);
QWidget::event(e);
never executed: return QWidget::event(e);
0
636}-
637-
638-
639void QAbstractButton::mousePressEvent(QMouseEvent *e)-
640{-
641 QAbstractButtonPrivate * const d = d_func();-
642 if (e->button() != Qt::LeftButton
e->button() != Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
643 e->ignore();-
644 return;
never executed: return;
0
645 }-
646 if (hitButton(e->pos())
hitButton(e->pos())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
647 setDown(true);-
648 d->pressed = true;-
649 repaint();-
650 QApplication::flush();-
651 d->emitPressed();-
652 e->accept();-
653 }
never executed: end of block
else {
0
654 e->ignore();-
655 }
never executed: end of block
0
656}-
657-
658-
659void QAbstractButton::mouseReleaseEvent(QMouseEvent *e)-
660{-
661 QAbstractButtonPrivate * const d = d_func();-
662 d->pressed = false;-
663-
664 if (e->button() != Qt::LeftButton
e->button() != Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
665 e->ignore();-
666 return;
never executed: return;
0
667 }-
668-
669 if (!d->down
!d->downDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
670-
671 d->refresh();-
672 e->ignore();-
673 return;
never executed: return;
0
674 }-
675-
676 if (hitButton(e->pos())
hitButton(e->pos())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
677 d->repeatTimer.stop();-
678 d->click();-
679 e->accept();-
680 }
never executed: end of block
else {
0
681 setDown(false);-
682 e->ignore();-
683 }
never executed: end of block
0
684}-
685-
686-
687void QAbstractButton::mouseMoveEvent(QMouseEvent *e)-
688{-
689 QAbstractButtonPrivate * const d = d_func();-
690 if (!(e->buttons() & Qt::LeftButton)
!(e->buttons()...t::LeftButton)Description
TRUEnever evaluated
FALSEnever evaluated
|| !d->pressed
!d->pressedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
691 e->ignore();-
692 return;
never executed: return;
0
693 }-
694-
695 if (hitButton(e->pos()) != d->down
hitButton(e->pos()) != d->downDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
696 setDown(!d->down);-
697 repaint();-
698 QApplication::flush();-
699 if (d->down
d->downDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
700 d->emitPressed();
never executed: d->emitPressed();
0
701 else-
702 d->emitReleased();
never executed: d->emitReleased();
0
703 e->accept();-
704 }
never executed: end of block
else if (!hitButton(e->pos())
!hitButton(e->pos())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
705 e->ignore();-
706 }
never executed: end of block
0
707}
never executed: end of block
0
708-
709-
710void QAbstractButton::keyPressEvent(QKeyEvent *e)-
711{-
712 QAbstractButtonPrivate * const d = d_func();-
713 bool next = true;-
714 switch (e->key()) {-
715 case
never executed: case Qt::Key_Enter:
Qt::Key_Enter:
never executed: case Qt::Key_Enter:
0
716 case
never executed: case Qt::Key_Return:
Qt::Key_Return:
never executed: case Qt::Key_Return:
0
717 e->ignore();-
718 break;
never executed: break;
0
719 case
never executed: case Qt::Key_Select:
Qt::Key_Select:
never executed: case Qt::Key_Select:
0
720 case
never executed: case Qt::Key_Space:
Qt::Key_Space:
never executed: case Qt::Key_Space:
0
721 if (!e->isAutoRepeat()
!e->isAutoRepeat()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
722 setDown(true);-
723 repaint();-
724 QApplication::flush();-
725 d->emitPressed();-
726 }
never executed: end of block
0
727 break;
never executed: break;
0
728 case
never executed: case Qt::Key_Up:
Qt::Key_Up:
never executed: case Qt::Key_Up:
0
729 next = false;-
730-
731 case
never executed: case Qt::Key_Left:
Qt::Key_Left:
never executed: case Qt::Key_Left:
code before this statement never executed: case Qt::Key_Left:
0
732 case
never executed: case Qt::Key_Right:
Qt::Key_Right:
never executed: case Qt::Key_Right:
0
733 case
never executed: case Qt::Key_Down:
Qt::Key_Down:
never executed: case Qt::Key_Down:
{
0
734 QWidget *pw = parentWidget();-
735 if (d->autoExclusive
d->autoExclusiveDescription
TRUEnever evaluated
FALSEnever evaluated
0
736-
737 || d->group
d->groupDescription
TRUEnever evaluated
FALSEnever evaluated
0
738-
739-
740 || (pw
pwDescription
TRUEnever evaluated
FALSEnever evaluated
&& qobject_cast<QAbstractItemView *>(pw->parentWidget())
qobject_cast<Q...arentWidget())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
741-
742 ) {-
743-
744-
745-
746-
747 d->moveFocus(e->key());-
748 if (hasFocus()
hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
749 e->ignore();
never executed: e->ignore();
0
750 }
never executed: end of block
else {
0
751-
752 QWidget *w = pw
pwDescription
TRUEnever evaluated
FALSEnever evaluated
? pw : this;
0
753 bool reverse = (w->layoutDirection() == Qt::RightToLeft);-
754 if ((e->key() == Qt::Key_Left
e->key() == Qt::Key_LeftDescription
TRUEnever evaluated
FALSEnever evaluated
&& !reverse
!reverseDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
755 || (e->key() == Qt::Key_Right
e->key() == Qt::Key_RightDescription
TRUEnever evaluated
FALSEnever evaluated
&& reverse
reverseDescription
TRUEnever evaluated
FALSEnever evaluated
)) {
0
756 next = false;-
757 }
never executed: end of block
0
758 focusNextPrevChild(next);-
759 }
never executed: end of block
0
760 break;
never executed: break;
0
761 }-
762 default
never executed: default:
:
never executed: default:
0
763 if (e->matches(QKeySequence::Cancel)
e->matches(QKe...uence::Cancel)Description
TRUEnever evaluated
FALSEnever evaluated
&& d->down
d->downDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
764 setDown(false);-
765 repaint();-
766 QApplication::flush();-
767 d->emitReleased();-
768 return;
never executed: return;
0
769 }-
770 e->ignore();-
771 }
never executed: end of block
0
772}-
773-
774-
775void QAbstractButton::keyReleaseEvent(QKeyEvent *e)-
776{-
777 QAbstractButtonPrivate * const d = d_func();-
778-
779 if (!e->isAutoRepeat()
!e->isAutoRepeat()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
780 d->repeatTimer.stop();
never executed: d->repeatTimer.stop();
0
781-
782 switch (e->key()) {-
783 case
never executed: case Qt::Key_Select:
Qt::Key_Select:
never executed: case Qt::Key_Select:
0
784 case
never executed: case Qt::Key_Space:
Qt::Key_Space:
never executed: case Qt::Key_Space:
0
785 if (!e->isAutoRepeat()
!e->isAutoRepeat()Description
TRUEnever evaluated
FALSEnever evaluated
&& d->down
d->downDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
786 d->click();
never executed: d->click();
0
787 break;
never executed: break;
0
788 default
never executed: default:
:
never executed: default:
0
789 e->ignore();-
790 }
never executed: end of block
0
791}-
792-
793-
794-
795void QAbstractButton::timerEvent(QTimerEvent *e)-
796{-
797 QAbstractButtonPrivate * const d = d_func();-
798 if (e->timerId() == d->repeatTimer.timerId()
e->timerId() =...imer.timerId()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
799 d->repeatTimer.start(d->autoRepeatInterval, this);-
800 if (d->down
d->downDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
801 QPointer<QAbstractButton> guard(this);-
802 nextCheckState();-
803 if (guard
guardDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
804 d->emitReleased();
never executed: d->emitReleased();
0
805 if (guard
guardDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
806 d->emitClicked();
never executed: d->emitClicked();
0
807 if (guard
guardDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
808 d->emitPressed();
never executed: d->emitPressed();
0
809 }
never executed: end of block
0
810 }
never executed: end of block
else if (e->timerId() == d->animateTimer.timerId()
e->timerId() =...imer.timerId()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
811 d->animateTimer.stop();-
812 d->click();-
813 }
never executed: end of block
0
814}
never executed: end of block
0
815-
816-
817void QAbstractButton::focusInEvent(QFocusEvent *e)-
818{-
819 QAbstractButtonPrivate * const d = d_func();-
820-
821-
822-
823 d->fixFocusPolicy();-
824 QWidget::focusInEvent(e);-
825}
never executed: end of block
0
826-
827-
828void QAbstractButton::focusOutEvent(QFocusEvent *e)-
829{-
830 QAbstractButtonPrivate * const d = d_func();-
831 if (e->reason() != Qt::PopupFocusReason
e->reason() !=...pupFocusReasonDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->down
d->downDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
832 d->down = false;-
833 d->emitReleased();-
834 }
never executed: end of block
0
835 QWidget::focusOutEvent(e);-
836}
never executed: end of block
0
837-
838-
839void QAbstractButton::changeEvent(QEvent *e)-
840{-
841 QAbstractButtonPrivate * const d = d_func();-
842 switch (e->type()) {-
843 case
never executed: case QEvent::EnabledChange:
QEvent::EnabledChange:
never executed: case QEvent::EnabledChange:
0
844 if (!isEnabled()
!isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
&& d->down
d->downDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
845 d->down = false;-
846 d->emitReleased();-
847 }
never executed: end of block
0
848 break;
never executed: break;
0
849 default
never executed: default:
:
never executed: default:
0
850 d->sizeHint = QSize();-
851 break;
never executed: break;
0
852 }-
853 QWidget::changeEvent(e);-
854}
never executed: end of block
0
855QSize QAbstractButton::iconSize() const-
856{-
857 const QAbstractButtonPrivate * const d = d_func();-
858 if (d->iconSize.isValid()
d->iconSize.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
859 return
never executed: return d->iconSize;
d->iconSize;
never executed: return d->iconSize;
0
860 int e = style()->pixelMetric(QStyle::PM_ButtonIconSize, 0, this);-
861 return
never executed: return QSize(e, e);
QSize(e, e);
never executed: return QSize(e, e);
0
862}-
863-
864void QAbstractButton::setIconSize(const QSize &size)-
865{-
866 QAbstractButtonPrivate * const d = d_func();-
867 if (d->iconSize == size
d->iconSize == sizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
868 return;
never executed: return;
0
869-
870 d->iconSize = size;-
871 d->sizeHint = QSize();-
872 updateGeometry();-
873 if (isVisible()
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
874 update();-
875 }
never executed: end of block
0
876}
never executed: end of block
0
877-
878-
879-
880-
881-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9