1 | // Copyright (C) 2017 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QQUICKSWIPEDELEGATE_P_H |
5 | #define QQUICKSWIPEDELEGATE_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtQuickTemplates2/private/qquickitemdelegate_p.h> |
19 | |
20 | QT_BEGIN_NAMESPACE |
21 | |
22 | class QQuickSwipe; |
23 | class QQuickSwipeDelegatePrivate; |
24 | class QQuickSwipeDelegateAttached; |
25 | class QQuickSwipeDelegateAttachedPrivate; |
26 | |
27 | class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSwipeDelegate : public QQuickItemDelegate |
28 | { |
29 | Q_OBJECT |
30 | Q_PROPERTY(QQuickSwipe *swipe READ swipe CONSTANT FINAL) |
31 | QML_NAMED_ELEMENT(SwipeDelegate) |
32 | QML_ATTACHED(QQuickSwipeDelegateAttached) |
33 | QML_ADDED_IN_VERSION(2, 0) |
34 | |
35 | public: |
36 | explicit QQuickSwipeDelegate(QQuickItem *parent = nullptr); |
37 | |
38 | QQuickSwipe *swipe() const; |
39 | |
40 | enum Side { Left = 1, Right = -1 }; |
41 | Q_ENUM(Side) |
42 | |
43 | static QQuickSwipeDelegateAttached *qmlAttachedProperties(QObject *object); |
44 | |
45 | protected: |
46 | bool childMouseEventFilter(QQuickItem *child, QEvent *event) override; |
47 | void mousePressEvent(QMouseEvent *event) override; |
48 | void mouseMoveEvent(QMouseEvent *event) override; |
49 | void mouseReleaseEvent(QMouseEvent *event) override; |
50 | void mouseUngrabEvent() override; |
51 | void touchEvent(QTouchEvent *event) override; |
52 | |
53 | void componentComplete() override; |
54 | void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override; |
55 | |
56 | QFont defaultFont() const override; |
57 | |
58 | #if QT_CONFIG(accessibility) |
59 | QAccessible::Role accessibleRole() const override; |
60 | #endif |
61 | |
62 | private: |
63 | Q_DISABLE_COPY(QQuickSwipeDelegate) |
64 | Q_DECLARE_PRIVATE(QQuickSwipeDelegate) |
65 | }; |
66 | |
67 | class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSwipeDelegateAttached : public QObject |
68 | { |
69 | Q_OBJECT |
70 | Q_PROPERTY(bool pressed READ isPressed NOTIFY pressedChanged FINAL) |
71 | |
72 | public: |
73 | explicit QQuickSwipeDelegateAttached(QObject *object = nullptr); |
74 | |
75 | bool isPressed() const; |
76 | void setPressed(bool pressed); |
77 | |
78 | Q_SIGNALS: |
79 | void pressedChanged(); |
80 | void clicked(); |
81 | |
82 | private: |
83 | Q_DISABLE_COPY(QQuickSwipeDelegateAttached) |
84 | Q_DECLARE_PRIVATE(QQuickSwipeDelegateAttached) |
85 | }; |
86 | |
87 | QT_END_NAMESPACE |
88 | |
89 | QML_DECLARE_TYPE(QQuickSwipeDelegate) |
90 | Q_DECLARE_METATYPE(QQuickSwipeDelegate::Side) |
91 | |
92 | #endif // QQUICKSWIPEDELEGATE_P_H |
93 |