| Line | Source Code | Coverage |
|---|
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | QScrollArea::QScrollArea(QWidget *parent) | - |
| 7 | : QAbstractScrollArea(*new QScrollAreaPrivate,parent) | - |
| 8 | { | - |
| 9 | QScrollAreaPrivate * const d = d_func(); | - |
| 10 | d->viewport->setBackgroundRole(QPalette::NoRole); | - |
| 11 | d->vbar->setSingleStep(20); | - |
| 12 | d->hbar->setSingleStep(20); | - |
| 13 | d->layoutChildren(); | - |
| 14 | } executed: }Execution Count:39 | 39 |
| 15 | | - |
| 16 | | - |
| 17 | | - |
| 18 | | - |
| 19 | QScrollArea::QScrollArea(QScrollAreaPrivate &dd, QWidget *parent) | - |
| 20 | : QAbstractScrollArea(dd, parent) | - |
| 21 | { | - |
| 22 | QScrollAreaPrivate * const d = d_func(); | - |
| 23 | d->viewport->setBackgroundRole(QPalette::NoRole); | - |
| 24 | d->vbar->setSingleStep(20); | - |
| 25 | d->hbar->setSingleStep(20); | - |
| 26 | d->layoutChildren(); | - |
| 27 | } | 0 |
| 28 | | - |
| 29 | | - |
| 30 | | - |
| 31 | | - |
| 32 | | - |
| 33 | | - |
| 34 | QScrollArea::~QScrollArea() | - |
| 35 | { | - |
| 36 | } | - |
| 37 | | - |
| 38 | void QScrollAreaPrivate::updateWidgetPosition() | - |
| 39 | { | - |
| 40 | QScrollArea * const q = q_func(); | - |
| 41 | Qt::LayoutDirection dir = q->layoutDirection(); | - |
| 42 | QRect scrolled = QStyle::visualRect(dir, viewport->rect(), QRect(QPoint(-hbar->value(), -vbar->value()), widget->size())); | - |
| 43 | QRect aligned = QStyle::alignedRect(dir, alignment, widget->size(), viewport->rect()); | - |
| 44 | widget->move(widget->width() < viewport->width() ? aligned.x() : scrolled.x(), | - |
| 45 | widget->height() < viewport->height() ? aligned.y() : scrolled.y()); | - |
| 46 | } executed: }Execution Count:90 | 90 |
| 47 | | - |
| 48 | void QScrollAreaPrivate::updateScrollBars() | - |
| 49 | { | - |
| 50 | QScrollArea * const q = q_func(); | - |
| 51 | if (!widget) evaluated: !widget| yes Evaluation Count:15 | yes Evaluation Count:78 |
| 15-78 |
| 52 | return; executed: return;Execution Count:15 | 15 |
| 53 | QSize p = viewport->size(); | - |
| 54 | QSize m = q->maximumViewportSize(); | - |
| 55 | | - |
| 56 | QSize min = qSmartMinSize(widget); | - |
| 57 | QSize max = qSmartMaxSize(widget); | - |
| 58 | | - |
| 59 | if (resizable) { evaluated: resizable| yes Evaluation Count:27 | yes Evaluation Count:51 |
| 27-51 |
| 60 | if ((widget->layout() ? widget->layout()->hasHeightForWidth() : widget->sizePolicy().hasHeightForWidth())) { partially evaluated: widget->layout()| no Evaluation Count:0 | yes Evaluation Count:27 |
| 0-27 |
| 61 | QSize p_hfw = p.expandedTo(min).boundedTo(max); | - |
| 62 | int h = widget->heightForWidth( p_hfw.width() ); | - |
| 63 | min = QSize(p_hfw.width(), qMax(p_hfw.height(), h)); | - |
| 64 | } executed: }Execution Count:4 | 4 |
| 65 | } executed: }Execution Count:27 | 27 |
| 66 | | - |
| 67 | if ((resizable && m.expandedTo(min) == m && m.boundedTo(max) == m) evaluated: resizable| yes Evaluation Count:27 | yes Evaluation Count:51 |
evaluated: m.expandedTo(min) == m| yes Evaluation Count:25 | yes Evaluation Count:2 |
partially evaluated: m.boundedTo(max) == m| yes Evaluation Count:25 | no Evaluation Count:0 |
| 0-51 |
| 68 | || (!resizable && m.expandedTo(widget->size()) == m)) evaluated: !resizable| yes Evaluation Count:51 | yes Evaluation Count:2 |
evaluated: m.expandedTo(widget->size()) == m| yes Evaluation Count:25 | yes Evaluation Count:26 |
| 2-51 |
| 69 | p = m; executed: p = m;Execution Count:50 | 50 |
| 70 | | - |
| 71 | if (resizable) evaluated: resizable| yes Evaluation Count:27 | yes Evaluation Count:51 |
| 27-51 |
| 72 | widget->resize(p.expandedTo(min).boundedTo(max)); executed: widget->resize(p.expandedTo(min).boundedTo(max));Execution Count:27 | 27 |
| 73 | QSize v = widget->size(); | - |
| 74 | | - |
| 75 | hbar->setRange(0, v.width() - p.width()); | - |
| 76 | hbar->setPageStep(p.width()); | - |
| 77 | vbar->setRange(0, v.height() - p.height()); | - |
| 78 | vbar->setPageStep(p.height()); | - |
| 79 | updateWidgetPosition(); | - |
| 80 | | - |
| 81 | } executed: }Execution Count:78 | 78 |
| 82 | | - |
| 83 | | - |
| 84 | | - |
| 85 | | - |
| 86 | | - |
| 87 | | - |
| 88 | | - |
| 89 | QWidget *QScrollArea::widget() const | - |
| 90 | { | - |
| 91 | const QScrollAreaPrivate * const d = d_func(); | - |
| 92 | return d->widget; executed: return d->widget;Execution Count:2 | 2 |
| 93 | } | - |
| 94 | void QScrollArea::setWidget(QWidget *widget) | - |
| 95 | { | - |
| 96 | QScrollAreaPrivate * const d = d_func(); | - |
| 97 | if (widget == d->widget || !widget) partially evaluated: widget == d->widget| no Evaluation Count:0 | yes Evaluation Count:32 |
evaluated: !widget| yes Evaluation Count:1 | yes Evaluation Count:31 |
| 0-32 |
| 98 | return; executed: return;Execution Count:1 | 1 |
| 99 | | - |
| 100 | delete d->widget; | - |
| 101 | d->widget = 0; | - |
| 102 | d->hbar->setValue(0); | - |
| 103 | d->vbar->setValue(0); | - |
| 104 | if (widget->parentWidget() != d->viewport) partially evaluated: widget->parentWidget() != d->viewport| yes Evaluation Count:31 | no Evaluation Count:0 |
| 0-31 |
| 105 | widget->setParent(d->viewport); executed: widget->setParent(d->viewport);Execution Count:31 | 31 |
| 106 | if (!widget->testAttribute(Qt::WA_Resized)) evaluated: !widget->testAttribute(Qt::WA_Resized)| yes Evaluation Count:24 | yes Evaluation Count:7 |
| 7-24 |
| 107 | widget->resize(widget->sizeHint()); executed: widget->resize(widget->sizeHint());Execution Count:24 | 24 |
| 108 | d->widget = widget; | - |
| 109 | d->widget->setAutoFillBackground(true); | - |
| 110 | widget->installEventFilter(this); | - |
| 111 | d->widgetSize = QSize(); | - |
| 112 | d->updateScrollBars(); | - |
| 113 | d->widget->show(); | - |
| 114 | | - |
| 115 | } executed: }Execution Count:31 | 31 |
| 116 | | - |
| 117 | | - |
| 118 | | - |
| 119 | | - |
| 120 | | - |
| 121 | | - |
| 122 | | - |
| 123 | QWidget *QScrollArea::takeWidget() | - |
| 124 | { | - |
| 125 | QScrollAreaPrivate * const d = d_func(); | - |
| 126 | QWidget *w = d->widget; | - |
| 127 | d->widget = 0; | - |
| 128 | if (w) | 0 |
| 129 | w->setParent(0); never executed: w->setParent(0); | 0 |
| 130 | return w; never executed: return w; | 0 |
| 131 | } | - |
| 132 | | - |
| 133 | | - |
| 134 | | - |
| 135 | | - |
| 136 | bool QScrollArea::event(QEvent *e) | - |
| 137 | { | - |
| 138 | QScrollAreaPrivate * const d = d_func(); | - |
| 139 | if (e->type() == QEvent::StyleChange || e->type() == QEvent::LayoutRequest) { evaluated: e->type() == QEvent::StyleChange| yes Evaluation Count:2 | yes Evaluation Count:358 |
evaluated: e->type() == QEvent::LayoutRequest| yes Evaluation Count:1 | yes Evaluation Count:357 |
| 1-358 |
| 140 | d->updateScrollBars(); | - |
| 141 | } executed: }Execution Count:3 | 3 |
| 142 | return QAbstractScrollArea::event(e); executed: return QAbstractScrollArea::event(e);Execution Count:360 | 360 |
| 143 | } | - |
| 144 | | - |
| 145 | | - |
| 146 | | - |
| 147 | | - |
| 148 | | - |
| 149 | bool QScrollArea::eventFilter(QObject *o, QEvent *e) | - |
| 150 | { | - |
| 151 | QScrollAreaPrivate * const d = d_func(); | - |
| 152 | | - |
| 153 | | - |
| 154 | | - |
| 155 | | - |
| 156 | | - |
| 157 | | - |
| 158 | | - |
| 159 | if (o == d->widget && e->type() == QEvent::Resize) evaluated: o == d->widget| yes Evaluation Count:121 | yes Evaluation Count:106 |
evaluated: e->type() == QEvent::Resize| yes Evaluation Count:10 | yes Evaluation Count:111 |
| 10-121 |
| 160 | d->updateScrollBars(); executed: d->updateScrollBars();Execution Count:10 | 10 |
| 161 | | - |
| 162 | return QAbstractScrollArea::eventFilter(o, e); executed: return QAbstractScrollArea::eventFilter(o, e);Execution Count:227 | 227 |
| 163 | } | - |
| 164 | | - |
| 165 | | - |
| 166 | | - |
| 167 | | - |
| 168 | void QScrollArea::resizeEvent(QResizeEvent *) | - |
| 169 | { | - |
| 170 | QScrollAreaPrivate * const d = d_func(); | - |
| 171 | d->updateScrollBars(); | - |
| 172 | | - |
| 173 | } executed: }Execution Count:23 | 23 |
| 174 | | - |
| 175 | | - |
| 176 | | - |
| 177 | | - |
| 178 | void QScrollArea::scrollContentsBy(int, int) | - |
| 179 | { | - |
| 180 | QScrollAreaPrivate * const d = d_func(); | - |
| 181 | if (!d->widget) evaluated: !d->widget| yes Evaluation Count:2 | yes Evaluation Count:12 |
| 2-12 |
| 182 | return; executed: return;Execution Count:2 | 2 |
| 183 | d->updateWidgetPosition(); | - |
| 184 | } executed: }Execution Count:12 | 12 |
| 185 | bool QScrollArea::widgetResizable() const | - |
| 186 | { | - |
| 187 | const QScrollAreaPrivate * const d = d_func(); | - |
| 188 | return d->resizable; executed: return d->resizable;Execution Count:2 | 2 |
| 189 | } | - |
| 190 | | - |
| 191 | void QScrollArea::setWidgetResizable(bool resizable) | - |
| 192 | { | - |
| 193 | QScrollAreaPrivate * const d = d_func(); | - |
| 194 | d->resizable = resizable; | - |
| 195 | updateGeometry(); | - |
| 196 | d->updateScrollBars(); | - |
| 197 | } executed: }Execution Count:26 | 26 |
| 198 | | - |
| 199 | | - |
| 200 | | - |
| 201 | | - |
| 202 | QSize QScrollArea::sizeHint() const | - |
| 203 | { | - |
| 204 | const QScrollAreaPrivate * const d = d_func(); | - |
| 205 | int f = 2 * d->frameWidth; | - |
| 206 | QSize sz(f, f); | - |
| 207 | int h = fontMetrics().height(); | - |
| 208 | if (d->widget) { partially evaluated: d->widget| no Evaluation Count:0 | yes Evaluation Count:40 |
| 0-40 |
| 209 | if (!d->widgetSize.isValid()) never evaluated: !d->widgetSize.isValid() | 0 |
| 210 | d->widgetSize = d->resizable ? d->widget->sizeHint() : d->widget->size(); never executed: d->widgetSize = d->resizable ? d->widget->sizeHint() : d->widget->size(); never evaluated: d->resizable | 0 |
| 211 | sz += d->widgetSize; | - |
| 212 | } else { | 0 |
| 213 | sz += QSize(12 * h, 8 * h); | - |
| 214 | } executed: }Execution Count:40 | 40 |
| 215 | if (d->vbarpolicy == Qt::ScrollBarAlwaysOn) partially evaluated: d->vbarpolicy == Qt::ScrollBarAlwaysOn| no Evaluation Count:0 | yes Evaluation Count:40 |
| 0-40 |
| 216 | sz.setWidth(sz.width() + d->vbar->sizeHint().width()); never executed: sz.setWidth(sz.width() + d->vbar->sizeHint().width()); | 0 |
| 217 | if (d->hbarpolicy == Qt::ScrollBarAlwaysOn) partially evaluated: d->hbarpolicy == Qt::ScrollBarAlwaysOn| no Evaluation Count:0 | yes Evaluation Count:40 |
| 0-40 |
| 218 | sz.setHeight(sz.height() + d->hbar->sizeHint().height()); never executed: sz.setHeight(sz.height() + d->hbar->sizeHint().height()); | 0 |
| 219 | return sz.boundedTo(QSize(36 * h, 24 * h)); executed: return sz.boundedTo(QSize(36 * h, 24 * h));Execution Count:40 | 40 |
| 220 | } | - |
| 221 | | - |
| 222 | | - |
| 223 | | - |
| 224 | | - |
| 225 | | - |
| 226 | | - |
| 227 | bool QScrollArea::focusNextPrevChild(bool next) | - |
| 228 | { | - |
| 229 | if (QWidget::focusNextPrevChild(next)) { never evaluated: QWidget::focusNextPrevChild(next) | 0 |
| 230 | if (QWidget *fw = focusWidget()) never evaluated: QWidget *fw = focusWidget() | 0 |
| 231 | ensureWidgetVisible(fw); never executed: ensureWidgetVisible(fw); | 0 |
| 232 | return true; never executed: return true; | 0 |
| 233 | } | - |
| 234 | return false; never executed: return false; | 0 |
| 235 | } | - |
| 236 | | - |
| 237 | | - |
| 238 | | - |
| 239 | | - |
| 240 | | - |
| 241 | | - |
| 242 | | - |
| 243 | void QScrollArea::ensureVisible(int x, int y, int xmargin, int ymargin) | - |
| 244 | { | - |
| 245 | QScrollAreaPrivate * const d = d_func(); | - |
| 246 | | - |
| 247 | int logicalX = QStyle::visualPos(layoutDirection(), d->viewport->rect(), QPoint(x, y)).x(); | - |
| 248 | | - |
| 249 | if (logicalX - xmargin < d->hbar->value()) { never evaluated: logicalX - xmargin < d->hbar->value() | 0 |
| 250 | d->hbar->setValue(qMax(0, logicalX - xmargin)); | - |
| 251 | } else if (logicalX > d->hbar->value() + d->viewport->width() - xmargin) { never evaluated: logicalX > d->hbar->value() + d->viewport->width() - xmargin | 0 |
| 252 | d->hbar->setValue(qMin(logicalX - d->viewport->width() + xmargin, d->hbar->maximum())); | - |
| 253 | } | 0 |
| 254 | | - |
| 255 | if (y - ymargin < d->vbar->value()) { never evaluated: y - ymargin < d->vbar->value() | 0 |
| 256 | d->vbar->setValue(qMax(0, y - ymargin)); | - |
| 257 | } else if (y > d->vbar->value() + d->viewport->height() - ymargin) { never evaluated: y > d->vbar->value() + d->viewport->height() - ymargin | 0 |
| 258 | d->vbar->setValue(qMin(y - d->viewport->height() + ymargin, d->vbar->maximum())); | - |
| 259 | } | 0 |
| 260 | } | - |
| 261 | void QScrollArea::ensureWidgetVisible(QWidget *childWidget, int xmargin, int ymargin) | - |
| 262 | { | - |
| 263 | QScrollAreaPrivate * const d = d_func(); | - |
| 264 | | - |
| 265 | if (!d->widget->isAncestorOf(childWidget)) partially evaluated: !d->widget->isAncestorOf(childWidget)| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 266 | return; | 0 |
| 267 | | - |
| 268 | const QRect microFocus = childWidget->inputMethodQuery(Qt::ImCursorRectangle).toRect(); | - |
| 269 | const QRect defaultMicroFocus = | - |
| 270 | childWidget->QWidget::inputMethodQuery(Qt::ImCursorRectangle).toRect(); | - |
| 271 | QRect focusRect = (microFocus != defaultMicroFocus) partially evaluated: (microFocus != defaultMicroFocus)| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 272 | ? QRect(childWidget->mapTo(d->widget, microFocus.topLeft()), microFocus.size()) | - |
| 273 | : QRect(childWidget->mapTo(d->widget, QPoint(0,0)), childWidget->size()); | - |
| 274 | const QRect visibleRect(-d->widget->pos(), d->viewport->size()); | - |
| 275 | | - |
| 276 | if (visibleRect.contains(focusRect)) partially evaluated: visibleRect.contains(focusRect)| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 277 | return; | 0 |
| 278 | | - |
| 279 | focusRect.adjust(-xmargin, -ymargin, xmargin, ymargin); | - |
| 280 | | - |
| 281 | if (focusRect.width() > visibleRect.width()) partially evaluated: focusRect.width() > visibleRect.width()| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 282 | d->hbar->setValue(focusRect.center().x() - d->viewport->width() / 2); never executed: d->hbar->setValue(focusRect.center().x() - d->viewport->width() / 2); | 0 |
| 283 | else if (focusRect.right() > visibleRect.right()) partially evaluated: focusRect.right() > visibleRect.right()| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 284 | d->hbar->setValue(focusRect.right() - d->viewport->width()); executed: d->hbar->setValue(focusRect.right() - d->viewport->width());Execution Count:1 | 1 |
| 285 | else if (focusRect.left() < visibleRect.left()) never evaluated: focusRect.left() < visibleRect.left() | 0 |
| 286 | d->hbar->setValue(focusRect.left()); never executed: d->hbar->setValue(focusRect.left()); | 0 |
| 287 | | - |
| 288 | if (focusRect.height() > visibleRect.height()) partially evaluated: focusRect.height() > visibleRect.height()| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 289 | d->vbar->setValue(focusRect.center().y() - d->viewport->height() / 2); never executed: d->vbar->setValue(focusRect.center().y() - d->viewport->height() / 2); | 0 |
| 290 | else if (focusRect.bottom() > visibleRect.bottom()) partially evaluated: focusRect.bottom() > visibleRect.bottom()| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 291 | d->vbar->setValue(focusRect.bottom() - d->viewport->height()); executed: d->vbar->setValue(focusRect.bottom() - d->viewport->height());Execution Count:1 | 1 |
| 292 | else if (focusRect.top() < visibleRect.top()) never evaluated: focusRect.top() < visibleRect.top() | 0 |
| 293 | d->vbar->setValue(focusRect.top()); never executed: d->vbar->setValue(focusRect.top()); | 0 |
| 294 | } | - |
| 295 | void QScrollArea::setAlignment(Qt::Alignment alignment) | - |
| 296 | { | - |
| 297 | QScrollAreaPrivate * const d = d_func(); | - |
| 298 | d->alignment = alignment; | - |
| 299 | if (d->widget) never evaluated: d->widget | 0 |
| 300 | d->updateWidgetPosition(); never executed: d->updateWidgetPosition(); | 0 |
| 301 | } | 0 |
| 302 | | - |
| 303 | Qt::Alignment QScrollArea::alignment() const | - |
| 304 | { | - |
| 305 | const QScrollAreaPrivate * const d = d_func(); | - |
| 306 | return d->alignment; never executed: return d->alignment; | 0 |
| 307 | } | - |
| 308 | | - |
| 309 | | - |
| 310 | | - |
| | |