| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qgroupbox.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||
| 8 | class QGroupBoxPrivate : public QWidgetPrivate | - | ||||||||||||||||||||||||
| 9 | { | - | ||||||||||||||||||||||||
| 10 | inline QGroupBox* q_func() { return static_cast<QGroupBox *>(q_ptr); } inline const QGroupBox* q_func() const { return static_cast<const QGroupBox *>(q_ptr); } friend class QGroupBox; | - | ||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||
| 12 | public: | - | ||||||||||||||||||||||||
| 13 | void skip(); | - | ||||||||||||||||||||||||
| 14 | void init(); | - | ||||||||||||||||||||||||
| 15 | void calculateFrame(); | - | ||||||||||||||||||||||||
| 16 | QString title; | - | ||||||||||||||||||||||||
| 17 | int align; | - | ||||||||||||||||||||||||
| 18 | - | |||||||||||||||||||||||||
| 19 | int shortcutId; | - | ||||||||||||||||||||||||
| 20 | - | |||||||||||||||||||||||||
| 21 | - | |||||||||||||||||||||||||
| 22 | void _q_fixFocus(Qt::FocusReason reason); | - | ||||||||||||||||||||||||
| 23 | void _q_setChildrenEnabled(bool b); | - | ||||||||||||||||||||||||
| 24 | void click(); | - | ||||||||||||||||||||||||
| 25 | bool flat; | - | ||||||||||||||||||||||||
| 26 | bool checkable; | - | ||||||||||||||||||||||||
| 27 | bool checked; | - | ||||||||||||||||||||||||
| 28 | bool hover; | - | ||||||||||||||||||||||||
| 29 | bool overCheckBox; | - | ||||||||||||||||||||||||
| 30 | QStyle::SubControl pressedControl; | - | ||||||||||||||||||||||||
| 31 | }; | - | ||||||||||||||||||||||||
| 32 | void QGroupBox::initStyleOption(QStyleOptionGroupBox *option) const | - | ||||||||||||||||||||||||
| 33 | { | - | ||||||||||||||||||||||||
| 34 | if (!option
| 0 | ||||||||||||||||||||||||
| 35 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 36 | - | |||||||||||||||||||||||||
| 37 | const QGroupBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 38 | option->initFrom(this); | - | ||||||||||||||||||||||||
| 39 | option->text = d->title; | - | ||||||||||||||||||||||||
| 40 | option->lineWidth = 1; | - | ||||||||||||||||||||||||
| 41 | option->midLineWidth = 0; | - | ||||||||||||||||||||||||
| 42 | option->textAlignment = Qt::Alignment(d->align); | - | ||||||||||||||||||||||||
| 43 | option->activeSubControls |= d->pressedControl; | - | ||||||||||||||||||||||||
| 44 | option->subControls = QStyle::SC_GroupBoxFrame; | - | ||||||||||||||||||||||||
| 45 | - | |||||||||||||||||||||||||
| 46 | if (d->hover
| 0 | ||||||||||||||||||||||||
| 47 | option->state |= QStyle::State_MouseOver; never executed: option->state |= QStyle::State_MouseOver; | 0 | ||||||||||||||||||||||||
| 48 | else | - | ||||||||||||||||||||||||
| 49 | option->state &= ~QStyle::State_MouseOver; never executed: option->state &= ~QStyle::State_MouseOver; | 0 | ||||||||||||||||||||||||
| 50 | - | |||||||||||||||||||||||||
| 51 | if (d->flat
| 0 | ||||||||||||||||||||||||
| 52 | option->features |= QStyleOptionFrame::Flat; never executed: option->features |= QStyleOptionFrame::Flat; | 0 | ||||||||||||||||||||||||
| 53 | - | |||||||||||||||||||||||||
| 54 | if (d->checkable
| 0 | ||||||||||||||||||||||||
| 55 | option->subControls |= QStyle::SC_GroupBoxCheckBox; | - | ||||||||||||||||||||||||
| 56 | option->state |= (d->checked
| 0 | ||||||||||||||||||||||||
| 57 | if ((d->pressedControl == QStyle::SC_GroupBoxCheckBox
| 0 | ||||||||||||||||||||||||
| 58 | || d->pressedControl == QStyle::SC_GroupBoxLabel
| 0 | ||||||||||||||||||||||||
| 59 | option->state |= QStyle::State_Sunken; never executed: option->state |= QStyle::State_Sunken; | 0 | ||||||||||||||||||||||||
| 60 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 61 | - | |||||||||||||||||||||||||
| 62 | if (!option->palette.isBrushSet(isEnabled() ? QPalette::Active :
| 0 | ||||||||||||||||||||||||
| 63 | QPalette::Disabled, QPalette::WindowText)
| 0 | ||||||||||||||||||||||||
| 64 | option->textColor = QColor(style()->styleHint(QStyle::SH_GroupBox_TextLabelColor, never executed: option->textColor = QColor(style()->styleHint(QStyle::SH_GroupBox_TextLabelColor, option, this)); | 0 | ||||||||||||||||||||||||
| 65 | option, this)); never executed: option->textColor = QColor(style()->styleHint(QStyle::SH_GroupBox_TextLabelColor, option, this)); | 0 | ||||||||||||||||||||||||
| 66 | - | |||||||||||||||||||||||||
| 67 | if (!d->title.isEmpty()
| 0 | ||||||||||||||||||||||||
| 68 | option->subControls |= QStyle::SC_GroupBoxLabel; never executed: option->subControls |= QStyle::SC_GroupBoxLabel; | 0 | ||||||||||||||||||||||||
| 69 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 70 | - | |||||||||||||||||||||||||
| 71 | void QGroupBoxPrivate::click() | - | ||||||||||||||||||||||||
| 72 | { | - | ||||||||||||||||||||||||
| 73 | QGroupBox * const q = q_func(); | - | ||||||||||||||||||||||||
| 74 | - | |||||||||||||||||||||||||
| 75 | QPointer<QGroupBox> guard(q); | - | ||||||||||||||||||||||||
| 76 | q->setChecked(!checked); | - | ||||||||||||||||||||||||
| 77 | if (!guard
| 0 | ||||||||||||||||||||||||
| 78 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 79 | q->clicked(checked); | - | ||||||||||||||||||||||||
| 80 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 81 | QGroupBox::QGroupBox(QWidget *parent) | - | ||||||||||||||||||||||||
| 82 | : QWidget(*new QGroupBoxPrivate, parent, 0) | - | ||||||||||||||||||||||||
| 83 | { | - | ||||||||||||||||||||||||
| 84 | QGroupBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 85 | d->init(); | - | ||||||||||||||||||||||||
| 86 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 87 | - | |||||||||||||||||||||||||
| 88 | - | |||||||||||||||||||||||||
| 89 | - | |||||||||||||||||||||||||
| 90 | - | |||||||||||||||||||||||||
| 91 | - | |||||||||||||||||||||||||
| 92 | QGroupBox::QGroupBox(const QString &title, QWidget *parent) | - | ||||||||||||||||||||||||
| 93 | : QWidget(*new QGroupBoxPrivate, parent, 0) | - | ||||||||||||||||||||||||
| 94 | { | - | ||||||||||||||||||||||||
| 95 | QGroupBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 96 | d->init(); | - | ||||||||||||||||||||||||
| 97 | setTitle(title); | - | ||||||||||||||||||||||||
| 98 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 99 | - | |||||||||||||||||||||||||
| 100 | - | |||||||||||||||||||||||||
| 101 | - | |||||||||||||||||||||||||
| 102 | - | |||||||||||||||||||||||||
| 103 | - | |||||||||||||||||||||||||
| 104 | QGroupBox::~QGroupBox() | - | ||||||||||||||||||||||||
| 105 | { | - | ||||||||||||||||||||||||
| 106 | } | - | ||||||||||||||||||||||||
| 107 | - | |||||||||||||||||||||||||
| 108 | void QGroupBoxPrivate::init() | - | ||||||||||||||||||||||||
| 109 | { | - | ||||||||||||||||||||||||
| 110 | QGroupBox * const q = q_func(); | - | ||||||||||||||||||||||||
| 111 | align = Qt::AlignLeft; | - | ||||||||||||||||||||||||
| 112 | - | |||||||||||||||||||||||||
| 113 | shortcutId = 0; | - | ||||||||||||||||||||||||
| 114 | - | |||||||||||||||||||||||||
| 115 | flat = false; | - | ||||||||||||||||||||||||
| 116 | checkable = false; | - | ||||||||||||||||||||||||
| 117 | checked = true; | - | ||||||||||||||||||||||||
| 118 | hover = false; | - | ||||||||||||||||||||||||
| 119 | overCheckBox = false; | - | ||||||||||||||||||||||||
| 120 | pressedControl = QStyle::SC_None; | - | ||||||||||||||||||||||||
| 121 | calculateFrame(); | - | ||||||||||||||||||||||||
| 122 | q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, | - | ||||||||||||||||||||||||
| 123 | QSizePolicy::GroupBox)); | - | ||||||||||||||||||||||||
| 124 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 125 | - | |||||||||||||||||||||||||
| 126 | void QGroupBox::setTitle(const QString &title) | - | ||||||||||||||||||||||||
| 127 | { | - | ||||||||||||||||||||||||
| 128 | QGroupBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 129 | if (d->title == title
| 0 | ||||||||||||||||||||||||
| 130 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 131 | d->title = title; | - | ||||||||||||||||||||||||
| 132 | - | |||||||||||||||||||||||||
| 133 | releaseShortcut(d->shortcutId); | - | ||||||||||||||||||||||||
| 134 | d->shortcutId = grabShortcut(QKeySequence::mnemonic(title)); | - | ||||||||||||||||||||||||
| 135 | - | |||||||||||||||||||||||||
| 136 | d->calculateFrame(); | - | ||||||||||||||||||||||||
| 137 | - | |||||||||||||||||||||||||
| 138 | update(); | - | ||||||||||||||||||||||||
| 139 | updateGeometry(); | - | ||||||||||||||||||||||||
| 140 | - | |||||||||||||||||||||||||
| 141 | QAccessibleEvent event(this, QAccessible::NameChanged); | - | ||||||||||||||||||||||||
| 142 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||
| 143 | - | |||||||||||||||||||||||||
| 144 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 145 | QString QGroupBox::title() const | - | ||||||||||||||||||||||||
| 146 | { | - | ||||||||||||||||||||||||
| 147 | const QGroupBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 148 | return never executed: d->title;return d->title;never executed: return d->title; | 0 | ||||||||||||||||||||||||
| 149 | } | - | ||||||||||||||||||||||||
| 150 | Qt::Alignment QGroupBox::alignment() const | - | ||||||||||||||||||||||||
| 151 | { | - | ||||||||||||||||||||||||
| 152 | const QGroupBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 153 | return never executed: QFlag(d->align);return QFlag(d->align);never executed: return QFlag(d->align); | 0 | ||||||||||||||||||||||||
| 154 | } | - | ||||||||||||||||||||||||
| 155 | - | |||||||||||||||||||||||||
| 156 | void QGroupBox::setAlignment(int alignment) | - | ||||||||||||||||||||||||
| 157 | { | - | ||||||||||||||||||||||||
| 158 | QGroupBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 159 | d->align = alignment; | - | ||||||||||||||||||||||||
| 160 | updateGeometry(); | - | ||||||||||||||||||||||||
| 161 | update(); | - | ||||||||||||||||||||||||
| 162 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 163 | - | |||||||||||||||||||||||||
| 164 | - | |||||||||||||||||||||||||
| 165 | - | |||||||||||||||||||||||||
| 166 | void QGroupBox::resizeEvent(QResizeEvent *e) | - | ||||||||||||||||||||||||
| 167 | { | - | ||||||||||||||||||||||||
| 168 | QWidget::resizeEvent(e); | - | ||||||||||||||||||||||||
| 169 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||
| 171 | - | |||||||||||||||||||||||||
| 172 | - | |||||||||||||||||||||||||
| 173 | - | |||||||||||||||||||||||||
| 174 | void QGroupBox::paintEvent(QPaintEvent *) | - | ||||||||||||||||||||||||
| 175 | { | - | ||||||||||||||||||||||||
| 176 | QStylePainter paint(this); | - | ||||||||||||||||||||||||
| 177 | QStyleOptionGroupBox option; | - | ||||||||||||||||||||||||
| 178 | initStyleOption(&option); | - | ||||||||||||||||||||||||
| 179 | paint.drawComplexControl(QStyle::CC_GroupBox, option); | - | ||||||||||||||||||||||||
| 180 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 181 | - | |||||||||||||||||||||||||
| 182 | - | |||||||||||||||||||||||||
| 183 | bool QGroupBox::event(QEvent *e) | - | ||||||||||||||||||||||||
| 184 | { | - | ||||||||||||||||||||||||
| 185 | QGroupBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 186 | - | |||||||||||||||||||||||||
| 187 | if (e->type() == QEvent::Shortcut
| 0 | ||||||||||||||||||||||||
| 188 | QShortcutEvent *se = static_cast<QShortcutEvent *>(e); | - | ||||||||||||||||||||||||
| 189 | if (se->shortcutId() == d->shortcutId
| 0 | ||||||||||||||||||||||||
| 190 | if (!isCheckable()
| 0 | ||||||||||||||||||||||||
| 191 | d->_q_fixFocus(Qt::ShortcutFocusReason); | - | ||||||||||||||||||||||||
| 192 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 193 | d->click(); | - | ||||||||||||||||||||||||
| 194 | setFocus(Qt::ShortcutFocusReason); | - | ||||||||||||||||||||||||
| 195 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 196 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 197 | } | - | ||||||||||||||||||||||||
| 198 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 199 | - | |||||||||||||||||||||||||
| 200 | QStyleOptionGroupBox box; | - | ||||||||||||||||||||||||
| 201 | initStyleOption(&box); | - | ||||||||||||||||||||||||
| 202 | switch (e->type()) { | - | ||||||||||||||||||||||||
| 203 | case never executed: QEvent::HoverEnter:case QEvent::HoverEnter:never executed: case QEvent::HoverEnter: | 0 | ||||||||||||||||||||||||
| 204 | case never executed: QEvent::HoverMove:case QEvent::HoverMove:never executed: {case QEvent::HoverMove: | 0 | ||||||||||||||||||||||||
| 205 | QStyle::SubControl control = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box, | - | ||||||||||||||||||||||||
| 206 | static_cast<QHoverEvent *>(e)->pos(), | - | ||||||||||||||||||||||||
| 207 | this); | - | ||||||||||||||||||||||||
| 208 | bool oldHover = d->hover; | - | ||||||||||||||||||||||||
| 209 | d->hover = d->checkable
| 0 | ||||||||||||||||||||||||
| 210 | if (oldHover != d->hover
| 0 | ||||||||||||||||||||||||
| 211 | QRect rect = style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this) | - | ||||||||||||||||||||||||
| 212 | | style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxLabel, this); | - | ||||||||||||||||||||||||
| 213 | update(rect); | - | ||||||||||||||||||||||||
| 214 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 215 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 216 | } | - | ||||||||||||||||||||||||
| 217 | case never executed: QEvent::HoverLeave:case QEvent::HoverLeave:never executed: case QEvent::HoverLeave: | 0 | ||||||||||||||||||||||||
| 218 | d->hover = false; | - | ||||||||||||||||||||||||
| 219 | if (d->checkable
| 0 | ||||||||||||||||||||||||
| 220 | QRect rect = style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this) | - | ||||||||||||||||||||||||
| 221 | | style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxLabel, this); | - | ||||||||||||||||||||||||
| 222 | update(rect); | - | ||||||||||||||||||||||||
| 223 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 224 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 225 | case never executed: QEvent::KeyPress:case QEvent::KeyPress:never executed: {case QEvent::KeyPress: | 0 | ||||||||||||||||||||||||
| 226 | QKeyEvent *k = static_cast<QKeyEvent*>(e); | - | ||||||||||||||||||||||||
| 227 | if (!k->isAutoRepeat()
| 0 | ||||||||||||||||||||||||
| 228 | d->pressedControl = QStyle::SC_GroupBoxCheckBox; | - | ||||||||||||||||||||||||
| 229 | update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this)); | - | ||||||||||||||||||||||||
| 230 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 231 | } | - | ||||||||||||||||||||||||
| 232 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 233 | } | - | ||||||||||||||||||||||||
| 234 | case never executed: QEvent::KeyRelease:case QEvent::KeyRelease:never executed: {case QEvent::KeyRelease: | 0 | ||||||||||||||||||||||||
| 235 | QKeyEvent *k = static_cast<QKeyEvent*>(e); | - | ||||||||||||||||||||||||
| 236 | if (!k->isAutoRepeat()
| 0 | ||||||||||||||||||||||||
| 237 | bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
| 0 | ||||||||||||||||||||||||
| 238 | || d->pressedControl == QStyle::SC_GroupBoxCheckBox
| 0 | ||||||||||||||||||||||||
| 239 | d->pressedControl = QStyle::SC_None; | - | ||||||||||||||||||||||||
| 240 | if (toggle
| 0 | ||||||||||||||||||||||||
| 241 | d->click(); never executed: d->click(); | 0 | ||||||||||||||||||||||||
| 242 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 243 | } | - | ||||||||||||||||||||||||
| 244 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 245 | } | - | ||||||||||||||||||||||||
| 246 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 247 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 248 | } | - | ||||||||||||||||||||||||
| 249 | return never executed: QWidget::event(e);return QWidget::event(e);never executed: return QWidget::event(e); | 0 | ||||||||||||||||||||||||
| 250 | } | - | ||||||||||||||||||||||||
| 251 | - | |||||||||||||||||||||||||
| 252 | - | |||||||||||||||||||||||||
| 253 | void QGroupBox::childEvent(QChildEvent *c) | - | ||||||||||||||||||||||||
| 254 | { | - | ||||||||||||||||||||||||
| 255 | QGroupBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 256 | if (c->type() != QEvent::ChildAdded
| 0 | ||||||||||||||||||||||||
| 257 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 258 | QWidget *w = (QWidget*)c->child(); | - | ||||||||||||||||||||||||
| 259 | if (w->isWindow()
| 0 | ||||||||||||||||||||||||
| 260 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 261 | if (d->checkable
| 0 | ||||||||||||||||||||||||
| 262 | if (d->checked
| 0 | ||||||||||||||||||||||||
| 263 | if (!w->testAttribute(Qt::WA_ForceDisabled)
| 0 | ||||||||||||||||||||||||
| 264 | w->setEnabled(true); never executed: w->setEnabled(true); | 0 | ||||||||||||||||||||||||
| 265 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 266 | if (w->isEnabled()
| 0 | ||||||||||||||||||||||||
| 267 | w->setEnabled(false); | - | ||||||||||||||||||||||||
| 268 | w->setAttribute(Qt::WA_ForceDisabled, false); | - | ||||||||||||||||||||||||
| 269 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 270 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 271 | } | - | ||||||||||||||||||||||||
| 272 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 273 | void QGroupBoxPrivate::_q_fixFocus(Qt::FocusReason reason) | - | ||||||||||||||||||||||||
| 274 | { | - | ||||||||||||||||||||||||
| 275 | QGroupBox * const q = q_func(); | - | ||||||||||||||||||||||||
| 276 | QWidget *fw = q->focusWidget(); | - | ||||||||||||||||||||||||
| 277 | if (!fw
| 0 | ||||||||||||||||||||||||
| 278 | QWidget * best = 0; | - | ||||||||||||||||||||||||
| 279 | QWidget * candidate = 0; | - | ||||||||||||||||||||||||
| 280 | QWidget * w = q; | - | ||||||||||||||||||||||||
| 281 | while ((
| 0 | ||||||||||||||||||||||||
| 282 | if (q->isAncestorOf(w)
| 0 | ||||||||||||||||||||||||
| 283 | if (!best
| 0 | ||||||||||||||||||||||||
| 284 | - | |||||||||||||||||||||||||
| 285 | - | |||||||||||||||||||||||||
| 286 | best = w; never executed: best = w; | 0 | ||||||||||||||||||||||||
| 287 | else | - | ||||||||||||||||||||||||
| 288 | if (!candidate
| 0 | ||||||||||||||||||||||||
| 289 | - | |||||||||||||||||||||||||
| 290 | candidate = w; never executed: candidate = w; | 0 | ||||||||||||||||||||||||
| 291 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 292 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 293 | if (best
| 0 | ||||||||||||||||||||||||
| 294 | fw = best; never executed: fw = best; | 0 | ||||||||||||||||||||||||
| 295 | else if (candidate
| 0 | ||||||||||||||||||||||||
| 296 | fw = candidate; never executed: fw = candidate; | 0 | ||||||||||||||||||||||||
| 297 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 298 | if (fw
| 0 | ||||||||||||||||||||||||
| 299 | fw->setFocus(reason); never executed: fw->setFocus(reason); | 0 | ||||||||||||||||||||||||
| 300 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 301 | - | |||||||||||||||||||||||||
| 302 | - | |||||||||||||||||||||||||
| 303 | - | |||||||||||||||||||||||||
| 304 | - | |||||||||||||||||||||||||
| 305 | void QGroupBoxPrivate::calculateFrame() | - | ||||||||||||||||||||||||
| 306 | { | - | ||||||||||||||||||||||||
| 307 | QGroupBox * const q = q_func(); | - | ||||||||||||||||||||||||
| 308 | QStyleOptionGroupBox box; | - | ||||||||||||||||||||||||
| 309 | q->initStyleOption(&box); | - | ||||||||||||||||||||||||
| 310 | QRect contentsRect = q->style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxContents, q); | - | ||||||||||||||||||||||||
| 311 | q->setContentsMargins(contentsRect.left() - box.rect.left(), contentsRect.top() - box.rect.top(), | - | ||||||||||||||||||||||||
| 312 | box.rect.right() - contentsRect.right(), box.rect.bottom() - contentsRect.bottom()); | - | ||||||||||||||||||||||||
| 313 | setLayoutItemMargins(QStyle::SE_GroupBoxLayoutItem, &box); | - | ||||||||||||||||||||||||
| 314 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 315 | - | |||||||||||||||||||||||||
| 316 | - | |||||||||||||||||||||||||
| 317 | - | |||||||||||||||||||||||||
| 318 | void QGroupBox::focusInEvent(QFocusEvent *fe) | - | ||||||||||||||||||||||||
| 319 | { | - | ||||||||||||||||||||||||
| 320 | QGroupBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 321 | if (focusPolicy() == Qt::NoFocus
| 0 | ||||||||||||||||||||||||
| 322 | d->_q_fixFocus(fe->reason()); | - | ||||||||||||||||||||||||
| 323 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 324 | QWidget::focusInEvent(fe); | - | ||||||||||||||||||||||||
| 325 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 326 | } | - | ||||||||||||||||||||||||
| 327 | - | |||||||||||||||||||||||||
| 328 | - | |||||||||||||||||||||||||
| 329 | - | |||||||||||||||||||||||||
| 330 | - | |||||||||||||||||||||||||
| 331 | - | |||||||||||||||||||||||||
| 332 | QSize QGroupBox::minimumSizeHint() const | - | ||||||||||||||||||||||||
| 333 | { | - | ||||||||||||||||||||||||
| 334 | const QGroupBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 335 | QStyleOptionGroupBox option; | - | ||||||||||||||||||||||||
| 336 | initStyleOption(&option); | - | ||||||||||||||||||||||||
| 337 | - | |||||||||||||||||||||||||
| 338 | QFontMetrics metrics(fontMetrics()); | - | ||||||||||||||||||||||||
| 339 | - | |||||||||||||||||||||||||
| 340 | int baseWidth = metrics.width(d->title) + metrics.width(QLatin1Char(' ')); | - | ||||||||||||||||||||||||
| 341 | int baseHeight = metrics.height(); | - | ||||||||||||||||||||||||
| 342 | if (d->checkable
| 0 | ||||||||||||||||||||||||
| 343 | baseWidth += style()->pixelMetric(QStyle::PM_IndicatorWidth); | - | ||||||||||||||||||||||||
| 344 | baseWidth += style()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing); | - | ||||||||||||||||||||||||
| 345 | baseHeight = qMax(baseHeight, style()->pixelMetric(QStyle::PM_IndicatorHeight)); | - | ||||||||||||||||||||||||
| 346 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 347 | - | |||||||||||||||||||||||||
| 348 | QSize size = style()->sizeFromContents(QStyle::CT_GroupBox, &option, QSize(baseWidth, baseHeight), this); | - | ||||||||||||||||||||||||
| 349 | return never executed: size.expandedTo(QWidget::minimumSizeHint());return size.expandedTo(QWidget::minimumSizeHint());never executed: return size.expandedTo(QWidget::minimumSizeHint()); | 0 | ||||||||||||||||||||||||
| 350 | } | - | ||||||||||||||||||||||||
| 351 | bool QGroupBox::isFlat() const | - | ||||||||||||||||||||||||
| 352 | { | - | ||||||||||||||||||||||||
| 353 | const QGroupBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 354 | return never executed: d->flat;return d->flat;never executed: return d->flat; | 0 | ||||||||||||||||||||||||
| 355 | } | - | ||||||||||||||||||||||||
| 356 | - | |||||||||||||||||||||||||
| 357 | void QGroupBox::setFlat(bool b) | - | ||||||||||||||||||||||||
| 358 | { | - | ||||||||||||||||||||||||
| 359 | QGroupBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 360 | if (d->flat == b
| 0 | ||||||||||||||||||||||||
| 361 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 362 | d->flat = b; | - | ||||||||||||||||||||||||
| 363 | updateGeometry(); | - | ||||||||||||||||||||||||
| 364 | update(); | - | ||||||||||||||||||||||||
| 365 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 366 | void QGroupBox::setCheckable(bool checkable) | - | ||||||||||||||||||||||||
| 367 | { | - | ||||||||||||||||||||||||
| 368 | QGroupBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 369 | - | |||||||||||||||||||||||||
| 370 | bool wasCheckable = d->checkable; | - | ||||||||||||||||||||||||
| 371 | d->checkable = checkable; | - | ||||||||||||||||||||||||
| 372 | - | |||||||||||||||||||||||||
| 373 | if (checkable
| 0 | ||||||||||||||||||||||||
| 374 | setChecked(true); | - | ||||||||||||||||||||||||
| 375 | if (!wasCheckable
| 0 | ||||||||||||||||||||||||
| 376 | setFocusPolicy(Qt::StrongFocus); | - | ||||||||||||||||||||||||
| 377 | d->_q_setChildrenEnabled(true); | - | ||||||||||||||||||||||||
| 378 | updateGeometry(); | - | ||||||||||||||||||||||||
| 379 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 380 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 381 | if (wasCheckable
| 0 | ||||||||||||||||||||||||
| 382 | setFocusPolicy(Qt::NoFocus); | - | ||||||||||||||||||||||||
| 383 | d->_q_setChildrenEnabled(true); | - | ||||||||||||||||||||||||
| 384 | updateGeometry(); | - | ||||||||||||||||||||||||
| 385 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 386 | d->_q_setChildrenEnabled(true); | - | ||||||||||||||||||||||||
| 387 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 388 | - | |||||||||||||||||||||||||
| 389 | if (wasCheckable != checkable
| 0 | ||||||||||||||||||||||||
| 390 | d->calculateFrame(); | - | ||||||||||||||||||||||||
| 391 | update(); | - | ||||||||||||||||||||||||
| 392 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 393 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 394 | - | |||||||||||||||||||||||||
| 395 | bool QGroupBox::isCheckable() const | - | ||||||||||||||||||||||||
| 396 | { | - | ||||||||||||||||||||||||
| 397 | const QGroupBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 398 | return never executed: d->checkable;return d->checkable;never executed: return d->checkable; | 0 | ||||||||||||||||||||||||
| 399 | } | - | ||||||||||||||||||||||||
| 400 | - | |||||||||||||||||||||||||
| 401 | - | |||||||||||||||||||||||||
| 402 | bool QGroupBox::isChecked() const | - | ||||||||||||||||||||||||
| 403 | { | - | ||||||||||||||||||||||||
| 404 | const QGroupBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 405 | return never executed: d->checkablereturn d->checkable && d->checked;
never executed: return d->checkable && d->checked; | 0 | ||||||||||||||||||||||||
| 406 | } | - | ||||||||||||||||||||||||
| 407 | void QGroupBox::setChecked(bool b) | - | ||||||||||||||||||||||||
| 408 | { | - | ||||||||||||||||||||||||
| 409 | QGroupBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 410 | if (d->checkable
| 0 | ||||||||||||||||||||||||
| 411 | update(); | - | ||||||||||||||||||||||||
| 412 | d->checked = b; | - | ||||||||||||||||||||||||
| 413 | d->_q_setChildrenEnabled(b); | - | ||||||||||||||||||||||||
| 414 | - | |||||||||||||||||||||||||
| 415 | QAccessible::State st; | - | ||||||||||||||||||||||||
| 416 | st.checked = true; | - | ||||||||||||||||||||||||
| 417 | QAccessibleStateChangeEvent e(this, st); | - | ||||||||||||||||||||||||
| 418 | QAccessible::updateAccessibility(&e); | - | ||||||||||||||||||||||||
| 419 | - | |||||||||||||||||||||||||
| 420 | toggled(b); | - | ||||||||||||||||||||||||
| 421 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 422 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 423 | - | |||||||||||||||||||||||||
| 424 | - | |||||||||||||||||||||||||
| 425 | - | |||||||||||||||||||||||||
| 426 | - | |||||||||||||||||||||||||
| 427 | - | |||||||||||||||||||||||||
| 428 | void QGroupBoxPrivate::_q_setChildrenEnabled(bool b) | - | ||||||||||||||||||||||||
| 429 | { | - | ||||||||||||||||||||||||
| 430 | QGroupBox * const q = q_func(); | - | ||||||||||||||||||||||||
| 431 | QObjectList childList = q->children(); | - | ||||||||||||||||||||||||
| 432 | for (int i = 0; i < childList.size()
| 0 | ||||||||||||||||||||||||
| 433 | QObject *o = childList.at(i); | - | ||||||||||||||||||||||||
| 434 | if (o->isWidgetType()
| 0 | ||||||||||||||||||||||||
| 435 | QWidget *w = static_cast<QWidget *>(o); | - | ||||||||||||||||||||||||
| 436 | if (b
| 0 | ||||||||||||||||||||||||
| 437 | if (!w->testAttribute(Qt::WA_ForceDisabled)
| 0 | ||||||||||||||||||||||||
| 438 | w->setEnabled(true); never executed: w->setEnabled(true); | 0 | ||||||||||||||||||||||||
| 439 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 440 | if (w->isEnabled()
| 0 | ||||||||||||||||||||||||
| 441 | w->setEnabled(false); | - | ||||||||||||||||||||||||
| 442 | w->setAttribute(Qt::WA_ForceDisabled, false); | - | ||||||||||||||||||||||||
| 443 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 444 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 445 | } | - | ||||||||||||||||||||||||
| 446 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 447 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 448 | - | |||||||||||||||||||||||||
| 449 | - | |||||||||||||||||||||||||
| 450 | void QGroupBox::changeEvent(QEvent *ev) | - | ||||||||||||||||||||||||
| 451 | { | - | ||||||||||||||||||||||||
| 452 | QGroupBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 453 | if (ev->type() == QEvent::EnabledChange
| 0 | ||||||||||||||||||||||||
| 454 | if (d->checkable
| 0 | ||||||||||||||||||||||||
| 455 | - | |||||||||||||||||||||||||
| 456 | if (!d->checked
| 0 | ||||||||||||||||||||||||
| 457 | d->_q_setChildrenEnabled(false); never executed: d->_q_setChildrenEnabled(false); | 0 | ||||||||||||||||||||||||
| 458 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 459 | } never executed: else if (ev->type() == QEvent::FontChangeend of block
| 0 | ||||||||||||||||||||||||
| 460 | - | |||||||||||||||||||||||||
| 461 | - | |||||||||||||||||||||||||
| 462 | - | |||||||||||||||||||||||||
| 463 | || ev->type() == QEvent::StyleChange
| 0 | ||||||||||||||||||||||||
| 464 | d->calculateFrame(); | - | ||||||||||||||||||||||||
| 465 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 466 | QWidget::changeEvent(ev); | - | ||||||||||||||||||||||||
| 467 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 468 | - | |||||||||||||||||||||||||
| 469 | - | |||||||||||||||||||||||||
| 470 | void QGroupBox::mousePressEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
| 471 | { | - | ||||||||||||||||||||||||
| 472 | if (event->button() != Qt::LeftButton
| 0 | ||||||||||||||||||||||||
| 473 | event->ignore(); | - | ||||||||||||||||||||||||
| 474 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 475 | } | - | ||||||||||||||||||||||||
| 476 | - | |||||||||||||||||||||||||
| 477 | QGroupBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 478 | QStyleOptionGroupBox box; | - | ||||||||||||||||||||||||
| 479 | initStyleOption(&box); | - | ||||||||||||||||||||||||
| 480 | d->pressedControl = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box, | - | ||||||||||||||||||||||||
| 481 | event->pos(), this); | - | ||||||||||||||||||||||||
| 482 | if (d->checkable
| 0 | ||||||||||||||||||||||||
| 483 | d->overCheckBox = true; | - | ||||||||||||||||||||||||
| 484 | update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this)); | - | ||||||||||||||||||||||||
| 485 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 486 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 487 | - | |||||||||||||||||||||||||
| 488 | - | |||||||||||||||||||||||||
| 489 | void QGroupBox::mouseMoveEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
| 490 | { | - | ||||||||||||||||||||||||
| 491 | QGroupBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 492 | QStyleOptionGroupBox box; | - | ||||||||||||||||||||||||
| 493 | initStyleOption(&box); | - | ||||||||||||||||||||||||
| 494 | QStyle::SubControl pressed = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box, | - | ||||||||||||||||||||||||
| 495 | event->pos(), this); | - | ||||||||||||||||||||||||
| 496 | bool oldOverCheckBox = d->overCheckBox; | - | ||||||||||||||||||||||||
| 497 | d->overCheckBox = (pressed == QStyle::SC_GroupBoxCheckBox
| 0 | ||||||||||||||||||||||||
| 498 | if (d->checkable
| 0 | ||||||||||||||||||||||||
| 499 | && (
| 0 | ||||||||||||||||||||||||
| 500 | 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 | ||||||||||||||||||||||||
| 501 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 502 | - | |||||||||||||||||||||||||
| 503 | - | |||||||||||||||||||||||||
| 504 | void QGroupBox::mouseReleaseEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
| 505 | { | - | ||||||||||||||||||||||||
| 506 | if (event->button() != Qt::LeftButton
| 0 | ||||||||||||||||||||||||
| 507 | event->ignore(); | - | ||||||||||||||||||||||||
| 508 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 509 | } | - | ||||||||||||||||||||||||
| 510 | - | |||||||||||||||||||||||||
| 511 | QGroupBoxPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
| 512 | if (!d->overCheckBox
| 0 | ||||||||||||||||||||||||
| 513 | event->ignore(); | - | ||||||||||||||||||||||||
| 514 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 515 | } | - | ||||||||||||||||||||||||
| 516 | QStyleOptionGroupBox box; | - | ||||||||||||||||||||||||
| 517 | initStyleOption(&box); | - | ||||||||||||||||||||||||
| 518 | QStyle::SubControl released = style()->hitTestComplexControl(QStyle::CC_GroupBox, &box, | - | ||||||||||||||||||||||||
| 519 | event->pos(), this); | - | ||||||||||||||||||||||||
| 520 | bool toggle = d->checkable
| 0 | ||||||||||||||||||||||||
| 521 | || released == QStyle::SC_GroupBoxCheckBox
| 0 | ||||||||||||||||||||||||
| 522 | d->pressedControl = QStyle::SC_None; | - | ||||||||||||||||||||||||
| 523 | d->overCheckBox = false; | - | ||||||||||||||||||||||||
| 524 | if (toggle
| 0 | ||||||||||||||||||||||||
| 525 | d->click(); never executed: d->click(); | 0 | ||||||||||||||||||||||||
| 526 | else if (d->checkable
| 0 | ||||||||||||||||||||||||
| 527 | 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 | ||||||||||||||||||||||||
| 528 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 529 | - | |||||||||||||||||||||||||
| 530 | - | |||||||||||||||||||||||||
| 531 | - | |||||||||||||||||||||||||
| 532 | - | |||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |