| Line | Source Code | Coverage |
|---|
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | class QCheckBoxPrivate : public QAbstractButtonPrivate | - |
| 6 | { | - |
| 7 | inline QCheckBox* q_func() { return static_cast<QCheckBox *>(q_ptr); } inline const QCheckBox* q_func() const { return static_cast<const QCheckBox *>(q_ptr); } friend class QCheckBox; | - |
| 8 | public: | - |
| 9 | QCheckBoxPrivate() | - |
| 10 | : QAbstractButtonPrivate(QSizePolicy::CheckBox), tristate(false), noChange(false), | - |
| 11 | hovering(true), publishedState(Qt::Unchecked) {} executed: }Execution Count:31 | 31 |
| 12 | | - |
| 13 | uint tristate : 1; | - |
| 14 | uint noChange : 1; | - |
| 15 | uint hovering : 1; | - |
| 16 | uint publishedState : 2; | - |
| 17 | | - |
| 18 | void init(); | - |
| 19 | }; | - |
| 20 | void QCheckBoxPrivate::init() | - |
| 21 | { | - |
| 22 | QCheckBox * const q = q_func(); | - |
| 23 | q->setCheckable(true); | - |
| 24 | q->setMouseTracking(true); | - |
| 25 | q->setForegroundRole(QPalette::WindowText); | - |
| 26 | setLayoutItemMargins(QStyle::SE_CheckBoxLayoutItem); | - |
| 27 | } executed: }Execution Count:31 | 31 |
| 28 | void QCheckBox::initStyleOption(QStyleOptionButton *option) const | - |
| 29 | { | - |
| 30 | if (!option) partially evaluated: !option| no Evaluation Count:0 | yes Evaluation Count:30 |
| 0-30 |
| 31 | return; | 0 |
| 32 | const QCheckBoxPrivate * const d = d_func(); | - |
| 33 | option->initFrom(this); | - |
| 34 | if (d->down) evaluated: d->down| yes Evaluation Count:2 | yes Evaluation Count:28 |
| 2-28 |
| 35 | option->state |= QStyle::State_Sunken; executed: option->state |= QStyle::State_Sunken;Execution Count:2 | 2 |
| 36 | if (d->tristate && d->noChange) evaluated: d->tristate| yes Evaluation Count:2 | yes Evaluation Count:28 |
partially evaluated: d->noChange| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-28 |
| 37 | option->state |= QStyle::State_NoChange; executed: option->state |= QStyle::State_NoChange;Execution Count:2 | 2 |
| 38 | else | - |
| 39 | option->state |= d->checked ? QStyle::State_On : QStyle::State_Off; executed: option->state |= d->checked ? QStyle::State_On : QStyle::State_Off;Execution Count:28 evaluated: d->checked| yes Evaluation Count:4 | yes Evaluation Count:24 |
| 4-28 |
| 40 | if (testAttribute(Qt::WA_Hover) && underMouse()) { partially evaluated: testAttribute(Qt::WA_Hover)| no Evaluation Count:0 | yes Evaluation Count:30 |
never evaluated: underMouse() | 0-30 |
| 41 | if (d->hovering) never evaluated: d->hovering | 0 |
| 42 | option->state |= QStyle::State_MouseOver; never executed: option->state |= QStyle::State_MouseOver; | 0 |
| 43 | else | - |
| 44 | option->state &= ~QStyle::State_MouseOver; never executed: option->state &= ~QStyle::State_MouseOver; | 0 |
| 45 | } | - |
| 46 | option->text = d->text; | - |
| 47 | option->icon = d->icon; | - |
| 48 | option->iconSize = iconSize(); | - |
| 49 | } executed: }Execution Count:30 | 30 |
| 50 | | - |
| 51 | | - |
| 52 | | - |
| 53 | | - |
| 54 | | - |
| 55 | | - |
| 56 | | - |
| 57 | QCheckBox::QCheckBox(QWidget *parent) | - |
| 58 | : QAbstractButton (*new QCheckBoxPrivate, parent) | - |
| 59 | { | - |
| 60 | QCheckBoxPrivate * const d = d_func(); | - |
| 61 | d->init(); | - |
| 62 | } executed: }Execution Count:18 | 18 |
| 63 | | - |
| 64 | | - |
| 65 | | - |
| 66 | | - |
| 67 | | - |
| 68 | | - |
| 69 | | - |
| 70 | QCheckBox::QCheckBox(const QString &text, QWidget *parent) | - |
| 71 | : QAbstractButton (*new QCheckBoxPrivate, parent) | - |
| 72 | { | - |
| 73 | QCheckBoxPrivate * const d = d_func(); | - |
| 74 | d->init(); | - |
| 75 | setText(text); | - |
| 76 | } executed: }Execution Count:13 | 13 |
| 77 | | - |
| 78 | | - |
| 79 | | - |
| 80 | | - |
| 81 | QCheckBox::~QCheckBox() | - |
| 82 | { | - |
| 83 | } | - |
| 84 | | - |
| 85 | void QCheckBox::setTristate(bool y) | - |
| 86 | { | - |
| 87 | QCheckBoxPrivate * const d = d_func(); | - |
| 88 | d->tristate = y; | - |
| 89 | } executed: }Execution Count:19 | 19 |
| 90 | | - |
| 91 | bool QCheckBox::isTristate() const | - |
| 92 | { | - |
| 93 | const QCheckBoxPrivate * const d = d_func(); | - |
| 94 | return d->tristate; executed: return d->tristate;Execution Count:2 | 2 |
| 95 | } | - |
| 96 | Qt::CheckState QCheckBox::checkState() const | - |
| 97 | { | - |
| 98 | const QCheckBoxPrivate * const d = d_func(); | - |
| 99 | if (d->tristate && d->noChange) evaluated: d->tristate| yes Evaluation Count:12 | yes Evaluation Count:56 |
evaluated: d->noChange| yes Evaluation Count:3 | yes Evaluation Count:9 |
| 3-56 |
| 100 | return Qt::PartiallyChecked; executed: return Qt::PartiallyChecked;Execution Count:3 | 3 |
| 101 | return d->checked ? Qt::Checked : Qt::Unchecked; executed: return d->checked ? Qt::Checked : Qt::Unchecked;Execution Count:65 | 65 |
| 102 | } | - |
| 103 | void QCheckBox::setCheckState(Qt::CheckState state) | - |
| 104 | { | - |
| 105 | QCheckBoxPrivate * const d = d_func(); | - |
| 106 | if (state == Qt::PartiallyChecked) { partially evaluated: state == Qt::PartiallyChecked| yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
| 107 | d->tristate = true; | - |
| 108 | d->noChange = true; | - |
| 109 | } else { executed: }Execution Count:5 | 5 |
| 110 | d->noChange = false; | - |
| 111 | } | 0 |
| 112 | d->blockRefresh = true; | - |
| 113 | setChecked(state != Qt::Unchecked); | - |
| 114 | d->blockRefresh = false; | - |
| 115 | d->refresh(); | - |
| 116 | if ((uint)state != d->publishedState) { evaluated: (uint)state != d->publishedState| yes Evaluation Count:3 | yes Evaluation Count:2 |
| 2-3 |
| 117 | d->publishedState = state; | - |
| 118 | stateChanged(state); | - |
| 119 | } executed: }Execution Count:3 | 3 |
| 120 | } executed: }Execution Count:5 | 5 |
| 121 | | - |
| 122 | | - |
| 123 | | - |
| 124 | | - |
| 125 | | - |
| 126 | QSize QCheckBox::sizeHint() const | - |
| 127 | { | - |
| 128 | const QCheckBoxPrivate * const d = d_func(); | - |
| 129 | if (d->sizeHint.isValid()) evaluated: d->sizeHint.isValid()| yes Evaluation Count:22 | yes Evaluation Count:18 |
| 18-22 |
| 130 | return d->sizeHint; executed: return d->sizeHint;Execution Count:22 | 22 |
| 131 | ensurePolished(); | - |
| 132 | QFontMetrics fm = fontMetrics(); | - |
| 133 | QStyleOptionButton opt; | - |
| 134 | initStyleOption(&opt); | - |
| 135 | QSize sz = style()->itemTextRect(fm, QRect(), Qt::TextShowMnemonic, false, | - |
| 136 | text()).size(); | - |
| 137 | if (!opt.icon.isNull()) partially evaluated: !opt.icon.isNull()| no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
| 138 | sz = QSize(sz.width() + opt.iconSize.width() + 4, qMax(sz.height(), opt.iconSize.height())); never executed: sz = QSize(sz.width() + opt.iconSize.width() + 4, qMax(sz.height(), opt.iconSize.height())); | 0 |
| 139 | d->sizeHint = (style()->sizeFromContents(QStyle::CT_CheckBox, &opt, sz, this) | - |
| 140 | .expandedTo(QApplication::globalStrut())); | - |
| 141 | return d->sizeHint; executed: return d->sizeHint;Execution Count:18 | 18 |
| 142 | } | - |
| 143 | | - |
| 144 | | - |
| 145 | | - |
| 146 | | - |
| 147 | | - |
| 148 | QSize QCheckBox::minimumSizeHint() const | - |
| 149 | { | - |
| 150 | return sizeHint(); executed: return sizeHint();Execution Count:20 | 20 |
| 151 | } | - |
| 152 | | - |
| 153 | | - |
| 154 | | - |
| 155 | | - |
| 156 | void QCheckBox::paintEvent(QPaintEvent *) | - |
| 157 | { | - |
| 158 | QStylePainter p(this); | - |
| 159 | QStyleOptionButton opt; | - |
| 160 | initStyleOption(&opt); | - |
| 161 | p.drawControl(QStyle::CE_CheckBox, opt); | - |
| 162 | } executed: }Execution Count:12 | 12 |
| 163 | | - |
| 164 | | - |
| 165 | | - |
| 166 | | - |
| 167 | void QCheckBox::mouseMoveEvent(QMouseEvent *e) | - |
| 168 | { | - |
| 169 | QCheckBoxPrivate * const d = d_func(); | - |
| 170 | if (testAttribute(Qt::WA_Hover)) { never evaluated: testAttribute(Qt::WA_Hover) | 0 |
| 171 | bool hit = false; | - |
| 172 | if (underMouse()) never evaluated: underMouse() | 0 |
| 173 | hit = hitButton(e->pos()); never executed: hit = hitButton(e->pos()); | 0 |
| 174 | | - |
| 175 | if (hit != d->hovering) { never evaluated: hit != d->hovering | 0 |
| 176 | update(rect()); | - |
| 177 | d->hovering = hit; | - |
| 178 | } | 0 |
| 179 | } | 0 |
| 180 | | - |
| 181 | QAbstractButton::mouseMoveEvent(e); | - |
| 182 | } | 0 |
| 183 | | - |
| 184 | | - |
| 185 | | - |
| 186 | | - |
| 187 | | - |
| 188 | bool QCheckBox::hitButton(const QPoint &pos) const | - |
| 189 | { | - |
| 190 | QStyleOptionButton opt; | - |
| 191 | initStyleOption(&opt); | - |
| 192 | return style()->subElementRect(QStyle::SE_CheckBoxClickRect, &opt, this).contains(pos); never executed: return style()->subElementRect(QStyle::SE_CheckBoxClickRect, &opt, this).contains(pos); | 0 |
| 193 | } | - |
| 194 | | - |
| 195 | | - |
| 196 | | - |
| 197 | | - |
| 198 | void QCheckBox::checkStateSet() | - |
| 199 | { | - |
| 200 | QCheckBoxPrivate * const d = d_func(); | - |
| 201 | d->noChange = false; | - |
| 202 | Qt::CheckState state = checkState(); | - |
| 203 | if ((uint)state != d->publishedState) { evaluated: (uint)state != d->publishedState| yes Evaluation Count:29 | yes Evaluation Count:28 |
| 28-29 |
| 204 | d->publishedState = state; | - |
| 205 | stateChanged(state); | - |
| 206 | } executed: }Execution Count:29 | 29 |
| 207 | } executed: }Execution Count:57 | 57 |
| 208 | | - |
| 209 | | - |
| 210 | | - |
| 211 | | - |
| 212 | void QCheckBox::nextCheckState() | - |
| 213 | { | - |
| 214 | QCheckBoxPrivate * const d = d_func(); | - |
| 215 | if (d->tristate) partially evaluated: d->tristate| no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
| 216 | setCheckState((Qt::CheckState)((checkState() + 1) % 3)); never executed: setCheckState((Qt::CheckState)((checkState() + 1) % 3)); | 0 |
| 217 | else { | - |
| 218 | QAbstractButton::nextCheckState(); | - |
| 219 | QCheckBox::checkStateSet(); | - |
| 220 | } executed: }Execution Count:3 | 3 |
| 221 | } | - |
| 222 | | - |
| 223 | | - |
| 224 | | - |
| 225 | | - |
| 226 | bool QCheckBox::event(QEvent *e) | - |
| 227 | { | - |
| 228 | QCheckBoxPrivate * const d = d_func(); | - |
| 229 | if (e->type() == QEvent::StyleChange partially evaluated: e->type() == QEvent::StyleChange| no Evaluation Count:0 | yes Evaluation Count:268 |
| 0-268 |
| 230 | | - |
| 231 | | - |
| 232 | | - |
| 233 | ) | - |
| 234 | d->setLayoutItemMargins(QStyle::SE_CheckBoxLayoutItem); never executed: d->setLayoutItemMargins(QStyle::SE_CheckBoxLayoutItem); | 0 |
| 235 | return QAbstractButton::event(e); executed: return QAbstractButton::event(e);Execution Count:268 | 268 |
| 236 | } | - |
| 237 | | - |
| 238 | | - |
| 239 | | - |
| 240 | | - |
| 241 | | - |
| | |