Override virtual method in private class instead of downcasting
Move QGraphicsView specific code into reimplementation of now virtual (and const) canStartScrollingAt. Remove unhelpful comment. Change-Id: Ib4799e48ac4f85748c77c52d29511a0490303676 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
e349f787d5
commit
c8dea4a833
@ -613,6 +613,26 @@ void QGraphicsViewPrivate::updateScroll()
|
||||
dirtyScroll = false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
* don't start scrolling when a drag mode has been set
|
||||
* don't start scrolling on a movable item
|
||||
*/
|
||||
bool QGraphicsViewPrivate::canStartScrollingAt(const QPoint &startPos) const
|
||||
{
|
||||
Q_Q(const QGraphicsView);
|
||||
if (q->dragMode() != QGraphicsView::NoDrag)
|
||||
return false;
|
||||
|
||||
const QGraphicsItem *childItem = q->itemAt(startPos);
|
||||
|
||||
if (childItem && (childItem->flags() & QGraphicsItem::ItemIsMovable))
|
||||
return false;
|
||||
|
||||
return QAbstractScrollAreaPrivate::canStartScrollingAt(startPos);
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
|
@ -117,6 +117,7 @@ public:
|
||||
QTransform matrix;
|
||||
qint64 scrollX, scrollY;
|
||||
void updateScroll();
|
||||
bool canStartScrollingAt(const QPoint &startPos) const override;
|
||||
|
||||
qreal leftIndent;
|
||||
qreal topIndent;
|
||||
|
@ -1361,28 +1361,13 @@ void QAbstractScrollArea::scrollContentsBy(int, int)
|
||||
viewport()->update();
|
||||
}
|
||||
|
||||
bool QAbstractScrollAreaPrivate::canStartScrollingAt( const QPoint &startPos )
|
||||
bool QAbstractScrollAreaPrivate::canStartScrollingAt(const QPoint &startPos) const
|
||||
{
|
||||
Q_Q(QAbstractScrollArea);
|
||||
|
||||
#if QT_CONFIG(graphicsview)
|
||||
// don't start scrolling when a drag mode has been set.
|
||||
// don't start scrolling on a movable item.
|
||||
if (QGraphicsView *view = qobject_cast<QGraphicsView *>(q)) {
|
||||
if (view->dragMode() != QGraphicsView::NoDrag)
|
||||
return false;
|
||||
|
||||
QGraphicsItem *childItem = view->itemAt(startPos);
|
||||
|
||||
if (childItem && (childItem->flags() & QGraphicsItem::ItemIsMovable))
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
Q_Q(const QAbstractScrollArea);
|
||||
|
||||
// don't start scrolling on a QAbstractSlider
|
||||
if (qobject_cast<QAbstractSlider *>(q->viewport()->childAt(startPos))) {
|
||||
if (qobject_cast<QAbstractSlider *>(q->viewport()->childAt(startPos)))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -94,9 +94,8 @@ public:
|
||||
void init();
|
||||
void layoutChildren();
|
||||
void layoutChildren_helper(bool *needHorizontalScrollbar, bool *needVerticalScrollbar);
|
||||
// ### Fix for 4.4, talk to Bjoern E or Girish.
|
||||
virtual void scrollBarPolicyChanged(Qt::Orientation, Qt::ScrollBarPolicy) {}
|
||||
bool canStartScrollingAt( const QPoint &startPos );
|
||||
virtual bool canStartScrollingAt( const QPoint &startPos ) const;
|
||||
|
||||
void flashScrollBars();
|
||||
void setScrollBarTransient(QScrollBar *scrollBar, bool transient);
|
||||
|
Loading…
x
Reference in New Issue
Block a user