Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | | - |
21 | | - |
22 | | - |
23 | | - |
24 | | - |
25 | | - |
26 | | - |
27 | | - |
28 | | - |
29 | | - |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
36 | | - |
37 | | - |
38 | | - |
39 | | - |
40 | #include "qgroupbox.h" | - |
41 | #ifndef QT_NO_GROUPBOX | - |
42 | #include "qapplication.h" | - |
43 | #include "qbitmap.h" | - |
44 | #include "qdrawutil.h" | - |
45 | #include "qevent.h" | - |
46 | #include "qlayout.h" | - |
47 | #include "qradiobutton.h" | - |
48 | #include "qstyle.h" | - |
49 | #include "qstyleoption.h" | - |
50 | #include "qstylepainter.h" | - |
51 | #ifndef QT_NO_ACCESSIBILITY | - |
52 | #include "qaccessible.h" | - |
53 | #endif | - |
54 | #include <private/qwidget_p.h> | - |
55 | | - |
56 | #include "qdebug.h" | - |
57 | | - |
58 | QT_BEGIN_NAMESPACE | - |
59 | | - |
60 | class QGroupBoxPrivate : public QWidgetPrivate | - |
61 | { | - |
62 | Q_DECLARE_PUBLIC(QGroupBox) | - |
63 | | - |
64 | public: | - |
65 | void skip(); | - |
66 | void init(); | - |
67 | void calculateFrame(); | - |
68 | QString title; | - |
69 | int align; | - |
70 | #ifndef QT_NO_SHORTCUT | - |
71 | int shortcutId; | - |
72 | #endif | - |
73 | | - |
74 | void _q_fixFocus(Qt::FocusReason reason); | - |
75 | void _q_setChildrenEnabled(bool b); | - |
76 | void click(); | - |
77 | bool flat; | - |
78 | bool checkable; | - |
79 | bool checked; | - |
80 | bool hover; | - |
81 | bool overCheckBox; | - |
82 | QStyle::SubControl pressedControl; | - |
83 | }; | - |
84 | | - |
85 | | - |
86 | | - |
87 | | - |
88 | | - |
89 | | - |
90 | | - |
91 | | - |
92 | void QGroupBox::initStyleOption(QStyleOptionGroupBox *option) const | - |
93 | { | - |
94 | if (!option)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
95 | return; never executed: return; | 0 |
96 | | - |
97 | Q_D(const QGroupBox); | - |
98 | option->initFrom(this); | - |
99 | option->text = d->title; | - |
100 | option->lineWidth = 1; | - |
101 | option->midLineWidth = 0; | - |
102 | option->textAlignment = Qt::Alignment(d->align); | - |
103 | option->activeSubControls |= d->pressedControl; | - |
104 | option->subControls = QStyle::SC_GroupBoxFrame; | - |
105 | | - |
106 | if (d->hover)option->state|=.setFlag(QStyle::State_MouseOver; | - |
| else | |
| option, d->state &= ~QStyle::State_MouseOver;hover); | |
107 | if (d->flat)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
108 | option->features |= QStyleOptionFrame::Flat; never executed: option->features |= QStyleOptionFrame::Flat; | 0 |
109 | | - |
110 | if (d->checkable) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
111 | option->subControls |= QStyle::SC_GroupBoxCheckBox; | - |
112 | option->state |= (d->checked ? QStyle::State_On : QStyle::State_Off);TRUE | never evaluated | FALSE | never evaluated |
| 0 |
113 | if ((d->pressedControl == QStyle::SC_GroupBoxCheckBoxTRUE | never evaluated | FALSE | never evaluated |
| 0 |
114 | || d->pressedControl == QStyle::SC_GroupBoxLabel) && (d->hover || d->overCheckBox))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
115 | option->state |= QStyle::State_Sunken; never executed: option->state |= QStyle::State_Sunken; | 0 |
116 | } never executed: end of block | 0 |
117 | | - |
118 | if (!option->palette.isBrushSet(isEnabled() ? QPalette::Active :TRUE | never evaluated | FALSE | never evaluated |
| 0 |
119 | QPalette::Disabled, QPalette::WindowText))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
120 | option->textColor = QColor(style()->styleHint(QStyle::SH_GroupBox_TextLabelColor, never executed: option->textColor = QColor(style()->styleHint(QStyle::SH_GroupBox_TextLabelColor, option, this)); | 0 |
121 | option, this)); never executed: option->textColor = QColor(style()->styleHint(QStyle::SH_GroupBox_TextLabelColor, option, this)); | 0 |
122 | | - |
123 | if (!d->title.isEmpty())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
124 | option->subControls |= QStyle::SC_GroupBoxLabel; never executed: option->subControls |= QStyle::SC_GroupBoxLabel; | 0 |
125 | } never executed: end of block | 0 |
126 | | - |
127 | void QGroupBoxPrivate::click() | - |
128 | { | - |
129 | Q_Q(QGroupBox); | - |
130 | | - |
131 | QPointer<QGroupBox> guard(q); | - |
132 | q->setChecked(!checked); | - |
133 | if (!guard) | - |
134 | return; | - |
135 | emit q->clicked(checked); | - |
136 | } | - |
137 | | - |
138 | | - |
139 | | - |
140 | | - |
141 | | - |
142 | | - |
143 | | - |
144 | | - |
145 | | - |
146 | | - |
147 | | - |
148 | | - |
149 | | - |
150 | | - |
151 | | - |
152 | | - |
153 | | - |
154 | | - |
155 | | - |
156 | | - |
157 | | - |
158 | | - |
159 | | - |
160 | | - |
161 | | - |
162 | | - |
163 | | - |
164 | | - |
165 | | - |
166 | | - |
167 | | - |
168 | | - |
169 | | - |
170 | | - |
171 | | - |
172 | | - |
173 | | - |
174 | | - |
175 | | - |
176 | | - |
177 | | - |
178 | | - |
179 | | - |
180 | | - |
181 | | - |
182 | | - |
183 | | - |
184 | | - |
185 | QGroupBox::QGroupBox(QWidget *parent) | - |
186 | : QWidget(*new QGroupBoxPrivate, parent, 0) | - |
187 | { | - |
188 | Q_D(QGroupBox); | - |
189 | d->init(); | - |
190 | } | - |
191 | | - |
192 | | - |
193 | | - |
194 | | - |
195 | | - |
196 | QGroupBox::QGroupBox(const QString &title, QWidget *parent) | - |
197 | : QWidget(*new QGroupBoxPrivate, parent, 0) | - |
198 | { | - |
199 | Q_D(QGroupBox); | - |
200 | d->init(); | - |
201 | setTitle(title); | - |
202 | } | - |
203 | | - |
204 | | - |
205 | | - |
206 | | - |
207 | | - |
208 | QGroupBox::~QGroupBox() | - |
209 | { | - |
210 | } | - |
211 | | - |
212 | void QGroupBoxPrivate::init() | - |
213 | { | - |
214 | Q_Q(QGroupBox); | - |
215 | align = Qt::AlignLeft; | - |
216 | #ifndef QT_NO_SHORTCUT | - |
217 | shortcutId = 0; | - |
218 | #endif | - |
219 | flat = false; | - |
220 | checkable = false; | - |
221 | checked = true; | - |
222 | hover = false; | - |
223 | overCheckBox = false; | - |
224 | pressedControl = QStyle::SC_None; | - |
225 | calculateFrame(); | - |
226 | q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, | - |
227 | QSizePolicy::GroupBox)); | - |
228 | } | - |
229 | | - |
230 | void QGroupBox::setTitle(const QString &title) | - |
231 | { | - |
232 | Q_D(QGroupBox); | - |
233 | if (d->title == title) | - |
234 | return; | - |
235 | d->title = title; | - |
236 | #ifndef QT_NO_SHORTCUT | - |
237 | releaseShortcut(d->shortcutId); | - |
238 | d->shortcutId = grabShortcut(QKeySequence::mnemonic(title)); | - |
239 | #endif | - |
240 | d->calculateFrame(); | - |
241 | | - |
242 | update(); | - |
243 | updateGeometry(); | - |
244 | #ifndef QT_NO_ACCESSIBILITY | - |
245 | QAccessibleEvent event(this, QAccessible::NameChanged); | - |
246 | QAccessible::updateAccessibility(&event); | - |
247 | #endif | - |
248 | } | - |
249 | | - |
250 | | - |
251 | | - |
252 | | - |
253 | | - |
254 | | - |
255 | | - |
256 | | - |
257 | | - |
258 | | - |
259 | | - |
260 | | - |
261 | | - |
262 | | - |
263 | | - |
264 | | - |
265 | | - |
266 | | - |
267 | | - |
268 | | - |
269 | QString QGroupBox::title() const | - |
270 | { | - |
271 | Q_D(const QGroupBox); | - |
272 | return d->title; | - |
273 | } | - |
274 | | - |
275 | | - |
276 | | - |
277 | | - |
278 | | - |
279 | | - |
280 | | - |
281 | | - |
282 | | - |
283 | | - |
284 | | - |
285 | | - |
286 | | - |
287 | | - |
288 | | - |
289 | | - |
290 | | - |
291 | | - |
292 | | - |
293 | Qt::Alignment QGroupBox::alignment() const | - |
294 | { | - |
295 | Q_D(const QGroupBox); | - |
296 | return QFlag(d->align); | - |
297 | } | - |
298 | | - |
299 | void QGroupBox::setAlignment(int alignment) | - |
300 | { | - |
301 | Q_D(QGroupBox); | - |
302 | d->align = alignment; | - |
303 | updateGeometry(); | - |
304 | update(); | - |
305 | } | - |
306 | | - |
307 | | - |
308 | | - |
309 | void QGroupBox::resizeEvent(QResizeEvent *e) | - |
310 | { | - |
311 | QWidget::resizeEvent(e); | - |
312 | } | - |
313 | | - |
314 | | - |
315 | | - |
316 | | - |
317 | void QGroupBox::paintEvent(QPaintEvent *) | - |
318 | { | - |
319 | QStylePainter paint(this); | - |
320 | QStyleOptionGroupBox option; | - |
321 | initStyleOption(&option); | - |
322 | paint.drawComplexControl(QStyle::CC_GroupBox, option); | - |
323 | } | - |
324 | | - |
325 | | - |
326 | bool QGroupBox::event(QEvent *e) | - |
327 | { | - |
328 | Q_D(QGroupBox); | - |
329 | #ifndef QT_NO_SHORTCUT | - |
330 | if (e->type() == QEvent::Shortcut) { | - |
331 | QShortcutEvent *se = static_cast<QShortcutEvent *>(e); | - |
332 | if (se->shortcutId() == d->shortcutId) { | - |
333 | if (!isCheckable()) { | - |
334 | d->_q_fixFocus(Qt::ShortcutFocusReason); | - |
335 | } else { | - |
336 | d->click(); | - |
337 | setFocus(Qt::ShortcutFocusReason); | - |
338 | } | - |
339 | return true; | - |
340 | } | - |
341 | } | - |
342 | #endif | - |
343 | QStyleOptionGroupBox box; | - |
344 | initStyleOption(&box); | - |
345 | switch (e->type()) { | - |
346 | case QEvent::HoverEnter: | - |
347 | case QEvent::HoverMove: { | - |
348 | QStyle::SubControl control = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box, | - |
349 | static_cast<QHoverEvent *>(e)->pos(), | - |
350 | this); | - |
351 | bool oldHover = d->hover; | - |
352 | d->hover = d->checkable && (control == QStyle::SC_GroupBoxLabel || control == QStyle::SC_GroupBoxCheckBox); | - |
353 | if (oldHover != d->hover) { | - |
354 | QRect rect = style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this) | - |
355 | | style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxLabel, this); | - |
356 | update(rect); | - |
357 | } | - |
358 | return true; | - |
359 | } | - |
360 | case QEvent::HoverLeave: | - |
361 | d->hover = false; | - |
362 | if (d->checkable) { | - |
363 | QRect rect = style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this) | - |
364 | | style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxLabel, this); | - |
365 | update(rect); | - |
366 | } | - |
367 | return true; | - |
368 | case QEvent::KeyPress: { | - |
369 | QKeyEvent *k = static_cast<QKeyEvent*>(e); | - |
370 | if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) { | - |
371 | d->pressedControl = QStyle::SC_GroupBoxCheckBox; | - |
372 | update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this)); | - |
373 | return true; | - |
374 | } | - |
375 | break; | - |
376 | } | - |
377 | case QEvent::KeyRelease: { | - |
378 | QKeyEvent *k = static_cast<QKeyEvent*>(e); | - |
379 | if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) { | - |
380 | bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel | - |
381 | || d->pressedControl == QStyle::SC_GroupBoxCheckBox); | - |
382 | d->pressedControl = QStyle::SC_None; | - |
383 | if (toggle) | - |
384 | d->click(); | - |
385 | return true; | - |
386 | } | - |
387 | break; | - |
388 | } | - |
389 | default: | - |
390 | break; | - |
391 | } | - |
392 | return QWidget::event(e); | - |
393 | } | - |
394 | | - |
395 | | - |
396 | void QGroupBox::childEvent(QChildEvent *c) | - |
397 | { | - |
398 | Q_D(QGroupBox); | - |
399 | if (c->type() != QEvent::ChildAdded || !c->child()->isWidgetType()) | - |
400 | return; | - |
401 | QWidget *w = (QWidget*)c->child(); | - |
402 | if (w->isWindow()) | - |
403 | return; | - |
404 | if (d->checkable) { | - |
405 | if (d->checked) { | - |
406 | if (!w->testAttribute(Qt::WA_ForceDisabled)) | - |
407 | w->setEnabled(true); | - |
408 | } else { | - |
409 | if (w->isEnabled()) { | - |
410 | w->setEnabled(false); | - |
411 | w->setAttribute(Qt::WA_ForceDisabled, false); | - |
412 | } | - |
413 | } | - |
414 | } | - |
415 | } | - |
416 | | - |
417 | | - |
418 | | - |
419 | | - |
420 | | - |
421 | | - |
422 | | - |
423 | | - |
424 | | - |
425 | void QGroupBoxPrivate::_q_fixFocus(Qt::FocusReason reason) | - |
426 | { | - |
427 | Q_Q(QGroupBox); | - |
428 | QWidget *fw = q->focusWidget(); | - |
429 | if (!fw || fw == q) { | - |
430 | QWidget * best = 0; | - |
431 | QWidget * candidate = 0; | - |
432 | QWidget * w = q; | - |
433 | while ((w = w->nextInFocusChain()) != q) { | - |
434 | if (q->isAncestorOf(w) && (w->focusPolicy() & Qt::TabFocus) == Qt::TabFocus && w->isVisibleTo(q)) { | - |
435 | if (!best && qobject_cast<QRadioButton*>(w) && ((QRadioButton*)w)->isChecked()) | - |
436 | | - |
437 | | - |
438 | best = w; | - |
439 | else | - |
440 | if (!candidate) | - |
441 | | - |
442 | candidate = w; | - |
443 | } | - |
444 | } | - |
445 | if (best) | - |
446 | fw = best; | - |
447 | else if (candidate) | - |
448 | fw = candidate; | - |
449 | } | - |
450 | if (fw) | - |
451 | fw->setFocus(reason); | - |
452 | } | - |
453 | | - |
454 | | - |
455 | | - |
456 | | - |
457 | void QGroupBoxPrivate::calculateFrame() | - |
458 | { | - |
459 | Q_Q(QGroupBox); | - |
460 | QStyleOptionGroupBox box; | - |
461 | q->initStyleOption(&box); | - |
462 | QRect contentsRect = q->style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxContents, q); | - |
463 | q->setContentsMargins(contentsRect.left() - box.rect.left(), contentsRect.top() - box.rect.top(), | - |
464 | box.rect.right() - contentsRect.right(), box.rect.bottom() - contentsRect.bottom()); | - |
465 | setLayoutItemMargins(QStyle::SE_GroupBoxLayoutItem, &box); | - |
466 | } | - |
467 | | - |
468 | | - |
469 | | - |
470 | void QGroupBox::focusInEvent(QFocusEvent *fe) | - |
471 | { | - |
472 | Q_D(QGroupBox); | - |
473 | if (focusPolicy() == Qt::NoFocus) { | - |
474 | d->_q_fixFocus(fe->reason()); | - |
475 | } else { | - |
476 | QWidget::focusInEvent(fe); | - |
477 | } | - |
478 | } | - |
479 | | - |
480 | | - |
481 | | - |
482 | | - |
483 | | - |
484 | QSize QGroupBox::minimumSizeHint() const | - |
485 | { | - |
486 | Q_D(const QGroupBox); | - |
487 | QStyleOptionGroupBox option; | - |
488 | initStyleOption(&option); | - |
489 | | - |
490 | QFontMetrics metrics(fontMetrics()); | - |
491 | | - |
492 | int baseWidth = metrics.width(d->title) + metrics.width(QLatin1Char(' ')); | - |
493 | int baseHeight = metrics.height(); | - |
494 | if (d->checkable) { | - |
495 | baseWidth += style()->pixelMetric(QStyle::PM_IndicatorWidth); | - |
496 | baseWidth += style()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing); | - |
497 | baseHeight = qMax(baseHeight, style()->pixelMetric(QStyle::PM_IndicatorHeight)); | - |
498 | } | - |
499 | | - |
500 | QSize size = style()->sizeFromContents(QStyle::CT_GroupBox, &option, QSize(baseWidth, baseHeight), this); | - |
501 | return size.expandedTo(QWidget::minimumSizeHint()); | - |
502 | } | - |
503 | | - |
504 | | - |
505 | | - |
506 | | - |
507 | | - |
508 | | - |
509 | | - |
510 | | - |
511 | | - |
512 | | - |
513 | | - |
514 | | - |
515 | | - |
516 | | - |
517 | | - |
518 | | - |
519 | | - |
520 | | - |
521 | bool QGroupBox::isFlat() const | - |
522 | { | - |
523 | Q_D(const QGroupBox); | - |
524 | return d->flat; | - |
525 | } | - |
526 | | - |
527 | void QGroupBox::setFlat(bool b) | - |
528 | { | - |
529 | Q_D(QGroupBox); | - |
530 | if (d->flat == b) | - |
531 | return; | - |
532 | d->flat = b; | - |
533 | updateGeometry(); | - |
534 | update(); | - |
535 | } | - |
536 | | - |
537 | | - |
538 | | - |
539 | | - |
540 | | - |
541 | | - |
542 | | - |
543 | | - |
544 | | - |
545 | | - |
546 | | - |
547 | | - |
548 | | - |
549 | | - |
550 | | - |
551 | | - |
552 | | - |
553 | | - |
554 | void QGroupBox::setCheckable(bool checkable) | - |
555 | { | - |
556 | Q_D(QGroupBox); | - |
557 | | - |
558 | bool wasCheckable = d->checkable; | - |
559 | d->checkable = checkable; | - |
560 | | - |
561 | if (checkable) { | - |
562 | setChecked(true); | - |
563 | if (!wasCheckable) { | - |
564 | setFocusPolicy(Qt::StrongFocus); | - |
565 | d->_q_setChildrenEnabled(true); | - |
566 | updateGeometry(); | - |
567 | } | - |
568 | } else { | - |
569 | if (wasCheckable) { | - |
570 | setFocusPolicy(Qt::NoFocus); | - |
571 | d->_q_setChildrenEnabled(true); | - |
572 | updateGeometry(); | - |
573 | } | - |
574 | d->_q_setChildrenEnabled(true); | - |
575 | } | - |
576 | | - |
577 | if (wasCheckable != checkable) { | - |
578 | d->calculateFrame(); | - |
579 | update(); | - |
580 | } | - |
581 | } | - |
582 | | - |
583 | bool QGroupBox::isCheckable() const | - |
584 | { | - |
585 | Q_D(const QGroupBox); | - |
586 | return d->checkable; | - |
587 | } | - |
588 | | - |
589 | | - |
590 | bool QGroupBox::isChecked() const | - |
591 | { | - |
592 | Q_D(const QGroupBox); | - |
593 | return d->checkable && d->checked; | - |
594 | } | - |
595 | | - |
596 | | - |
597 | | - |
598 | | - |
599 | | - |
600 | | - |
601 | | - |
602 | | - |
603 | | - |
604 | | - |
605 | | - |
606 | | - |
607 | | - |
608 | | - |
609 | | - |
610 | | - |
611 | | - |
612 | | - |
613 | | - |
614 | | - |
615 | | - |
616 | | - |
617 | | - |
618 | | - |
619 | | - |
620 | | - |
621 | | - |
622 | | - |
623 | | - |
624 | | - |
625 | | - |
626 | | - |
627 | | - |
628 | | - |
629 | | - |
630 | | - |
631 | | - |
632 | | - |
633 | | - |
634 | void QGroupBox::setChecked(bool b) | - |
635 | { | - |
636 | Q_D(QGroupBox); | - |
637 | if (d->checkable && b != d->checked) { | - |
638 | update(); | - |
639 | d->checked = b; | - |
640 | d->_q_setChildrenEnabled(b); | - |
641 | #ifndef QT_NO_ACCESSIBILITY | - |
642 | QAccessible::State st; | - |
643 | st.checked = true; | - |
644 | QAccessibleStateChangeEvent e(this, st); | - |
645 | QAccessible::updateAccessibility(&e); | - |
646 | #endif | - |
647 | emit toggled(b); | - |
648 | } | - |
649 | } | - |
650 | | - |
651 | | - |
652 | | - |
653 | | - |
654 | | - |
655 | void QGroupBoxPrivate::_q_setChildrenEnabled(bool b) | - |
656 | { | - |
657 | Q_Q(QGroupBox); | - |
658 | QObjectList childList = q->children();for (int i = 0; i < childList.size(); ++i) {QObject *o = childList.at(i);: q->children()) { | - |
659 | if (o->isWidgetType()) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
660 | QWidget *w = static_cast<QWidget *>(o); | - |
661 | if (b) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
662 | if (!w->testAttribute(Qt::WA_ForceDisabled))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
663 | w->setEnabled(true); never executed: w->setEnabled(true); | 0 |
664 | } else { never executed: end of block | 0 |
665 | if (w->isEnabled()) {TRUE | never evaluated | FALSE | never evaluated |
| 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 | | - |
675 | void QGroupBox::changeEvent(QEvent *ev) | - |
676 | { | - |
677 | Q_D(QGroupBox); | - |
678 | if (ev->type() == QEvent::EnabledChange) { | - |
679 | if (d->checkable && isEnabled()) { | - |
680 | | - |
681 | if (!d->checked) | - |
682 | d->_q_setChildrenEnabled(false); | - |
683 | } | - |
684 | } else if (ev->type() == QEvent::FontChange | - |
685 | #ifdef Q_OS_MAC | - |
686 | || ev->type() == QEvent::MacSizeChange | - |
687 | #endif | - |
688 | || ev->type() == QEvent::StyleChange) { | - |
689 | d->calculateFrame(); | - |
690 | } | - |
691 | QWidget::changeEvent(ev); | - |
692 | } | - |
693 | | - |
694 | | - |
695 | void QGroupBox::mousePressEvent(QMouseEvent *event) | - |
696 | { | - |
697 | if (event->button() != Qt::LeftButton) {TRUE | never evaluated | FALSE | never evaluated |
| 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))) {TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
708 | d->overCheckBox = true; | - |
709 | update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this)); | - |
710 | } else { never executed: end of block | 0 |
711 | event->ignore(); | - |
712 | } never executed: end of block | 0 |
713 | } | - |
714 | | - |
715 | | - |
716 | void QGroupBox::mouseMoveEvent(QMouseEvent *event) | - |
717 | { | - |
718 | Q_D(QGroupBox); | - |
719 | QStyleOptionGroupBox box; | - |
720 | initStyleOption(&box); | - |
721 | QStyle::SubControl pressed = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box, | - |
722 | event->pos(), this); | - |
723 | bool oldOverCheckBox = d->overCheckBox; | - |
724 | d->overCheckBox = (pressed == QStyle::SC_GroupBoxCheckBox || pressed == QStyle::SC_GroupBoxLabel);TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
725 | if (d->checkable && (d->pressedControl == QStyle::SC_GroupBoxCheckBox || d->pressedControl == QStyle::SC_GroupBoxLabel)TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
726 | && (d->overCheckBox != oldOverCheckBox))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
727 | 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 |
728 | | - |
729 | event->ignore(); | - |
730 | } never executed: end of block | 0 |
731 | | - |
732 | | - |
733 | void QGroupBox::mouseReleaseEvent(QMouseEvent *event) | - |
734 | { | - |
735 | if (event->button() != Qt::LeftButton) { | - |
736 | event->ignore(); | - |
737 | return; | - |
738 | } | - |
739 | | - |
740 | Q_D(QGroupBox); | - |
741 | if (!d->overCheckBox) { | - |
742 | event->ignore(); | - |
743 | return; | - |
744 | } | - |
745 | QStyleOptionGroupBox box; | - |
746 | initStyleOption(&box); | - |
747 | QStyle::SubControl released = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box, | - |
748 | event->pos(), this); | - |
749 | bool toggle = d->checkable && (released == QStyle::SC_GroupBoxLabel | - |
750 | || released == QStyle::SC_GroupBoxCheckBox); | - |
751 | d->pressedControl = QStyle::SC_None; | - |
752 | d->overCheckBox = false; | - |
753 | if (toggle) | - |
754 | d->click(); | - |
755 | else if (d->checkable) | - |
756 | update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this)); | - |
757 | } | - |
758 | | - |
759 | | - |
760 | QT_END_NAMESPACE | - |
761 | | - |
762 | #include "moc_qgroupbox.cpp" | - |
763 | | - |
764 | #endif //QT_NO_GROUPBOX | - |
| | |