| 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 QQUICKSWIPEVIEW_P_H |
| 5 | #define QQUICKSWIPEVIEW_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/qquickcontainer_p.h> |
| 19 | |
| 20 | QT_REQUIRE_CONFIG(quicktemplates2_container); |
| 21 | |
| 22 | QT_BEGIN_NAMESPACE |
| 23 | |
| 24 | class QQuickSwipeViewAttached; |
| 25 | class QQuickSwipeViewPrivate; |
| 26 | |
| 27 | class Q_QUICKTEMPLATES2_EXPORT QQuickSwipeView : public QQuickContainer |
| 28 | { |
| 29 | Q_OBJECT |
| 30 | // 2.1 (Qt 5.8) |
| 31 | Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged FINAL REVISION(2, 1)) |
| 32 | // 2.2 (Qt 5.9) |
| 33 | Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged FINAL REVISION(2, 2)) |
| 34 | // 2.3 (Qt 5.10) |
| 35 | Q_PROPERTY(bool horizontal READ isHorizontal NOTIFY orientationChanged FINAL REVISION(2, 3)) |
| 36 | Q_PROPERTY(bool vertical READ isVertical NOTIFY orientationChanged FINAL REVISION(2, 3)) |
| 37 | QML_NAMED_ELEMENT(SwipeView) |
| 38 | QML_ATTACHED(QQuickSwipeViewAttached) |
| 39 | QML_ADDED_IN_VERSION(2, 0) |
| 40 | |
| 41 | public: |
| 42 | explicit QQuickSwipeView(QQuickItem *parent = nullptr); |
| 43 | |
| 44 | static QQuickSwipeViewAttached *qmlAttachedProperties(QObject *object); |
| 45 | |
| 46 | // 2.1 (Qt 5.8) |
| 47 | bool isInteractive() const; |
| 48 | void setInteractive(bool interactive); |
| 49 | |
| 50 | // 2.2 (Qt 5.9) |
| 51 | Qt::Orientation orientation() const; |
| 52 | void setOrientation(Qt::Orientation orientation); |
| 53 | |
| 54 | // 2.3 (Qt 5.10) |
| 55 | bool isHorizontal() const; |
| 56 | bool isVertical() const; |
| 57 | |
| 58 | Q_SIGNALS: |
| 59 | // 2.1 (Qt 5.8) |
| 60 | Q_REVISION(2, 1) void interactiveChanged(); |
| 61 | // 2.2 (Qt 5.9) |
| 62 | Q_REVISION(2, 2) void orientationChanged(); |
| 63 | |
| 64 | protected: |
| 65 | void componentComplete() override; |
| 66 | void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override; |
| 67 | void itemAdded(int index, QQuickItem *item) override; |
| 68 | void itemMoved(int index, QQuickItem *item) override; |
| 69 | void itemRemoved(int index, QQuickItem *item) override; |
| 70 | |
| 71 | #if QT_CONFIG(accessibility) |
| 72 | QAccessible::Role accessibleRole() const override; |
| 73 | #endif |
| 74 | |
| 75 | private: |
| 76 | Q_DISABLE_COPY(QQuickSwipeView) |
| 77 | Q_DECLARE_PRIVATE(QQuickSwipeView) |
| 78 | }; |
| 79 | |
| 80 | class QQuickSwipeViewAttachedPrivate; |
| 81 | |
| 82 | class Q_QUICKTEMPLATES2_EXPORT QQuickSwipeViewAttached : public QObject |
| 83 | { |
| 84 | Q_OBJECT |
| 85 | Q_PROPERTY(int index READ index NOTIFY indexChanged FINAL) |
| 86 | Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY isCurrentItemChanged FINAL) |
| 87 | Q_PROPERTY(QQuickSwipeView *view READ view NOTIFY viewChanged FINAL) |
| 88 | // 2.1 (Qt 5.8) |
| 89 | Q_PROPERTY(bool isNextItem READ isNextItem NOTIFY isNextItemChanged FINAL REVISION(2, 1)) |
| 90 | Q_PROPERTY(bool isPreviousItem READ isPreviousItem NOTIFY isPreviousItemChanged FINAL REVISION(2, 1)) |
| 91 | |
| 92 | public: |
| 93 | explicit QQuickSwipeViewAttached(QObject *parent = nullptr); |
| 94 | |
| 95 | int index() const; |
| 96 | bool isCurrentItem() const; |
| 97 | QQuickSwipeView *view() const; |
| 98 | |
| 99 | // 2.1 (Qt 5.8) |
| 100 | bool isNextItem() const; |
| 101 | bool isPreviousItem() const; |
| 102 | |
| 103 | Q_SIGNALS: |
| 104 | void indexChanged(); |
| 105 | void isCurrentItemChanged(); |
| 106 | void viewChanged(); |
| 107 | // 2.1 (Qt 5.8) |
| 108 | /*Q_REVISION(2, 1)*/ void isNextItemChanged(); |
| 109 | /*Q_REVISION(2, 1)*/ void isPreviousItemChanged(); |
| 110 | |
| 111 | private: |
| 112 | Q_DISABLE_COPY(QQuickSwipeViewAttached) |
| 113 | Q_DECLARE_PRIVATE(QQuickSwipeViewAttached) |
| 114 | }; |
| 115 | |
| 116 | QT_END_NAMESPACE |
| 117 | |
| 118 | #endif // QQUICKSWIPEVIEW_P_H |
| 119 | |