| Line | Source | Count |
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | QAbstractScrollAreaPrivate::QAbstractScrollAreaPrivate() | - |
| 9 | :hbar(0), vbar(0), vbarpolicy(Qt::ScrollBarAsNeeded), hbarpolicy(Qt::ScrollBarAsNeeded), | - |
| 10 | shownOnce(false), inResize(false), sizeAdjustPolicy(QAbstractScrollArea::AdjustIgnored), | - |
| 11 | viewport(0), cornerWidget(0), left(0), top(0), right(0), bottom(0), | - |
| 12 | xoffset(0), yoffset(0), viewportFilter(0) | - |
| 13 | | - |
| 14 | | - |
| 15 | | - |
| 16 | { | - |
| 17 | } | - |
| 18 | | - |
| 19 | QAbstractScrollAreaPrivate::~QAbstractScrollAreaPrivate() | - |
| 20 | { | - |
| 21 | } | - |
| 22 | | - |
| 23 | QAbstractScrollAreaScrollBarContainer::QAbstractScrollAreaScrollBarContainer(Qt::Orientation orientation, QWidget *parent) | - |
| 24 | :QWidget(parent), scrollBar(new QScrollBar(orientation, this)), | - |
| 25 | layout(new QBoxLayout(orientation == Qt::Horizontal ? QBoxLayout::LeftToRight : QBoxLayout::TopToBottom)), | - |
| 26 | orientation(orientation) | - |
| 27 | { | - |
| 28 | setLayout(layout); | - |
| 29 | layout->setMargin(0); | - |
| 30 | layout->setSpacing(0); | - |
| 31 | layout->addWidget(scrollBar); | - |
| 32 | layout->setSizeConstraint(QLayout::SetMaximumSize); | - |
| 33 | } | - |
| 34 | | - |
| 35 | | - |
| 36 | | - |
| 37 | | - |
| 38 | void QAbstractScrollAreaScrollBarContainer::addWidget(QWidget *widget, LogicalPosition position) | - |
| 39 | { | - |
| 40 | QSizePolicy policy = widget->sizePolicy(); | - |
| 41 | if (orientation == Qt::Vertical) | - |
| 42 | policy.setHorizontalPolicy(QSizePolicy::Ignored); | - |
| 43 | else | - |
| 44 | policy.setVerticalPolicy(QSizePolicy::Ignored); | - |
| 45 | widget->setSizePolicy(policy); | - |
| 46 | widget->setParent(this); | - |
| 47 | | - |
| 48 | const int insertIndex = (position & LogicalLeft) ? 0 : scrollBarLayoutIndex() + 1; | - |
| 49 | layout->insertWidget(insertIndex, widget); | - |
| 50 | } | - |
| 51 | | - |
| 52 | | - |
| 53 | | - |
| 54 | | - |
| 55 | | - |
| 56 | QWidgetList QAbstractScrollAreaScrollBarContainer::widgets(LogicalPosition position) | - |
| 57 | { | - |
| 58 | QWidgetList list; | - |
| 59 | const int scrollBarIndex = scrollBarLayoutIndex(); | - |
| 60 | if (position == LogicalLeft) { | - |
| 61 | list.reserve(scrollBarIndex); | - |
| 62 | for (int i = 0; i < scrollBarIndex; ++i) | - |
| 63 | list.append(layout->itemAt(i)->widget()); | - |
| 64 | } else if (position == LogicalRight) { | - |
| 65 | const int layoutItemCount = layout->count(); | - |
| 66 | list.reserve(layoutItemCount - (scrollBarIndex + 1)); | - |
| 67 | for (int i = scrollBarIndex + 1; i < layoutItemCount; ++i) | - |
| 68 | list.append(layout->itemAt(i)->widget()); | - |
| 69 | } | - |
| 70 | return list; | - |
| 71 | } | - |
| 72 | | - |
| 73 | | - |
| 74 | | - |
| 75 | | - |
| 76 | | - |
| 77 | | - |
| 78 | | - |
| 79 | int QAbstractScrollAreaScrollBarContainer::scrollBarLayoutIndex() const | - |
| 80 | { | - |
| 81 | const int layoutItemCount = layout->count(); | - |
| 82 | for (int i = 0; i < layoutItemCount; ++i) { | - |
| 83 | if (qobject_cast<QScrollBar *>(layout->itemAt(i)->widget())) | - |
| 84 | return i; | - |
| 85 | } | - |
| 86 | return -1; | - |
| 87 | } | - |
| 88 | | - |
| 89 | | - |
| 90 | | - |
| 91 | void QAbstractScrollAreaPrivate::replaceScrollBar(QScrollBar *scrollBar, | - |
| 92 | Qt::Orientation orientation) | - |
| 93 | { | - |
| 94 | QAbstractScrollArea * const q = q_func(); | - |
| 95 | | - |
| 96 | QAbstractScrollAreaScrollBarContainer *container = scrollBarContainers[orientation]; | - |
| 97 | bool horizontal = (orientation == Qt::Horizontal); | - |
| 98 | QScrollBar *oldBar = horizontal| TRUE | never evaluated | | FALSE | never evaluated |
? hbar : vbar; | 0 |
| 99 | if (horizontal| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 100 | hbar = scrollBar; never executed: hbar = scrollBar; | 0 |
| 101 | else | - |
| 102 | vbar = scrollBar; never executed: vbar = scrollBar; | 0 |
| 103 | scrollBar->setParent(container); | - |
| 104 | container->scrollBar = scrollBar; | - |
| 105 | container->layout->removeWidget(oldBar); | - |
| 106 | container->layout->insertWidget(0, scrollBar); | - |
| 107 | scrollBar->setVisible(oldBar->isVisibleTo(container)); | - |
| 108 | scrollBar->setInvertedAppearance(oldBar->invertedAppearance()); | - |
| 109 | scrollBar->setInvertedControls(oldBar->invertedControls()); | - |
| 110 | scrollBar->setRange(oldBar->minimum(), oldBar->maximum()); | - |
| 111 | scrollBar->setOrientation(oldBar->orientation()); | - |
| 112 | scrollBar->setPageStep(oldBar->pageStep()); | - |
| 113 | scrollBar->setSingleStep(oldBar->singleStep()); | - |
| 114 | scrollBar->d_func()->viewMayChangeSingleStep = oldBar->d_func()->viewMayChangeSingleStep; | - |
| 115 | scrollBar->setSliderDown(oldBar->isSliderDown()); | - |
| 116 | scrollBar->setSliderPosition(oldBar->sliderPosition()); | - |
| 117 | scrollBar->setTracking(oldBar->hasTracking()); | - |
| 118 | scrollBar->setValue(oldBar->value()); | - |
| 119 | scrollBar->installEventFilter(q); | - |
| 120 | oldBar->removeEventFilter(q); | - |
| 121 | delete oldBar; | - |
| 122 | | - |
| 123 | QObject::connect(scrollBar, qFlagLocation("2""valueChanged(int)" "\0" __FILE__ ":" "274""281"), | - |
| 124 | q, horizontal ? qFlagLocation("1""_q_hslide(int)" "\0" __FILE__ ":" "275""282") : qFlagLocation("1""_q_vslide(int)" "\0" __FILE__ ":" "275""282")); | - |
| 125 | QObject::connect(scrollBar, qFlagLocation("2""rangeChanged(int,int)" "\0" __FILE__ ":" "276""283"), | - |
| 126 | q, qFlagLocation("1""_q_showOrHideScrollBars()" "\0" __FILE__ ":" "277""284"), Qt::QueuedConnection); | - |
| 127 | } never executed: end of block | 0 |
| 128 | | - |
| 129 | void QAbstractScrollAreaPrivate::init() | - |
| 130 | { | - |
| 131 | QAbstractScrollArea * const q = q_func(); | - |
| 132 | viewport = new QWidget(q); | - |
| 133 | viewport->setObjectName(QLatin1String("qt_scrollarea_viewport")); | - |
| 134 | viewport->setBackgroundRole(QPalette::Base); | - |
| 135 | viewport->setAutoFillBackground(true); | - |
| 136 | scrollBarContainers[Qt::Horizontal] = new QAbstractScrollAreaScrollBarContainer(Qt::Horizontal, q); | - |
| 137 | scrollBarContainers[Qt::Horizontal]->setObjectName(QLatin1String("qt_scrollarea_hcontainer")); | - |
| 138 | hbar = scrollBarContainers[Qt::Horizontal]->scrollBar; | - |
| 139 | hbar->setRange(0,0); | - |
| 140 | scrollBarContainers[Qt::Horizontal]->setVisible(false); | - |
| 141 | hbar->installEventFilter(q); | - |
| 142 | QObject::connect(hbar, qFlagLocation("2""valueChanged(int)" "\0" __FILE__ ":" "293""300"), q, qFlagLocation("1""_q_hslide(int)" "\0" __FILE__ ":" "293""300")); | - |
| 143 | QObject::connect(hbar, qFlagLocation("2""rangeChanged(int,int)" "\0" __FILE__ ":" "294""301"), q, qFlagLocation("1""_q_showOrHideScrollBars()" "\0" __FILE__ ":" "294""301"), Qt::QueuedConnection); | - |
| 144 | scrollBarContainers[Qt::Vertical] = new QAbstractScrollAreaScrollBarContainer(Qt::Vertical, q); | - |
| 145 | scrollBarContainers[Qt::Vertical]->setObjectName(QLatin1String("qt_scrollarea_vcontainer")); | - |
| 146 | vbar = scrollBarContainers[Qt::Vertical]->scrollBar; | - |
| 147 | vbar->setRange(0,0); | - |
| 148 | scrollBarContainers[Qt::Vertical]->setVisible(false); | - |
| 149 | vbar->installEventFilter(q); | - |
| 150 | QObject::connect(vbar, qFlagLocation("2""valueChanged(int)" "\0" __FILE__ ":" "301""308"), q, qFlagLocation("1""_q_vslide(int)" "\0" __FILE__ ":" "301""308")); | - |
| 151 | QObject::connect(vbar, qFlagLocation("2""rangeChanged(int,int)" "\0" __FILE__ ":" "302""309"), q, qFlagLocation("1""_q_showOrHideScrollBars()" "\0" __FILE__ ":" "302""309"), Qt::QueuedConnection); | - |
| 152 | viewportFilter.reset(new QAbstractScrollAreaFilter(this)); | - |
| 153 | viewport->installEventFilter(viewportFilter.data()); | - |
| 154 | viewport->setFocusProxy(q); | - |
| 155 | q->setFocusPolicy(Qt::StrongFocus); | - |
| 156 | q->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); | - |
| 157 | q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | - |
| 158 | layoutChildren(); | - |
| 159 | | - |
| 160 | | - |
| 161 | viewport->grabGesture(Qt::PanGesture); | - |
| 162 | | - |
| 163 | | - |
| 164 | } | - |
| 165 | void QAbstractScrollAreaPrivate::layoutChildren() | - |
| 166 | { | - |
| 167 | QAbstractScrollArea * const q = q_func(); | - |
| 168 | bool htransient = hbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, hbar); | - |
| 169 | bool needh = (| TRUE | never evaluated | | FALSE | never evaluated |
hbarpolicy != Qt::ScrollBarAlwaysOff)| TRUE | never evaluated | | FALSE | never evaluated |
&& ((hbarpolicy == Qt::ScrollBarAlwaysOn| TRUE | never evaluated | | FALSE | never evaluated |
&& !htransient| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 170 | || ((hbarpolicy == Qt::ScrollBarAsNeeded| TRUE | never evaluated | | FALSE | never evaluated |
|| htransient| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 171 | && hbar->minimum() < hbar->maximum()| TRUE | never evaluated | | FALSE | never evaluated |
&& !hbar->sizeHint().isEmpty()| TRUE | never evaluated | | FALSE | never evaluated |
)); | 0 |
| 172 | | - |
| 173 | bool vtransient = vbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, vbar); | - |
| 174 | bool needv = (| TRUE | never evaluated | | FALSE | never evaluated |
vbarpolicy != Qt::ScrollBarAlwaysOff)| TRUE | never evaluated | | FALSE | never evaluated |
&& ((vbarpolicy == Qt::ScrollBarAlwaysOn| TRUE | never evaluated | | FALSE | never evaluated |
&& !vtransient| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 175 | || ((vbarpolicy == Qt::ScrollBarAsNeeded| TRUE | never evaluated | | FALSE | never evaluated |
|| vtransient| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 176 | && vbar->minimum() < vbar->maximum()| TRUE | never evaluated | | FALSE | never evaluated |
&& !vbar->sizeHint().isEmpty()| TRUE | never evaluated | | FALSE | never evaluated |
)); | 0 |
| 177 | | - |
| 178 | QStyleOption opt(0); | - |
| 179 | opt.init(q); | - |
| 180 | | - |
| 181 | const int hscrollOverlap = hbar->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarOverlap, &opt, hbar); | - |
| 182 | const int vscrollOverlap = vbar->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarOverlap, &opt, vbar); | - |
| 183 | const int hsbExt = hbar->sizeHint().height(); | - |
| 184 | const int vsbExt = vbar->sizeHint().width(); | - |
| 185 | const QPoint extPoint(vsbExt, hsbExt); | - |
| 186 | const QSize extSize(vsbExt, hsbExt); | - |
| 187 | | - |
| 188 | const QRect widgetRect = q->rect(); | - |
| 189 | | - |
| 190 | const bool hasCornerWidget = (cornerWidget != 0); | - |
| 191 | QPoint cornerOffset((needv && vscrollOverlap == 0) ? vsbExt : 0, (needh && hscrollOverlap == 0) ? hsbExt : 0); | - |
| 192 | QRect controlsRect; | - |
| 193 | QRect viewportRect; | - |
| 194 | | - |
| 195 | | - |
| 196 | | - |
| 197 | if ((| TRUE | never evaluated | | FALSE | never evaluated |
frameStyle != QFrame::NoFrame)| TRUE | never evaluated | | FALSE | never evaluated |
&& | 0 |
| 198 | q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, &opt, q)| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 199 | controlsRect = widgetRect; | - |
| 200 | const int spacing = q->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing, &opt, q); | - |
| 201 | const QPoint cornerExtra(needv ? spacing + vscrollOverlap : 0, needh ? spacing + hscrollOverlap : 0); | - |
| 202 | QRect frameRect = widgetRect; | - |
| 203 | frameRect.adjust(0, 0, -cornerOffset.x() - cornerExtra.x(), -cornerOffset.y() - cornerExtra.y()); | - |
| 204 | q->setFrameRect(QStyle::visualRect(opt.direction, opt.rect, frameRect)); | - |
| 205 | | - |
| 206 | | - |
| 207 | | - |
| 208 | viewportRect = QStyle::visualRect(opt.direction, opt.rect, q->contentsRect()); | - |
| 209 | } never executed: end of block else { | 0 |
| 210 | q->setFrameRect(QStyle::visualRect(opt.direction, opt.rect, widgetRect)); | - |
| 211 | controlsRect = q->contentsRect(); | - |
| 212 | viewportRect = QRect(controlsRect.topLeft(), controlsRect.bottomRight() - cornerOffset); | - |
| 213 | } never executed: end of block | 0 |
| 214 | | - |
| 215 | cornerOffset = QPoint(needv ? vsbExt : 0, needh ? hsbExt : 0); | - |
| 216 | | - |
| 217 | | - |
| 218 | | - |
| 219 | if (hasCornerWidget| TRUE | never evaluated | | FALSE | never evaluated |
&& ((needv| TRUE | never evaluated | | FALSE | never evaluated |
&& vscrollOverlap == 0| TRUE | never evaluated | | FALSE | never evaluated |
) || (needh| TRUE | never evaluated | | FALSE | never evaluated |
&& hscrollOverlap == 0| TRUE | never evaluated | | FALSE | never evaluated |
))) | 0 |
| 220 | cornerOffset = extPoint; never executed: cornerOffset = extPoint; | 0 |
| 221 | const QPoint cornerPoint(controlsRect.bottomRight() + QPoint(1, 1) - cornerOffset); | - |
| 222 | | - |
| 223 | | - |
| 224 | | - |
| 225 | if (needv| TRUE | never evaluated | | FALSE | never evaluated |
&& needh| TRUE | never evaluated | | FALSE | never evaluated |
&& !hasCornerWidget| TRUE | never evaluated | | FALSE | never evaluated |
&& hscrollOverlap == 0| TRUE | never evaluated | | FALSE | never evaluated |
&& vscrollOverlap == 0| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 226 | cornerPaintingRect = QStyle::visualRect(opt.direction, opt.rect, QRect(cornerPoint, extSize)); never executed: cornerPaintingRect = QStyle::visualRect(opt.direction, opt.rect, QRect(cornerPoint, extSize)); | 0 |
| 227 | else | - |
| 228 | cornerPaintingRect = QRect(); never executed: cornerPaintingRect = QRect(); | 0 |
| 229 | int vHeaderRight = 0; | - |
| 230 | int hHeaderBottom = 0; | - |
| 231 | if ((vscrollOverlap > 0| TRUE | never evaluated | | FALSE | never evaluated |
&& needv| TRUE | never evaluated | | FALSE | never evaluated |
) || (hscrollOverlap > 0| TRUE | never evaluated | | FALSE | never evaluated |
&& needh| TRUE | never evaluated | | FALSE | never evaluated |
)) { | 0 |
| 232 | const QList<QHeaderView *> headers = q->findChildren<QHeaderView*>(); | - |
| 233 | if (headers.count() <= 2| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 234 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(headers)>::type> _container_((headers)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (const QHeaderView *header = *_container_.i; _container_.control; _container_.control = 0: headers) { | - |
| 235 | const QRect geo = header->geometry(); | - |
| 236 | if (header->orientation() == Qt::Vertical| TRUE | never evaluated | | FALSE | never evaluated |
&& header->isVisible()| TRUE | never evaluated | | FALSE | never evaluated |
&& QStyle::visualRect(opt.direction, opt.rect, geo).left() <= opt.rect.width() / 2| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 237 | vHeaderRight = QStyle::visualRect(opt.direction, opt.rect, geo).right(); never executed: vHeaderRight = QStyle::visualRect(opt.direction, opt.rect, geo).right(); | 0 |
| 238 | else if (header->orientation() == Qt::Horizontal| TRUE | never evaluated | | FALSE | never evaluated |
&& header->isVisible()| TRUE | never evaluated | | FALSE | never evaluated |
&& geo.top() <= q->frameWidth()| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 239 | hHeaderBottom = geo.bottom(); never executed: hHeaderBottom = geo.bottom(); | 0 |
| 240 | } never executed: end of block | 0 |
| 241 | } never executed: end of block | 0 |
| 242 | } never executed: end of block | 0 |
| 243 | | - |
| 244 | if (needh| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 245 | QRect horizontalScrollBarRect(QPoint(controlsRect.left() + vHeaderRight, cornerPoint.y()), QPoint(cornerPoint.x() - 1, controlsRect.bottom())); | - |
| 246 | | - |
| 247 | | - |
| 248 | | - |
| 249 | | - |
| 250 | if (!hasCornerWidget| TRUE | never evaluated | | FALSE | never evaluated |
&& htransient| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 251 | | - |
| 252 | | - |
| 253 | | - |
| 254 | horizontalScrollBarRect.adjust(0, 0, cornerOffset.x(), 0); never executed: horizontalScrollBarRect.adjust(0, 0, cornerOffset.x(), 0); | 0 |
| 255 | scrollBarContainers[Qt::Horizontal]->setGeometry(QStyle::visualRect(opt.direction, opt.rect, horizontalScrollBarRect)); | - |
| 256 | scrollBarContainers[Qt::Horizontal]->raise(); | - |
| 257 | } never executed: end of block | 0 |
| 258 | | - |
| 259 | if (needv| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 260 | QRect verticalScrollBarRect (QPoint(cornerPoint.x(), controlsRect.top() + hHeaderBottom), QPoint(controlsRect.right(), cornerPoint.y() - 1)); | - |
| 261 | if (!hasCornerWidget| TRUE | never evaluated | | FALSE | never evaluated |
&& vtransient| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 262 | | - |
| 263 | | - |
| 264 | | - |
| 265 | verticalScrollBarRect.adjust(0, 0, 0, cornerOffset.y()); never executed: verticalScrollBarRect.adjust(0, 0, 0, cornerOffset.y()); | 0 |
| 266 | scrollBarContainers[Qt::Vertical]->setGeometry(QStyle::visualRect(opt.direction, opt.rect, verticalScrollBarRect)); | - |
| 267 | scrollBarContainers[Qt::Vertical]->raise(); | - |
| 268 | } never executed: end of block | 0 |
| 269 | | - |
| 270 | if (cornerWidget| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 271 | const QRect cornerWidgetRect(cornerPoint, controlsRect.bottomRight()); | - |
| 272 | cornerWidget->setGeometry(QStyle::visualRect(opt.direction, opt.rect, cornerWidgetRect)); | - |
| 273 | } never executed: end of block | 0 |
| 274 | | - |
| 275 | scrollBarContainers[Qt::Horizontal]->setVisible(needh); | - |
| 276 | scrollBarContainers[Qt::Vertical]->setVisible(needv); | - |
| 277 | | - |
| 278 | if (q->isRightToLeft()| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 279 | viewportRect.adjust(right, top, -left, -bottom); never executed: viewportRect.adjust(right, top, -left, -bottom); | 0 |
| 280 | else | - |
| 281 | viewportRect.adjust(left, top, -right, -bottom); never executed: viewportRect.adjust(left, top, -right, -bottom); | 0 |
| 282 | | - |
| 283 | viewport->setGeometry(QStyle::visualRect(opt.direction, opt.rect, viewportRect)); | - |
| 284 | } never executed: end of block | 0 |
| 285 | QAbstractScrollArea::QAbstractScrollArea(QAbstractScrollAreaPrivate &dd, QWidget *parent) | - |
| 286 | :QFrame(dd, parent) | - |
| 287 | { | - |
| 288 | QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 289 | if (true) { | - |
| 290 | d->init(); | - |
| 291 | } else { dead code: { d->viewportFilter.reset(); qt_noop(); } | - |
| 292 | d->viewportFilter.reset(); dead code: { d->viewportFilter.reset(); qt_noop(); } | - |
| 293 | qt_noop(); dead code: { d->viewportFilter.reset(); qt_noop(); } | - |
| 294 | } dead code: { d->viewportFilter.reset(); qt_noop(); } | - |
| 295 | } | - |
| 296 | | - |
| 297 | | - |
| 298 | | - |
| 299 | | - |
| 300 | | - |
| 301 | | - |
| 302 | QAbstractScrollArea::QAbstractScrollArea(QWidget *parent) | - |
| 303 | :QFrame(*new QAbstractScrollAreaPrivate, parent) | - |
| 304 | { | - |
| 305 | QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 306 | if (true) { | - |
| 307 | d->init(); | - |
| 308 | } else { dead code: { d->viewportFilter.reset(); qt_noop(); } | - |
| 309 | d->viewportFilter.reset(); dead code: { d->viewportFilter.reset(); qt_noop(); } | - |
| 310 | qt_noop(); dead code: { d->viewportFilter.reset(); qt_noop(); } | - |
| 311 | } dead code: { d->viewportFilter.reset(); qt_noop(); } | - |
| 312 | } | - |
| 313 | | - |
| 314 | | - |
| 315 | | - |
| 316 | | - |
| 317 | | - |
| 318 | QAbstractScrollArea::~QAbstractScrollArea() | - |
| 319 | { | - |
| 320 | QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 321 | | - |
| 322 | d->viewportFilter.reset(); | - |
| 323 | } | - |
| 324 | void QAbstractScrollArea::setViewport(QWidget *widget) | - |
| 325 | { | - |
| 326 | QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 327 | if (widget != d->viewport) { | - |
| 328 | QWidget *oldViewport = d->viewport; | - |
| 329 | if (!widget) | - |
| 330 | widget = new QWidget; | - |
| 331 | d->viewport = widget; | - |
| 332 | d->viewport->setParent(this); | - |
| 333 | d->viewport->setFocusProxy(this); | - |
| 334 | d->viewport->installEventFilter(d->viewportFilter.data()); | - |
| 335 | | - |
| 336 | | - |
| 337 | d->viewport->grabGesture(Qt::PanGesture); | - |
| 338 | | - |
| 339 | | - |
| 340 | d->layoutChildren(); | - |
| 341 | | - |
| 342 | QWidgetPrivate::get(d->viewport)->initializeViewportFramebuffer(); | - |
| 343 | | - |
| 344 | if (isVisible()) | - |
| 345 | d->viewport->show(); | - |
| 346 | setupViewport(widget); | - |
| 347 | delete oldViewport; | - |
| 348 | } | - |
| 349 | } | - |
| 350 | QWidget *QAbstractScrollArea::viewport() const | - |
| 351 | { | - |
| 352 | const QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 353 | return d->viewport; | - |
| 354 | } | - |
| 355 | | - |
| 356 | | - |
| 357 | | - |
| 358 | | - |
| 359 | | - |
| 360 | | - |
| 361 | | - |
| 362 | QSize QAbstractScrollArea::maximumViewportSize() const | - |
| 363 | { | - |
| 364 | const QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 365 | int hsbExt = d->hbar->sizeHint().height(); | - |
| 366 | int vsbExt = d->vbar->sizeHint().width(); | - |
| 367 | | - |
| 368 | int f = 2 * d->frameWidth; | - |
| 369 | QSize max = size() - QSize(f + d->left + d->right, f + d->top + d->bottom); | - |
| 370 | if (d->vbarpolicy == Qt::ScrollBarAlwaysOn) | - |
| 371 | max.rwidth() -= vsbExt; | - |
| 372 | if (d->hbarpolicy == Qt::ScrollBarAlwaysOn) | - |
| 373 | max.rheight() -= hsbExt; | - |
| 374 | return max; | - |
| 375 | } | - |
| 376 | Qt::ScrollBarPolicy QAbstractScrollArea::verticalScrollBarPolicy() const | - |
| 377 | { | - |
| 378 | const QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 379 | return d->vbarpolicy; | - |
| 380 | } | - |
| 381 | | - |
| 382 | void QAbstractScrollArea::setVerticalScrollBarPolicy(Qt::ScrollBarPolicy policy) | - |
| 383 | { | - |
| 384 | QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 385 | const Qt::ScrollBarPolicy oldPolicy = d->vbarpolicy; | - |
| 386 | d->vbarpolicy = policy; | - |
| 387 | if (isVisible()) | - |
| 388 | d->layoutChildren(); | - |
| 389 | if (oldPolicy != d->vbarpolicy) | - |
| 390 | d->scrollBarPolicyChanged(Qt::Vertical, d->vbarpolicy); | - |
| 391 | } | - |
| 392 | | - |
| 393 | | - |
| 394 | | - |
| 395 | | - |
| 396 | | - |
| 397 | | - |
| 398 | | - |
| 399 | QScrollBar *QAbstractScrollArea::verticalScrollBar() const | - |
| 400 | { | - |
| 401 | const QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 402 | return d->vbar; | - |
| 403 | } | - |
| 404 | void QAbstractScrollArea::setVerticalScrollBar(QScrollBar *scrollBar) | - |
| 405 | { | - |
| 406 | QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 407 | if (!(__builtin_expect(!!(!| TRUE | never evaluated | | FALSE | never evaluated |
scrollBar)), false)| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 408 | QMessageLogger(__FILE__, 709716, __PRETTY_FUNCTION__).warning("QAbstractScrollArea::setVerticalScrollBar: Cannot set a null scroll bar"); | - |
| 409 | return; never executed: return; | 0 |
| 410 | } | - |
| 411 | | - |
| 412 | d->replaceScrollBar(scrollBar, Qt::Vertical); | - |
| 413 | } never executed: end of block | 0 |
| 414 | Qt::ScrollBarPolicy QAbstractScrollArea::horizontalScrollBarPolicy() const | - |
| 415 | { | - |
| 416 | const QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 417 | return d->hbarpolicy; | - |
| 418 | } | - |
| 419 | | - |
| 420 | void QAbstractScrollArea::setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy policy) | - |
| 421 | { | - |
| 422 | QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 423 | const Qt::ScrollBarPolicy oldPolicy = d->hbarpolicy; | - |
| 424 | d->hbarpolicy = policy; | - |
| 425 | if (isVisible()) | - |
| 426 | d->layoutChildren(); | - |
| 427 | if (oldPolicy != d->hbarpolicy) | - |
| 428 | d->scrollBarPolicyChanged(Qt::Horizontal, d->hbarpolicy); | - |
| 429 | } | - |
| 430 | | - |
| 431 | | - |
| 432 | | - |
| 433 | | - |
| 434 | | - |
| 435 | | - |
| 436 | QScrollBar *QAbstractScrollArea::horizontalScrollBar() const | - |
| 437 | { | - |
| 438 | const QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 439 | return d->hbar; | - |
| 440 | } | - |
| 441 | void QAbstractScrollArea::setHorizontalScrollBar(QScrollBar *scrollBar) | - |
| 442 | { | - |
| 443 | QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 444 | if (!(__builtin_expect(!!(!| TRUE | never evaluated | | FALSE | never evaluated |
scrollBar)), false)| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 445 | QMessageLogger(__FILE__, 770777, __PRETTY_FUNCTION__).warning("QAbstractScrollArea::setHorizontalScrollBar: Cannot set a null scroll bar"); | - |
| 446 | return; never executed: return; | 0 |
| 447 | } | - |
| 448 | | - |
| 449 | d->replaceScrollBar(scrollBar, Qt::Horizontal); | - |
| 450 | } never executed: end of block | 0 |
| 451 | QWidget *QAbstractScrollArea::cornerWidget() const | - |
| 452 | { | - |
| 453 | const QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 454 | return d->cornerWidget; | - |
| 455 | } | - |
| 456 | void QAbstractScrollArea::setCornerWidget(QWidget *widget) | - |
| 457 | { | - |
| 458 | QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 459 | QWidget* oldWidget = d->cornerWidget; | - |
| 460 | if (oldWidget != widget) { | - |
| 461 | if (oldWidget) | - |
| 462 | oldWidget->hide(); | - |
| 463 | d->cornerWidget = widget; | - |
| 464 | | - |
| 465 | if (widget && widget->parentWidget() != this) | - |
| 466 | widget->setParent(this); | - |
| 467 | | - |
| 468 | d->layoutChildren(); | - |
| 469 | if (widget) | - |
| 470 | widget->show(); | - |
| 471 | } else { | - |
| 472 | d->cornerWidget = widget; | - |
| 473 | d->layoutChildren(); | - |
| 474 | } | - |
| 475 | } | - |
| 476 | void QAbstractScrollArea::addScrollBarWidget(QWidget *widget, Qt::Alignment alignment) | - |
| 477 | { | - |
| 478 | QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 479 | | - |
| 480 | if (widget == 0) | - |
| 481 | return; | - |
| 482 | | - |
| 483 | const Qt::Orientation scrollBarOrientation | - |
| 484 | = ((alignment & Qt::AlignLeft) || (alignment & Qt::AlignRight)) ? Qt::Horizontal : Qt::Vertical; | - |
| 485 | const QAbstractScrollAreaScrollBarContainer::LogicalPosition position | - |
| 486 | = ((alignment & Qt::AlignRight) || (alignment & Qt::AlignBottom)) | - |
| 487 | ? QAbstractScrollAreaScrollBarContainer::LogicalRight : QAbstractScrollAreaScrollBarContainer::LogicalLeft; | - |
| 488 | d->scrollBarContainers[scrollBarOrientation]->addWidget(widget, position); | - |
| 489 | d->layoutChildren(); | - |
| 490 | if (isHidden() == false) | - |
| 491 | widget->show(); | - |
| 492 | } | - |
| 493 | QWidgetList QAbstractScrollArea::scrollBarWidgets(Qt::Alignment alignment) | - |
| 494 | { | - |
| 495 | QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 496 | | - |
| 497 | QWidgetList list; | - |
| 498 | | - |
| 499 | if (alignment & Qt::AlignLeft) | - |
| 500 | list += d->scrollBarContainers[Qt::Horizontal]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalLeft); | - |
| 501 | if (alignment & Qt::AlignRight) | - |
| 502 | list += d->scrollBarContainers[Qt::Horizontal]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalRight); | - |
| 503 | if (alignment & Qt::AlignTop) | - |
| 504 | list += d->scrollBarContainers[Qt::Vertical]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalLeft); | - |
| 505 | if (alignment & Qt::AlignBottom) | - |
| 506 | list += d->scrollBarContainers[Qt::Vertical]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalRight); | - |
| 507 | | - |
| 508 | return list; | - |
| 509 | } | - |
| 510 | void QAbstractScrollArea::setViewportMargins(int left, int top, int right, int bottom) | - |
| 511 | { | - |
| 512 | QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 513 | d->left = left; | - |
| 514 | d->top = top; | - |
| 515 | d->right = right; | - |
| 516 | d->bottom = bottom; | - |
| 517 | d->layoutChildren(); | - |
| 518 | } | - |
| 519 | void QAbstractScrollArea::setViewportMargins(const QMargins &margins) | - |
| 520 | { | - |
| 521 | setViewportMargins(margins.left(), margins.top(), | - |
| 522 | margins.right(), margins.bottom()); | - |
| 523 | } | - |
| 524 | QMargins QAbstractScrollArea::viewportMargins() const | - |
| 525 | { | - |
| 526 | const QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 527 | return QMargins(d->left, d->top, d->right, d->bottom); | - |
| 528 | } | - |
| 529 | | - |
| 530 | | - |
| 531 | bool QAbstractScrollArea::eventFilter(QObject *o, QEvent *e) | - |
| 532 | { | - |
| 533 | QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 534 | if ((o == d->hbar || o == d->vbar) && (e->type() == QEvent::HoverEnter || e->type() == QEvent::HoverLeave)) { | - |
| 535 | if (d->hbarpolicy == Qt::ScrollBarAsNeeded && d->vbarpolicy == Qt::ScrollBarAsNeeded) { | - |
| 536 | QScrollBar *sbar = static_cast<QScrollBar*>(o); | - |
| 537 | QScrollBar *sibling = sbar == d->hbar ? d->vbar : d->hbar; | - |
| 538 | if (sbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, sbar) && | - |
| 539 | sibling->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, sibling)) | - |
| 540 | d->setScrollBarTransient(sibling, e->type() == QEvent::HoverLeave); | - |
| 541 | } | - |
| 542 | } | - |
| 543 | return QFrame::eventFilter(o, e); | - |
| 544 | } | - |
| 545 | bool QAbstractScrollArea::event(QEvent *e) | - |
| 546 | { | - |
| 547 | QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 548 | switch (e->type()) { | - |
| 549 | case QEvent::AcceptDropsChange: | - |
| 550 | | - |
| 551 | | - |
| 552 | | - |
| 553 | | - |
| 554 | | - |
| 555 | if (d->viewport) | - |
| 556 | d->viewport->setAcceptDrops(acceptDrops()); | - |
| 557 | break; | - |
| 558 | case QEvent::MouseTrackingChange: | - |
| 559 | d->viewport->setMouseTracking(hasMouseTracking()); | - |
| 560 | break; | - |
| 561 | case QEvent::Resize: | - |
| 562 | if (!d->inResize) { | - |
| 563 | d->inResize = true; | - |
| 564 | d->layoutChildren(); | - |
| 565 | d->inResize = false; | - |
| 566 | } | - |
| 567 | break; | - |
| 568 | case QEvent::Show: | - |
| 569 | if (!d->shownOnce && d->sizeAdjustPolicy == QAbstractScrollArea::AdjustToContentsOnFirstShow) { | - |
| 570 | d->sizeHint = QSize(); | - |
| 571 | updateGeometry(); | - |
| 572 | } | - |
| 573 | d->shownOnce = true; | - |
| 574 | return QFrame::event(e); | - |
| 575 | case QEvent::Paint: { | - |
| 576 | QStyleOption option; | - |
| 577 | option.initFrom(this); | - |
| 578 | if (d->cornerPaintingRect.isValid()) { | - |
| 579 | option.rect = d->cornerPaintingRect; | - |
| 580 | QPainter p(this); | - |
| 581 | style()->drawPrimitive(QStyle::PE_PanelScrollAreaCorner, &option, &p, this); | - |
| 582 | } | - |
| 583 | | - |
| 584 | | - |
| 585 | | - |
| 586 | | - |
| 587 | | - |
| 588 | | - |
| 589 | | - |
| 590 | } | - |
| 591 | QFrame::paintEvent((QPaintEvent*)e); | - |
| 592 | break; | - |
| 593 | | - |
| 594 | case QEvent::ContextMenu: | - |
| 595 | if (static_cast<QContextMenuEvent *>(e)->reason() == QContextMenuEvent::Keyboard) | - |
| 596 | return QFrame::event(e); | - |
| 597 | e->ignore(); | - |
| 598 | break; | - |
| 599 | | - |
| 600 | case QEvent::MouseButtonPress: | - |
| 601 | case QEvent::MouseButtonRelease: | - |
| 602 | case QEvent::MouseButtonDblClick: | - |
| 603 | case QEvent::MouseMove: | - |
| 604 | case QEvent::Wheel: | - |
| 605 | | - |
| 606 | case QEvent::Drop: | - |
| 607 | case QEvent::DragEnter: | - |
| 608 | case QEvent::DragMove: | - |
| 609 | case QEvent::DragLeave: | - |
| 610 | | - |
| 611 | | - |
| 612 | case QEvent::TouchBegin: | - |
| 613 | case QEvent::TouchUpdate: | - |
| 614 | case QEvent::TouchEnd: | - |
| 615 | return false; | - |
| 616 | | - |
| 617 | case QEvent::Gesture: | - |
| 618 | { | - |
| 619 | QGestureEvent *ge = static_cast<QGestureEvent *>(e); | - |
| 620 | QPanGesture *g = static_cast<QPanGesture *>(ge->gesture(Qt::PanGesture)); | - |
| 621 | if (g) { | - |
| 622 | QScrollBar *hBar = horizontalScrollBar(); | - |
| 623 | QScrollBar *vBar = verticalScrollBar(); | - |
| 624 | QPointF delta = g->delta(); | - |
| 625 | if (!delta.isNull()) { | - |
| 626 | if (QApplication::isRightToLeft()) | - |
| 627 | delta.rx() *= -1; | - |
| 628 | int newX = hBar->value() - delta.x(); | - |
| 629 | int newY = vBar->value() - delta.y(); | - |
| 630 | hBar->setValue(newX); | - |
| 631 | vBar->setValue(newY); | - |
| 632 | } | - |
| 633 | return true; | - |
| 634 | } | - |
| 635 | return false; | - |
| 636 | } | - |
| 637 | | - |
| 638 | case QEvent::ScrollPrepare: | - |
| 639 | { | - |
| 640 | QScrollPrepareEvent *se = static_cast<QScrollPrepareEvent *>(e); | - |
| 641 | if (d->canStartScrollingAt(se->startPos().toPoint())) { | - |
| 642 | QScrollBar *hBar = horizontalScrollBar(); | - |
| 643 | QScrollBar *vBar = verticalScrollBar(); | - |
| 644 | | - |
| 645 | se->setViewportSize(QSizeF(viewport()->size())); | - |
| 646 | se->setContentPosRange(QRectF(0, 0, hBar->maximum(), vBar->maximum())); | - |
| 647 | se->setContentPos(QPointF(hBar->value(), vBar->value())); | - |
| 648 | se->accept(); | - |
| 649 | return true; | - |
| 650 | } | - |
| 651 | return false; | - |
| 652 | } | - |
| 653 | case QEvent::Scroll: | - |
| 654 | { | - |
| 655 | QScrollEvent *se = static_cast<QScrollEvent *>(e); | - |
| 656 | | - |
| 657 | QScrollBar *hBar = horizontalScrollBar(); | - |
| 658 | QScrollBar *vBar = verticalScrollBar(); | - |
| 659 | hBar->setValue(se->contentPos().x()); | - |
| 660 | vBar->setValue(se->contentPos().y()); | - |
| 661 | { | - |
| 662 | QPoint delta = d->overshoot - se->overshootDistance().toPoint(); | - |
| 663 | if (!delta.isNull()) | - |
| 664 | viewport()->move(viewport()->pos() + delta); | - |
| 665 | } | - |
| 666 | d->overshoot = se->overshootDistance().toPoint(); | - |
| 667 | | - |
| 668 | return true; | - |
| 669 | } | - |
| 670 | case QEvent::StyleChange: | - |
| 671 | case QEvent::LayoutDirectionChange: | - |
| 672 | case QEvent::ApplicationLayoutDirectionChange: | - |
| 673 | case QEvent::LayoutRequest: | - |
| 674 | d->layoutChildren(); | - |
| 675 | | - |
| 676 | default: | - |
| 677 | return QFrame::event(e); | - |
| 678 | } | - |
| 679 | return true; | - |
| 680 | } | - |
| 681 | bool QAbstractScrollArea::viewportEvent(QEvent *e) | - |
| 682 | { | - |
| 683 | switch (e->type()) { | - |
| 684 | case QEvent::Resize: | - |
| 685 | case QEvent::Paint: | - |
| 686 | case QEvent::MouseButtonPress: | - |
| 687 | case QEvent::MouseButtonRelease: | - |
| 688 | case QEvent::MouseButtonDblClick: | - |
| 689 | case QEvent::TouchBegin: | - |
| 690 | case QEvent::TouchUpdate: | - |
| 691 | case QEvent::TouchEnd: | - |
| 692 | case QEvent::MouseMove: | - |
| 693 | case QEvent::ContextMenu: | - |
| 694 | | - |
| 695 | case QEvent::Wheel: | - |
| 696 | | - |
| 697 | | - |
| 698 | case QEvent::Drop: | - |
| 699 | case QEvent::DragEnter: | - |
| 700 | case QEvent::DragMove: | - |
| 701 | case QEvent::DragLeave: | - |
| 702 | | - |
| 703 | | - |
| 704 | | - |
| 705 | | - |
| 706 | if (e->type() == QEvent::Resize) | - |
| 707 | QWidgetPrivate::get(viewport())->resizeViewportFramebuffer(); | - |
| 708 | | - |
| 709 | return QFrame::event(e); | - |
| 710 | case QEvent::LayoutRequest: | - |
| 711 | | - |
| 712 | case QEvent::Gesture: | - |
| 713 | case QEvent::GestureOverride: | - |
| 714 | return event(e); | - |
| 715 | | - |
| 716 | case QEvent::ScrollPrepare: | - |
| 717 | case QEvent::Scroll: | - |
| 718 | return event(e); | - |
| 719 | default: | - |
| 720 | break; | - |
| 721 | } | - |
| 722 | return false; | - |
| 723 | } | - |
| 724 | void QAbstractScrollArea::resizeEvent(QResizeEvent *) | - |
| 725 | { | - |
| 726 | } | - |
| 727 | void QAbstractScrollArea::paintEvent(QPaintEvent*) | - |
| 728 | { | - |
| 729 | } | - |
| 730 | void QAbstractScrollArea::mousePressEvent(QMouseEvent *e) | - |
| 731 | { | - |
| 732 | e->ignore(); | - |
| 733 | } | - |
| 734 | void QAbstractScrollArea::mouseReleaseEvent(QMouseEvent *e) | - |
| 735 | { | - |
| 736 | e->ignore(); | - |
| 737 | } | - |
| 738 | void QAbstractScrollArea::mouseDoubleClickEvent(QMouseEvent *e) | - |
| 739 | { | - |
| 740 | e->ignore(); | - |
| 741 | } | - |
| 742 | void QAbstractScrollArea::mouseMoveEvent(QMouseEvent *e) | - |
| 743 | { | - |
| 744 | e->ignore(); | - |
| 745 | } | - |
| 746 | void QAbstractScrollArea::wheelEvent(QWheelEvent *e) | - |
| 747 | { | - |
| 748 | QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 749 | if (static_cast<QWheelEvent*>(e)->orientation() == Qt::Horizontal) | - |
| 750 | QApplication::sendEvent(d->hbar, e); | - |
| 751 | else | - |
| 752 | QApplication::sendEvent(d->vbar, e); | - |
| 753 | } | - |
| 754 | void QAbstractScrollArea::contextMenuEvent(QContextMenuEvent *e) | - |
| 755 | { | - |
| 756 | e->ignore(); | - |
| 757 | } | - |
| 758 | | - |
| 759 | | - |
| 760 | | - |
| 761 | | - |
| 762 | | - |
| 763 | | - |
| 764 | | - |
| 765 | void QAbstractScrollArea::keyPressEvent(QKeyEvent * e) | - |
| 766 | { | - |
| 767 | QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 768 | if (false){ dead code: { } | - |
| 769 | | - |
| 770 | } dead code: { } else if (e == QKeySequence::MoveToPreviousPage) { | - |
| 771 | d->vbar->triggerAction(QScrollBar::SliderPageStepSub); | - |
| 772 | } else if (e == QKeySequence::MoveToNextPage) { | - |
| 773 | d->vbar->triggerAction(QScrollBar::SliderPageStepAdd); | - |
| 774 | | - |
| 775 | } else { | - |
| 776 | | - |
| 777 | | - |
| 778 | | - |
| 779 | | - |
| 780 | | - |
| 781 | | - |
| 782 | switch (e->key()) { | - |
| 783 | case Qt::Key_Up: | - |
| 784 | d->vbar->triggerAction(QScrollBar::SliderSingleStepSub); | - |
| 785 | break; | - |
| 786 | case Qt::Key_Down: | - |
| 787 | d->vbar->triggerAction(QScrollBar::SliderSingleStepAdd); | - |
| 788 | break; | - |
| 789 | case Qt::Key_Left: | - |
| 790 | d->hbar->triggerAction( | - |
| 791 | layoutDirection() == Qt::LeftToRight | - |
| 792 | ? QScrollBar::SliderSingleStepSub : QScrollBar::SliderSingleStepAdd); | - |
| 793 | break; | - |
| 794 | case Qt::Key_Right: | - |
| 795 | d->hbar->triggerAction( | - |
| 796 | layoutDirection() == Qt::LeftToRight | - |
| 797 | ? QScrollBar::SliderSingleStepAdd : QScrollBar::SliderSingleStepSub); | - |
| 798 | break; | - |
| 799 | default: | - |
| 800 | e->ignore(); | - |
| 801 | return; | - |
| 802 | } | - |
| 803 | } | - |
| 804 | e->accept(); | - |
| 805 | } | - |
| 806 | void QAbstractScrollArea::dragEnterEvent(QDragEnterEvent *) | - |
| 807 | { | - |
| 808 | } | - |
| 809 | void QAbstractScrollArea::dragMoveEvent(QDragMoveEvent *) | - |
| 810 | { | - |
| 811 | } | - |
| 812 | void QAbstractScrollArea::dragLeaveEvent(QDragLeaveEvent *) | - |
| 813 | { | - |
| 814 | } | - |
| 815 | void QAbstractScrollArea::dropEvent(QDropEvent *) | - |
| 816 | { | - |
| 817 | } | - |
| 818 | void QAbstractScrollArea::scrollContentsBy(int, int) | - |
| 819 | { | - |
| 820 | viewport()->update(); | - |
| 821 | } | - |
| 822 | | - |
| 823 | bool QAbstractScrollAreaPrivate::canStartScrollingAt( const QPoint &startPos ) | - |
| 824 | { | - |
| 825 | QAbstractScrollArea * const q = q_func(); | - |
| 826 | | - |
| 827 | | - |
| 828 | | - |
| 829 | | - |
| 830 | if (QGraphicsView *view = qobject_cast<QGraphicsView *>(q)) { | - |
| 831 | if (view->dragMode() != QGraphicsView::NoDrag) | - |
| 832 | return false; | - |
| 833 | | - |
| 834 | QGraphicsItem *childItem = view->itemAt(startPos); | - |
| 835 | | - |
| 836 | if (childItem && (childItem->flags() & QGraphicsItem::ItemIsMovable)) | - |
| 837 | return false; | - |
| 838 | } | - |
| 839 | | - |
| 840 | | - |
| 841 | | - |
| 842 | if (qobject_cast<QAbstractSlider *>(q->viewport()->childAt(startPos))) { | - |
| 843 | return false; | - |
| 844 | } | - |
| 845 | | - |
| 846 | return true; | - |
| 847 | } | - |
| 848 | | - |
| 849 | void QAbstractScrollAreaPrivate::flashScrollBars() | - |
| 850 | { | - |
| 851 | bool htransient = hbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, hbar); | - |
| 852 | if ((hbarpolicy != Qt::ScrollBarAlwaysOff) && (hbarpolicy == Qt::ScrollBarAsNeeded || htransient)) | - |
| 853 | hbar->d_func()->flash(); | - |
| 854 | bool vtransient = vbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, vbar); | - |
| 855 | if ((vbarpolicy != Qt::ScrollBarAlwaysOff) && (vbarpolicy == Qt::ScrollBarAsNeeded || vtransient)) | - |
| 856 | vbar->d_func()->flash(); | - |
| 857 | } | - |
| 858 | | - |
| 859 | void QAbstractScrollAreaPrivate::setScrollBarTransient(QScrollBar *scrollBar, bool transient) | - |
| 860 | { | - |
| 861 | scrollBar->d_func()->setTransient(transient); | - |
| 862 | } | - |
| 863 | | - |
| 864 | void QAbstractScrollAreaPrivate::_q_hslide(int x) | - |
| 865 | { | - |
| 866 | QAbstractScrollArea * const q = q_func(); | - |
| 867 | int dx = xoffset - x; | - |
| 868 | xoffset = x; | - |
| 869 | q->scrollContentsBy(dx, 0); | - |
| 870 | flashScrollBars(); | - |
| 871 | } | - |
| 872 | | - |
| 873 | void QAbstractScrollAreaPrivate::_q_vslide(int y) | - |
| 874 | { | - |
| 875 | QAbstractScrollArea * const q = q_func(); | - |
| 876 | int dy = yoffset - y; | - |
| 877 | yoffset = y; | - |
| 878 | q->scrollContentsBy(0, dy); | - |
| 879 | flashScrollBars(); | - |
| 880 | } | - |
| 881 | | - |
| 882 | void QAbstractScrollAreaPrivate::_q_showOrHideScrollBars() | - |
| 883 | { | - |
| 884 | layoutChildren(); | - |
| 885 | | - |
| 886 | | - |
| 887 | | - |
| 888 | | - |
| 889 | | - |
| 890 | | - |
| 891 | | - |
| 892 | } | - |
| 893 | | - |
| 894 | QPoint QAbstractScrollAreaPrivate::contentsOffset() const | - |
| 895 | { | - |
| 896 | const QAbstractScrollArea * const q = q_func(); | - |
| 897 | QPoint offset; | - |
| 898 | if (vbar->isVisible()) | - |
| 899 | offset.setY(vbar->value()); | - |
| 900 | if (hbar->isVisible()) { | - |
| 901 | if (q->isRightToLeft()) | - |
| 902 | offset.setX(hbar->maximum() - hbar->value()); | - |
| 903 | else | - |
| 904 | offset.setX(hbar->value()); | - |
| 905 | } | - |
| 906 | return offset; | - |
| 907 | } | - |
| 908 | | - |
| 909 | | - |
| 910 | | - |
| 911 | | - |
| 912 | | - |
| 913 | QSize QAbstractScrollArea::minimumSizeHint() const | - |
| 914 | { | - |
| 915 | const QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 916 | int hsbExt = d->hbar->sizeHint().height(); | - |
| 917 | int vsbExt = d->vbar->sizeHint().width(); | - |
| 918 | int extra = 2 * d->frameWidth; | - |
| 919 | QStyleOption opt; | - |
| 920 | opt.initFrom(this); | - |
| 921 | if ((d->frameStyle != QFrame::NoFrame) | - |
| 922 | && style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, &opt, this)) { | - |
| 923 | extra += style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing, &opt, this); | - |
| 924 | } | - |
| 925 | return QSize(d->scrollBarContainers[Qt::Horizontal]->sizeHint().width() + vsbExt + extra, | - |
| 926 | d->scrollBarContainers[Qt::Vertical]->sizeHint().height() + hsbExt + extra); | - |
| 927 | } | - |
| 928 | | - |
| 929 | | - |
| 930 | | - |
| 931 | | - |
| 932 | | - |
| 933 | | - |
| 934 | QSize QAbstractScrollArea::sizeHint() const | - |
| 935 | { | - |
| 936 | const QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 937 | if (d->sizeAdjustPolicy == QAbstractScrollArea::AdjustIgnored) | - |
| 938 | return QSize(256, 192); | - |
| 939 | | - |
| 940 | if (!d->sizeHint.isValid() || d->sizeAdjustPolicy == QAbstractScrollArea::AdjustToContents) { | - |
| 941 | const int f = 2 * d->frameWidth; | - |
| 942 | const QSize frame( f, f ); | - |
| 943 | const QSize scrollbars(d->vbarpolicy == Qt::ScrollBarAlwaysOn ? d->vbar->sizeHint().width() : 0, | - |
| 944 | d->hbarpolicy == Qt::ScrollBarAlwaysOn ? d->hbar->sizeHint().height() : 0); | - |
| 945 | d->sizeHint = frame + scrollbars + viewportSizeHint(); | - |
| 946 | } | - |
| 947 | return d->sizeHint; | - |
| 948 | } | - |
| 949 | | - |
| 950 | | - |
| 951 | | - |
| 952 | | - |
| 953 | | - |
| 954 | | - |
| 955 | | - |
| 956 | QSize QAbstractScrollArea::viewportSizeHint() const | - |
| 957 | { | - |
| 958 | const QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 959 | if (d->viewport) { | - |
| 960 | const QSize sh = d->viewport->sizeHint(); | - |
| 961 | if (sh.isValid()) { | - |
| 962 | return sh; | - |
| 963 | } | - |
| 964 | } | - |
| 965 | const int h = qMax(10, fontMetrics().height()); | - |
| 966 | return QSize(6 * h, 4 * h); | - |
| 967 | } | - |
| 968 | QAbstractScrollArea::SizeAdjustPolicy QAbstractScrollArea::sizeAdjustPolicy() const | - |
| 969 | { | - |
| 970 | const QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 971 | return d->sizeAdjustPolicy; | - |
| 972 | } | - |
| 973 | | - |
| 974 | void QAbstractScrollArea::setSizeAdjustPolicy(SizeAdjustPolicy policy) | - |
| 975 | { | - |
| 976 | QAbstractScrollAreaPrivate * const d = d_func(); | - |
| 977 | if (d->sizeAdjustPolicy == policy) | - |
| 978 | return; | - |
| 979 | | - |
| 980 | d->sizeAdjustPolicy = policy; | - |
| 981 | d->sizeHint = QSize(); | - |
| 982 | updateGeometry(); | - |
| 983 | } | - |
| 984 | void QAbstractScrollArea::setupViewport(QWidget *viewport) | - |
| 985 | { | - |
| 986 | (void)viewport;; | - |
| 987 | } | - |
| 988 | | - |
| 989 | | - |
| 990 | | - |
| | |