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