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

source code of qtdeclarative/src/quicktemplates/qquickselectionrectangle_p.h