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