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