aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-04-28 15:50:14 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2017-04-28 17:45:46 +0000
commitf71d22d6e077410c42291486e15b67215baa0739 (patch)
tree20ae1093a73c4952be1d6923ab4153fbb98a93b8 /src/quicktemplates2
parentc3ddc2e8124b7b03279d6d3a1b76858cc7763af1 (diff)
Add QQuickPopupPrivate::contains() for convenience
This logic seemed to be repeated in several places... Change-Id: I3b74140c7d7e44fa6ada12cf7844d96086d99e47 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r--src/quicktemplates2/qquickdrawer.cpp10
-rw-r--r--src/quicktemplates2/qquickpopup.cpp7
-rw-r--r--src/quicktemplates2/qquickpopup_p_p.h2
3 files changed, 13 insertions, 6 deletions
diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp
index 44500bd3..b896c142 100644
--- a/src/quicktemplates2/qquickdrawer.cpp
+++ b/src/quicktemplates2/qquickdrawer.cpp
@@ -308,7 +308,7 @@ bool QQuickDrawerPrivate::grabMouse(QQuickItem *item, QMouseEvent *event)
}
// Don't be too eager to steal presses outside the drawer (QTBUG-53929)
- if (overThreshold && qFuzzyCompare(position, qreal(1.0)) && !popupItem->contains(popupItem->mapFromScene(movePoint))) {
+ if (overThreshold && qFuzzyCompare(position, qreal(1.0)) && !contains(movePoint)) {
if (edge == Qt::LeftEdge || edge == Qt::RightEdge)
overThreshold = qAbs(movePoint.x() - q->width()) < dragMargin;
else
@@ -323,7 +323,7 @@ bool QQuickDrawerPrivate::grabMouse(QQuickItem *item, QMouseEvent *event)
offset = positionAt(movePoint) - position;
// don't jump when dragged open
- if (offset > 0 && position > 0 && !popupItem->contains(popupItem->mapFromScene(movePoint)))
+ if (offset > 0 && position > 0 && !contains(movePoint))
offset = 0;
}
}
@@ -358,7 +358,7 @@ bool QQuickDrawerPrivate::grabTouch(QQuickItem *item, QTouchEvent *event)
}
// Don't be too eager to steal presses outside the drawer (QTBUG-53929)
- if (overThreshold && qFuzzyCompare(position, qreal(1.0)) && !popupItem->contains(popupItem->mapFromScene(movePoint))) {
+ if (overThreshold && qFuzzyCompare(position, qreal(1.0)) && !contains(movePoint)) {
if (edge == Qt::LeftEdge || edge == Qt::RightEdge)
overThreshold = qAbs(movePoint.x() - q->width()) < dragMargin;
else
@@ -370,7 +370,7 @@ bool QQuickDrawerPrivate::grabTouch(QQuickItem *item, QTouchEvent *event)
offset = positionAt(movePoint) - position;
// don't jump when dragged open
- if (offset > 0 && position > 0 && !popupItem->contains(popupItem->mapFromScene(movePoint)))
+ if (offset > 0 && position > 0 && !contains(movePoint))
offset = 0;
}
}
@@ -399,7 +399,7 @@ bool QQuickDrawerPrivate::handleMove(QQuickItem *item, const QPointF &point, ulo
return false;
// limit/reset the offset to the edge of the drawer when pushed from the outside
- if (qFuzzyCompare(position, 1.0) && !popupItem->contains(popupItem->mapFromScene(point)))
+ if (qFuzzyCompare(position, 1.0) && !contains(point))
offset = 0;
bool isGrabbed = popupItem->keepMouseGrab() || popupItem->keepTouchGrab();
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
index 68a82204..9fb712ea 100644
--- a/src/quicktemplates2/qquickpopup.cpp
+++ b/src/quicktemplates2/qquickpopup.cpp
@@ -284,7 +284,7 @@ bool QQuickPopupPrivate::tryClose(const QPointF &pos, QQuickPopup::ClosePolicy f
const bool onOutside = closePolicy & (flags & outsideFlags);
const bool onOutsideParent = closePolicy & (flags & outsideParentFlags);
if (onOutside || onOutsideParent) {
- if (!popupItem->contains(popupItem->mapFromScene(pos))) {
+ if (!contains(pos)) {
if (!onOutsideParent || !parentItem || !parentItem->contains(parentItem->mapFromScene(pos))) {
closeOrReject();
return true;
@@ -294,6 +294,11 @@ bool QQuickPopupPrivate::tryClose(const QPointF &pos, QQuickPopup::ClosePolicy f
return false;
}
+bool QQuickPopupPrivate::contains(const QPointF &scenePos) const
+{
+ return popupItem->contains(popupItem->mapFromScene(scenePos));
+}
+
bool QQuickPopupPrivate::acceptTouch(const QTouchEvent::TouchPoint &point)
{
if (point.id() == touchId)
diff --git a/src/quicktemplates2/qquickpopup_p_p.h b/src/quicktemplates2/qquickpopup_p_p.h
index 5c2fe4f7..f5697993 100644
--- a/src/quicktemplates2/qquickpopup_p_p.h
+++ b/src/quicktemplates2/qquickpopup_p_p.h
@@ -97,6 +97,8 @@ public:
void closeOrReject();
bool tryClose(const QPointF &pos, QQuickPopup::ClosePolicy flags);
+ bool contains(const QPointF &scenePos) const;
+
virtual bool acceptTouch(const QTouchEvent::TouchPoint &point);
virtual bool blockInput(QQuickItem *item, const QPointF &point) const;