OpenCoverage

qcheckbox.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qcheckbox.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5class QCheckBoxPrivate : public QAbstractButtonPrivate-
6{-
7 inline QCheckBox* q_func() { return static_cast<QCheckBox *>(q_ptr); } inline const QCheckBox* q_func() const { return static_cast<const QCheckBox *>(q_ptr); } friend class QCheckBox;-
8public:-
9 QCheckBoxPrivate()-
10 : QAbstractButtonPrivate(QSizePolicy::CheckBox), tristate(false), noChange(false),-
11 hovering(true), publishedState(Qt::Unchecked) {}
never executed: end of block
0
12-
13 uint tristate : 1;-
14 uint noChange : 1;-
15 uint hovering : 1;-
16 uint publishedState : 2;-
17-
18 void init();-
19};-
20void QCheckBoxPrivate::init()-
21{-
22 QCheckBox * const q = q_func();-
23 q->setCheckable(true);-
24 q->setMouseTracking(true);-
25 q->setForegroundRole(QPalette::WindowText);-
26 setLayoutItemMargins(QStyle::SE_CheckBoxLayoutItem);-
27}
never executed: end of block
0
28void QCheckBox::initStyleOption(QStyleOptionButton *option) const-
29{-
30 if (!option
!optionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
31 return;
never executed: return;
0
32 const QCheckBoxPrivate * const d = d_func();-
33 option->initFrom(this);-
34 if (d->down
d->downDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
35 option->state |= QStyle::State_Sunken;
never executed: option->state |= QStyle::State_Sunken;
0
36 if (d->tristate
d->tristateDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->noChange
d->noChangeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
37 option->state |= QStyle::State_NoChange;
never executed: option->state |= QStyle::State_NoChange;
0
38 else-
39 option->state |= d->checked
d->checkedDescription
TRUEnever evaluated
FALSEnever evaluated
? QStyle::State_On : QStyle::State_Off;
never executed: option->state |= d->checked ? QStyle::State_On : QStyle::State_Off;
0
40 if (testAttribute(Qt::WA_Hover)
testAttribute(Qt::WA_Hover)Description
TRUEnever evaluated
FALSEnever evaluated
&& underMouse()
underMouse()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
41 option->state.setFlag(QStyle::State_MouseOver, d->hovering);-
42 }
never executed: end of block
0
43 option->text = d->text;-
44 option->icon = d->icon;-
45 option->iconSize = iconSize();-
46}
never executed: end of block
0
47-
48-
49-
50-
51-
52-
53-
54QCheckBox::QCheckBox(QWidget *parent)-
55 : QAbstractButton (*new QCheckBoxPrivate, parent)-
56{-
57 QCheckBoxPrivate * const d = d_func();-
58 d->init();-
59}
never executed: end of block
0
60-
61-
62-
63-
64-
65-
66-
67QCheckBox::QCheckBox(const QString &text, QWidget *parent)-
68 : QAbstractButton (*new QCheckBoxPrivate, parent)-
69{-
70 QCheckBoxPrivate * const d = d_func();-
71 d->init();-
72 setText(text);-
73}
never executed: end of block
0
74-
75-
76-
77-
78QCheckBox::~QCheckBox()-
79{-
80}-
81-
82void QCheckBox::setTristate(bool y)-
83{-
84 QCheckBoxPrivate * const d = d_func();-
85 d->tristate = y;-
86}
never executed: end of block
0
87-
88bool QCheckBox::isTristate() const-
89{-
90 const QCheckBoxPrivate * const d = d_func();-
91 return
never executed: return d->tristate;
d->tristate;
never executed: return d->tristate;
0
92}-
93Qt::CheckState QCheckBox::checkState() const-
94{-
95 const QCheckBoxPrivate * const d = d_func();-
96 if (d->tristate
d->tristateDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->noChange
d->noChangeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
97 return
never executed: return Qt::PartiallyChecked;
Qt::PartiallyChecked;
never executed: return Qt::PartiallyChecked;
0
98 return
never executed: return d->checked ? Qt::Checked : Qt::Unchecked;
d->checked ? Qt::Checked : Qt::Unchecked;
never executed: return d->checked ? Qt::Checked : Qt::Unchecked;
0
99}-
100void QCheckBox::setCheckState(Qt::CheckState state)-
101{-
102 QCheckBoxPrivate * const d = d_func();-
103 if (state == Qt::PartiallyChecked
state == Qt::PartiallyCheckedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
104 d->tristate = true;-
105 d->noChange = true;-
106 }
never executed: end of block
else {
0
107 d->noChange = false;-
108 }
never executed: end of block
0
109 d->blockRefresh = true;-
110 setChecked(state != Qt::Unchecked);-
111 d->blockRefresh = false;-
112 d->refresh();-
113 if ((
(uint)state !=...publishedStateDescription
TRUEnever evaluated
FALSEnever evaluated
uint)state != d->publishedState
(uint)state !=...publishedStateDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
114 d->publishedState = state;-
115 stateChanged(state);-
116 }
never executed: end of block
0
117}
never executed: end of block
0
118-
119-
120-
121-
122-
123QSize QCheckBox::sizeHint() const-
124{-
125 const QCheckBoxPrivate * const d = d_func();-
126 if (d->sizeHint.isValid()
d->sizeHint.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
127 return
never executed: return d->sizeHint;
d->sizeHint;
never executed: return d->sizeHint;
0
128 ensurePolished();-
129 QFontMetrics fm = fontMetrics();-
130 QStyleOptionButton opt;-
131 initStyleOption(&opt);-
132 QSize sz = style()->itemTextRect(fm, QRect(), Qt::TextShowMnemonic, false,-
133 text()).size();-
134 if (!opt.icon.isNull()
!opt.icon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
135 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
136 d->sizeHint = (style()->sizeFromContents(QStyle::CT_CheckBox, &opt, sz, this)-
137 .expandedTo(QApplication::globalStrut()));-
138 return
never executed: return d->sizeHint;
d->sizeHint;
never executed: return d->sizeHint;
0
139}-
140-
141-
142-
143-
144-
145QSize QCheckBox::minimumSizeHint() const-
146{-
147 return
never executed: return sizeHint();
sizeHint();
never executed: return sizeHint();
0
148}-
149-
150-
151-
152-
153void QCheckBox::paintEvent(QPaintEvent *)-
154{-
155 QStylePainter p(this);-
156 QStyleOptionButton opt;-
157 initStyleOption(&opt);-
158 p.drawControl(QStyle::CE_CheckBox, opt);-
159}
never executed: end of block
0
160-
161-
162-
163-
164void QCheckBox::mouseMoveEvent(QMouseEvent *e)-
165{-
166 QCheckBoxPrivate * const d = d_func();-
167 if (testAttribute(Qt::WA_Hover)
testAttribute(Qt::WA_Hover)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
168 bool hit = false;-
169 if (underMouse()
underMouse()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
170 hit = hitButton(e->pos());
never executed: hit = hitButton(e->pos());
0
171-
172 if (hit != d->hovering
hit != d->hoveringDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
173 update(rect());-
174 d->hovering = hit;-
175 }
never executed: end of block
0
176 }
never executed: end of block
0
177-
178 QAbstractButton::mouseMoveEvent(e);-
179}
never executed: end of block
0
180-
181-
182-
183-
184-
185bool QCheckBox::hitButton(const QPoint &pos) const-
186{-
187 QStyleOptionButton opt;-
188 initStyleOption(&opt);-
189 return
never executed: return style()->subElementRect(QStyle::SE_CheckBoxClickRect, &opt, this).contains(pos);
style()->subElementRect(QStyle::SE_CheckBoxClickRect, &opt, this).contains(pos);
never executed: return style()->subElementRect(QStyle::SE_CheckBoxClickRect, &opt, this).contains(pos);
0
190}-
191-
192-
193-
194-
195void QCheckBox::checkStateSet()-
196{-
197 QCheckBoxPrivate * const d = d_func();-
198 d->noChange = false;-
199 Qt::CheckState state = checkState();-
200 if ((
(uint)state !=...publishedStateDescription
TRUEnever evaluated
FALSEnever evaluated
uint)state != d->publishedState
(uint)state !=...publishedStateDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
201 d->publishedState = state;-
202 stateChanged(state);-
203 }
never executed: end of block
0
204}
never executed: end of block
0
205-
206-
207-
208-
209void QCheckBox::nextCheckState()-
210{-
211 QCheckBoxPrivate * const d = d_func();-
212 if (d->tristate
d->tristateDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
213 setCheckState((Qt::CheckState)((checkState() + 1) % 3));
never executed: setCheckState((Qt::CheckState)((checkState() + 1) % 3));
0
214 else {-
215 QAbstractButton::nextCheckState();-
216 QCheckBox::checkStateSet();-
217 }
never executed: end of block
0
218}-
219-
220-
221-
222-
223bool QCheckBox::event(QEvent *e)-
224{-
225 QCheckBoxPrivate * const d = d_func();-
226 if (e->type() == QEvent::StyleChange
e->type() == Q...t::StyleChangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
227-
228-
229-
230 )-
231 d->setLayoutItemMargins(QStyle::SE_CheckBoxLayoutItem);
never executed: d->setLayoutItemMargins(QStyle::SE_CheckBoxLayoutItem);
0
232 return
never executed: return QAbstractButton::event(e);
QAbstractButton::event(e);
never executed: return QAbstractButton::event(e);
0
233}-
234-
235-
236-
237-
238-
Switch to Source codePreprocessed file

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