Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickselectionrectangle_p.h
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
4
5#ifndef QQUICKSELECTIONRECTANGLE_P_H
6#define QQUICKSELECTIONRECTANGLE_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtQuick/qquickitem.h>
20#include <QtQuickTemplates2/private/qquickcontrol_p.h>
21
22#include <QtCore/qpointer.h>
23
24QT_BEGIN_NAMESPACE
25
26class QQuickSelectionRectanglePrivate;
27class QQuickSelectable;
28class QQuickSelectionRectangleAttached;
29class QQmlComponent;
30
31class Q_QUICKTEMPLATES2_EXPORT QQuickSelectionRectangle : public QQuickControl
32{
33 Q_OBJECT
34 Q_PROPERTY(SelectionMode selectionMode READ selectionMode WRITE setSelectionMode NOTIFY selectionModeChanged FINAL)
35 Q_PROPERTY(QQuickItem *target READ target WRITE setTarget NOTIFY targetChanged FINAL)
36 Q_PROPERTY(QQmlComponent *topLeftHandle READ topLeftHandle WRITE setTopLeftHandle NOTIFY topLeftHandleChanged FINAL)
37 Q_PROPERTY(QQmlComponent *bottomRightHandle READ bottomRightHandle WRITE setBottomRightHandle NOTIFY bottomRightHandleChanged FINAL)
38 Q_PROPERTY(bool active READ active NOTIFY activeChanged FINAL)
39 Q_PROPERTY(bool dragging READ dragging NOTIFY draggingChanged FINAL)
40
41 QML_NAMED_ELEMENT(SelectionRectangle)
42 QML_ATTACHED(QQuickSelectionRectangleAttached)
43 QML_ADDED_IN_VERSION(6, 2)
44
45public:
46 enum SelectionMode {
47 Drag,
48 PressAndHold,
49 Auto
50 };
51 Q_ENUM(SelectionMode)
52
53 explicit QQuickSelectionRectangle(QQuickItem *parent = nullptr);
54
55 QQuickItem *target() const;
56 void setTarget(QQuickItem *target);
57
58 bool active();
59 bool dragging();
60
61 SelectionMode selectionMode() const;
62 void setSelectionMode(SelectionMode selectionMode);
63
64 QQmlComponent *topLeftHandle() const;
65 void setTopLeftHandle(QQmlComponent *topLeftHandle);
66 QQmlComponent *bottomRightHandle() const;
67 void setBottomRightHandle(QQmlComponent *bottomRightHandle);
68
69 static QQuickSelectionRectangleAttached *qmlAttachedProperties(QObject *obj);
70
71Q_SIGNALS:
72 void targetChanged();
73 void activeChanged();
74 void draggingChanged();
75 void topLeftHandleChanged();
76 void bottomRightHandleChanged();
77 void selectionModeChanged();
78
79private:
80 Q_DISABLE_COPY(QQuickSelectionRectangle)
81 Q_DECLARE_PRIVATE(QQuickSelectionRectangle)
82};
83
84class Q_QUICKTEMPLATES2_EXPORT QQuickSelectionRectangleAttached : public QObject
85{
86 Q_OBJECT
87 Q_PROPERTY(QQuickSelectionRectangle *control READ control NOTIFY controlChanged FINAL)
88 Q_PROPERTY(bool dragging READ dragging NOTIFY draggingChanged FINAL)
89
90public:
91 QQuickSelectionRectangleAttached(QObject *parent);
92
93 QQuickSelectionRectangle *control() const;
94 void setControl(QQuickSelectionRectangle *control);
95
96 bool dragging() const;
97 void setDragging(bool dragging);
98
99Q_SIGNALS:
100 void controlChanged();
101 void draggingChanged();
102
103private:
104 QPointer<QQuickSelectionRectangle> m_control;
105 bool m_dragging = false;
106
107 friend class QQuickSelectionRectanglePrivate;
108};
109
110QT_END_NAMESPACE
111
112#endif // QQUICKSELECTIONRECTANGLE_P_H
QQuickItem * createHandle(QQmlComponent *delegate, Qt::Corner corner)
QQuickItem * handleUnderPos(const QPointF &pos)
QQuickSelectionRectangleAttached * getAttachedObject(const QObject *object) const