| 1 | // Copyright (C) 2021 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 QQUICKSELECTIONRECTANGLE_P_H |
| 5 | #define QQUICKSELECTIONRECTANGLE_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 <QtQuick/qquickitem.h> |
| 19 | #include <QtQuickTemplates2/private/qquickcontrol_p.h> |
| 20 | |
| 21 | #include <QtCore/qpointer.h> |
| 22 | |
| 23 | QT_BEGIN_NAMESPACE |
| 24 | |
| 25 | class QQuickSelectionRectanglePrivate; |
| 26 | class QQuickSelectable; |
| 27 | class QQuickSelectionRectangleAttached; |
| 28 | |
| 29 | class Q_QUICKTEMPLATES2_EXPORT QQuickSelectionRectangle : public QQuickControl |
| 30 | { |
| 31 | Q_OBJECT |
| 32 | Q_PROPERTY(SelectionMode selectionMode READ selectionMode WRITE setSelectionMode NOTIFY selectionModeChanged FINAL) |
| 33 | Q_PROPERTY(QQuickItem *target READ target WRITE setTarget NOTIFY targetChanged FINAL) |
| 34 | Q_PROPERTY(QQmlComponent *topLeftHandle READ topLeftHandle WRITE setTopLeftHandle NOTIFY topLeftHandleChanged FINAL) |
| 35 | Q_PROPERTY(QQmlComponent *bottomRightHandle READ bottomRightHandle WRITE setBottomRightHandle NOTIFY bottomRightHandleChanged FINAL) |
| 36 | Q_PROPERTY(bool active READ active NOTIFY activeChanged FINAL) |
| 37 | Q_PROPERTY(bool dragging READ dragging NOTIFY draggingChanged FINAL) |
| 38 | |
| 39 | QML_NAMED_ELEMENT(SelectionRectangle) |
| 40 | QML_ATTACHED(QQuickSelectionRectangleAttached) |
| 41 | QML_ADDED_IN_VERSION(6, 2) |
| 42 | |
| 43 | public: |
| 44 | enum SelectionMode { |
| 45 | Drag, |
| 46 | PressAndHold, |
| 47 | Auto |
| 48 | }; |
| 49 | Q_ENUM(SelectionMode) |
| 50 | |
| 51 | explicit QQuickSelectionRectangle(QQuickItem *parent = nullptr); |
| 52 | |
| 53 | QQuickItem *target() const; |
| 54 | void setTarget(QQuickItem *target); |
| 55 | |
| 56 | bool active(); |
| 57 | bool dragging(); |
| 58 | |
| 59 | SelectionMode selectionMode() const; |
| 60 | void setSelectionMode(SelectionMode selectionMode); |
| 61 | |
| 62 | QQmlComponent *topLeftHandle() const; |
| 63 | void setTopLeftHandle(QQmlComponent *topLeftHandle); |
| 64 | QQmlComponent *bottomRightHandle() const; |
| 65 | void setBottomRightHandle(QQmlComponent *bottomRightHandle); |
| 66 | |
| 67 | static QQuickSelectionRectangleAttached *qmlAttachedProperties(QObject *obj); |
| 68 | |
| 69 | Q_SIGNALS: |
| 70 | void targetChanged(); |
| 71 | void activeChanged(); |
| 72 | void draggingChanged(); |
| 73 | void topLeftHandleChanged(); |
| 74 | void bottomRightHandleChanged(); |
| 75 | void selectionModeChanged(); |
| 76 | |
| 77 | private: |
| 78 | Q_DISABLE_COPY(QQuickSelectionRectangle) |
| 79 | Q_DECLARE_PRIVATE(QQuickSelectionRectangle) |
| 80 | }; |
| 81 | |
| 82 | class Q_QUICKTEMPLATES2_EXPORT QQuickSelectionRectangleAttached : public QObject |
| 83 | { |
| 84 | Q_OBJECT |
| 85 | Q_PROPERTY(QQuickSelectionRectangle *control READ control NOTIFY controlChanged FINAL) |
| 86 | Q_PROPERTY(bool dragging READ dragging NOTIFY draggingChanged FINAL) |
| 87 | |
| 88 | public: |
| 89 | QQuickSelectionRectangleAttached(QObject *parent); |
| 90 | |
| 91 | QQuickSelectionRectangle *control() const; |
| 92 | void setControl(QQuickSelectionRectangle *control); |
| 93 | |
| 94 | bool dragging() const; |
| 95 | void setDragging(bool dragging); |
| 96 | |
| 97 | Q_SIGNALS: |
| 98 | void controlChanged(); |
| 99 | void draggingChanged(); |
| 100 | |
| 101 | private: |
| 102 | QPointer<QQuickSelectionRectangle> m_control; |
| 103 | bool m_dragging = false; |
| 104 | |
| 105 | friend class QQuickSelectionRectanglePrivate; |
| 106 | }; |
| 107 | |
| 108 | QT_END_NAMESPACE |
| 109 | |
| 110 | #endif // QQUICKSELECTIONRECTANGLE_P_H |
| 111 |
