Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qgroupbox.h" | - |
43 | #ifndef QT_NO_GROUPBOX | - |
44 | #include "qapplication.h" | - |
45 | #include "qbitmap.h" | - |
46 | #include "qdrawutil.h" | - |
47 | #include "qevent.h" | - |
48 | #include "qlayout.h" | - |
49 | #include "qradiobutton.h" | - |
50 | #include "qstyle.h" | - |
51 | #include "qstyleoption.h" | - |
52 | #include "qstylepainter.h" | - |
53 | #ifndef QT_NO_ACCESSIBILITY | - |
54 | #include "qaccessible.h" | - |
55 | #endif | - |
56 | #include <private/qwidget_p.h> | - |
57 | | - |
58 | #include "qdebug.h" | - |
59 | | - |
60 | QT_BEGIN_NAMESPACE | - |
61 | | - |
62 | class QGroupBoxPrivate : public QWidgetPrivate | - |
63 | { | - |
64 | Q_DECLARE_PUBLIC(QGroupBox) | - |
65 | | - |
66 | public: | - |
67 | void skip(); | - |
68 | void init(); | - |
69 | void calculateFrame(); | - |
70 | QString title; | - |
71 | int align; | - |
72 | #ifndef QT_NO_SHORTCUT | - |
73 | int shortcutId; | - |
74 | #endif | - |
75 | | - |
76 | void _q_fixFocus(Qt::FocusReason reason); | - |
77 | void _q_setChildrenEnabled(bool b); | - |
78 | void click(); | - |
79 | bool flat; | - |
80 | bool checkable; | - |
81 | bool checked; | - |
82 | bool hover; | - |
83 | bool overCheckBox; | - |
84 | QStyle::SubControl pressedControl; | - |
85 | }; | - |
86 | | - |
87 | /*! | - |
88 | Initialize \a option with the values from this QGroupBox. This method | - |
89 | is useful for subclasses when they need a QStyleOptionGroupBox, but don't want | - |
90 | to fill in all the information themselves. | - |
91 | | - |
92 | \sa QStyleOption::initFrom() | - |
93 | */ | - |
94 | void QGroupBox::initStyleOption(QStyleOptionGroupBox *option) const | - |
95 | { | - |
96 | if (!option) partially evaluated: !option no Evaluation Count:0 | yes Evaluation Count:1009 |
| 0-1009 |
97 | return; | 0 |
98 | | - |
99 | Q_D(const QGroupBox); executed (the execution status of this line is deduced): const QGroupBoxPrivate * const d = d_func(); | - |
100 | option->initFrom(this); executed (the execution status of this line is deduced): option->initFrom(this); | - |
101 | option->text = d->title; executed (the execution status of this line is deduced): option->text = d->title; | - |
102 | option->lineWidth = 1; executed (the execution status of this line is deduced): option->lineWidth = 1; | - |
103 | option->midLineWidth = 0; executed (the execution status of this line is deduced): option->midLineWidth = 0; | - |
104 | option->textAlignment = Qt::Alignment(d->align); executed (the execution status of this line is deduced): option->textAlignment = Qt::Alignment(d->align); | - |
105 | option->activeSubControls |= d->pressedControl; executed (the execution status of this line is deduced): option->activeSubControls |= d->pressedControl; | - |
106 | option->subControls = QStyle::SC_GroupBoxFrame; executed (the execution status of this line is deduced): option->subControls = QStyle::SC_GroupBoxFrame; | - |
107 | | - |
108 | if (d->hover) partially evaluated: d->hover no Evaluation Count:0 | yes Evaluation Count:1009 |
| 0-1009 |
109 | option->state |= QStyle::State_MouseOver; never executed: option->state |= QStyle::State_MouseOver; | 0 |
110 | else | - |
111 | option->state &= ~QStyle::State_MouseOver; executed: option->state &= ~QStyle::State_MouseOver; Execution Count:1009 | 1009 |
112 | | - |
113 | if (d->flat) partially evaluated: d->flat no Evaluation Count:0 | yes Evaluation Count:1009 |
| 0-1009 |
114 | option->features |= QStyleOptionFrameV2::Flat; never executed: option->features |= QStyleOptionFrameV2::Flat; | 0 |
115 | | - |
116 | if (d->checkable) { evaluated: d->checkable yes Evaluation Count:157 | yes Evaluation Count:852 |
| 157-852 |
117 | option->subControls |= QStyle::SC_GroupBoxCheckBox; executed (the execution status of this line is deduced): option->subControls |= QStyle::SC_GroupBoxCheckBox; | - |
118 | option->state |= (d->checked ? QStyle::State_On : QStyle::State_Off); evaluated: d->checked yes Evaluation Count:113 | yes Evaluation Count:44 |
| 44-113 |
119 | if ((d->pressedControl == QStyle::SC_GroupBoxCheckBox evaluated: d->pressedControl == QStyle::SC_GroupBoxCheckBox yes Evaluation Count:8 | yes Evaluation Count:149 |
| 8-149 |
120 | || d->pressedControl == QStyle::SC_GroupBoxLabel) && (d->hover || d->overCheckBox)) evaluated: d->pressedControl == QStyle::SC_GroupBoxLabel yes Evaluation Count:4 | yes Evaluation Count:145 |
partially evaluated: d->hover no Evaluation Count:0 | yes Evaluation Count:12 |
partially evaluated: d->overCheckBox yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-145 |
121 | option->state |= QStyle::State_Sunken; executed: option->state |= QStyle::State_Sunken; Execution Count:12 | 12 |
122 | } executed: } Execution Count:157 | 157 |
123 | | - |
124 | if (!option->palette.isBrushSet(isEnabled() ? QPalette::Active : partially evaluated: !option->palette.isBrushSet(isEnabled() ? QPalette::Active : QPalette::Disabled, QPalette::WindowText) yes Evaluation Count:1009 | no Evaluation Count:0 |
| 0-1009 |
125 | QPalette::Disabled, QPalette::WindowText)) partially evaluated: !option->palette.isBrushSet(isEnabled() ? QPalette::Active : QPalette::Disabled, QPalette::WindowText) yes Evaluation Count:1009 | no Evaluation Count:0 |
| 0-1009 |
126 | option->textColor = QColor(style()->styleHint(QStyle::SH_GroupBox_TextLabelColor, executed: option->textColor = QColor(style()->styleHint(QStyle::SH_GroupBox_TextLabelColor, option, this)); Execution Count:1009 | 1009 |
127 | option, this)); executed: option->textColor = QColor(style()->styleHint(QStyle::SH_GroupBox_TextLabelColor, option, this)); Execution Count:1009 | 1009 |
128 | | - |
129 | if (!d->title.isEmpty()) evaluated: !d->title.isEmpty() yes Evaluation Count:634 | yes Evaluation Count:375 |
| 375-634 |
130 | option->subControls |= QStyle::SC_GroupBoxLabel; executed: option->subControls |= QStyle::SC_GroupBoxLabel; Execution Count:634 | 634 |
131 | } executed: } Execution Count:1009 | 1009 |
132 | | - |
133 | void QGroupBoxPrivate::click() | - |
134 | { | - |
135 | Q_Q(QGroupBox); executed (the execution status of this line is deduced): QGroupBox * const q = q_func(); | - |
136 | | - |
137 | QPointer<QGroupBox> guard(q); executed (the execution status of this line is deduced): QPointer<QGroupBox> guard(q); | - |
138 | q->setChecked(!checked); executed (the execution status of this line is deduced): q->setChecked(!checked); | - |
139 | if (!guard) partially evaluated: !guard no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
140 | return; | 0 |
141 | emit q->clicked(checked); executed (the execution status of this line is deduced): q->clicked(checked); | - |
142 | } executed: } Execution Count:6 | 6 |
143 | | - |
144 | /*! | - |
145 | \class QGroupBox | - |
146 | \brief The QGroupBox widget provides a group box frame with a title. | - |
147 | | - |
148 | \ingroup organizers | - |
149 | \ingroup geomanagement | - |
150 | \inmodule QtWidgets | - |
151 | | - |
152 | A group box provides a frame, a title on top, a keyboard shortcut, and | - |
153 | displays various other widgets inside itself. The keyboard shortcut moves | - |
154 | keyboard focus to one of the group box's child widgets. | - |
155 | | - |
156 | QGroupBox also lets you set the \l title (normally set in the | - |
157 | constructor) and the title's \l alignment. Group boxes can be | - |
158 | \l checkable. Child widgets in checkable group boxes are enabled or | - |
159 | disabled depending on whether or not the group box is \l checked. | - |
160 | | - |
161 | You can minimize the space consumption of a group box by enabling | - |
162 | the \l flat property. In most \l{QStyle}{styles}, enabling this | - |
163 | property results in the removal of the left, right and bottom | - |
164 | edges of the frame. | - |
165 | | - |
166 | QGroupBox doesn't automatically lay out the child widgets (which | - |
167 | are often \l{QCheckBox}es or \l{QRadioButton}s but can be any | - |
168 | widgets). The following example shows how we can set up a | - |
169 | QGroupBox with a layout: | - |
170 | | - |
171 | \snippet widgets/groupbox/window.cpp 2 | - |
172 | | - |
173 | \table 100% | - |
174 | \row \li \inlineimage windowsvista-groupbox.png Screenshot of a Windows Vista style group box | - |
175 | \li \inlineimage macintosh-groupbox.png Screenshot of a Macintosh style group box | - |
176 | \li \inlineimage fusion-groupbox.png Screenshot of a Fusion style group box | - |
177 | \row \li A \l{Windows Vista Style Widget Gallery}{Windows Vista style} group box. | - |
178 | \li A \l{Macintosh Style Widget Gallery}{Macintosh style} group box. | - |
179 | \li A \l{Fusion Style Widget Gallery}{Fusion style} group box. | - |
180 | \endtable | - |
181 | | - |
182 | \sa QButtonGroup, {Group Box Example} | - |
183 | */ | - |
184 | | - |
185 | | - |
186 | | - |
187 | /*! | - |
188 | Constructs a group box widget with the given \a parent but with no title. | - |
189 | */ | - |
190 | | - |
191 | QGroupBox::QGroupBox(QWidget *parent) | - |
192 | : QWidget(*new QGroupBoxPrivate, parent, 0) | - |
193 | { | - |
194 | Q_D(QGroupBox); executed (the execution status of this line is deduced): QGroupBoxPrivate * const d = d_func(); | - |
195 | d->init(); executed (the execution status of this line is deduced): d->init(); | - |
196 | } executed: } Execution Count:41 | 41 |
197 | | - |
198 | /*! | - |
199 | Constructs a group box with the given \a title and \a parent. | - |
200 | */ | - |
201 | | - |
202 | QGroupBox::QGroupBox(const QString &title, QWidget *parent) | - |
203 | : QWidget(*new QGroupBoxPrivate, parent, 0) | - |
204 | { | - |
205 | Q_D(QGroupBox); executed (the execution status of this line is deduced): QGroupBoxPrivate * const d = d_func(); | - |
206 | d->init(); executed (the execution status of this line is deduced): d->init(); | - |
207 | setTitle(title); executed (the execution status of this line is deduced): setTitle(title); | - |
208 | } executed: } Execution Count:26 | 26 |
209 | | - |
210 | | - |
211 | /*! | - |
212 | Destroys the group box. | - |
213 | */ | - |
214 | QGroupBox::~QGroupBox() | - |
215 | { | - |
216 | } | - |
217 | | - |
218 | void QGroupBoxPrivate::init() | - |
219 | { | - |
220 | Q_Q(QGroupBox); executed (the execution status of this line is deduced): QGroupBox * const q = q_func(); | - |
221 | align = Qt::AlignLeft; executed (the execution status of this line is deduced): align = Qt::AlignLeft; | - |
222 | #ifndef QT_NO_SHORTCUT | - |
223 | shortcutId = 0; executed (the execution status of this line is deduced): shortcutId = 0; | - |
224 | #endif | - |
225 | flat = false; executed (the execution status of this line is deduced): flat = false; | - |
226 | checkable = false; executed (the execution status of this line is deduced): checkable = false; | - |
227 | checked = true; executed (the execution status of this line is deduced): checked = true; | - |
228 | hover = false; executed (the execution status of this line is deduced): hover = false; | - |
229 | overCheckBox = false; executed (the execution status of this line is deduced): overCheckBox = false; | - |
230 | pressedControl = QStyle::SC_None; executed (the execution status of this line is deduced): pressedControl = QStyle::SC_None; | - |
231 | calculateFrame(); executed (the execution status of this line is deduced): calculateFrame(); | - |
232 | q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, executed (the execution status of this line is deduced): q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, | - |
233 | QSizePolicy::GroupBox)); executed (the execution status of this line is deduced): QSizePolicy::GroupBox)); | - |
234 | } executed: } Execution Count:67 | 67 |
235 | | - |
236 | void QGroupBox::setTitle(const QString &title) | - |
237 | { | - |
238 | Q_D(QGroupBox); executed (the execution status of this line is deduced): QGroupBoxPrivate * const d = d_func(); | - |
239 | if (d->title == title) // no change evaluated: d->title == title yes Evaluation Count:1 | yes Evaluation Count:54 |
| 1-54 |
240 | return; executed: return; Execution Count:1 | 1 |
241 | d->title = title; executed (the execution status of this line is deduced): d->title = title; | - |
242 | #ifndef QT_NO_SHORTCUT | - |
243 | releaseShortcut(d->shortcutId); executed (the execution status of this line is deduced): releaseShortcut(d->shortcutId); | - |
244 | d->shortcutId = grabShortcut(QKeySequence::mnemonic(title)); executed (the execution status of this line is deduced): d->shortcutId = grabShortcut(QKeySequence::mnemonic(title)); | - |
245 | #endif | - |
246 | d->calculateFrame(); executed (the execution status of this line is deduced): d->calculateFrame(); | - |
247 | | - |
248 | update(); executed (the execution status of this line is deduced): update(); | - |
249 | updateGeometry(); executed (the execution status of this line is deduced): updateGeometry(); | - |
250 | #ifndef QT_NO_ACCESSIBILITY | - |
251 | QAccessibleEvent event(this, QAccessible::NameChanged); executed (the execution status of this line is deduced): QAccessibleEvent event(this, QAccessible::NameChanged); | - |
252 | QAccessible::updateAccessibility(&event); executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&event); | - |
253 | #endif | - |
254 | } executed: } Execution Count:54 | 54 |
255 | | - |
256 | /*! | - |
257 | \property QGroupBox::title | - |
258 | \brief the group box title text | - |
259 | | - |
260 | The group box title text will have a keyboard shortcut if the title | - |
261 | contains an ampersand ('&') followed by a letter. | - |
262 | | - |
263 | \snippet code/src_gui_widgets_qgroupbox.cpp 0 | - |
264 | | - |
265 | In the example above, \uicontrol Alt+U moves the keyboard focus to the | - |
266 | group box. See the \l {QShortcut#mnemonic}{QShortcut} | - |
267 | documentation for details (to display an actual ampersand, use | - |
268 | '&&'). | - |
269 | | - |
270 | There is no default title text. | - |
271 | | - |
272 | \sa alignment | - |
273 | */ | - |
274 | | - |
275 | QString QGroupBox::title() const | - |
276 | { | - |
277 | Q_D(const QGroupBox); executed (the execution status of this line is deduced): const QGroupBoxPrivate * const d = d_func(); | - |
278 | return d->title; executed: return d->title; Execution Count:22 | 22 |
279 | } | - |
280 | | - |
281 | /*! | - |
282 | \property QGroupBox::alignment | - |
283 | \brief the alignment of the group box title. | - |
284 | | - |
285 | Most styles place the title at the top of the frame. The horizontal | - |
286 | alignment of the title can be specified using single values from | - |
287 | the following list: | - |
288 | | - |
289 | \list | - |
290 | \li Qt::AlignLeft aligns the title text with the left-hand side of the group box. | - |
291 | \li Qt::AlignRight aligns the title text with the right-hand side of the group box. | - |
292 | \li Qt::AlignHCenter aligns the title text with the horizontal center of the group box. | - |
293 | \endlist | - |
294 | | - |
295 | The default alignment is Qt::AlignLeft. | - |
296 | | - |
297 | \sa Qt::Alignment | - |
298 | */ | - |
299 | Qt::Alignment QGroupBox::alignment() const | - |
300 | { | - |
301 | Q_D(const QGroupBox); executed (the execution status of this line is deduced): const QGroupBoxPrivate * const d = d_func(); | - |
302 | return QFlag(d->align); executed: return QFlag(d->align); Execution Count:15 | 15 |
303 | } | - |
304 | | - |
305 | void QGroupBox::setAlignment(int alignment) | - |
306 | { | - |
307 | Q_D(QGroupBox); never executed (the execution status of this line is deduced): QGroupBoxPrivate * const d = d_func(); | - |
308 | d->align = alignment; never executed (the execution status of this line is deduced): d->align = alignment; | - |
309 | updateGeometry(); never executed (the execution status of this line is deduced): updateGeometry(); | - |
310 | update(); never executed (the execution status of this line is deduced): update(); | - |
311 | } | 0 |
312 | | - |
313 | /*! \reimp | - |
314 | */ | - |
315 | void QGroupBox::resizeEvent(QResizeEvent *e) | - |
316 | { | - |
317 | QWidget::resizeEvent(e); executed (the execution status of this line is deduced): QWidget::resizeEvent(e); | - |
318 | } executed: } Execution Count:24 | 24 |
319 | | - |
320 | /*! \reimp | - |
321 | */ | - |
322 | | - |
323 | void QGroupBox::paintEvent(QPaintEvent *) | - |
324 | { | - |
325 | QStylePainter paint(this); executed (the execution status of this line is deduced): QStylePainter paint(this); | - |
326 | QStyleOptionGroupBox option; executed (the execution status of this line is deduced): QStyleOptionGroupBox option; | - |
327 | initStyleOption(&option); executed (the execution status of this line is deduced): initStyleOption(&option); | - |
328 | paint.drawComplexControl(QStyle::CC_GroupBox, option); executed (the execution status of this line is deduced): paint.drawComplexControl(QStyle::CC_GroupBox, option); | - |
329 | } executed: } Execution Count:29 | 29 |
330 | | - |
331 | /*! \reimp */ | - |
332 | bool QGroupBox::event(QEvent *e) | - |
333 | { | - |
334 | Q_D(QGroupBox); executed (the execution status of this line is deduced): QGroupBoxPrivate * const d = d_func(); | - |
335 | #ifndef QT_NO_SHORTCUT | - |
336 | if (e->type() == QEvent::Shortcut) { partially evaluated: e->type() == QEvent::Shortcut no Evaluation Count:0 | yes Evaluation Count:760 |
| 0-760 |
337 | QShortcutEvent *se = static_cast<QShortcutEvent *>(e); never executed (the execution status of this line is deduced): QShortcutEvent *se = static_cast<QShortcutEvent *>(e); | - |
338 | if (se->shortcutId() == d->shortcutId) { never evaluated: se->shortcutId() == d->shortcutId | 0 |
339 | if (!isCheckable()) { never evaluated: !isCheckable() | 0 |
340 | d->_q_fixFocus(Qt::ShortcutFocusReason); never executed (the execution status of this line is deduced): d->_q_fixFocus(Qt::ShortcutFocusReason); | - |
341 | } else { | 0 |
342 | d->click(); never executed (the execution status of this line is deduced): d->click(); | - |
343 | setFocus(Qt::ShortcutFocusReason); never executed (the execution status of this line is deduced): setFocus(Qt::ShortcutFocusReason); | - |
344 | } | 0 |
345 | return true; never executed: return true; | 0 |
346 | } | - |
347 | } | 0 |
348 | #endif | - |
349 | QStyleOptionGroupBox box; executed (the execution status of this line is deduced): QStyleOptionGroupBox box; | - |
350 | initStyleOption(&box); executed (the execution status of this line is deduced): initStyleOption(&box); | - |
351 | switch (e->type()) { | - |
352 | case QEvent::HoverEnter: | - |
353 | case QEvent::HoverMove: { | - |
354 | QStyle::SubControl control = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box, never executed (the execution status of this line is deduced): QStyle::SubControl control = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box, | - |
355 | static_cast<QHoverEvent *>(e)->pos(), never executed (the execution status of this line is deduced): static_cast<QHoverEvent *>(e)->pos(), | - |
356 | this); never executed (the execution status of this line is deduced): this); | - |
357 | bool oldHover = d->hover; never executed (the execution status of this line is deduced): bool oldHover = d->hover; | - |
358 | d->hover = d->checkable && (control == QStyle::SC_GroupBoxLabel || control == QStyle::SC_GroupBoxCheckBox); never evaluated: d->checkable never evaluated: control == QStyle::SC_GroupBoxLabel never evaluated: control == QStyle::SC_GroupBoxCheckBox | 0 |
359 | if (oldHover != d->hover) { never evaluated: oldHover != d->hover | 0 |
360 | QRect rect = style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this) never executed (the execution status of this line is deduced): QRect rect = style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this) | - |
361 | | style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxLabel, this); never executed (the execution status of this line is deduced): | style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxLabel, this); | - |
362 | update(rect); never executed (the execution status of this line is deduced): update(rect); | - |
363 | } | 0 |
364 | return true; never executed: return true; | 0 |
365 | } | - |
366 | case QEvent::HoverLeave: | - |
367 | d->hover = false; never executed (the execution status of this line is deduced): d->hover = false; | - |
368 | if (d->checkable) { never evaluated: d->checkable | 0 |
369 | QRect rect = style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this) never executed (the execution status of this line is deduced): QRect rect = style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this) | - |
370 | | style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxLabel, this); never executed (the execution status of this line is deduced): | style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxLabel, this); | - |
371 | update(rect); never executed (the execution status of this line is deduced): update(rect); | - |
372 | } | 0 |
373 | return true; never executed: return true; | 0 |
374 | case QEvent::KeyPress: { | - |
375 | QKeyEvent *k = static_cast<QKeyEvent*>(e); executed (the execution status of this line is deduced): QKeyEvent *k = static_cast<QKeyEvent*>(e); | - |
376 | if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) { partially evaluated: !k->isAutoRepeat() yes Evaluation Count:3 | no Evaluation Count:0 |
partially evaluated: k->key() == Qt::Key_Select no Evaluation Count:0 | yes Evaluation Count:3 |
partially evaluated: k->key() == Qt::Key_Space no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
377 | d->pressedControl = QStyle::SC_GroupBoxCheckBox; never executed (the execution status of this line is deduced): d->pressedControl = QStyle::SC_GroupBoxCheckBox; | - |
378 | update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this)); never executed (the execution status of this line is deduced): update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this)); | - |
379 | return true; never executed: return true; | 0 |
380 | } | - |
381 | break; executed: break; Execution Count:3 | 3 |
382 | } | - |
383 | case QEvent::KeyRelease: { | - |
384 | QKeyEvent *k = static_cast<QKeyEvent*>(e); executed (the execution status of this line is deduced): QKeyEvent *k = static_cast<QKeyEvent*>(e); | - |
385 | if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) { partially evaluated: !k->isAutoRepeat() yes Evaluation Count:13 | no Evaluation Count:0 |
partially evaluated: k->key() == Qt::Key_Select no Evaluation Count:0 | yes Evaluation Count:13 |
partially evaluated: k->key() == Qt::Key_Space no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
386 | bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel never evaluated: d->pressedControl == QStyle::SC_GroupBoxLabel | 0 |
387 | || d->pressedControl == QStyle::SC_GroupBoxCheckBox); never evaluated: d->pressedControl == QStyle::SC_GroupBoxCheckBox | 0 |
388 | d->pressedControl = QStyle::SC_None; never executed (the execution status of this line is deduced): d->pressedControl = QStyle::SC_None; | - |
389 | if (toggle) | 0 |
390 | d->click(); never executed: d->click(); | 0 |
391 | return true; never executed: return true; | 0 |
392 | } | - |
393 | break; executed: break; Execution Count:13 | 13 |
394 | } | - |
395 | default: | - |
396 | break; executed: break; Execution Count:744 | 744 |
397 | } | - |
398 | return QWidget::event(e); executed: return QWidget::event(e); Execution Count:760 | 760 |
399 | } | - |
400 | | - |
401 | /*!\reimp */ | - |
402 | void QGroupBox::childEvent(QChildEvent *c) | - |
403 | { | - |
404 | Q_D(QGroupBox); executed (the execution status of this line is deduced): QGroupBoxPrivate * const d = d_func(); | - |
405 | if (c->type() != QEvent::ChildAdded || !c->child()->isWidgetType()) evaluated: c->type() != QEvent::ChildAdded yes Evaluation Count:89 | yes Evaluation Count:156 |
evaluated: !c->child()->isWidgetType() yes Evaluation Count:35 | yes Evaluation Count:121 |
| 35-156 |
406 | return; executed: return; Execution Count:124 | 124 |
407 | QWidget *w = (QWidget*)c->child(); executed (the execution status of this line is deduced): QWidget *w = (QWidget*)c->child(); | - |
408 | if (d->checkable) { evaluated: d->checkable yes Evaluation Count:9 | yes Evaluation Count:112 |
| 9-112 |
409 | if (d->checked) { evaluated: d->checked yes Evaluation Count:6 | yes Evaluation Count:3 |
| 3-6 |
410 | if (!w->testAttribute(Qt::WA_ForceDisabled)) partially evaluated: !w->testAttribute(Qt::WA_ForceDisabled) yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
411 | w->setEnabled(true); executed: w->setEnabled(true); Execution Count:6 | 6 |
412 | } else { executed: } Execution Count:6 | 6 |
413 | if (w->isEnabled()) { partially evaluated: w->isEnabled() yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
414 | w->setEnabled(false); executed (the execution status of this line is deduced): w->setEnabled(false); | - |
415 | w->setAttribute(Qt::WA_ForceDisabled, false); executed (the execution status of this line is deduced): w->setAttribute(Qt::WA_ForceDisabled, false); | - |
416 | } executed: } Execution Count:3 | 3 |
417 | } executed: } Execution Count:3 | 3 |
418 | } | - |
419 | } executed: } Execution Count:121 | 121 |
420 | | - |
421 | | - |
422 | /*! | - |
423 | \internal | - |
424 | | - |
425 | This private slot finds a widget in this group box that can accept | - |
426 | focus, and gives the focus to that widget. | - |
427 | */ | - |
428 | | - |
429 | void QGroupBoxPrivate::_q_fixFocus(Qt::FocusReason reason) | - |
430 | { | - |
431 | Q_Q(QGroupBox); executed (the execution status of this line is deduced): QGroupBox * const q = q_func(); | - |
432 | QWidget *fw = q->focusWidget(); executed (the execution status of this line is deduced): QWidget *fw = q->focusWidget(); | - |
433 | if (!fw || fw == q) { partially evaluated: !fw no Evaluation Count:0 | yes Evaluation Count:1 |
partially evaluated: fw == q yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
434 | QWidget * best = 0; executed (the execution status of this line is deduced): QWidget * best = 0; | - |
435 | QWidget * candidate = 0; executed (the execution status of this line is deduced): QWidget * candidate = 0; | - |
436 | QWidget * w = q; executed (the execution status of this line is deduced): QWidget * w = q; | - |
437 | while ((w = w->nextInFocusChain()) != q) { evaluated: (w = w->nextInFocusChain()) != q yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
438 | if (q->isAncestorOf(w) && (w->focusPolicy() & Qt::TabFocus) == Qt::TabFocus && w->isVisibleTo(q)) { partially evaluated: q->isAncestorOf(w) yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: (w->focusPolicy() & Qt::TabFocus) == Qt::TabFocus yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: w->isVisibleTo(q) yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
439 | if (!best && qobject_cast<QRadioButton*>(w) && ((QRadioButton*)w)->isChecked()) partially evaluated: !best yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: qobject_cast<QRadioButton*>(w) no Evaluation Count:0 | yes Evaluation Count:1 |
never evaluated: ((QRadioButton*)w)->isChecked() | 0-1 |
440 | // we prefer a checked radio button or a widget that | - |
441 | // already has focus, if there is one | - |
442 | best = w; never executed: best = w; | 0 |
443 | else | - |
444 | if (!candidate) partially evaluated: !candidate yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
445 | // but we'll accept anything that takes focus | - |
446 | candidate = w; executed: candidate = w; Execution Count:1 | 1 |
447 | } | - |
448 | } executed: } Execution Count:1 | 1 |
449 | if (best) partially evaluated: best no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
450 | fw = best; never executed: fw = best; | 0 |
451 | else if (candidate) partially evaluated: candidate yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
452 | fw = candidate; executed: fw = candidate; Execution Count:1 | 1 |
453 | } | - |
454 | if (fw) partially evaluated: fw yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
455 | fw->setFocus(reason); executed: fw->setFocus(reason); Execution Count:1 | 1 |
456 | } executed: } Execution Count:1 | 1 |
457 | | - |
458 | /* | - |
459 | Sets the right frame rect depending on the title. | - |
460 | */ | - |
461 | void QGroupBoxPrivate::calculateFrame() | - |
462 | { | - |
463 | Q_Q(QGroupBox); executed (the execution status of this line is deduced): QGroupBox * const q = q_func(); | - |
464 | QStyleOptionGroupBox box; executed (the execution status of this line is deduced): QStyleOptionGroupBox box; | - |
465 | q->initStyleOption(&box); executed (the execution status of this line is deduced): q->initStyleOption(&box); | - |
466 | QRect contentsRect = q->style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxContents, q); executed (the execution status of this line is deduced): QRect contentsRect = q->style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxContents, q); | - |
467 | q->setContentsMargins(contentsRect.left() - box.rect.left(), contentsRect.top() - box.rect.top(), executed (the execution status of this line is deduced): q->setContentsMargins(contentsRect.left() - box.rect.left(), contentsRect.top() - box.rect.top(), | - |
468 | box.rect.right() - contentsRect.right(), box.rect.bottom() - contentsRect.bottom()); executed (the execution status of this line is deduced): box.rect.right() - contentsRect.right(), box.rect.bottom() - contentsRect.bottom()); | - |
469 | setLayoutItemMargins(QStyle::SE_GroupBoxLayoutItem, &box); executed (the execution status of this line is deduced): setLayoutItemMargins(QStyle::SE_GroupBoxLayoutItem, &box); | - |
470 | } executed: } Execution Count:155 | 155 |
471 | | - |
472 | /*! \reimp | - |
473 | */ | - |
474 | void QGroupBox::focusInEvent(QFocusEvent *fe) | - |
475 | { // note no call to super | - |
476 | Q_D(QGroupBox); executed (the execution status of this line is deduced): QGroupBoxPrivate * const d = d_func(); | - |
477 | if (focusPolicy() == Qt::NoFocus) { partially evaluated: focusPolicy() == Qt::NoFocus yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
478 | d->_q_fixFocus(fe->reason()); executed (the execution status of this line is deduced): d->_q_fixFocus(fe->reason()); | - |
479 | } else { executed: } Execution Count:1 | 1 |
480 | QWidget::focusInEvent(fe); never executed (the execution status of this line is deduced): QWidget::focusInEvent(fe); | - |
481 | } | 0 |
482 | } | - |
483 | | - |
484 | | - |
485 | /*! | - |
486 | \reimp | - |
487 | */ | - |
488 | QSize QGroupBox::minimumSizeHint() const | - |
489 | { | - |
490 | Q_D(const QGroupBox); executed (the execution status of this line is deduced): const QGroupBoxPrivate * const d = d_func(); | - |
491 | QStyleOptionGroupBox option; executed (the execution status of this line is deduced): QStyleOptionGroupBox option; | - |
492 | initStyleOption(&option); executed (the execution status of this line is deduced): initStyleOption(&option); | - |
493 | | - |
494 | QFontMetrics metrics(fontMetrics()); executed (the execution status of this line is deduced): QFontMetrics metrics(fontMetrics()); | - |
495 | | - |
496 | int baseWidth = metrics.width(d->title) + metrics.width(QLatin1Char(' ')); executed (the execution status of this line is deduced): int baseWidth = metrics.width(d->title) + metrics.width(QLatin1Char(' ')); | - |
497 | int baseHeight = metrics.height(); executed (the execution status of this line is deduced): int baseHeight = metrics.height(); | - |
498 | if (d->checkable) { evaluated: d->checkable yes Evaluation Count:4 | yes Evaluation Count:38 |
| 4-38 |
499 | baseWidth += style()->pixelMetric(QStyle::PM_IndicatorWidth); executed (the execution status of this line is deduced): baseWidth += style()->pixelMetric(QStyle::PM_IndicatorWidth); | - |
500 | baseWidth += style()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing); executed (the execution status of this line is deduced): baseWidth += style()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing); | - |
501 | baseHeight = qMax(baseHeight, style()->pixelMetric(QStyle::PM_IndicatorHeight)); executed (the execution status of this line is deduced): baseHeight = qMax(baseHeight, style()->pixelMetric(QStyle::PM_IndicatorHeight)); | - |
502 | } executed: } Execution Count:4 | 4 |
503 | | - |
504 | QSize size = style()->sizeFromContents(QStyle::CT_GroupBox, &option, QSize(baseWidth, baseHeight), this); executed (the execution status of this line is deduced): QSize size = style()->sizeFromContents(QStyle::CT_GroupBox, &option, QSize(baseWidth, baseHeight), this); | - |
505 | return size.expandedTo(QWidget::minimumSizeHint()); executed: return size.expandedTo(QWidget::minimumSizeHint()); Execution Count:42 | 42 |
506 | } | - |
507 | | - |
508 | /*! | - |
509 | \property QGroupBox::flat | - |
510 | \brief whether the group box is painted flat or has a frame | - |
511 | | - |
512 | A group box usually consists of a surrounding frame with a title | - |
513 | at the top. If this property is enabled, only the top part of the frame is | - |
514 | drawn in most styles; otherwise, the whole frame is drawn. | - |
515 | | - |
516 | By default, this property is disabled, i.e., group boxes are not flat unless | - |
517 | explicitly specified. | - |
518 | | - |
519 | \b{Note:} In some styles, flat and non-flat group boxes have similar | - |
520 | representations and may not be as distinguishable as they are in other | - |
521 | styles. | - |
522 | | - |
523 | \sa title | - |
524 | */ | - |
525 | bool QGroupBox::isFlat() const | - |
526 | { | - |
527 | Q_D(const QGroupBox); executed (the execution status of this line is deduced): const QGroupBoxPrivate * const d = d_func(); | - |
528 | return d->flat; executed: return d->flat; Execution Count:42 | 42 |
529 | } | - |
530 | | - |
531 | void QGroupBox::setFlat(bool b) | - |
532 | { | - |
533 | Q_D(QGroupBox); never executed (the execution status of this line is deduced): QGroupBoxPrivate * const d = d_func(); | - |
534 | if (d->flat == b) never evaluated: d->flat == b | 0 |
535 | return; | 0 |
536 | d->flat = b; never executed (the execution status of this line is deduced): d->flat = b; | - |
537 | updateGeometry(); never executed (the execution status of this line is deduced): updateGeometry(); | - |
538 | update(); never executed (the execution status of this line is deduced): update(); | - |
539 | } | 0 |
540 | | - |
541 | | - |
542 | /*! | - |
543 | \property QGroupBox::checkable | - |
544 | \brief whether the group box has a checkbox in its title | - |
545 | | - |
546 | If this property is true, the group box displays its title using | - |
547 | a checkbox in place of an ordinary label. If the checkbox is checked, | - |
548 | the group box's children are enabled; otherwise, they are disabled and | - |
549 | inaccessible. | - |
550 | | - |
551 | By default, group boxes are not checkable. | - |
552 | | - |
553 | If this property is enabled for a group box, it will also be initially | - |
554 | checked to ensure that its contents are enabled. | - |
555 | | - |
556 | \sa checked | - |
557 | */ | - |
558 | void QGroupBox::setCheckable(bool checkable) | - |
559 | { | - |
560 | Q_D(QGroupBox); executed (the execution status of this line is deduced): QGroupBoxPrivate * const d = d_func(); | - |
561 | | - |
562 | bool wasCheckable = d->checkable; executed (the execution status of this line is deduced): bool wasCheckable = d->checkable; | - |
563 | d->checkable = checkable; executed (the execution status of this line is deduced): d->checkable = checkable; | - |
564 | | - |
565 | if (checkable) { evaluated: checkable yes Evaluation Count:20 | yes Evaluation Count:7 |
| 7-20 |
566 | setChecked(true); executed (the execution status of this line is deduced): setChecked(true); | - |
567 | if (!wasCheckable) { partially evaluated: !wasCheckable yes Evaluation Count:20 | no Evaluation Count:0 |
| 0-20 |
568 | setFocusPolicy(Qt::StrongFocus); executed (the execution status of this line is deduced): setFocusPolicy(Qt::StrongFocus); | - |
569 | d->_q_setChildrenEnabled(true); executed (the execution status of this line is deduced): d->_q_setChildrenEnabled(true); | - |
570 | updateGeometry(); executed (the execution status of this line is deduced): updateGeometry(); | - |
571 | } executed: } Execution Count:20 | 20 |
572 | } else { executed: } Execution Count:20 | 20 |
573 | if (wasCheckable) { partially evaluated: wasCheckable no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
574 | setFocusPolicy(Qt::NoFocus); never executed (the execution status of this line is deduced): setFocusPolicy(Qt::NoFocus); | - |
575 | d->_q_setChildrenEnabled(true); never executed (the execution status of this line is deduced): d->_q_setChildrenEnabled(true); | - |
576 | updateGeometry(); never executed (the execution status of this line is deduced): updateGeometry(); | - |
577 | } | 0 |
578 | d->_q_setChildrenEnabled(true); executed (the execution status of this line is deduced): d->_q_setChildrenEnabled(true); | - |
579 | } executed: } Execution Count:7 | 7 |
580 | | - |
581 | if (wasCheckable != checkable) { evaluated: wasCheckable != checkable yes Evaluation Count:20 | yes Evaluation Count:7 |
| 7-20 |
582 | d->calculateFrame(); executed (the execution status of this line is deduced): d->calculateFrame(); | - |
583 | update(); executed (the execution status of this line is deduced): update(); | - |
584 | } executed: } Execution Count:20 | 20 |
585 | } executed: } Execution Count:27 | 27 |
586 | | - |
587 | bool QGroupBox::isCheckable() const | - |
588 | { | - |
589 | Q_D(const QGroupBox); executed (the execution status of this line is deduced): const QGroupBoxPrivate * const d = d_func(); | - |
590 | return d->checkable; executed: return d->checkable; Execution Count:8 | 8 |
591 | } | - |
592 | | - |
593 | | - |
594 | bool QGroupBox::isChecked() const | - |
595 | { | - |
596 | Q_D(const QGroupBox); executed (the execution status of this line is deduced): const QGroupBoxPrivate * const d = d_func(); | - |
597 | return d->checkable && d->checked; executed: return d->checkable && d->checked; Execution Count:42 | 42 |
598 | } | - |
599 | | - |
600 | | - |
601 | /*! | - |
602 | \fn void QGroupBox::toggled(bool on) | - |
603 | | - |
604 | If the group box is checkable, this signal is emitted when the check box | - |
605 | is toggled. \a on is true if the check box is checked; otherwise, it is false. | - |
606 | | - |
607 | \sa checkable | - |
608 | */ | - |
609 | | - |
610 | | - |
611 | /*! | - |
612 | \fn void QGroupBox::clicked(bool checked) | - |
613 | \since 4.2 | - |
614 | | - |
615 | This signal is emitted when the check box is activated (i.e., pressed down | - |
616 | then released while the mouse cursor is inside the button), or when the | - |
617 | shortcut key is typed. Notably, this signal is \e not emitted if you call | - |
618 | setChecked(). | - |
619 | | - |
620 | If the check box is checked, \a checked is true; it is false if the check | - |
621 | box is unchecked. | - |
622 | | - |
623 | \sa checkable, toggled(), checked | - |
624 | */ | - |
625 | | - |
626 | /*! | - |
627 | \property QGroupBox::checked | - |
628 | \brief whether the group box is checked | - |
629 | | - |
630 | If the group box is checkable, it is displayed with a check box. | - |
631 | If the check box is checked, the group box's children are enabled; | - |
632 | otherwise, the children are disabled and are inaccessible to the user. | - |
633 | | - |
634 | By default, checkable group boxes are also checked. | - |
635 | | - |
636 | \sa checkable | - |
637 | */ | - |
638 | void QGroupBox::setChecked(bool b) | - |
639 | { | - |
640 | Q_D(QGroupBox); executed (the execution status of this line is deduced): QGroupBoxPrivate * const d = d_func(); | - |
641 | if (d->checkable && b != d->checked) { evaluated: d->checkable yes Evaluation Count:51 | yes Evaluation Count:6 |
evaluated: b != d->checked yes Evaluation Count:23 | yes Evaluation Count:28 |
| 6-51 |
642 | update(); executed (the execution status of this line is deduced): update(); | - |
643 | d->checked = b; executed (the execution status of this line is deduced): d->checked = b; | - |
644 | d->_q_setChildrenEnabled(b); executed (the execution status of this line is deduced): d->_q_setChildrenEnabled(b); | - |
645 | #ifndef QT_NO_ACCESSIBILITY | - |
646 | QAccessible::State st; executed (the execution status of this line is deduced): QAccessible::State st; | - |
647 | st.checked = true; executed (the execution status of this line is deduced): st.checked = true; | - |
648 | QAccessibleStateChangeEvent *ev = new QAccessibleStateChangeEvent(this, st); executed (the execution status of this line is deduced): QAccessibleStateChangeEvent *ev = new QAccessibleStateChangeEvent(this, st); | - |
649 | QAccessible::updateAccessibility(ev); executed (the execution status of this line is deduced): QAccessible::updateAccessibility(ev); | - |
650 | #endif | - |
651 | emit toggled(b); executed (the execution status of this line is deduced): toggled(b); | - |
652 | } executed: } Execution Count:23 | 23 |
653 | } executed: } Execution Count:57 | 57 |
654 | | - |
655 | /* | - |
656 | sets all children of the group box except the qt_groupbox_checkbox | - |
657 | to either disabled/enabled | - |
658 | */ | - |
659 | void QGroupBoxPrivate::_q_setChildrenEnabled(bool b) | - |
660 | { | - |
661 | Q_Q(QGroupBox); executed (the execution status of this line is deduced): QGroupBox * const q = q_func(); | - |
662 | QObjectList childList = q->children(); executed (the execution status of this line is deduced): QObjectList childList = q->children(); | - |
663 | for (int i = 0; i < childList.size(); ++i) { evaluated: i < childList.size() yes Evaluation Count:14 | yes Evaluation Count:53 |
| 14-53 |
664 | QObject *o = childList.at(i); executed (the execution status of this line is deduced): QObject *o = childList.at(i); | - |
665 | if (o->isWidgetType()) { evaluated: o->isWidgetType() yes Evaluation Count:12 | yes Evaluation Count:2 |
| 2-12 |
666 | QWidget *w = static_cast<QWidget *>(o); executed (the execution status of this line is deduced): QWidget *w = static_cast<QWidget *>(o); | - |
667 | if (b) { evaluated: b yes Evaluation Count:4 | yes Evaluation Count:8 |
| 4-8 |
668 | if (!w->testAttribute(Qt::WA_ForceDisabled)) partially evaluated: !w->testAttribute(Qt::WA_ForceDisabled) yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
669 | w->setEnabled(true); executed: w->setEnabled(true); Execution Count:4 | 4 |
670 | } else { executed: } Execution Count:4 | 4 |
671 | if (w->isEnabled()) { evaluated: w->isEnabled() yes Evaluation Count:7 | yes Evaluation Count:1 |
| 1-7 |
672 | w->setEnabled(false); executed (the execution status of this line is deduced): w->setEnabled(false); | - |
673 | w->setAttribute(Qt::WA_ForceDisabled, false); executed (the execution status of this line is deduced): w->setAttribute(Qt::WA_ForceDisabled, false); | - |
674 | } executed: } Execution Count:7 | 7 |
675 | } executed: } Execution Count:8 | 8 |
676 | } | - |
677 | } executed: } Execution Count:14 | 14 |
678 | } executed: } Execution Count:53 | 53 |
679 | | - |
680 | /*! \reimp */ | - |
681 | void QGroupBox::changeEvent(QEvent *ev) | - |
682 | { | - |
683 | Q_D(QGroupBox); executed (the execution status of this line is deduced): QGroupBoxPrivate * const d = d_func(); | - |
684 | if (ev->type() == QEvent::EnabledChange) { evaluated: ev->type() == QEvent::EnabledChange yes Evaluation Count:18 | yes Evaluation Count:159 |
| 18-159 |
685 | if (d->checkable && isEnabled()) { partially evaluated: d->checkable yes Evaluation Count:18 | no Evaluation Count:0 |
evaluated: isEnabled() yes Evaluation Count:9 | yes Evaluation Count:9 |
| 0-18 |
686 | // we are being enabled - disable children | - |
687 | if (!d->checked) evaluated: !d->checked yes Evaluation Count:3 | yes Evaluation Count:6 |
| 3-6 |
688 | d->_q_setChildrenEnabled(false); executed: d->_q_setChildrenEnabled(false); Execution Count:3 | 3 |
689 | } executed: } Execution Count:9 | 9 |
690 | } else if (ev->type() == QEvent::FontChange executed: } Execution Count:18 partially evaluated: ev->type() == QEvent::FontChange no Evaluation Count:0 | yes Evaluation Count:159 |
| 0-159 |
691 | #ifdef Q_OS_MAC executed (the execution status of this line is deduced):
| - |
692 | || ev->type() == QEvent::MacSizeChange executed (the execution status of this line is deduced):
| - |
693 | #endif executed (the execution status of this line is deduced):
| - |
694 | || ev->type() == QEvent::StyleChange) { evaluated: ev->type() == QEvent::StyleChange yes Evaluation Count:14 | yes Evaluation Count:145 |
| 14-145 |
695 | d->calculateFrame(); executed (the execution status of this line is deduced): d->calculateFrame(); | - |
696 | } executed: } Execution Count:14 | 14 |
697 | QWidget::changeEvent(ev); executed (the execution status of this line is deduced): QWidget::changeEvent(ev); | - |
698 | } executed: } Execution Count:177 | 177 |
699 | | - |
700 | /*! \reimp */ | - |
701 | void QGroupBox::mousePressEvent(QMouseEvent *event) | - |
702 | { | - |
703 | if (event->button() != Qt::LeftButton) { partially evaluated: event->button() != Qt::LeftButton no Evaluation Count:0 | yes Evaluation Count:17 |
| 0-17 |
704 | event->ignore(); never executed (the execution status of this line is deduced): event->ignore(); | - |
705 | return; | 0 |
706 | } | - |
707 | | - |
708 | Q_D(QGroupBox); executed (the execution status of this line is deduced): QGroupBoxPrivate * const d = d_func(); | - |
709 | QStyleOptionGroupBox box; executed (the execution status of this line is deduced): QStyleOptionGroupBox box; | - |
710 | initStyleOption(&box); executed (the execution status of this line is deduced): initStyleOption(&box); | - |
711 | d->pressedControl = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box, executed (the execution status of this line is deduced): d->pressedControl = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box, | - |
712 | event->pos(), this); executed (the execution status of this line is deduced): event->pos(), this); | - |
713 | if (d->checkable && (d->pressedControl & (QStyle::SC_GroupBoxCheckBox | QStyle::SC_GroupBoxLabel))) { evaluated: d->checkable yes Evaluation Count:12 | yes Evaluation Count:5 |
evaluated: (d->pressedControl & (QStyle::SC_GroupBoxCheckBox | QStyle::SC_GroupBoxLabel)) yes Evaluation Count:6 | yes Evaluation Count:6 |
| 5-12 |
714 | d->overCheckBox = true; executed (the execution status of this line is deduced): d->overCheckBox = true; | - |
715 | update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this)); executed (the execution status of this line is deduced): update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this)); | - |
716 | } executed: } Execution Count:6 | 6 |
717 | } executed: } Execution Count:17 | 17 |
718 | | - |
719 | /*! \reimp */ | - |
720 | void QGroupBox::mouseMoveEvent(QMouseEvent *event) | - |
721 | { | - |
722 | Q_D(QGroupBox); never executed (the execution status of this line is deduced): QGroupBoxPrivate * const d = d_func(); | - |
723 | QStyleOptionGroupBox box; never executed (the execution status of this line is deduced): QStyleOptionGroupBox box; | - |
724 | initStyleOption(&box); never executed (the execution status of this line is deduced): initStyleOption(&box); | - |
725 | QStyle::SubControl pressed = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box, never executed (the execution status of this line is deduced): QStyle::SubControl pressed = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box, | - |
726 | event->pos(), this); never executed (the execution status of this line is deduced): event->pos(), this); | - |
727 | bool oldOverCheckBox = d->overCheckBox; never executed (the execution status of this line is deduced): bool oldOverCheckBox = d->overCheckBox; | - |
728 | d->overCheckBox = (pressed == QStyle::SC_GroupBoxCheckBox || pressed == QStyle::SC_GroupBoxLabel); never evaluated: pressed == QStyle::SC_GroupBoxCheckBox never evaluated: pressed == QStyle::SC_GroupBoxLabel | 0 |
729 | if (d->checkable && (d->pressedControl == QStyle::SC_GroupBoxCheckBox || d->pressedControl == QStyle::SC_GroupBoxLabel) never evaluated: d->checkable never evaluated: d->pressedControl == QStyle::SC_GroupBoxCheckBox never evaluated: d->pressedControl == QStyle::SC_GroupBoxLabel | 0 |
730 | && (d->overCheckBox != oldOverCheckBox)) never evaluated: (d->overCheckBox != oldOverCheckBox) | 0 |
731 | update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this)); never executed: update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this)); | 0 |
732 | } | 0 |
733 | | - |
734 | /*! \reimp */ | - |
735 | void QGroupBox::mouseReleaseEvent(QMouseEvent *event) | - |
736 | { | - |
737 | if (event->button() != Qt::LeftButton) { partially evaluated: event->button() != Qt::LeftButton no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
738 | event->ignore(); never executed (the execution status of this line is deduced): event->ignore(); | - |
739 | return; | 0 |
740 | } | - |
741 | | - |
742 | Q_D(QGroupBox); executed (the execution status of this line is deduced): QGroupBoxPrivate * const d = d_func(); | - |
743 | if (!d->overCheckBox) { evaluated: !d->overCheckBox yes Evaluation Count:12 | yes Evaluation Count:6 |
| 6-12 |
744 | event->ignore(); executed (the execution status of this line is deduced): event->ignore(); | - |
745 | return; executed: return; Execution Count:12 | 12 |
746 | } | - |
747 | QStyleOptionGroupBox box; never executed (the execution status of this line is deduced): QStyleOptionGroupBox box; | - |
748 | initStyleOption(&box); never executed (the execution status of this line is deduced): initStyleOption(&box); | - |
749 | QStyle::SubControl released = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box, never executed (the execution status of this line is deduced): QStyle::SubControl released = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box, | - |
750 | event->pos(), this); never executed (the execution status of this line is deduced): event->pos(), this); | - |
751 | bool toggle = d->checkable && (released == QStyle::SC_GroupBoxLabel partially evaluated: d->checkable yes Evaluation Count:6 | no Evaluation Count:0 |
evaluated: released == QStyle::SC_GroupBoxLabel yes Evaluation Count:2 | yes Evaluation Count:4 |
| 0-6 |
752 | || released == QStyle::SC_GroupBoxCheckBox); partially evaluated: released == QStyle::SC_GroupBoxCheckBox yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
753 | d->pressedControl = QStyle::SC_None; never executed (the execution status of this line is deduced): d->pressedControl = QStyle::SC_None; | - |
754 | d->overCheckBox = false; never executed (the execution status of this line is deduced): d->overCheckBox = false; | - |
755 | if (toggle) partially evaluated: toggle yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
756 | d->click(); executed: d->click(); Execution Count:6 | 6 |
757 | else if (d->checkable) never evaluated: d->checkable | 0 |
758 | update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this)); never executed: update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this)); | 0 |
759 | } | - |
760 | | - |
761 | | - |
762 | QT_END_NAMESPACE | - |
763 | | - |
764 | #include "moc_qgroupbox.cpp" | - |
765 | | - |
766 | #endif //QT_NO_GROUPBOX | - |
767 | | - |
| | |