10#include <QtGui/qstylehints.h>
11#include <QtGui/private/qguiapplication_p.h>
12#include <QtGui/private/qeventpoint_p.h>
13#include <QtGui/qpa/qplatformtheme.h>
14#include <QtQml/qqmlinfo.h>
15#include <QtQuick/private/qquickanimation_p.h>
16#include <QtQuick/private/qquicktransition_p.h>
17#include <QtQuick/private/qquicktransitionmanager_p_p.h>
78 return qobject_cast<Attached*>(qmlAttachedPropertiesObject<QQuickSwipeDelegate>(
item,
false));
113 void reposition(PositionAnimation animationPolicy);
163 const int count = animations.
count(&animations);
181 return swipe->d_func();
270 const qreal relevantWidth = relevantItem ? relevantItem->
width() : 0.0;
275 if (animationPolicy == AnimatePosition) {
277 contentItem->setProperty(
"x", contentItemX);
279 background->setProperty(
"x",
position * relevantWidth);
282 contentItem->setX(contentItemX);
284 background->setX(
position * relevantWidth);
357 qmlWarning(
control) <<
"left/right/behind properties may only be set when swipe.position is 0";
376 q->setPosition(newPosition);
419 d->warnAboutMixingDelegates();
424 d->warnAboutSettingDelegatesWhileVisible();
432 d->leftItem =
nullptr;
435 d->control->setFiltersChildMouseEvents(
d->hasDelegates());
452 if (
d->left ||
d->right) {
453 d->warnAboutMixingDelegates();
458 d->warnAboutSettingDelegatesWhileVisible();
465 delete d->behindItem;
466 d->behindItem =
nullptr;
469 d->control->setFiltersChildMouseEvents(
d->hasDelegates());
487 d->warnAboutMixingDelegates();
492 d->warnAboutSettingDelegatesWhileVisible();
500 d->rightItem =
nullptr;
503 d->control->setFiltersChildMouseEvents(
d->hasDelegates());
517 if (
item ==
d->leftItem)
524 d->leftItem->setParentItem(
d->control);
527 d->leftItem->setZ(-2);
536 return d->behindItem;
542 if (
item ==
d->behindItem)
545 delete d->behindItem;
546 d->behindItem =
item;
549 d->behindItem->setParentItem(
d->control);
552 d->behindItem->setZ(-2);
567 if (
item ==
d->rightItem)
574 d->rightItem->setParentItem(
d->control);
577 d->rightItem->setZ(-2);
597 d->reposition(AnimatePosition);
638 return d->transition;
662 d->beginTransition(side);
663 d->wasComplete =
true;
664 d->velocityCalculator.reset();
665 d->positionBeforePress =
d->position;
668void QQuickSwipe::close()
674 if (
d->control->isPressed()) {
679 d->beginTransition(0.0);
680 d->waitForTransition =
true;
681 d->wasComplete =
false;
682 d->positionBeforePress = 0.0;
683 d->velocityCalculator.reset();
699 const bool extraAllocated =
extra.isAllocated();
701 if (((!
p->widthValid() || !extraAllocated || !
extra->hasBackgroundWidth))
702 || (extraAllocated && (
extra->hasLeftInset ||
extra->hasRightInset))) {
706 || (extraAllocated && (
extra->hasTopInset ||
extra->hasBottomInset))) {
723 q->mousePressEvent(
event);
771 if (!swipePrivate->
left && !swipePrivate->
right && !swipePrivate->
behind)
780 if (!
q->keepMouseGrab()) {
785 if (
window && overThreshold) {
789 q->setKeepMouseGrab(
true);
798 if (
q->keepMouseGrab()) {
804 || ((swipePrivate->
left || swipePrivate->
right)
814 const qreal normalizedDistance = relevantItem ?
distance / relevantItem->
width() : 0.0;
839 position =
distance > 0 ? normalizedDistance - 1.0 : normalizedDistance + 1.0;
848 if (
event->position().toPoint().y() < 0 ||
event->position().toPoint().y() >
height) {
851 q->setPressed(
false);
857 return q->keepMouseGrab();
868 const bool hadGrabbedMouse =
q->keepMouseGrab();
869 q->setKeepMouseGrab(
false);
874 q->setPressed(
false);
882 if (hadGrabbedMouse) {
885 q->setPressed(
false);
901 }
else if (swipePrivate->
position < -0.5 ||
918 return hadGrabbedMouse;
928 QMutableEventPoint::setPosition(localizedEvent.
point(0), localPos);
945 for (
int i = 0;
i < itemAndChildren.
size(); ++
i) {
946 auto item = itemAndChildren.
at(
i);
950 const bool wasPressed = attached->isPressed();
953 emit attached->clicked();
970 && !
item->property(
"_q_QQuickSwipeDelegate_warned").toBool()) {
972 item->setProperty(
"_q_QQuickSwipeDelegate_warned",
true);
1205 switch (
event->type()) {
1215 return d->handleMouseReleaseEvent(
child, mouseEvent);
1222 attached->setPressed(
false);
1244 auto item =
d->swipe.rightItem();
1246 d->pressedItem =
item;
1249 item =
d->swipe.leftItem();
1251 d->pressedItem =
item;
1262 d->handleMouseMoveEvent(
this,
event);
1266 d->handleMouseMoveEvent(
d->pressedItem,
event);
1275 if (
d->pressedItem) {
1276 if (
d->pressedItem->acceptedMouseButtons())
1277 d->handleMouseReleaseEvent(
d->pressedItem,
event);
1278 d->pressedItem =
nullptr;
1287 auto item =
d->swipe.rightItem();
1289 if (
auto control = qmlobject_cast<QQuickControl *>(
item))
1293 attached->setPressed(
false);
1295 item =
d->swipe.leftItem();
1297 if (
auto control = qmlobject_cast<QQuickControl *>(
item))
1301 attached->setPressed(
false);
1305 d->pressedItem =
nullptr;
1329 swipePrivate->
reposition(DontAnimatePosition);
1338#if QT_CONFIG(accessibility)
1339QAccessible::Role QQuickSwipeDelegate::accessibleRole()
const
1341 return QAccessible::ListItem;
1385 qWarning() <<
"Attached properties of SwipeDelegate must be accessed through an Item";
1493#include "moc_qquickswipe_p.cpp"
1494#include "moc_qquickswipedelegate_p.cpp"
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
virtual bool contains(const QPointF &point) const
Returns true if this item contains point, which is in local coordinates; otherwise,...
QPointF mapToItem(const QGraphicsItem *item, const QPointF &point) const
Maps the point point, which is in this item's coordinate system, to item's coordinate system,...
QList< QGraphicsItem * > childItems() const
void setParentItem(QGraphicsItem *parent)
Sets this item's parent item to newParent.
void setAcceptedMouseButtons(Qt::MouseButtons buttons)
Sets the mouse buttons that this item accepts mouse events for.
QPointF mapFromScene(const QPointF &point) const
Maps the point point, which is in this item's scene's coordinate system, to this item's coordinate sy...
bool isAncestorOf(const QGraphicsItem *child) const
Returns true if this item is an ancestor of child (i.e., if this item is child's parent,...
static QStyleHints * styleHints()
Returns the application's style hints.
static void setObjectOwnership(QObject *, ObjectOwnership)
Sets the ownership of object.
qreal length() const
Returns the length of the line.
The QPalette class contains color groups for each widget state.
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
QEventPoint & point(qsizetype i)
Returns a QEventPoint reference for the point at index i.
The QQmlComponent class encapsulates a QML component definition.
QList< QQmlError > errors() const
Returns the list of errors that occurred during the last compile or create operation.
The QQmlContext class defines a context within a QML engine.
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
virtual void componentComplete()=0
Invoked after the root component that caused this instantiation has completed construction.
The QQmlProperty class abstracts accessing properties on objects created from QML.
void setDefaultTarget(const QQmlProperty &)
QQuickDeferredPointer< QQuickItem > background
QQuickDeferredPointer< QQuickItem > contentItem
qreal getRightInset() const
qreal getLeftInset() const
qreal getBottomInset() const
QLazilyAllocated< ExtraData > extra
virtual void handleUngrab()
qreal getTopInset() const
virtual void resizeContent()
static QQuickControlPrivate * get(QQuickControl *control)
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
static QQuickItemPrivate * get(QQuickItem *item)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
virtual void mouseReleaseEvent(QMouseEvent *event)
This event handler can be reimplemented in a subclass to receive mouse release events for an item.
qreal y
Defines the item's y position relative to its parent.
void setAcceptTouchEvents(bool accept)
If enabled is true, this sets the item to accept touch events; otherwise, touch events are not accept...
QQuickWindow * window() const
Returns the window in which this item is rendered.
virtual void mousePressEvent(QMouseEvent *event)
This event handler can be reimplemented in a subclass to receive mouse press events for an item.
qreal width
This property holds the width of this item.
bool filtersChildMouseEvents() const
Returns whether pointer events intended for this item's children should be filtered through this item...
bool isComponentComplete() const
Returns true if construction of the QML component is complete; otherwise returns false.
bool keepMouseGrab() const
Returns whether mouse input should exclusively remain with this item.
virtual void mouseMoveEvent(QMouseEvent *event)
This event handler can be reimplemented in a subclass to receive mouse move events for an item.
QQuickSwipeDelegateAttached(QObject *object=nullptr)
void setPressed(bool pressed)
bool handleMouseMoveEvent(QQuickItem *item, QMouseEvent *event)
void forwardMouseEvent(QMouseEvent *event, QQuickItem *destination, QPointF localPos)
QQuickSwipeDelegatePrivate(QQuickSwipeDelegate *control)
void resizeBackground() override
QPalette defaultPalette() const override
bool attachedObjectsSetPressed(QQuickItem *item, QPointF scenePos, bool pressed, bool cancel=false)
bool handleMouseReleaseEvent(QQuickItem *item, QMouseEvent *event)
bool handleMousePressEvent(QQuickItem *item, QMouseEvent *event)
void resizeContent() override
void mousePressEvent(QMouseEvent *event) override
This event handler can be reimplemented in a subclass to receive mouse press events for an item.
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
static QQuickSwipeDelegateAttached * qmlAttachedProperties(QObject *object)
void mouseUngrabEvent() override
This event handler can be reimplemented in a subclass to be notified when a mouse ungrab event has oc...
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
QQuickSwipeDelegate(QQuickItem *parent=nullptr)
void touchEvent(QTouchEvent *event) override
This event handler can be reimplemented in a subclass to receive touch events for an item.
void mouseMoveEvent(QMouseEvent *event) override
This event handler can be reimplemented in a subclass to receive mouse move events for an item.
void mouseReleaseEvent(QMouseEvent *event) override
This event handler can be reimplemented in a subclass to receive mouse release events for an item.
bool childMouseEventFilter(QQuickItem *child, QEvent *event) override
Reimplement this method to filter the pointer events that are received by this item's children.
QFont defaultFont() const override
void warnAboutMixingDelegates()
void createAndShowRightItem()
QQuickTransition * transition
void createAndShowLeftItem()
QQuickSwipePrivate(QQuickSwipeDelegate *control)
QQuickVelocityCalculator velocityCalculator
QScopedPointer< QQuickSwipeTransitionManager > transitionManager
QQuickItem * showRelevantItemForPosition(qreal position)
qreal positionBeforePress
bool isTransitioning() const
void reposition(PositionAnimation animationPolicy)
bool hasDelegates() const
void createAndShowBehindItem()
QQuickItem * createDelegateItem(QQmlComponent *component)
static QQuickSwipePrivate * get(QQuickSwipe *swipe)
QQuickItem * createRelevantItemForDistance(qreal distance)
void beginTransition(qreal position)
QQuickSwipeDelegate * control
void warnAboutSettingDelegatesWhileVisible()
QQuickSwipeTransitionManager(QQuickSwipe *swipe)
void transition(QQuickTransition *transition, qreal position)
void setRightItem(QQuickItem *item)
void setComplete(bool complete)
void setBehindItem(QQuickItem *item)
void setEnabled(bool enabled)
QQuickSwipe(QQuickSwipeDelegate *control)
void setBehind(QQmlComponent *behind)
void setTransition(QQuickTransition *transition)
void setPosition(qreal position)
void setLeftItem(QQuickItem *item)
QQuickTransition * transition
void setLeft(QQmlComponent *left)
void setRight(QQmlComponent *right)
static QPalette palette(Scope scope)
static QFont font(Scope scope)
void transition(const QList< QQuickStateAction > &, QQuickTransition *transition, QObject *defaultTarget=nullptr)
void startMeasuring(const QPointF &point1, qint64 timestamp=0)
void stopMeasuring(const QPointF &m_point2, qint64 timestamp=0)
static bool dragOverThreshold(qreal d, Qt::Axis axis, const QEventPoint *tp, int startDragThreshold=-1)
\inmodule QtCore\reentrant
constexpr qreal width() const noexcept
Returns the width of the rectangle.
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
int startDragDistance
the distance, in pixels, that the mouse must be moved with a button held down before a drag and drop ...
The QTouchEvent class contains parameters that describe a touch event.
constexpr size_type size() const noexcept
const T & at(qsizetype idx) const
Combined button and popup list for selecting options.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char * destination
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
bool qFuzzyIsNull(qfloat16 f) noexcept
bool qIsNull(qfloat16 f) noexcept
constexpr T qAbs(const T &t)
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei height
GLenum GLenum GLsizei count
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLsizei GLsizei GLfloat distance
GLdouble GLdouble GLdouble GLdouble q
static qreal component(const QPointF &point, unsigned int i)
void qmlExecuteDeferred(QObject *object)
QQmlContext * qmlContext(const QObject *obj)
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
static qreal adjustedPosition(QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static QQuickAttachedPropertyPropagator * attachedObject(const QMetaObject *type, QObject *object, bool create=false)
QQuickAnchors * anchors(QQuickItem *item)
QQuickItem * qobject_cast< QQuickItem * >(QObject *o)
static bool isChildOrGrandchildOf(QQuickItem *child, QQuickItem *item)
static const qreal exposeVelocityThreshold
static void warnIfHorizontallyAnchored(QQuickItem *item, const QString &itemName)
QLatin1StringView QLatin1String
#define QStringLiteral(str)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent