aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-11-23 16:10:32 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2016-11-23 16:10:32 +0100
commit4236abbd68560aef74fb70ecc2b0bc34d17cda7c (patch)
tree74c452a1ea60d44437e2432d9d647d30235a79da /src/quicktemplates2
parent261e84c3e333574b300ea0b09f87fccc88c4a0ea (diff)
parent9812a9cc1e71b0a3d8f25c0db2457f8673e53054 (diff)
Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts: src/quicktemplates2/qquickswipedelegate_p.h Change-Id: I5446503c1e4f21cb37f4fffeb3453d1c84b54b30
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r--src/quicktemplates2/qquickswipe_p.h120
-rw-r--r--src/quicktemplates2/qquickswipedelegate.cpp51
-rw-r--r--src/quicktemplates2/qquickswipedelegate_p.h61
-rw-r--r--src/quicktemplates2/qquickswipedelegate_p_p.h76
-rw-r--r--src/quicktemplates2/quicktemplates2.pri2
5 files changed, 229 insertions, 81 deletions
diff --git a/src/quicktemplates2/qquickswipe_p.h b/src/quicktemplates2/qquickswipe_p.h
new file mode 100644
index 00000000..c1a28819
--- /dev/null
+++ b/src/quicktemplates2/qquickswipe_p.h
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKSWIPE_P_H
+#define QQUICKSWIPE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qobject.h>
+#include <QtQuickTemplates2/private/qtquicktemplates2global_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlComponent;
+class QQuickItem;
+class QQuickSwipeDelegate;
+class QQuickSwipePrivate;
+
+class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSwipe : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal position READ position NOTIFY positionChanged FINAL)
+ Q_PROPERTY(bool complete READ isComplete NOTIFY completeChanged FINAL)
+ Q_PROPERTY(QQmlComponent *left READ left WRITE setLeft NOTIFY leftChanged FINAL)
+ Q_PROPERTY(QQmlComponent *behind READ behind WRITE setBehind NOTIFY behindChanged FINAL)
+ Q_PROPERTY(QQmlComponent *right READ right WRITE setRight NOTIFY rightChanged FINAL)
+ Q_PROPERTY(QQuickItem *leftItem READ leftItem NOTIFY leftItemChanged FINAL)
+ Q_PROPERTY(QQuickItem *behindItem READ behindItem NOTIFY behindItemChanged FINAL)
+ Q_PROPERTY(QQuickItem *rightItem READ rightItem NOTIFY rightItemChanged FINAL)
+
+public:
+ explicit QQuickSwipe(QQuickSwipeDelegate *control);
+
+ qreal position() const;
+ void setPosition(qreal position);
+
+ bool isComplete() const;
+ void setComplete(bool complete);
+
+ QQmlComponent *left() const;
+ void setLeft(QQmlComponent *left);
+
+ QQmlComponent *behind() const;
+ void setBehind(QQmlComponent *behind);
+
+ QQmlComponent *right() const;
+ void setRight(QQmlComponent *right);
+
+ QQuickItem *leftItem() const;
+ void setLeftItem(QQuickItem *item);
+
+ QQuickItem *behindItem() const;
+ void setBehindItem(QQuickItem *item);
+
+ QQuickItem *rightItem() const;
+ void setRightItem(QQuickItem *item);
+
+ Q_REVISION(1) Q_INVOKABLE void close();
+
+Q_SIGNALS:
+ void positionChanged();
+ void completeChanged();
+ /*Q_REVISION(1)*/ void completed();
+ void leftChanged();
+ void behindChanged();
+ void rightChanged();
+ void leftItemChanged();
+ void behindItemChanged();
+ void rightItemChanged();
+
+private:
+ Q_DISABLE_COPY(QQuickSwipe)
+ Q_DECLARE_PRIVATE(QQuickSwipe)
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKSWIPE_P_H
diff --git a/src/quicktemplates2/qquickswipedelegate.cpp b/src/quicktemplates2/qquickswipedelegate.cpp
index caeea3e9..743f38ff 100644
--- a/src/quicktemplates2/qquickswipedelegate.cpp
+++ b/src/quicktemplates2/qquickswipedelegate.cpp
@@ -35,6 +35,7 @@
****************************************************************************/
#include "qquickswipedelegate_p.h"
+#include "qquickswipedelegate_p_p.h"
#include "qquickcontrol_p_p.h"
#include "qquickitemdelegate_p_p.h"
#include "qquickvelocitycalculator_p_p.h"
@@ -148,6 +149,8 @@ public:
void warnAboutMixingDelegates();
void warnAboutSettingDelegatesWhileVisible();
+ bool hasDelegates() const;
+
QQuickSwipeDelegate *control;
// Same range as position, but is set before press events so that we can
// keep track of which direction the user must swipe when using left and right delegates.
@@ -348,6 +351,11 @@ void QQuickSwipePrivate::warnAboutSettingDelegatesWhileVisible()
qmlInfo(control) << "left/right/behind properties may only be set when swipe.position is 0";
}
+bool QQuickSwipePrivate::hasDelegates() const
+{
+ return left || right || behind;
+}
+
QQuickSwipe::QQuickSwipe(QQuickSwipeDelegate *control) :
QObject(*(new QQuickSwipePrivate(control)))
{
@@ -382,6 +390,8 @@ void QQuickSwipe::setLeft(QQmlComponent *left)
d->leftItem = nullptr;
}
+ d->control->setFiltersChildMouseEvents(d->hasDelegates());
+
emit leftChanged();
}
@@ -414,6 +424,8 @@ void QQuickSwipe::setBehind(QQmlComponent *behind)
d->behindItem = nullptr;
}
+ d->control->setFiltersChildMouseEvents(d->hasDelegates());
+
emit behindChanged();
}
@@ -446,6 +458,8 @@ void QQuickSwipe::setRight(QQmlComponent *right)
d->rightItem = nullptr;
}
+ d->control->setFiltersChildMouseEvents(d->hasDelegates());
+
emit rightChanged();
}
@@ -570,24 +584,10 @@ void QQuickSwipe::close()
d->velocityCalculator.reset();
}
-class QQuickSwipeDelegatePrivate : public QQuickItemDelegatePrivate
+QQuickSwipeDelegatePrivate::QQuickSwipeDelegatePrivate(QQuickSwipeDelegate *control) :
+ swipe(control)
{
- Q_DECLARE_PUBLIC(QQuickSwipeDelegate)
-
-public:
- QQuickSwipeDelegatePrivate(QQuickSwipeDelegate *control) :
- swipe(control)
- {
- }
-
- bool handleMousePressEvent(QQuickItem *item, QMouseEvent *event);
- bool handleMouseMoveEvent(QQuickItem *item, QMouseEvent *event);
- bool handleMouseReleaseEvent(QQuickItem *item, QMouseEvent *event);
-
- void resizeContent() override;
-
- QQuickSwipe swipe;
-};
+}
bool QQuickSwipeDelegatePrivate::handleMousePressEvent(QQuickItem *item, QMouseEvent *event)
{
@@ -708,6 +708,13 @@ bool QQuickSwipeDelegatePrivate::handleMouseMoveEvent(QQuickItem *item, QMouseEv
swipe.setPosition(position);
}
+ } else {
+ // The swipe wasn't initiated.
+ if (event->pos().y() < 0 || event->pos().y() > height) {
+ // The mouse went outside the vertical bounds of the control, so
+ // we should no longer consider it pressed.
+ q->setPressed(false);
+ }
}
event->accept();
@@ -791,7 +798,6 @@ void QQuickSwipeDelegatePrivate::resizeContent()
QQuickSwipeDelegate::QQuickSwipeDelegate(QQuickItem *parent) :
QQuickItemDelegate(*(new QQuickSwipeDelegatePrivate(this)), parent)
{
- setFiltersChildMouseEvents(true);
}
/*!
@@ -961,14 +967,17 @@ void QQuickSwipeDelegate::mousePressEvent(QMouseEvent *event)
void QQuickSwipeDelegate::mouseMoveEvent(QMouseEvent *event)
{
Q_D(QQuickSwipeDelegate);
- d->handleMouseMoveEvent(this, event);
+ if (filtersChildMouseEvents())
+ d->handleMouseMoveEvent(this, event);
+ else
+ QQuickItemDelegate::mouseMoveEvent(event);
}
void QQuickSwipeDelegate::mouseReleaseEvent(QMouseEvent *event)
{
Q_D(QQuickSwipeDelegate);
- QQuickItemDelegate::mouseReleaseEvent(event);
- d->handleMouseReleaseEvent(this, event);
+ if (!filtersChildMouseEvents() || !d->handleMouseReleaseEvent(this, event))
+ QQuickItemDelegate::mouseReleaseEvent(event);
}
void QQuickSwipeDelegate::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
diff --git a/src/quicktemplates2/qquickswipedelegate_p.h b/src/quicktemplates2/qquickswipedelegate_p.h
index ae23672b..16aa9837 100644
--- a/src/quicktemplates2/qquickswipedelegate_p.h
+++ b/src/quicktemplates2/qquickswipedelegate_p.h
@@ -52,8 +52,8 @@
QT_BEGIN_NAMESPACE
-class QQuickSwipeDelegatePrivate;
class QQuickSwipe;
+class QQuickSwipeDelegatePrivate;
class QQuickSwipeDelegateAttached;
class QQuickSwipeDelegateAttachedPrivate;
@@ -88,65 +88,6 @@ private:
Q_DECLARE_PRIVATE(QQuickSwipeDelegate)
};
-class QQuickSwipePrivate;
-
-class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSwipe : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(qreal position READ position NOTIFY positionChanged FINAL)
- Q_PROPERTY(bool complete READ isComplete NOTIFY completeChanged FINAL)
- Q_PROPERTY(QQmlComponent *left READ left WRITE setLeft NOTIFY leftChanged FINAL)
- Q_PROPERTY(QQmlComponent *behind READ behind WRITE setBehind NOTIFY behindChanged FINAL)
- Q_PROPERTY(QQmlComponent *right READ right WRITE setRight NOTIFY rightChanged FINAL)
- Q_PROPERTY(QQuickItem *leftItem READ leftItem NOTIFY leftItemChanged FINAL)
- Q_PROPERTY(QQuickItem *behindItem READ behindItem NOTIFY behindItemChanged FINAL)
- Q_PROPERTY(QQuickItem *rightItem READ rightItem NOTIFY rightItemChanged FINAL)
-
-public:
- explicit QQuickSwipe(QQuickSwipeDelegate *control);
-
- qreal position() const;
- void setPosition(qreal position);
-
- bool isComplete() const;
- void setComplete(bool complete);
-
- QQmlComponent *left() const;
- void setLeft(QQmlComponent *left);
-
- QQmlComponent *behind() const;
- void setBehind(QQmlComponent *behind);
-
- QQmlComponent *right() const;
- void setRight(QQmlComponent *right);
-
- QQuickItem *leftItem() const;
- void setLeftItem(QQuickItem *item);
-
- QQuickItem *behindItem() const;
- void setBehindItem(QQuickItem *item);
-
- QQuickItem *rightItem() const;
- void setRightItem(QQuickItem *item);
-
- Q_REVISION(1) Q_INVOKABLE void close();
-
-Q_SIGNALS:
- void positionChanged();
- void completeChanged();
- /*Q_REVISION(1)*/ void completed();
- void leftChanged();
- void behindChanged();
- void rightChanged();
- void leftItemChanged();
- void behindItemChanged();
- void rightItemChanged();
-
-private:
- Q_DISABLE_COPY(QQuickSwipe)
- Q_DECLARE_PRIVATE(QQuickSwipe)
-};
-
class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSwipeDelegateAttached : public QObject
{
Q_OBJECT
diff --git a/src/quicktemplates2/qquickswipedelegate_p_p.h b/src/quicktemplates2/qquickswipedelegate_p_p.h
new file mode 100644
index 00000000..0387ad70
--- /dev/null
+++ b/src/quicktemplates2/qquickswipedelegate_p_p.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKSWIPEDELEGATE_P_P_H
+#define QQUICKSWIPEDELEGATE_P_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQuickTemplates2/private/qquickitemdelegate_p_p.h>
+#include <QtQuickTemplates2/private/qquickswipe_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickSwipeDelegate;
+
+class QQuickSwipeDelegatePrivate : public QQuickItemDelegatePrivate
+{
+ Q_DECLARE_PUBLIC(QQuickSwipeDelegate)
+
+public:
+ QQuickSwipeDelegatePrivate(QQuickSwipeDelegate *control);
+
+ bool handleMousePressEvent(QQuickItem *item, QMouseEvent *event);
+ bool handleMouseMoveEvent(QQuickItem *item, QMouseEvent *event);
+ bool handleMouseReleaseEvent(QQuickItem *item, QMouseEvent *event);
+
+ void resizeContent() override;
+
+ QQuickSwipe swipe;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKSWIPEDELEGATE_P_P_H
diff --git a/src/quicktemplates2/quicktemplates2.pri b/src/quicktemplates2/quicktemplates2.pri
index 939d2f0e..4a128501 100644
--- a/src/quicktemplates2/quicktemplates2.pri
+++ b/src/quicktemplates2/quicktemplates2.pri
@@ -55,7 +55,9 @@ HEADERS += \
$$PWD/qquickspinbox_p.h \
$$PWD/qquickstackview_p.h \
$$PWD/qquickstackview_p_p.h \
+ $$PWD/qquickswipe_p.h \
$$PWD/qquickswipedelegate_p.h \
+ $$PWD/qquickswipedelegate_p_p.h \
$$PWD/qquickswipeview_p.h \
$$PWD/qquickswitch_p.h \
$$PWD/qquickswitchdelegate_p.h \