widgets/qradiobutton.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5class QRadioButtonPrivate : public QAbstractButtonPrivate -
6{ -
7 inline QRadioButton* q_func() { return static_cast<QRadioButton *>(q_ptr); } inline const QRadioButton* q_func() const { return static_cast<const QRadioButton *>(q_ptr); } friend class QRadioButton; -
8 -
9public: -
10 QRadioButtonPrivate() : QAbstractButtonPrivate(QSizePolicy::RadioButton), hovering(true) {}
executed: }
Execution Count:51
51
11 void init(); -
12 uint hovering : 1; -
13}; -
14 -
15 -
16 -
17 -
18void QRadioButtonPrivate::init() -
19{ -
20 QRadioButton * const q = q_func(); -
21 q->setCheckable(true); -
22 q->setAutoExclusive(true); -
23 q->setMouseTracking(true); -
24 q->setForegroundRole(QPalette::WindowText); -
25 setLayoutItemMargins(QStyle::SE_RadioButtonLayoutItem); -
26}
executed: }
Execution Count:51
51
27QRadioButton::QRadioButton(QWidget *parent) -
28 : QAbstractButton(*new QRadioButtonPrivate, parent) -
29{ -
30 QRadioButtonPrivate * const d = d_func(); -
31 d->init(); -
32}
executed: }
Execution Count:38
38
33 -
34 -
35 -
36 -
37QRadioButton::~QRadioButton() -
38{ -
39} -
40 -
41 -
42 -
43 -
44 -
45 -
46 -
47QRadioButton::QRadioButton(const QString &text, QWidget *parent) -
48 : QAbstractButton(*new QRadioButtonPrivate, parent) -
49{ -
50 QRadioButtonPrivate * const d = d_func(); -
51 d->init(); -
52 setText(text); -
53}
executed: }
Execution Count:13
13
54void QRadioButton::initStyleOption(QStyleOptionButton *option) const -
55{ -
56 if (!option)
partially evaluated: !option
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61
0-61
57 return;
never executed: return;
0
58 const QRadioButtonPrivate * const d = d_func(); -
59 option->initFrom(this); -
60 option->text = d->text; -
61 option->icon = d->icon; -
62 option->iconSize = iconSize(); -
63 if (d->down)
evaluated: d->down
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:60
1-60
64 option->state |= QStyle::State_Sunken;
executed: option->state |= QStyle::State_Sunken;
Execution Count:1
1
65 option->state |= (d->checked) ? QStyle::State_On : QStyle::State_Off;
evaluated: (d->checked)
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:54
7-54
66 if (testAttribute(Qt::WA_Hover) && underMouse()) {
partially evaluated: testAttribute(Qt::WA_Hover)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61
never evaluated: underMouse()
0-61
67 if (d->hovering)
never evaluated: d->hovering
0
68 option->state |= QStyle::State_MouseOver;
never executed: option->state |= QStyle::State_MouseOver;
0
69 else -
70 option->state &= ~QStyle::State_MouseOver;
never executed: option->state &= ~QStyle::State_MouseOver;
0
71 } -
72}
executed: }
Execution Count:61
61
73 -
74 -
75 -
76 -
77QSize QRadioButton::sizeHint() const -
78{ -
79 const QRadioButtonPrivate * const d = d_func(); -
80 if (d->sizeHint.isValid())
evaluated: d->sizeHint.isValid()
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:35
34-35
81 return d->sizeHint;
executed: return d->sizeHint;
Execution Count:34
34
82 ensurePolished(); -
83 QStyleOptionButton opt; -
84 initStyleOption(&opt); -
85 QSize sz = style()->itemTextRect(fontMetrics(), QRect(), Qt::TextShowMnemonic, -
86 false, text()).size(); -
87 if (!opt.icon.isNull())
partially evaluated: !opt.icon.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:35
0-35
88 sz = QSize(sz.width() + opt.iconSize.width() + 4, qMax(sz.height(), opt.iconSize.height()));
never executed: sz = QSize(sz.width() + opt.iconSize.width() + 4, qMax(sz.height(), opt.iconSize.height()));
0
89 d->sizeHint = (style()->sizeFromContents(QStyle::CT_RadioButton, &opt, sz, this). -
90 expandedTo(QApplication::globalStrut())); -
91 return d->sizeHint;
executed: return d->sizeHint;
Execution Count:35
35
92} -
93 -
94 -
95 -
96 -
97QSize QRadioButton::minimumSizeHint() const -
98{ -
99 return sizeHint();
executed: return sizeHint();
Execution Count:34
34
100} -
101 -
102 -
103 -
104 -
105bool QRadioButton::hitButton(const QPoint &pos) const -
106{ -
107 QStyleOptionButton opt; -
108 initStyleOption(&opt); -
109 return style()->subElementRect(QStyle::SE_RadioButtonClickRect, &opt, this).contains(pos);
never executed: return style()->subElementRect(QStyle::SE_RadioButtonClickRect, &opt, this).contains(pos);
0
110} -
111 -
112 -
113 -
114 -
115void QRadioButton::mouseMoveEvent(QMouseEvent *e) -
116{ -
117 QRadioButtonPrivate * const d = d_func(); -
118 if (testAttribute(Qt::WA_Hover)) {
never evaluated: testAttribute(Qt::WA_Hover)
0
119 bool hit = false; -
120 if (underMouse())
never evaluated: underMouse()
0
121 hit = hitButton(e->pos());
never executed: hit = hitButton(e->pos());
0
122 -
123 if (hit != d->hovering) {
never evaluated: hit != d->hovering
0
124 update(); -
125 d->hovering = hit; -
126 }
never executed: }
0
127 }
never executed: }
0
128 -
129 QAbstractButton::mouseMoveEvent(e); -
130}
never executed: }
0
131 -
132 -
133 -
134void QRadioButton::paintEvent(QPaintEvent *) -
135{ -
136 QStylePainter p(this); -
137 QStyleOptionButton opt; -
138 initStyleOption(&opt); -
139 p.drawControl(QStyle::CE_RadioButton, opt); -
140}
executed: }
Execution Count:26
26
141 -
142 -
143bool QRadioButton::event(QEvent *e) -
144{ -
145 QRadioButtonPrivate * const d = d_func(); -
146 if (e->type() == QEvent::StyleChange
evaluated: e->type() == QEvent::StyleChange
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:424
17-424
147 -
148 -
149 -
150 ) -
151 d->setLayoutItemMargins(QStyle::SE_RadioButtonLayoutItem);
executed: d->setLayoutItemMargins(QStyle::SE_RadioButtonLayoutItem);
Execution Count:17
17
152 return QAbstractButton::event(e);
executed: return QAbstractButton::event(e);
Execution Count:441
441
153} -
154 -
155 -
156 -
157 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial