qabstractscrollarea.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qabstractscrollarea.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qabstractscrollarea.h"-
41-
42#ifndef QT_NO_SCROLLAREA-
43-
44#include "qscrollbar.h"-
45#include "qapplication.h"-
46#include "qstyle.h"-
47#include "qstyleoption.h"-
48#include "qevent.h"-
49#include "qdebug.h"-
50#include "qboxlayout.h"-
51#include "qpainter.h"-
52#include "qmargins.h"-
53#include "qheaderview.h"-
54-
55#include <QDebug>-
56-
57#include "qabstractscrollarea_p.h"-
58#include "qscrollbar_p.h"-
59#include <qwidget.h>-
60-
61#include <private/qapplication_p.h>-
62-
63#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
64#include <private/qt_mac_p.h>-
65#include <private/qt_cocoa_helpers_mac_p.h>-
66#endif-
67#ifdef Q_OS_WIN-
68# include <qlibrary.h>-
69# include <qt_windows.h>-
70#endif-
71-
72QT_BEGIN_NAMESPACE-
73-
74/*!-
75 \class QAbstractScrollArea-
76 \brief The QAbstractScrollArea widget provides a scrolling area with-
77 on-demand scroll bars.-
78-
79 \ingroup abstractwidgets-
80 \inmodule QtWidgets-
81-
82 QAbstractScrollArea is a low-level abstraction of a scrolling-
83 area. The area provides a central widget called the viewport, in-
84 which the contents of the area is to be scrolled (i.e, the-
85 visible parts of the contents are rendered in the viewport).-
86-
87 Next to the viewport is a vertical scroll bar, and below is a-
88 horizontal scroll bar. When all of the area contents fits in the-
89 viewport, each scroll bar can be either visible or hidden-
90 depending on the scroll bar's Qt::ScrollBarPolicy. When a scroll-
91 bar is hidden, the viewport expands in order to cover all-
92 available space. When a scroll bar becomes visible again, the-
93 viewport shrinks in order to make room for the scroll bar.-
94-
95 It is possible to reserve a margin area around the viewport, see-
96 setViewportMargins(). The feature is mostly used to place a-
97 QHeaderView widget above or beside the scrolling area. Subclasses-
98 of QAbstractScrollArea should implement margins.-
99-
100 When inheriting QAbstractScrollArea, you need to do the-
101 following:-
102-
103 \list-
104 \li Control the scroll bars by setting their-
105 range, value, page step, and tracking their-
106 movements.-
107 \li Draw the contents of the area in the viewport according-
108 to the values of the scroll bars.-
109 \li Handle events received by the viewport in-
110 viewportEvent() - notably resize events.-
111 \li Use \c{viewport->update()} to update the contents of the-
112 viewport instead of \l{QWidget::update()}{update()}-
113 as all painting operations take place on the viewport.-
114 \endlist-
115-
116 With a scroll bar policy of Qt::ScrollBarAsNeeded (the default),-
117 QAbstractScrollArea shows scroll bars when they provide a non-zero-
118 scrolling range, and hides them otherwise.-
119-
120 The scroll bars and viewport should be updated whenever the viewport-
121 receives a resize event or the size of the contents changes.-
122 The viewport also needs to be updated when the scroll bars-
123 values change. The initial values of the scroll bars are often-
124 set when the area receives new contents.-
125-
126 We give a simple example, in which we have implemented a scroll area-
127 that can scroll any QWidget. We make the widget a child of the-
128 viewport; this way, we do not have to calculate which part of-
129 the widget to draw but can simply move the widget with-
130 QWidget::move(). When the area contents or the viewport size-
131 changes, we do the following:-
132-
133 \snippet myscrollarea.cpp 1-
134-
135 When the scroll bars change value, we need to update the widget-
136 position, i.e., find the part of the widget that is to be drawn in-
137 the viewport:-
138-
139 \snippet myscrollarea.cpp 0-
140-
141 In order to track scroll bar movements, reimplement the virtual-
142 function scrollContentsBy(). In order to fine-tune scrolling-
143 behavior, connect to a scroll bar's-
144 QAbstractSlider::actionTriggered() signal and adjust the \l-
145 QAbstractSlider::sliderPosition as you wish.-
146-
147 For convenience, QAbstractScrollArea makes all viewport events-
148 available in the virtual viewportEvent() handler. QWidget's-
149 specialized handlers are remapped to viewport events in the cases-
150 where this makes sense. The remapped specialized handlers are:-
151 paintEvent(), mousePressEvent(), mouseReleaseEvent(),-
152 mouseDoubleClickEvent(), mouseMoveEvent(), wheelEvent(),-
153 dragEnterEvent(), dragMoveEvent(), dragLeaveEvent(), dropEvent(),-
154 contextMenuEvent(), and resizeEvent().-
155-
156 QScrollArea, which inherits QAbstractScrollArea, provides smooth-
157 scrolling for any QWidget (i.e., the widget is scrolled pixel by-
158 pixel). You only need to subclass QAbstractScrollArea if you need-
159 more specialized behavior. This is, for instance, true if the-
160 entire contents of the area is not suitable for being drawn on a-
161 QWidget or if you do not want smooth scrolling.-
162-
163 \sa QScrollArea-
164*/-
165-
166QAbstractScrollAreaPrivate::QAbstractScrollAreaPrivate()-
167 :hbar(0), vbar(0), vbarpolicy(Qt::ScrollBarAsNeeded), hbarpolicy(Qt::ScrollBarAsNeeded),-
168 shownOnce(false), inResize(false), sizeAdjustPolicy(QAbstractScrollArea::AdjustIgnored),-
169 viewport(0), cornerWidget(0), left(0), top(0), right(0), bottom(0),-
170 xoffset(0), yoffset(0), viewportFilter(0)-
171#ifdef Q_DEAD_CODE_FROM_QT4_WIN-
172 , singleFingerPanEnabled(false)-
173#endif-
174{-
175}
never executed: end of block
0
176-
177QAbstractScrollAreaPrivate::~QAbstractScrollAreaPrivate()-
178{-
179}-
180-
181QAbstractScrollAreaScrollBarContainer::QAbstractScrollAreaScrollBarContainer(Qt::Orientation orientation, QWidget *parent)-
182 :QWidget(parent), scrollBar(new QScrollBar(orientation, this)),-
183 layout(new QBoxLayout(orientation == Qt::Horizontal ? QBoxLayout::LeftToRight : QBoxLayout::TopToBottom)),-
184 orientation(orientation)-
185{-
186 setLayout(layout);-
187 layout->setMargin(0);-
188 layout->setSpacing(0);-
189 layout->addWidget(scrollBar);-
190 layout->setSizeConstraint(QLayout::SetMaximumSize);-
191}
never executed: end of block
0
192-
193/*! \internal-
194 Adds a widget to the scroll bar container.-
195*/-
196void QAbstractScrollAreaScrollBarContainer::addWidget(QWidget *widget, LogicalPosition position)-
197{-
198 QSizePolicy policy = widget->sizePolicy();-
199 if (orientation == Qt::Vertical)
orientation == Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
200 policy.setHorizontalPolicy(QSizePolicy::Ignored);
never executed: policy.setHorizontalPolicy(QSizePolicy::Ignored);
0
201 else-
202 policy.setVerticalPolicy(QSizePolicy::Ignored);
never executed: policy.setVerticalPolicy(QSizePolicy::Ignored);
0
203 widget->setSizePolicy(policy);-
204 widget->setParent(this);-
205-
206 const int insertIndex = (position & LogicalLeft) ? 0 : scrollBarLayoutIndex() + 1;
(position & LogicalLeft)Description
TRUEnever evaluated
FALSEnever evaluated
0
207 layout->insertWidget(insertIndex, widget);-
208}
never executed: end of block
0
209-
210/*! \internal-
211 Retuns a list of scroll bar widgets for the given position. The scroll bar-
212 itself is not returned.-
213*/-
214QWidgetList QAbstractScrollAreaScrollBarContainer::widgets(LogicalPosition position)-
215{-
216 QWidgetList list;-
217 const int scrollBarIndex = scrollBarLayoutIndex();-
218 if (position == LogicalLeft) {
position == LogicalLeftDescription
TRUEnever evaluated
FALSEnever evaluated
0
219 list.reserve(scrollBarIndex);-
220 for (int i = 0; i < scrollBarIndex; ++i)
i < scrollBarIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
221 list.append(layout->itemAt(i)->widget());
never executed: list.append(layout->itemAt(i)->widget());
0
222 } else if (position == LogicalRight) {
never executed: end of block
position == LogicalRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
223 const int layoutItemCount = layout->count();-
224 list.reserve(layoutItemCount - (scrollBarIndex + 1));-
225 for (int i = scrollBarIndex + 1; i < layoutItemCount; ++i)
i < layoutItemCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
226 list.append(layout->itemAt(i)->widget());
never executed: list.append(layout->itemAt(i)->widget());
0
227 }
never executed: end of block
0
228 return list;
never executed: return list;
0
229}-
230-
231/*! \internal-
232 Returns the layout index for the scroll bar. This needs to be-
233 recalculated by a linear search for each use, since items in-
234 the layout can be removed at any time (i.e. when a widget is-
235 deleted or re-parented).-
236*/-
237int QAbstractScrollAreaScrollBarContainer::scrollBarLayoutIndex() const-
238{-
239 const int layoutItemCount = layout->count();-
240 for (int i = 0; i < layoutItemCount; ++i) {
i < layoutItemCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
241 if (qobject_cast<QScrollBar *>(layout->itemAt(i)->widget()))
qobject_cast<Q...(i)->widget())Description
TRUEnever evaluated
FALSEnever evaluated
0
242 return i;
never executed: return i;
0
243 }
never executed: end of block
0
244 return -1;
never executed: return -1;
0
245}-
246-
247/*! \internal-
248*/-
249void QAbstractScrollAreaPrivate::replaceScrollBar(QScrollBar *scrollBar,-
250 Qt::Orientation orientation)-
251{-
252 Q_Q(QAbstractScrollArea);-
253-
254 QAbstractScrollAreaScrollBarContainer *container = scrollBarContainers[orientation];-
255 bool horizontal = (orientation == Qt::Horizontal);-
256 QScrollBar *oldBar = horizontal ? hbar : vbar;
horizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
257 if (horizontal)
horizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
258 hbar = scrollBar;
never executed: hbar = scrollBar;
0
259 else-
260 vbar = scrollBar;
never executed: vbar = scrollBar;
0
261 scrollBar->setParent(container);-
262 container->scrollBar = scrollBar;-
263 container->layout->removeWidget(oldBar);-
264 container->layout->insertWidget(0, scrollBar);-
265 scrollBar->setVisible(oldBar->isVisibleTo(container));-
266 scrollBar->setInvertedAppearance(oldBar->invertedAppearance());-
267 scrollBar->setInvertedControls(oldBar->invertedControls());-
268 scrollBar->setRange(oldBar->minimum(), oldBar->maximum());-
269 scrollBar->setOrientation(oldBar->orientation());-
270 scrollBar->setPageStep(oldBar->pageStep());-
271 scrollBar->setSingleStep(oldBar->singleStep());-
272 scrollBar->d_func()->viewMayChangeSingleStep = oldBar->d_func()->viewMayChangeSingleStep;-
273 scrollBar->setSliderDown(oldBar->isSliderDown());-
274 scrollBar->setSliderPosition(oldBar->sliderPosition());-
275 scrollBar->setTracking(oldBar->hasTracking());-
276 scrollBar->setValue(oldBar->value());-
277 scrollBar->installEventFilter(q);-
278 oldBar->removeEventFilter(q);-
279 delete oldBar;-
280-
281 QObject::connect(scrollBar, SIGNAL(valueChanged(int)),-
282 q, horizontal ? SLOT(_q_hslide(int)) : SLOT(_q_vslide(int)));-
283 QObject::connect(scrollBar, SIGNAL(rangeChanged(int,int)),-
284 q, SLOT(_q_showOrHideScrollBars()), Qt::QueuedConnection);-
285}
never executed: end of block
0
286-
287void QAbstractScrollAreaPrivate::init()-
288{-
289 Q_Q(QAbstractScrollArea);-
290 viewport = new QWidget(q);-
291 viewport->setObjectName(QLatin1String("qt_scrollarea_viewport"));-
292 viewport->setBackgroundRole(QPalette::Base);-
293 viewport->setAutoFillBackground(true);-
294 scrollBarContainers[Qt::Horizontal] = new QAbstractScrollAreaScrollBarContainer(Qt::Horizontal, q);-
295 scrollBarContainers[Qt::Horizontal]->setObjectName(QLatin1String("qt_scrollarea_hcontainer"));-
296 hbar = scrollBarContainers[Qt::Horizontal]->scrollBar;-
297 hbar->setRange(0,0);-
298 scrollBarContainers[Qt::Horizontal]->setVisible(false);-
299 hbar->installEventFilter(q);-
300 QObject::connect(hbar, SIGNAL(valueChanged(int)), q, SLOT(_q_hslide(int)));-
301 QObject::connect(hbar, SIGNAL(rangeChanged(int,int)), q, SLOT(_q_showOrHideScrollBars()), Qt::QueuedConnection);-
302 scrollBarContainers[Qt::Vertical] = new QAbstractScrollAreaScrollBarContainer(Qt::Vertical, q);-
303 scrollBarContainers[Qt::Vertical]->setObjectName(QLatin1String("qt_scrollarea_vcontainer"));-
304 vbar = scrollBarContainers[Qt::Vertical]->scrollBar;-
305 vbar->setRange(0,0);-
306 scrollBarContainers[Qt::Vertical]->setVisible(false);-
307 vbar->installEventFilter(q);-
308 QObject::connect(vbar, SIGNAL(valueChanged(int)), q, SLOT(_q_vslide(int)));-
309 QObject::connect(vbar, SIGNAL(rangeChanged(int,int)), q, SLOT(_q_showOrHideScrollBars()), Qt::QueuedConnection);-
310 viewportFilter.reset(new QAbstractScrollAreaFilter(this));-
311 viewport->installEventFilter(viewportFilter.data());-
312 viewport->setFocusProxy(q);-
313 q->setFocusPolicy(Qt::StrongFocus);-
314 q->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);-
315 q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);-
316 layoutChildren();-
317#ifndef Q_OS_OSX-
318# ifndef QT_NO_GESTURES-
319 viewport->grabGesture(Qt::PanGesture);-
320# endif-
321#endif-
322}
never executed: end of block
0
323-
324#ifdef Q_DEAD_CODE_FROM_QT4_WIN-
325void QAbstractScrollAreaPrivate::setSingleFingerPanEnabled(bool on)-
326{-
327 singleFingerPanEnabled = on;-
328 QWidgetPrivate *dd = static_cast<QWidgetPrivate *>(QObjectPrivate::get(viewport));-
329 if (dd)-
330 dd->winSetupGestures();-
331}-
332#endif // Q_DEAD_CODE_FROM_QT4_WIN-
333-
334void QAbstractScrollAreaPrivate::layoutChildren()-
335{-
336 Q_Q(QAbstractScrollArea);-
337 bool htransient = hbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, hbar);-
338 bool needh = (hbarpolicy != Qt::ScrollBarAlwaysOff) && ((hbarpolicy == Qt::ScrollBarAlwaysOn && !htransient)
(hbarpolicy !=...lBarAlwaysOff)Description
TRUEnever evaluated
FALSEnever evaluated
hbarpolicy == ...ollBarAlwaysOnDescription
TRUEnever evaluated
FALSEnever evaluated
!htransientDescription
TRUEnever evaluated
FALSEnever evaluated
0
339 || ((hbarpolicy == Qt::ScrollBarAsNeeded || htransient)
hbarpolicy == ...ollBarAsNeededDescription
TRUEnever evaluated
FALSEnever evaluated
htransientDescription
TRUEnever evaluated
FALSEnever evaluated
0
340 && hbar->minimum() < hbar->maximum() && !hbar->sizeHint().isEmpty()));
hbar->minimum(...bar->maximum()Description
TRUEnever evaluated
FALSEnever evaluated
!hbar->sizeHint().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
341-
342 bool vtransient = vbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, vbar);-
343 bool needv = (vbarpolicy != Qt::ScrollBarAlwaysOff) && ((vbarpolicy == Qt::ScrollBarAlwaysOn && !vtransient)
(vbarpolicy !=...lBarAlwaysOff)Description
TRUEnever evaluated
FALSEnever evaluated
vbarpolicy == ...ollBarAlwaysOnDescription
TRUEnever evaluated
FALSEnever evaluated
!vtransientDescription
TRUEnever evaluated
FALSEnever evaluated
0
344 || ((vbarpolicy == Qt::ScrollBarAsNeeded || vtransient)
vbarpolicy == ...ollBarAsNeededDescription
TRUEnever evaluated
FALSEnever evaluated
vtransientDescription
TRUEnever evaluated
FALSEnever evaluated
0
345 && vbar->minimum() < vbar->maximum() && !vbar->sizeHint().isEmpty()));
vbar->minimum(...bar->maximum()Description
TRUEnever evaluated
FALSEnever evaluated
!vbar->sizeHint().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
346-
347 QStyleOption opt(0);-
348 opt.init(q);-
349-
350 const int hscrollOverlap = hbar->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarOverlap, &opt, hbar);-
351 const int vscrollOverlap = vbar->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarOverlap, &opt, vbar);-
352-
353#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
354 QWidget * const window = q->window();-
355-
356 // Use small scroll bars for tool windows, to match the native size grip.-
357 bool hbarIsSmall = hbar->testAttribute(Qt::WA_MacSmallSize);-
358 bool vbarIsSmall = vbar->testAttribute(Qt::WA_MacSmallSize);-
359 const Qt::WindowType windowType = window->windowType();-
360 if (windowType == Qt::Tool) {-
361 if (!hbarIsSmall) {-
362 hbar->setAttribute(Qt::WA_MacMiniSize, false);-
363 hbar->setAttribute(Qt::WA_MacNormalSize, false);-
364 hbar->setAttribute(Qt::WA_MacSmallSize, true);-
365 }-
366 if (!vbarIsSmall) {-
367 vbar->setAttribute(Qt::WA_MacMiniSize, false);-
368 vbar->setAttribute(Qt::WA_MacNormalSize, false);-
369 vbar->setAttribute(Qt::WA_MacSmallSize, true);-
370 }-
371 } else {-
372 if (hbarIsSmall) {-
373 hbar->setAttribute(Qt::WA_MacMiniSize, false);-
374 hbar->setAttribute(Qt::WA_MacNormalSize, false);-
375 hbar->setAttribute(Qt::WA_MacSmallSize, false);-
376 }-
377 if (vbarIsSmall) {-
378 vbar->setAttribute(Qt::WA_MacMiniSize, false);-
379 vbar->setAttribute(Qt::WA_MacNormalSize, false);-
380 vbar->setAttribute(Qt::WA_MacSmallSize, false);-
381 }-
382 }-
383#endif-
384-
385 const int hsbExt = hbar->sizeHint().height();-
386 const int vsbExt = vbar->sizeHint().width();-
387 const QPoint extPoint(vsbExt, hsbExt);-
388 const QSize extSize(vsbExt, hsbExt);-
389-
390 const QRect widgetRect = q->rect();-
391-
392 const bool hasCornerWidget = (cornerWidget != 0);-
393-
394// If the scroll bars are at the very right and bottom of the window we-
395// move their positions to be aligned with the size grip.-
396#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
397 // Check if a native sizegrip is present.-
398 bool hasMacReverseSizeGrip = false;-
399 bool hasMacSizeGrip = false;-
400 bool nativeGripPresent = false;-
401 if (q->testAttribute(Qt::WA_WState_Created))-
402 nativeGripPresent = qt_mac_checkForNativeSizeGrip(q);-
403-
404 if (nativeGripPresent) {-
405 // Look for a native size grip at the visual window bottom right and at the-
406 // absolute window bottom right. In reverse mode, the native size grip does not-
407 // swich side, so we need to check if it is on the "wrong side".-
408 const QPoint scrollAreaBottomRight = q->mapTo(window, widgetRect.bottomRight() - QPoint(frameWidth, frameWidth));-
409 const QPoint windowBottomRight = window->rect().bottomRight();-
410 const QPoint visualWindowBottomRight = QStyle::visualPos(opt.direction, opt.rect, windowBottomRight);-
411 const QPoint offset = windowBottomRight - scrollAreaBottomRight;-
412 const QPoint visualOffset = visualWindowBottomRight - scrollAreaBottomRight;-
413 hasMacSizeGrip = (visualOffset.manhattanLength() < vsbExt);-
414 hasMacReverseSizeGrip = (hasMacSizeGrip == false && (offset.manhattanLength() < hsbExt));-
415 }-
416#endif-
417-
418 QPoint cornerOffset((needv && vscrollOverlap == 0) ? vsbExt : 0, (needh && hscrollOverlap == 0) ? hsbExt : 0);-
419 QRect controlsRect;-
420 QRect viewportRect;-
421-
422 // In FrameOnlyAroundContents mode the frame is drawn between the controls and-
423 // the viewport, else the frame rect is equal to the widget rect.-
424 if ((frameStyle != QFrame::NoFrame) &&
(frameStyle !=...rame::NoFrame)Description
TRUEnever evaluated
FALSEnever evaluated
0
425 q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, &opt, q)) {
q->style()->st...ents, &opt, q)Description
TRUEnever evaluated
FALSEnever evaluated
0
426 controlsRect = widgetRect;-
427 const int spacing = q->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing, &opt, q);-
428 const QPoint cornerExtra(needv ? spacing + vscrollOverlap : 0, needh ? spacing + hscrollOverlap : 0);-
429 QRect frameRect = widgetRect;-
430 frameRect.adjust(0, 0, -cornerOffset.x() - cornerExtra.x(), -cornerOffset.y() - cornerExtra.y());-
431 q->setFrameRect(QStyle::visualRect(opt.direction, opt.rect, frameRect));-
432 // The frame rect needs to be in logical coords, however we need to flip-
433 // the contentsRect back before passing it on to the viewportRect-
434 // since the viewportRect has its logical coords calculated later.-
435 viewportRect = QStyle::visualRect(opt.direction, opt.rect, q->contentsRect());-
436 } else {
never executed: end of block
0
437 q->setFrameRect(QStyle::visualRect(opt.direction, opt.rect, widgetRect));-
438 controlsRect = q->contentsRect();-
439 viewportRect = QRect(controlsRect.topLeft(), controlsRect.bottomRight() - cornerOffset);-
440 }
never executed: end of block
0
441-
442 cornerOffset = QPoint(needv ? vsbExt : 0, needh ? hsbExt : 0);-
443-
444 // If we have a corner widget and are only showing one scroll bar, we need to move it-
445 // to make room for the corner widget.-
446 if (hasCornerWidget && ((needv && vscrollOverlap == 0) || (needh && hscrollOverlap == 0)))
hasCornerWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
needvDescription
TRUEnever evaluated
FALSEnever evaluated
vscrollOverlap == 0Description
TRUEnever evaluated
FALSEnever evaluated
needhDescription
TRUEnever evaluated
FALSEnever evaluated
hscrollOverlap == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
447 cornerOffset = extPoint;
never executed: cornerOffset = extPoint;
0
448-
449#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
450 // Also move the scroll bars if they are covered by the native Mac size grip.-
451 if (hasMacSizeGrip)-
452 cornerOffset = extPoint;-
453#endif-
454-
455 // The corner point is where the scroll bar rects, the corner widget rect and the-
456 // viewport rect meets.-
457 const QPoint cornerPoint(controlsRect.bottomRight() + QPoint(1, 1) - cornerOffset);-
458-
459 // Some styles paints the corner if both scorllbars are showing and there is-
460 // no corner widget.-
461 if (needv && needh && !hasCornerWidget && hscrollOverlap == 0 && vscrollOverlap == 0)
needvDescription
TRUEnever evaluated
FALSEnever evaluated
needhDescription
TRUEnever evaluated
FALSEnever evaluated
!hasCornerWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
hscrollOverlap == 0Description
TRUEnever evaluated
FALSEnever evaluated
vscrollOverlap == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
462 cornerPaintingRect = QStyle::visualRect(opt.direction, opt.rect, QRect(cornerPoint, extSize));
never executed: cornerPaintingRect = QStyle::visualRect(opt.direction, opt.rect, QRect(cornerPoint, extSize));
0
463 else-
464 cornerPaintingRect = QRect();
never executed: cornerPaintingRect = QRect();
0
465-
466#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
467 if (hasMacReverseSizeGrip)-
468 reverseCornerPaintingRect = QRect(controlsRect.bottomRight() + QPoint(1, 1) - extPoint, extSize);-
469 else-
470 reverseCornerPaintingRect = QRect();-
471#endif-
472-
473 // move the scrollbars away from top/left headers-
474 int vHeaderRight = 0;-
475 int hHeaderBottom = 0;-
476 if ((vscrollOverlap > 0 && needv) || (hscrollOverlap > 0 && needh)) {
vscrollOverlap > 0Description
TRUEnever evaluated
FALSEnever evaluated
needvDescription
TRUEnever evaluated
FALSEnever evaluated
hscrollOverlap > 0Description
TRUEnever evaluated
FALSEnever evaluated
needhDescription
TRUEnever evaluated
FALSEnever evaluated
0
477 const QList<QHeaderView *> headers = q->findChildren<QHeaderView*>();-
478 if (headers.count() <= 2) {
headers.count() <= 2Description
TRUEnever evaluated
FALSEnever evaluated
0
479 for (const QHeaderView *header : headers) {-
480 const QRect geo = header->geometry();-
481 if (header->orientation() == Qt::Vertical && header->isVisible() && QStyle::visualRect(opt.direction, opt.rect, geo).left() <= opt.rect.width() / 2)
header->orient...= Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
header->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
QStyle::visual...ct.width() / 2Description
TRUEnever evaluated
FALSEnever evaluated
0
482 vHeaderRight = QStyle::visualRect(opt.direction, opt.rect, geo).right();
never executed: vHeaderRight = QStyle::visualRect(opt.direction, opt.rect, geo).right();
0
483 else if (header->orientation() == Qt::Horizontal && header->isVisible() && geo.top() <= q->frameWidth())
header->orient...Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
header->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
geo.top() <= q->frameWidth()Description
TRUEnever evaluated
FALSEnever evaluated
0
484 hHeaderBottom = geo.bottom();
never executed: hHeaderBottom = geo.bottom();
0
485 }
never executed: end of block
0
486 }
never executed: end of block
0
487 }
never executed: end of block
0
488-
489 if (needh) {
needhDescription
TRUEnever evaluated
FALSEnever evaluated
0
490 QRect horizontalScrollBarRect(QPoint(controlsRect.left() + vHeaderRight, cornerPoint.y()), QPoint(cornerPoint.x() - 1, controlsRect.bottom()));-
491#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
492 if (hasMacReverseSizeGrip)-
493 horizontalScrollBarRect.adjust(vsbExt, 0, 0, 0);-
494#endif-
495 if (!hasCornerWidget && htransient)
!hasCornerWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
htransientDescription
TRUEnever evaluated
FALSEnever evaluated
0
496#ifdef Q_OS_MAC-
497 if (QSysInfo::macVersion() >= QSysInfo::MV_10_8)-
498#endif-
499 horizontalScrollBarRect.adjust(0, 0, cornerOffset.x(), 0);
never executed: horizontalScrollBarRect.adjust(0, 0, cornerOffset.x(), 0);
0
500 scrollBarContainers[Qt::Horizontal]->setGeometry(QStyle::visualRect(opt.direction, opt.rect, horizontalScrollBarRect));-
501 scrollBarContainers[Qt::Horizontal]->raise();-
502 }
never executed: end of block
0
503-
504 if (needv) {
needvDescription
TRUEnever evaluated
FALSEnever evaluated
0
505 QRect verticalScrollBarRect (QPoint(cornerPoint.x(), controlsRect.top() + hHeaderBottom), QPoint(controlsRect.right(), cornerPoint.y() - 1));-
506 if (!hasCornerWidget && vtransient)
!hasCornerWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
vtransientDescription
TRUEnever evaluated
FALSEnever evaluated
0
507#ifdef Q_OS_MAC-
508 if (QSysInfo::macVersion() >= QSysInfo::MV_10_8)-
509#endif-
510 verticalScrollBarRect.adjust(0, 0, 0, cornerOffset.y());
never executed: verticalScrollBarRect.adjust(0, 0, 0, cornerOffset.y());
0
511 scrollBarContainers[Qt::Vertical]->setGeometry(QStyle::visualRect(opt.direction, opt.rect, verticalScrollBarRect));-
512 scrollBarContainers[Qt::Vertical]->raise();-
513 }
never executed: end of block
0
514-
515 if (cornerWidget) {
cornerWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
516 const QRect cornerWidgetRect(cornerPoint, controlsRect.bottomRight());-
517 cornerWidget->setGeometry(QStyle::visualRect(opt.direction, opt.rect, cornerWidgetRect));-
518 }
never executed: end of block
0
519-
520 scrollBarContainers[Qt::Horizontal]->setVisible(needh);-
521 scrollBarContainers[Qt::Vertical]->setVisible(needv);-
522-
523 if (q->isRightToLeft())
q->isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
524 viewportRect.adjust(right, top, -left, -bottom);
never executed: viewportRect.adjust(right, top, -left, -bottom);
0
525 else-
526 viewportRect.adjust(left, top, -right, -bottom);
never executed: viewportRect.adjust(left, top, -right, -bottom);
0
527-
528 viewport->setGeometry(QStyle::visualRect(opt.direction, opt.rect, viewportRect)); // resize the viewport last-
529}
never executed: end of block
0
530-
531/*!-
532 \enum QAbstractScrollArea::SizeAdjustPolicy-
533 \since 5.2-
534-
535 This enum specifies how the size hint of the QAbstractScrollArea should-
536 adjust when the size of the viewport changes.-
537-
538 \value AdjustIgnored The scroll area will behave like before - and not do any adjust.-
539 \value AdjustToContents The scroll area will always adjust to the viewport-
540 \value AdjustToContentsOnFirstShow The scroll area will adjust to its viewport the first time it is shown.-
541*/-
542-
543-
544/*!-
545 \internal-
546-
547 Creates a new QAbstractScrollAreaPrivate, \a dd with the given \a parent.-
548*/-
549QAbstractScrollArea::QAbstractScrollArea(QAbstractScrollAreaPrivate &dd, QWidget *parent)-
550 :QFrame(dd, parent)-
551{-
552 Q_D(QAbstractScrollArea);-
553 QT_TRY {-
554 d->init();-
555 } QT_CATCH(...) {
never executed: end of block
dead code: { d->viewportFilter.reset(); qt_noop(); }
-
556 d->viewportFilter.reset();
dead code: { d->viewportFilter.reset(); qt_noop(); }
-
557 QT_RETHROW;
dead code: { d->viewportFilter.reset(); qt_noop(); }
-
558 }
dead code: { d->viewportFilter.reset(); qt_noop(); }
-
559}-
560-
561/*!-
562 Constructs a viewport.-
563-
564 The \a parent argument is sent to the QWidget constructor.-
565*/-
566QAbstractScrollArea::QAbstractScrollArea(QWidget *parent)-
567 :QFrame(*new QAbstractScrollAreaPrivate, parent)-
568{-
569 Q_D(QAbstractScrollArea);-
570 QT_TRY {-
571 d->init();-
572 } QT_CATCH(...) {
never executed: end of block
dead code: { d->viewportFilter.reset(); qt_noop(); }
-
573 d->viewportFilter.reset();
dead code: { d->viewportFilter.reset(); qt_noop(); }
-
574 QT_RETHROW;
dead code: { d->viewportFilter.reset(); qt_noop(); }
-
575 }
dead code: { d->viewportFilter.reset(); qt_noop(); }
-
576}-
577-
578-
579/*!-
580 Destroys the viewport.-
581 */-
582QAbstractScrollArea::~QAbstractScrollArea()-
583{-
584 Q_D(QAbstractScrollArea);-
585 // reset it here, otherwise we'll have a dangling pointer in ~QWidget-
586 d->viewportFilter.reset();-
587}
never executed: end of block
0
588-
589-
590/*!-
591 \since 4.2-
592 Sets the viewport to be the given \a widget.-
593 The QAbstractScrollArea will take ownership of the given \a widget.-
594-
595 If \a widget is 0, QAbstractScrollArea will assign a new QWidget instance-
596 for the viewport.-
597-
598 \sa viewport()-
599*/-
600void QAbstractScrollArea::setViewport(QWidget *widget)-
601{-
602 Q_D(QAbstractScrollArea);-
603 if (widget != d->viewport) {
widget != d->viewportDescription
TRUEnever evaluated
FALSEnever evaluated
0
604 QWidget *oldViewport = d->viewport;-
605 if (!widget)
!widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
606 widget = new QWidget;
never executed: widget = new QWidget;
0
607 d->viewport = widget;-
608 d->viewport->setParent(this);-
609 d->viewport->setFocusProxy(this);-
610 d->viewport->installEventFilter(d->viewportFilter.data());-
611#ifndef Q_DEAD_CODE_FROM_QT4_MAC-
612#ifndef QT_NO_GESTURES-
613 d->viewport->grabGesture(Qt::PanGesture);-
614#endif-
615#endif-
616 d->layoutChildren();-
617#ifndef QT_NO_OPENGL-
618 QWidgetPrivate::get(d->viewport)->initializeViewportFramebuffer();-
619#endif-
620 if (isVisible())
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
621 d->viewport->show();
never executed: d->viewport->show();
0
622 setupViewport(widget);-
623 delete oldViewport;-
624 }
never executed: end of block
0
625}
never executed: end of block
0
626-
627/*!-
628 Returns the viewport widget.-
629-
630 Use the QScrollArea::widget() function to retrieve the contents of-
631 the viewport widget.-
632-
633 \sa QScrollArea::widget()-
634*/-
635QWidget *QAbstractScrollArea::viewport() const-
636{-
637 Q_D(const QAbstractScrollArea);-
638 return d->viewport;
never executed: return d->viewport;
0
639}-
640-
641-
642/*!-
643Returns the size of the viewport as if the scroll bars had no valid-
644scrolling range.-
645*/-
646// ### still thinking about the name-
647QSize QAbstractScrollArea::maximumViewportSize() const-
648{-
649 Q_D(const QAbstractScrollArea);-
650 int hsbExt = d->hbar->sizeHint().height();-
651 int vsbExt = d->vbar->sizeHint().width();-
652-
653 int f = 2 * d->frameWidth;-
654 QSize max = size() - QSize(f + d->left + d->right, f + d->top + d->bottom);-
655 if (d->vbarpolicy == Qt::ScrollBarAlwaysOn)
d->vbarpolicy ...ollBarAlwaysOnDescription
TRUEnever evaluated
FALSEnever evaluated
0
656 max.rwidth() -= vsbExt;
never executed: max.rwidth() -= vsbExt;
0
657 if (d->hbarpolicy == Qt::ScrollBarAlwaysOn)
d->hbarpolicy ...ollBarAlwaysOnDescription
TRUEnever evaluated
FALSEnever evaluated
0
658 max.rheight() -= hsbExt;
never executed: max.rheight() -= hsbExt;
0
659 return max;
never executed: return max;
0
660}-
661-
662/*!-
663 \property QAbstractScrollArea::verticalScrollBarPolicy-
664 \brief the policy for the vertical scroll bar-
665-
666 The default policy is Qt::ScrollBarAsNeeded.-
667-
668 \sa horizontalScrollBarPolicy-
669*/-
670-
671Qt::ScrollBarPolicy QAbstractScrollArea::verticalScrollBarPolicy() const-
672{-
673 Q_D(const QAbstractScrollArea);-
674 return d->vbarpolicy;
never executed: return d->vbarpolicy;
0
675}-
676-
677void QAbstractScrollArea::setVerticalScrollBarPolicy(Qt::ScrollBarPolicy policy)-
678{-
679 Q_D(QAbstractScrollArea);-
680 const Qt::ScrollBarPolicy oldPolicy = d->vbarpolicy;-
681 d->vbarpolicy = policy;-
682 if (isVisible())
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
683 d->layoutChildren();
never executed: d->layoutChildren();
0
684 if (oldPolicy != d->vbarpolicy)
oldPolicy != d->vbarpolicyDescription
TRUEnever evaluated
FALSEnever evaluated
0
685 d->scrollBarPolicyChanged(Qt::Vertical, d->vbarpolicy);
never executed: d->scrollBarPolicyChanged(Qt::Vertical, d->vbarpolicy);
0
686}
never executed: end of block
0
687-
688-
689/*!-
690 Returns the vertical scroll bar.-
691-
692 \sa verticalScrollBarPolicy, horizontalScrollBar()-
693 */-
694QScrollBar *QAbstractScrollArea::verticalScrollBar() const-
695{-
696 Q_D(const QAbstractScrollArea);-
697 return d->vbar;
never executed: return d->vbar;
0
698}-
699-
700/*!-
701 \since 4.2-
702 Replaces the existing vertical scroll bar with \a scrollBar, and sets all-
703 the former scroll bar's slider properties on the new scroll bar. The former-
704 scroll bar is then deleted.-
705-
706 QAbstractScrollArea already provides vertical and horizontal scroll bars by-
707 default. You can call this function to replace the default vertical-
708 scroll bar with your own custom scroll bar.-
709-
710 \sa verticalScrollBar(), setHorizontalScrollBar()-
711*/-
712void QAbstractScrollArea::setVerticalScrollBar(QScrollBar *scrollBar)-
713{-
714 Q_D(QAbstractScrollArea);-
715 if (Q_UNLIKELY(!scrollBar)) {
__builtin_expe...llBar), false)Description
TRUEnever evaluated
FALSEnever evaluated
0
716 qWarning("QAbstractScrollArea::setVerticalScrollBar: Cannot set a null scroll bar");-
717 return;
never executed: return;
0
718 }-
719-
720 d->replaceScrollBar(scrollBar, Qt::Vertical);-
721}
never executed: end of block
0
722-
723/*!-
724 \property QAbstractScrollArea::horizontalScrollBarPolicy-
725 \brief the policy for the horizontal scroll bar-
726-
727 The default policy is Qt::ScrollBarAsNeeded.-
728-
729 \sa verticalScrollBarPolicy-
730*/-
731-
732Qt::ScrollBarPolicy QAbstractScrollArea::horizontalScrollBarPolicy() const-
733{-
734 Q_D(const QAbstractScrollArea);-
735 return d->hbarpolicy;
never executed: return d->hbarpolicy;
0
736}-
737-
738void QAbstractScrollArea::setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy policy)-
739{-
740 Q_D(QAbstractScrollArea);-
741 const Qt::ScrollBarPolicy oldPolicy = d->hbarpolicy;-
742 d->hbarpolicy = policy;-
743 if (isVisible())
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
744 d->layoutChildren();
never executed: d->layoutChildren();
0
745 if (oldPolicy != d->hbarpolicy)
oldPolicy != d->hbarpolicyDescription
TRUEnever evaluated
FALSEnever evaluated
0
746 d->scrollBarPolicyChanged(Qt::Horizontal, d->hbarpolicy);
never executed: d->scrollBarPolicyChanged(Qt::Horizontal, d->hbarpolicy);
0
747}
never executed: end of block
0
748-
749/*!-
750 Returns the horizontal scroll bar.-
751-
752 \sa horizontalScrollBarPolicy, verticalScrollBar()-
753 */-
754QScrollBar *QAbstractScrollArea::horizontalScrollBar() const-
755{-
756 Q_D(const QAbstractScrollArea);-
757 return d->hbar;
never executed: return d->hbar;
0
758}-
759-
760/*!-
761 \since 4.2-
762-
763 Replaces the existing horizontal scroll bar with \a scrollBar, and sets all-
764 the former scroll bar's slider properties on the new scroll bar. The former-
765 scroll bar is then deleted.-
766-
767 QAbstractScrollArea already provides horizontal and vertical scroll bars by-
768 default. You can call this function to replace the default horizontal-
769 scroll bar with your own custom scroll bar.-
770-
771 \sa horizontalScrollBar(), setVerticalScrollBar()-
772*/-
773void QAbstractScrollArea::setHorizontalScrollBar(QScrollBar *scrollBar)-
774{-
775 Q_D(QAbstractScrollArea);-
776 if (Q_UNLIKELY(!scrollBar)) {
__builtin_expe...llBar), false)Description
TRUEnever evaluated
FALSEnever evaluated
0
777 qWarning("QAbstractScrollArea::setHorizontalScrollBar: Cannot set a null scroll bar");-
778 return;
never executed: return;
0
779 }-
780-
781 d->replaceScrollBar(scrollBar, Qt::Horizontal);-
782}
never executed: end of block
0
783-
784/*!-
785 \since 4.2-
786-
787 Returns the widget in the corner between the two scroll bars.-
788-
789 By default, no corner widget is present.-
790*/-
791QWidget *QAbstractScrollArea::cornerWidget() const-
792{-
793 Q_D(const QAbstractScrollArea);-
794 return d->cornerWidget;
never executed: return d->cornerWidget;
0
795}-
796-
797/*!-
798 \since 4.2-
799-
800 Sets the widget in the corner between the two scroll bars to be-
801 \a widget.-
802-
803 You will probably also want to set at least one of the scroll bar-
804 modes to \c AlwaysOn.-
805-
806 Passing 0 shows no widget in the corner.-
807-
808 Any previous corner widget is hidden.-
809-
810 You may call setCornerWidget() with the same widget at different-
811 times.-
812-
813 All widgets set here will be deleted by the scroll area when it is-
814 destroyed unless you separately reparent the widget after setting-
815 some other corner widget (or 0).-
816-
817 Any \e newly set widget should have no current parent.-
818-
819 By default, no corner widget is present.-
820-
821 \sa horizontalScrollBarPolicy, horizontalScrollBarPolicy-
822*/-
823void QAbstractScrollArea::setCornerWidget(QWidget *widget)-
824{-
825 Q_D(QAbstractScrollArea);-
826 QWidget* oldWidget = d->cornerWidget;-
827 if (oldWidget != widget) {
oldWidget != widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
828 if (oldWidget)
oldWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
829 oldWidget->hide();
never executed: oldWidget->hide();
0
830 d->cornerWidget = widget;-
831-
832 if (widget && widget->parentWidget() != this)
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
widget->parentWidget() != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
833 widget->setParent(this);
never executed: widget->setParent(this);
0
834-
835 d->layoutChildren();-
836 if (widget)
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
837 widget->show();
never executed: widget->show();
0
838 } else {
never executed: end of block
0
839 d->cornerWidget = widget;-
840 d->layoutChildren();-
841 }
never executed: end of block
0
842}-
843-
844/*!-
845 \since 4.2-
846 Adds \a widget as a scroll bar widget in the location specified-
847 by \a alignment.-
848-
849 Scroll bar widgets are shown next to the horizontal or vertical-
850 scroll bar, and can be placed on either side of it. If you want-
851 the scroll bar widgets to be always visible, set the-
852 scrollBarPolicy for the corresponding scroll bar to \c AlwaysOn.-
853-
854 \a alignment must be one of Qt::Alignleft and Qt::AlignRight,-
855 which maps to the horizontal scroll bar, or Qt::AlignTop and-
856 Qt::AlignBottom, which maps to the vertical scroll bar.-
857-
858 A scroll bar widget can be removed by either re-parenting the-
859 widget or deleting it. It's also possible to hide a widget with-
860 QWidget::hide()-
861-
862 The scroll bar widget will be resized to fit the scroll bar-
863 geometry for the current style. The following describes the case-
864 for scroll bar widgets on the horizontal scroll bar:-
865-
866 The height of the widget will be set to match the height of the-
867 scroll bar. To control the width of the widget, use-
868 QWidget::setMinimumWidth and QWidget::setMaximumWidth, or-
869 implement QWidget::sizeHint() and set a horizontal size policy.-
870 If you want a square widget, call-
871 QStyle::pixelMetric(QStyle::PM_ScrollBarExtent) and set the-
872 width to this value.-
873-
874 \sa scrollBarWidgets()-
875*/-
876void QAbstractScrollArea::addScrollBarWidget(QWidget *widget, Qt::Alignment alignment)-
877{-
878 Q_D(QAbstractScrollArea);-
879-
880 if (widget == 0)
widget == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
881 return;
never executed: return;
0
882-
883 const Qt::Orientation scrollBarOrientation-
884 = ((alignment & Qt::AlignLeft) || (alignment & Qt::AlignRight)) ? Qt::Horizontal : Qt::Vertical;
(alignment & Qt::AlignLeft)Description
TRUEnever evaluated
FALSEnever evaluated
(alignment & Qt::AlignRight)Description
TRUEnever evaluated
FALSEnever evaluated
0
885 const QAbstractScrollAreaScrollBarContainer::LogicalPosition position-
886 = ((alignment & Qt::AlignRight) || (alignment & Qt::AlignBottom))
(alignment & Qt::AlignRight)Description
TRUEnever evaluated
FALSEnever evaluated
(alignment & Qt::AlignBottom)Description
TRUEnever evaluated
FALSEnever evaluated
0
887 ? QAbstractScrollAreaScrollBarContainer::LogicalRight : QAbstractScrollAreaScrollBarContainer::LogicalLeft;-
888 d->scrollBarContainers[scrollBarOrientation]->addWidget(widget, position);-
889 d->layoutChildren();-
890 if (isHidden() == false)
isHidden() == falseDescription
TRUEnever evaluated
FALSEnever evaluated
0
891 widget->show();
never executed: widget->show();
0
892}
never executed: end of block
0
893-
894/*!-
895 \since 4.2-
896 Returns a list of the currently set scroll bar widgets. \a alignment-
897 can be any combination of the four location flags.-
898-
899 \sa addScrollBarWidget()-
900*/-
901QWidgetList QAbstractScrollArea::scrollBarWidgets(Qt::Alignment alignment)-
902{-
903 Q_D(QAbstractScrollArea);-
904-
905 QWidgetList list;-
906-
907 if (alignment & Qt::AlignLeft)
alignment & Qt::AlignLeftDescription
TRUEnever evaluated
FALSEnever evaluated
0
908 list += d->scrollBarContainers[Qt::Horizontal]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalLeft);
never executed: list += d->scrollBarContainers[Qt::Horizontal]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalLeft);
0
909 if (alignment & Qt::AlignRight)
alignment & Qt::AlignRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
910 list += d->scrollBarContainers[Qt::Horizontal]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalRight);
never executed: list += d->scrollBarContainers[Qt::Horizontal]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalRight);
0
911 if (alignment & Qt::AlignTop)
alignment & Qt::AlignTopDescription
TRUEnever evaluated
FALSEnever evaluated
0
912 list += d->scrollBarContainers[Qt::Vertical]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalLeft);
never executed: list += d->scrollBarContainers[Qt::Vertical]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalLeft);
0
913 if (alignment & Qt::AlignBottom)
alignment & Qt::AlignBottomDescription
TRUEnever evaluated
FALSEnever evaluated
0
914 list += d->scrollBarContainers[Qt::Vertical]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalRight);
never executed: list += d->scrollBarContainers[Qt::Vertical]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalRight);
0
915-
916 return list;
never executed: return list;
0
917}-
918-
919/*!-
920 Sets the margins around the scrolling area to \a left, \a top, \a-
921 right and \a bottom. This is useful for applications such as-
922 spreadsheets with "locked" rows and columns. The marginal space is-
923 is left blank; put widgets in the unused area.-
924-
925 Note that this function is frequently called by QTreeView and-
926 QTableView, so margins must be implemented by QAbstractScrollArea-
927 subclasses. Also, if the subclasses are to be used in item views,-
928 they should not call this function.-
929-
930 By default all margins are zero.-
931 \sa viewportMargins()-
932*/-
933void QAbstractScrollArea::setViewportMargins(int left, int top, int right, int bottom)-
934{-
935 Q_D(QAbstractScrollArea);-
936 d->left = left;-
937 d->top = top;-
938 d->right = right;-
939 d->bottom = bottom;-
940 d->layoutChildren();-
941}
never executed: end of block
0
942-
943/*!-
944 \since 4.6-
945 Sets \a margins around the scrolling area. This is useful for-
946 applications such as spreadsheets with "locked" rows and columns.-
947 The marginal space is is left blank; put widgets in the unused-
948 area.-
949-
950 By default all margins are zero.-
951 \sa viewportMargins()-
952*/-
953void QAbstractScrollArea::setViewportMargins(const QMargins &margins)-
954{-
955 setViewportMargins(margins.left(), margins.top(),-
956 margins.right(), margins.bottom());-
957}
never executed: end of block
0
958-
959/*!-
960 \since 5.5-
961 Returns the margins around the scrolling area.-
962 By default all the margins are zero.-
963-
964 \sa setViewportMargins()-
965*/-
966QMargins QAbstractScrollArea::viewportMargins() const-
967{-
968 Q_D(const QAbstractScrollArea);-
969 return QMargins(d->left, d->top, d->right, d->bottom);
never executed: return QMargins(d->left, d->top, d->right, d->bottom);
0
970}-
971-
972/*! \internal */-
973bool QAbstractScrollArea::eventFilter(QObject *o, QEvent *e)-
974{-
975 Q_D(QAbstractScrollArea);-
976 if ((o == d->hbar || o == d->vbar) && (e->type() == QEvent::HoverEnter || e->type() == QEvent::HoverLeave)) {
o == d->hbarDescription
TRUEnever evaluated
FALSEnever evaluated
o == d->vbarDescription
TRUEnever evaluated
FALSEnever evaluated
e->type() == Q...nt::HoverEnterDescription
TRUEnever evaluated
FALSEnever evaluated
e->type() == Q...nt::HoverLeaveDescription
TRUEnever evaluated
FALSEnever evaluated
0
977 if (d->hbarpolicy == Qt::ScrollBarAsNeeded && d->vbarpolicy == Qt::ScrollBarAsNeeded) {
d->hbarpolicy ...ollBarAsNeededDescription
TRUEnever evaluated
FALSEnever evaluated
d->vbarpolicy ...ollBarAsNeededDescription
TRUEnever evaluated
FALSEnever evaluated
0
978 QScrollBar *sbar = static_cast<QScrollBar*>(o);-
979 QScrollBar *sibling = sbar == d->hbar ? d->vbar : d->hbar;
sbar == d->hbarDescription
TRUEnever evaluated
FALSEnever evaluated
0
980 if (sbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, sbar) &&
sbar->style()-...ient, 0, sbar)Description
TRUEnever evaluated
FALSEnever evaluated
0
981 sibling->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, sibling))
sibling->style...t, 0, sibling)Description
TRUEnever evaluated
FALSEnever evaluated
0
982 d->setScrollBarTransient(sibling, e->type() == QEvent::HoverLeave);
never executed: d->setScrollBarTransient(sibling, e->type() == QEvent::HoverLeave);
0
983 }
never executed: end of block
0
984 }
never executed: end of block
0
985 return QFrame::eventFilter(o, e);
never executed: return QFrame::eventFilter(o, e);
0
986}-
987-
988/*!-
989 \fn bool QAbstractScrollArea::event(QEvent *event)-
990-
991 \reimp-
992-
993 This is the main event handler for the QAbstractScrollArea widget (\e not-
994 the scrolling area viewport()). The specified \a event is a general event-
995 object that may need to be cast to the appropriate class depending on its-
996 type.-
997-
998 \sa QEvent::type()-
999*/-
1000bool QAbstractScrollArea::event(QEvent *e)-
1001{-
1002 Q_D(QAbstractScrollArea);-
1003 switch (e->type()) {-
1004 case QEvent::AcceptDropsChange:
never executed: case QEvent::AcceptDropsChange:
0
1005 // There was a chance that with accessibility client we get an-
1006 // event before the viewport was created.-
1007 // Also, in some cases we might get here from QWidget::event() virtual function which is (indirectly) called-
1008 // from the viewport constructor at the time when the d->viewport is not yet initialized even without any-
1009 // accessibility client. See qabstractscrollarea autotest for a test case.-
1010 if (d->viewport)
d->viewportDescription
TRUEnever evaluated
FALSEnever evaluated
0
1011 d->viewport->setAcceptDrops(acceptDrops());
never executed: d->viewport->setAcceptDrops(acceptDrops());
0
1012 break;
never executed: break;
0
1013 case QEvent::MouseTrackingChange:
never executed: case QEvent::MouseTrackingChange:
0
1014 d->viewport->setMouseTracking(hasMouseTracking());-
1015 break;
never executed: break;
0
1016 case QEvent::Resize:
never executed: case QEvent::Resize:
0
1017 if (!d->inResize) {
!d->inResizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1018 d->inResize = true;-
1019 d->layoutChildren();-
1020 d->inResize = false;-
1021 }
never executed: end of block
0
1022 break;
never executed: break;
0
1023 case QEvent::Show:
never executed: case QEvent::Show:
0
1024 if (!d->shownOnce && d->sizeAdjustPolicy == QAbstractScrollArea::AdjustToContentsOnFirstShow) {
!d->shownOnceDescription
TRUEnever evaluated
FALSEnever evaluated
d->sizeAdjustP...ntsOnFirstShowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1025 d->sizeHint = QSize();-
1026 updateGeometry();-
1027 }
never executed: end of block
0
1028 d->shownOnce = true;-
1029 return QFrame::event(e);
never executed: return QFrame::event(e);
0
1030 case QEvent::Paint: {
never executed: case QEvent::Paint:
0
1031 QStyleOption option;-
1032 option.initFrom(this);-
1033 if (d->cornerPaintingRect.isValid()) {
d->cornerPaint...Rect.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1034 option.rect = d->cornerPaintingRect;-
1035 QPainter p(this);-
1036 style()->drawPrimitive(QStyle::PE_PanelScrollAreaCorner, &option, &p, this);-
1037 }
never executed: end of block
0
1038#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
1039 if (d->reverseCornerPaintingRect.isValid()) {-
1040 option.rect = d->reverseCornerPaintingRect;-
1041 QPainter p(this);-
1042 style()->drawPrimitive(QStyle::PE_PanelScrollAreaCorner, &option, &p, this);-
1043 }-
1044#endif-
1045 }-
1046 QFrame::paintEvent((QPaintEvent*)e);-
1047 break;
never executed: break;
0
1048#ifndef QT_NO_CONTEXTMENU-
1049 case QEvent::ContextMenu:
never executed: case QEvent::ContextMenu:
0
1050 if (static_cast<QContextMenuEvent *>(e)->reason() == QContextMenuEvent::Keyboard)
static_cast<QC...vent::KeyboardDescription
TRUEnever evaluated
FALSEnever evaluated
0
1051 return QFrame::event(e);
never executed: return QFrame::event(e);
0
1052 e->ignore();-
1053 break;
never executed: break;
0
1054#endif // QT_NO_CONTEXTMENU-
1055 case QEvent::MouseButtonPress:
never executed: case QEvent::MouseButtonPress:
0
1056 case QEvent::MouseButtonRelease:
never executed: case QEvent::MouseButtonRelease:
0
1057 case QEvent::MouseButtonDblClick:
never executed: case QEvent::MouseButtonDblClick:
0
1058 case QEvent::MouseMove:
never executed: case QEvent::MouseMove:
0
1059 case QEvent::Wheel:
never executed: case QEvent::Wheel:
0
1060#ifndef QT_NO_DRAGANDDROP-
1061 case QEvent::Drop:
never executed: case QEvent::Drop:
0
1062 case QEvent::DragEnter:
never executed: case QEvent::DragEnter:
0
1063 case QEvent::DragMove:
never executed: case QEvent::DragMove:
0
1064 case QEvent::DragLeave:
never executed: case QEvent::DragLeave:
0
1065#endif-
1066 // ignore touch events in case they have been propagated from the viewport-
1067 case QEvent::TouchBegin:
never executed: case QEvent::TouchBegin:
0
1068 case QEvent::TouchUpdate:
never executed: case QEvent::TouchUpdate:
0
1069 case QEvent::TouchEnd:
never executed: case QEvent::TouchEnd:
0
1070 return false;
never executed: return false;
0
1071#ifndef QT_NO_GESTURES-
1072 case QEvent::Gesture:
never executed: case QEvent::Gesture:
0
1073 {-
1074 QGestureEvent *ge = static_cast<QGestureEvent *>(e);-
1075 QPanGesture *g = static_cast<QPanGesture *>(ge->gesture(Qt::PanGesture));-
1076 if (g) {
gDescription
TRUEnever evaluated
FALSEnever evaluated
0
1077 QScrollBar *hBar = horizontalScrollBar();-
1078 QScrollBar *vBar = verticalScrollBar();-
1079 QPointF delta = g->delta();-
1080 if (!delta.isNull()) {
!delta.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1081 if (QApplication::isRightToLeft())
QApplication::isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
1082 delta.rx() *= -1;
never executed: delta.rx() *= -1;
0
1083 int newX = hBar->value() - delta.x();-
1084 int newY = vBar->value() - delta.y();-
1085 hBar->setValue(newX);-
1086 vBar->setValue(newY);-
1087 }
never executed: end of block
0
1088 return true;
never executed: return true;
0
1089 }-
1090 return false;
never executed: return false;
0
1091 }-
1092#endif // QT_NO_GESTURES-
1093 case QEvent::ScrollPrepare:
never executed: case QEvent::ScrollPrepare:
0
1094 {-
1095 QScrollPrepareEvent *se = static_cast<QScrollPrepareEvent *>(e);-
1096 if (d->canStartScrollingAt(se->startPos().toPoint())) {
d->canStartScr...s().toPoint())Description
TRUEnever evaluated
FALSEnever evaluated
0
1097 QScrollBar *hBar = horizontalScrollBar();-
1098 QScrollBar *vBar = verticalScrollBar();-
1099-
1100 se->setViewportSize(QSizeF(viewport()->size()));-
1101 se->setContentPosRange(QRectF(0, 0, hBar->maximum(), vBar->maximum()));-
1102 se->setContentPos(QPointF(hBar->value(), vBar->value()));-
1103 se->accept();-
1104 return true;
never executed: return true;
0
1105 }-
1106 return false;
never executed: return false;
0
1107 }-
1108 case QEvent::Scroll:
never executed: case QEvent::Scroll:
0
1109 {-
1110 QScrollEvent *se = static_cast<QScrollEvent *>(e);-
1111-
1112 QScrollBar *hBar = horizontalScrollBar();-
1113 QScrollBar *vBar = verticalScrollBar();-
1114 hBar->setValue(se->contentPos().x());-
1115 vBar->setValue(se->contentPos().y());-
1116-
1117#ifdef Q_DEAD_CODE_FROM_QT4_WIN-
1118 typedef BOOL (*PtrBeginPanningFeedback)(HWND);-
1119 typedef BOOL (*PtrUpdatePanningFeedback)(HWND, LONG, LONG, BOOL);-
1120 typedef BOOL (*PtrEndPanningFeedback)(HWND, BOOL);-
1121-
1122 static PtrBeginPanningFeedback ptrBeginPanningFeedback = 0;-
1123 static PtrUpdatePanningFeedback ptrUpdatePanningFeedback = 0;-
1124 static PtrEndPanningFeedback ptrEndPanningFeedback = 0;-
1125-
1126 if (!ptrBeginPanningFeedback)-
1127 ptrBeginPanningFeedback = (PtrBeginPanningFeedback) QLibrary::resolve(QLatin1String("UxTheme"), "BeginPanningFeedback");-
1128 if (!ptrUpdatePanningFeedback)-
1129 ptrUpdatePanningFeedback = (PtrUpdatePanningFeedback) QLibrary::resolve(QLatin1String("UxTheme"), "UpdatePanningFeedback");-
1130 if (!ptrEndPanningFeedback)-
1131 ptrEndPanningFeedback = (PtrEndPanningFeedback) QLibrary::resolve(QLatin1String("UxTheme"), "EndPanningFeedback");-
1132-
1133 if (ptrBeginPanningFeedback && ptrUpdatePanningFeedback && ptrEndPanningFeedback) {-
1134 WId wid = window()->winId();-
1135-
1136 if (!se->overshootDistance().isNull() && d->overshoot.isNull())-
1137 ptrBeginPanningFeedback(wid);-
1138 if (!se->overshootDistance().isNull())-
1139 ptrUpdatePanningFeedback(wid, -se->overshootDistance().x(), -se->overshootDistance().y(), false);-
1140 if (se->overshootDistance().isNull() && !d->overshoot.isNull())-
1141 ptrEndPanningFeedback(wid, true);-
1142 } else-
1143#endif-
1144 {-
1145 QPoint delta = d->overshoot - se->overshootDistance().toPoint();-
1146 if (!delta.isNull())
!delta.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1147 viewport()->move(viewport()->pos() + delta);
never executed: viewport()->move(viewport()->pos() + delta);
0
1148 }-
1149 d->overshoot = se->overshootDistance().toPoint();-
1150-
1151 return true;
never executed: return true;
0
1152 }-
1153 case QEvent::StyleChange:
never executed: case QEvent::StyleChange:
0
1154 case QEvent::LayoutDirectionChange:
never executed: case QEvent::LayoutDirectionChange:
0
1155 case QEvent::ApplicationLayoutDirectionChange:
never executed: case QEvent::ApplicationLayoutDirectionChange:
0
1156 case QEvent::LayoutRequest:
never executed: case QEvent::LayoutRequest:
0
1157 d->layoutChildren();-
1158 // fall through-
1159 default:
code before this statement never executed: default:
never executed: default:
0
1160 return QFrame::event(e);
never executed: return QFrame::event(e);
0
1161 }-
1162 return true;
never executed: return true;
0
1163}-
1164-
1165/*!-
1166 \fn bool QAbstractScrollArea::viewportEvent(QEvent *event)-
1167-
1168 The main event handler for the scrolling area (the viewport() widget).-
1169 It handles the \a event specified, and can be called by subclasses to-
1170 provide reasonable default behavior.-
1171-
1172 Returns \c true to indicate to the event system that the event has been-
1173 handled, and needs no further processing; otherwise returns \c false to-
1174 indicate that the event should be propagated further.-
1175-
1176 You can reimplement this function in a subclass, but we recommend-
1177 using one of the specialized event handlers instead.-
1178-
1179 Specialized handlers for viewport events are: paintEvent(),-
1180 mousePressEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(),-
1181 mouseMoveEvent(), wheelEvent(), dragEnterEvent(), dragMoveEvent(),-
1182 dragLeaveEvent(), dropEvent(), contextMenuEvent(), and-
1183 resizeEvent().-
1184*/-
1185bool QAbstractScrollArea::viewportEvent(QEvent *e)-
1186{-
1187 switch (e->type()) {-
1188 case QEvent::Resize:
never executed: case QEvent::Resize:
0
1189 case QEvent::Paint:
never executed: case QEvent::Paint:
0
1190 case QEvent::MouseButtonPress:
never executed: case QEvent::MouseButtonPress:
0
1191 case QEvent::MouseButtonRelease:
never executed: case QEvent::MouseButtonRelease:
0
1192 case QEvent::MouseButtonDblClick:
never executed: case QEvent::MouseButtonDblClick:
0
1193 case QEvent::TouchBegin:
never executed: case QEvent::TouchBegin:
0
1194 case QEvent::TouchUpdate:
never executed: case QEvent::TouchUpdate:
0
1195 case QEvent::TouchEnd:
never executed: case QEvent::TouchEnd:
0
1196 case QEvent::MouseMove:
never executed: case QEvent::MouseMove:
0
1197 case QEvent::ContextMenu:
never executed: case QEvent::ContextMenu:
0
1198#ifndef QT_NO_WHEELEVENT-
1199 case QEvent::Wheel:
never executed: case QEvent::Wheel:
0
1200#endif-
1201#ifndef QT_NO_DRAGANDDROP-
1202 case QEvent::Drop:
never executed: case QEvent::Drop:
0
1203 case QEvent::DragEnter:
never executed: case QEvent::DragEnter:
0
1204 case QEvent::DragMove:
never executed: case QEvent::DragMove:
0
1205 case QEvent::DragLeave:
never executed: case QEvent::DragLeave:
0
1206#endif-
1207#ifndef QT_NO_OPENGL-
1208 // QOpenGLWidget needs special support because it has to know-
1209 // its size has changed, so that it can resize its fbo.-
1210 if (e->type() == QEvent::Resize)
e->type() == QEvent::ResizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1211 QWidgetPrivate::get(viewport())->resizeViewportFramebuffer();
never executed: QWidgetPrivate::get(viewport())->resizeViewportFramebuffer();
0
1212#endif-
1213 return QFrame::event(e);
never executed: return QFrame::event(e);
0
1214 case QEvent::LayoutRequest:
never executed: case QEvent::LayoutRequest:
0
1215#ifndef QT_NO_GESTURES-
1216 case QEvent::Gesture:
never executed: case QEvent::Gesture:
0
1217 case QEvent::GestureOverride:
never executed: case QEvent::GestureOverride:
0
1218 return event(e);
never executed: return event(e);
0
1219#endif-
1220 case QEvent::ScrollPrepare:
never executed: case QEvent::ScrollPrepare:
0
1221 case QEvent::Scroll:
never executed: case QEvent::Scroll:
0
1222 return event(e);
never executed: return event(e);
0
1223 default:
never executed: default:
0
1224 break;
never executed: break;
0
1225 }-
1226 return false; // let the viewport widget handle the event
never executed: return false;
0
1227}-
1228-
1229/*!-
1230 \fn void QAbstractScrollArea::resizeEvent(QResizeEvent *event)-
1231-
1232 This event handler can be reimplemented in a subclass to receive-
1233 resize events (passed in \a event), for the viewport() widget.-
1234-
1235 When resizeEvent() is called, the viewport already has its new-
1236 geometry: Its new size is accessible through the-
1237 QResizeEvent::size() function, and the old size through-
1238 QResizeEvent::oldSize().-
1239-
1240 \sa QWidget::resizeEvent()-
1241 */-
1242void QAbstractScrollArea::resizeEvent(QResizeEvent *)-
1243{-
1244}-
1245-
1246/*!-
1247 \fn void QAbstractScrollArea::paintEvent(QPaintEvent *event)-
1248-
1249 This event handler can be reimplemented in a subclass to receive-
1250 paint events (passed in \a event), for the viewport() widget.-
1251-
1252 \note If you open a painter, make sure to open it on the viewport().-
1253-
1254 \sa QWidget::paintEvent()-
1255*/-
1256void QAbstractScrollArea::paintEvent(QPaintEvent*)-
1257{-
1258}-
1259-
1260/*!-
1261 This event handler can be reimplemented in a subclass to receive-
1262 mouse press events for the viewport() widget. The event is passed-
1263 in \a e.-
1264-
1265 \sa QWidget::mousePressEvent()-
1266*/-
1267void QAbstractScrollArea::mousePressEvent(QMouseEvent *e)-
1268{-
1269 e->ignore();-
1270}
never executed: end of block
0
1271-
1272/*!-
1273 This event handler can be reimplemented in a subclass to receive-
1274 mouse release events for the viewport() widget. The event is-
1275 passed in \a e.-
1276-
1277 \sa QWidget::mouseReleaseEvent()-
1278*/-
1279void QAbstractScrollArea::mouseReleaseEvent(QMouseEvent *e)-
1280{-
1281 e->ignore();-
1282}
never executed: end of block
0
1283-
1284/*!-
1285 This event handler can be reimplemented in a subclass to receive-
1286 mouse double click events for the viewport() widget. The event is-
1287 passed in \a e.-
1288-
1289 \sa QWidget::mouseDoubleClickEvent()-
1290*/-
1291void QAbstractScrollArea::mouseDoubleClickEvent(QMouseEvent *e)-
1292{-
1293 e->ignore();-
1294}
never executed: end of block
0
1295-
1296/*!-
1297 This event handler can be reimplemented in a subclass to receive-
1298 mouse move events for the viewport() widget. The event is passed-
1299 in \a e.-
1300-
1301 \sa QWidget::mouseMoveEvent()-
1302*/-
1303void QAbstractScrollArea::mouseMoveEvent(QMouseEvent *e)-
1304{-
1305 e->ignore();-
1306}
never executed: end of block
0
1307-
1308/*!-
1309 This event handler can be reimplemented in a subclass to receive-
1310 wheel events for the viewport() widget. The event is passed in \a-
1311 e.-
1312-
1313 \sa QWidget::wheelEvent()-
1314*/-
1315#ifndef QT_NO_WHEELEVENT-
1316void QAbstractScrollArea::wheelEvent(QWheelEvent *e)-
1317{-
1318 Q_D(QAbstractScrollArea);-
1319 if (static_cast<QWheelEvent*>(e)->orientation() == Qt::Horizontal)
static_cast<QW...Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
1320 QApplication::sendEvent(d->hbar, e);
never executed: QApplication::sendEvent(d->hbar, e);
0
1321 else-
1322 QApplication::sendEvent(d->vbar, e);
never executed: QApplication::sendEvent(d->vbar, e);
0
1323}-
1324#endif-
1325-
1326#ifndef QT_NO_CONTEXTMENU-
1327/*!-
1328 This event handler can be reimplemented in a subclass to receive-
1329 context menu events for the viewport() widget. The event is passed-
1330 in \a e.-
1331-
1332 \sa QWidget::contextMenuEvent()-
1333*/-
1334void QAbstractScrollArea::contextMenuEvent(QContextMenuEvent *e)-
1335{-
1336 e->ignore();-
1337}
never executed: end of block
0
1338#endif // QT_NO_CONTEXTMENU-
1339-
1340/*!-
1341 This function is called with key event \a e when key presses-
1342 occur. It handles PageUp, PageDown, Up, Down, Left, and Right, and-
1343 ignores all other key presses.-
1344*/-
1345void QAbstractScrollArea::keyPressEvent(QKeyEvent * e)-
1346{-
1347 Q_D(QAbstractScrollArea);-
1348 if (false){
dead code: { }
-
1349#ifndef QT_NO_SHORTCUT
dead code: { }
-
1350 } else if (e == QKeySequence::MoveToPreviousPage) {
e == QKeySeque...ToPreviousPageDescription
TRUEnever evaluated
FALSEnever evaluated
dead code: { }
-
1351 d->vbar->triggerAction(QScrollBar::SliderPageStepSub);-
1352 } else if (e == QKeySequence::MoveToNextPage) {
never executed: end of block
e == QKeySeque...MoveToNextPageDescription
TRUEnever evaluated
FALSEnever evaluated
0
1353 d->vbar->triggerAction(QScrollBar::SliderPageStepAdd);-
1354#endif-
1355 } else {
never executed: end of block
0
1356#ifdef QT_KEYPAD_NAVIGATION-
1357 if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) {-
1358 e->ignore();-
1359 return;-
1360 }-
1361#endif-
1362 switch (e->key()) {-
1363 case Qt::Key_Up:
never executed: case Qt::Key_Up:
0
1364 d->vbar->triggerAction(QScrollBar::SliderSingleStepSub);-
1365 break;
never executed: break;
0
1366 case Qt::Key_Down:
never executed: case Qt::Key_Down:
0
1367 d->vbar->triggerAction(QScrollBar::SliderSingleStepAdd);-
1368 break;
never executed: break;
0
1369 case Qt::Key_Left:
never executed: case Qt::Key_Left:
0
1370#ifdef QT_KEYPAD_NAVIGATION-
1371 if (QApplication::keypadNavigationEnabled() && hasEditFocus()-
1372 && (!d->hbar->isVisible() || d->hbar->value() == d->hbar->minimum())) {-
1373 //if we aren't using the hbar or we are already at the leftmost point ignore-
1374 e->ignore();-
1375 return;-
1376 }-
1377#endif-
1378 d->hbar->triggerAction(-
1379 layoutDirection() == Qt::LeftToRight-
1380 ? QScrollBar::SliderSingleStepSub : QScrollBar::SliderSingleStepAdd);-
1381 break;
never executed: break;
0
1382 case Qt::Key_Right:
never executed: case Qt::Key_Right:
0
1383#ifdef QT_KEYPAD_NAVIGATION-
1384 if (QApplication::keypadNavigationEnabled() && hasEditFocus()-
1385 && (!d->hbar->isVisible() || d->hbar->value() == d->hbar->maximum())) {-
1386 //if we aren't using the hbar or we are already at the rightmost point ignore-
1387 e->ignore();-
1388 return;-
1389 }-
1390#endif-
1391 d->hbar->triggerAction(-
1392 layoutDirection() == Qt::LeftToRight-
1393 ? QScrollBar::SliderSingleStepAdd : QScrollBar::SliderSingleStepSub);-
1394 break;
never executed: break;
0
1395 default:
never executed: default:
0
1396 e->ignore();-
1397 return;
never executed: return;
0
1398 }-
1399 }-
1400 e->accept();-
1401}
never executed: end of block
0
1402-
1403-
1404#ifndef QT_NO_DRAGANDDROP-
1405/*!-
1406 \fn void QAbstractScrollArea::dragEnterEvent(QDragEnterEvent *event)-
1407-
1408 This event handler can be reimplemented in a subclass to receive-
1409 drag enter events (passed in \a event), for the viewport() widget.-
1410-
1411 \sa QWidget::dragEnterEvent()-
1412*/-
1413void QAbstractScrollArea::dragEnterEvent(QDragEnterEvent *)-
1414{-
1415}-
1416-
1417/*!-
1418 \fn void QAbstractScrollArea::dragMoveEvent(QDragMoveEvent *event)-
1419-
1420 This event handler can be reimplemented in a subclass to receive-
1421 drag move events (passed in \a event), for the viewport() widget.-
1422-
1423 \sa QWidget::dragMoveEvent()-
1424*/-
1425void QAbstractScrollArea::dragMoveEvent(QDragMoveEvent *)-
1426{-
1427}-
1428-
1429/*!-
1430 \fn void QAbstractScrollArea::dragLeaveEvent(QDragLeaveEvent *event)-
1431-
1432 This event handler can be reimplemented in a subclass to receive-
1433 drag leave events (passed in \a event), for the viewport() widget.-
1434-
1435 \sa QWidget::dragLeaveEvent()-
1436*/-
1437void QAbstractScrollArea::dragLeaveEvent(QDragLeaveEvent *)-
1438{-
1439}-
1440-
1441/*!-
1442 \fn void QAbstractScrollArea::dropEvent(QDropEvent *event)-
1443-
1444 This event handler can be reimplemented in a subclass to receive-
1445 drop events (passed in \a event), for the viewport() widget.-
1446-
1447 \sa QWidget::dropEvent()-
1448*/-
1449void QAbstractScrollArea::dropEvent(QDropEvent *)-
1450{-
1451}-
1452-
1453-
1454#endif-
1455-
1456/*!-
1457 This virtual handler is called when the scroll bars are moved by-
1458 \a dx, \a dy, and consequently the viewport's contents should be-
1459 scrolled accordingly.-
1460-
1461 The default implementation simply calls update() on the entire-
1462 viewport(), subclasses can reimplement this handler for-
1463 optimization purposes, or - like QScrollArea - to move a contents-
1464 widget. The parameters \a dx and \a dy are there for convenience,-
1465 so that the class knows how much should be scrolled (useful-
1466 e.g. when doing pixel-shifts). You may just as well ignore these-
1467 values and scroll directly to the position the scroll bars-
1468 indicate.-
1469-
1470 Calling this function in order to scroll programmatically is an-
1471 error, use the scroll bars instead (e.g. by calling-
1472 QScrollBar::setValue() directly).-
1473*/-
1474void QAbstractScrollArea::scrollContentsBy(int, int)-
1475{-
1476 viewport()->update();-
1477}
never executed: end of block
0
1478-
1479bool QAbstractScrollAreaPrivate::canStartScrollingAt( const QPoint &startPos )-
1480{-
1481 Q_Q(QAbstractScrollArea);-
1482-
1483#ifndef QT_NO_GRAPHICSVIEW-
1484 // don't start scrolling when a drag mode has been set.-
1485 // don't start scrolling on a movable item.-
1486 if (QGraphicsView *view = qobject_cast<QGraphicsView *>(q)) {
QGraphicsView ...hicsView *>(q)Description
TRUEnever evaluated
FALSEnever evaluated
0
1487 if (view->dragMode() != QGraphicsView::NoDrag)
view->dragMode...csView::NoDragDescription
TRUEnever evaluated
FALSEnever evaluated
0
1488 return false;
never executed: return false;
0
1489-
1490 QGraphicsItem *childItem = view->itemAt(startPos);-
1491-
1492 if (childItem && (childItem->flags() & QGraphicsItem::ItemIsMovable))
childItemDescription
TRUEnever evaluated
FALSEnever evaluated
(childItem->fl...ItemIsMovable)Description
TRUEnever evaluated
FALSEnever evaluated
0
1493 return false;
never executed: return false;
0
1494 }
never executed: end of block
0
1495#endif-
1496-
1497 // don't start scrolling on a QAbstractSlider-
1498 if (qobject_cast<QAbstractSlider *>(q->viewport()->childAt(startPos))) {
qobject_cast<Q...dAt(startPos))Description
TRUEnever evaluated
FALSEnever evaluated
0
1499 return false;
never executed: return false;
0
1500 }-
1501-
1502 return true;
never executed: return true;
0
1503}-
1504-
1505void QAbstractScrollAreaPrivate::flashScrollBars()-
1506{-
1507 bool htransient = hbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, hbar);-
1508 if ((hbarpolicy != Qt::ScrollBarAlwaysOff) && (hbarpolicy == Qt::ScrollBarAsNeeded || htransient))
(hbarpolicy !=...lBarAlwaysOff)Description
TRUEnever evaluated
FALSEnever evaluated
hbarpolicy == ...ollBarAsNeededDescription
TRUEnever evaluated
FALSEnever evaluated
htransientDescription
TRUEnever evaluated
FALSEnever evaluated
0
1509 hbar->d_func()->flash();
never executed: hbar->d_func()->flash();
0
1510 bool vtransient = vbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, vbar);-
1511 if ((vbarpolicy != Qt::ScrollBarAlwaysOff) && (vbarpolicy == Qt::ScrollBarAsNeeded || vtransient))
(vbarpolicy !=...lBarAlwaysOff)Description
TRUEnever evaluated
FALSEnever evaluated
vbarpolicy == ...ollBarAsNeededDescription
TRUEnever evaluated
FALSEnever evaluated
vtransientDescription
TRUEnever evaluated
FALSEnever evaluated
0
1512 vbar->d_func()->flash();
never executed: vbar->d_func()->flash();
0
1513}
never executed: end of block
0
1514-
1515void QAbstractScrollAreaPrivate::setScrollBarTransient(QScrollBar *scrollBar, bool transient)-
1516{-
1517 scrollBar->d_func()->setTransient(transient);-
1518}
never executed: end of block
0
1519-
1520void QAbstractScrollAreaPrivate::_q_hslide(int x)-
1521{-
1522 Q_Q(QAbstractScrollArea);-
1523 int dx = xoffset - x;-
1524 xoffset = x;-
1525 q->scrollContentsBy(dx, 0);-
1526 flashScrollBars();-
1527}
never executed: end of block
0
1528-
1529void QAbstractScrollAreaPrivate::_q_vslide(int y)-
1530{-
1531 Q_Q(QAbstractScrollArea);-
1532 int dy = yoffset - y;-
1533 yoffset = y;-
1534 q->scrollContentsBy(0, dy);-
1535 flashScrollBars();-
1536}
never executed: end of block
0
1537-
1538void QAbstractScrollAreaPrivate::_q_showOrHideScrollBars()-
1539{-
1540 layoutChildren();-
1541#ifdef Q_DEAD_CODE_FROM_QT4_WIN-
1542 // Need to re-subscribe to gestures as the content changes to make sure we-
1543 // enable/disable panning when needed.-
1544 QWidgetPrivate *dd = static_cast<QWidgetPrivate *>(QObjectPrivate::get(viewport));-
1545 if (dd)-
1546 dd->winSetupGestures();-
1547#endif // Q_DEAD_CODE_FROM_QT4_WIN-
1548}
never executed: end of block
0
1549-
1550QPoint QAbstractScrollAreaPrivate::contentsOffset() const-
1551{-
1552 Q_Q(const QAbstractScrollArea);-
1553 QPoint offset;-
1554 if (vbar->isVisible())
vbar->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
1555 offset.setY(vbar->value());
never executed: offset.setY(vbar->value());
0
1556 if (hbar->isVisible()) {
hbar->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
1557 if (q->isRightToLeft())
q->isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
0
1558 offset.setX(hbar->maximum() - hbar->value());
never executed: offset.setX(hbar->maximum() - hbar->value());
0
1559 else-
1560 offset.setX(hbar->value());
never executed: offset.setX(hbar->value());
0
1561 }-
1562 return offset;
never executed: return offset;
0
1563}-
1564-
1565/*!-
1566 \reimp-
1567-
1568*/-
1569QSize QAbstractScrollArea::minimumSizeHint() const-
1570{-
1571 Q_D(const QAbstractScrollArea);-
1572 int hsbExt = d->hbar->sizeHint().height();-
1573 int vsbExt = d->vbar->sizeHint().width();-
1574 int extra = 2 * d->frameWidth;-
1575 QStyleOption opt;-
1576 opt.initFrom(this);-
1577 if ((d->frameStyle != QFrame::NoFrame)
(d->frameStyle...rame::NoFrame)Description
TRUEnever evaluated
FALSEnever evaluated
0
1578 && style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, &opt, this)) {
style()->style...s, &opt, this)Description
TRUEnever evaluated
FALSEnever evaluated
0
1579 extra += style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing, &opt, this);-
1580 }
never executed: end of block
0
1581 return QSize(d->scrollBarContainers[Qt::Horizontal]->sizeHint().width() + vsbExt + extra,
never executed: return QSize(d->scrollBarContainers[Qt::Horizontal]->sizeHint().width() + vsbExt + extra, d->scrollBarContainers[Qt::Vertical]->sizeHint().height() + hsbExt + extra);
0
1582 d->scrollBarContainers[Qt::Vertical]->sizeHint().height() + hsbExt + extra);
never executed: return QSize(d->scrollBarContainers[Qt::Horizontal]->sizeHint().width() + vsbExt + extra, d->scrollBarContainers[Qt::Vertical]->sizeHint().height() + hsbExt + extra);
0
1583}-
1584-
1585/*!-
1586 Returns the sizeHint property of the scroll area. The size is determined by using-
1587 viewportSizeHint() plus some extra space for scroll bars, if needed.-
1588 \reimp-
1589*/-
1590QSize QAbstractScrollArea::sizeHint() const-
1591{-
1592 Q_D(const QAbstractScrollArea);-
1593 if (d->sizeAdjustPolicy == QAbstractScrollArea::AdjustIgnored)
d->sizeAdjustP...:AdjustIgnoredDescription
TRUEnever evaluated
FALSEnever evaluated
0
1594 return QSize(256, 192);
never executed: return QSize(256, 192);
0
1595-
1596 if (!d->sizeHint.isValid() || d->sizeAdjustPolicy == QAbstractScrollArea::AdjustToContents) {
!d->sizeHint.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
d->sizeAdjustP...justToContentsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1597 const int f = 2 * d->frameWidth;-
1598 const QSize frame( f, f );-
1599 const QSize scrollbars(d->vbarpolicy == Qt::ScrollBarAlwaysOn ? d->vbar->sizeHint().width() : 0,-
1600 d->hbarpolicy == Qt::ScrollBarAlwaysOn ? d->hbar->sizeHint().height() : 0);-
1601 d->sizeHint = frame + scrollbars + viewportSizeHint();-
1602 }
never executed: end of block
0
1603 return d->sizeHint;
never executed: return d->sizeHint;
0
1604}-
1605-
1606/*!-
1607 \since 5.2-
1608 Returns the recommended size for the viewport.-
1609 The default implementation returns viewport()->sizeHint().-
1610 Note that the size is just the viewport's size, without any scroll bars visible.-
1611 */-
1612QSize QAbstractScrollArea::viewportSizeHint() const-
1613{-
1614 Q_D(const QAbstractScrollArea);-
1615 if (d->viewport) {
d->viewportDescription
TRUEnever evaluated
FALSEnever evaluated
0
1616 const QSize sh = d->viewport->sizeHint();-
1617 if (sh.isValid()) {
sh.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
1618 return sh;
never executed: return sh;
0
1619 }-
1620 }
never executed: end of block
0
1621 const int h = qMax(10, fontMetrics().height());-
1622 return QSize(6 * h, 4 * h);
never executed: return QSize(6 * h, 4 * h);
0
1623}-
1624-
1625/*!-
1626 \since 5.2-
1627 \property QAbstractScrollArea::sizeAdjustPolicy-
1628 This property holds the policy describing how the size of the scroll area changes when the-
1629 size of the viewport changes.-
1630-
1631 The default policy is QAbstractScrollArea::AdjustIgnored.-
1632 Changing this property might actually resize the scrollarea.-
1633*/-
1634-
1635QAbstractScrollArea::SizeAdjustPolicy QAbstractScrollArea::sizeAdjustPolicy() const-
1636{-
1637 Q_D(const QAbstractScrollArea);-
1638 return d->sizeAdjustPolicy;
never executed: return d->sizeAdjustPolicy;
0
1639}-
1640-
1641void QAbstractScrollArea::setSizeAdjustPolicy(SizeAdjustPolicy policy)-
1642{-
1643 Q_D(QAbstractScrollArea);-
1644 if (d->sizeAdjustPolicy == policy)
d->sizeAdjustPolicy == policyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1645 return;
never executed: return;
0
1646-
1647 d->sizeAdjustPolicy = policy;-
1648 d->sizeHint = QSize();-
1649 updateGeometry();-
1650}
never executed: end of block
0
1651-
1652/*!-
1653 This slot is called by QAbstractScrollArea after setViewport(\a-
1654 viewport) has been called. Reimplement this function in a-
1655 subclass of QAbstractScrollArea to initialize the new \a viewport-
1656 before it is used.-
1657-
1658 \sa setViewport()-
1659*/-
1660void QAbstractScrollArea::setupViewport(QWidget *viewport)-
1661{-
1662 Q_UNUSED(viewport);-
1663}
never executed: end of block
0
1664-
1665QT_END_NAMESPACE-
1666-
1667#include "moc_qabstractscrollarea.cpp"-
1668#include "moc_qabstractscrollarea_p.cpp"-
1669-
1670#endif // QT_NO_SCROLLAREA-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9