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_P_H
5#define QQUICKSELECTIONRECTANGLE_P_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 "qquickselectionrectangle_p.h"
19
20#include <QtCore/qpointer.h>
21#include <QtCore/qtimer.h>
22
23#include <QtQuick/private/qquickselectable_p.h>
24#include <QtQuick/private/qquicktaphandler_p.h>
25#include <QtQuick/private/qquickdraghandler_p.h>
26
27#include <QtQuickTemplates2/private/qquickcontrol_p_p.h>
28
29QT_BEGIN_NAMESPACE
30
31class QQuickSelectionRectanglePrivate : public QQuickControlPrivate
32{
33public:
34 Q_DECLARE_PUBLIC(QQuickSelectionRectangle)
35
36 QQuickSelectionRectanglePrivate();
37
38 void updateDraggingState(bool isDragging);
39 void updateActiveState(bool isActive);
40 void updateHandles();
41 void updateSelectionMode();
42 void connectToTarget();
43 void scrollTowardsPos(const QPointF &pos);
44 QQuickItem *handleUnderPos(const QPointF &pos);
45
46 QQuickItem *createHandle(QQmlComponent *delegate, Qt::Corner corner);
47
48 QQuickSelectionRectangleAttached *getAttachedObject(const QObject *object) const;
49
50public:
51 QPointer<QQuickItem> m_target;
52
53 QQmlComponent *m_topLeftHandleDelegate = nullptr;
54 QQmlComponent *m_bottomRightHandleDelegate = nullptr;
55 QScopedPointer<QQuickItem> m_topLeftHandle;
56 QScopedPointer<QQuickItem> m_bottomRightHandle;
57 QPointer<QQuickItem> m_draggedHandle;
58
59 QQuickSelectable *m_selectable = nullptr;
60
61 QQuickTapHandler *m_tapHandler = nullptr;
62 QQuickDragHandler *m_dragHandler = nullptr;
63
64 QTimer m_scrollTimer;
65 QPointF m_scrollToPoint;
66 QSizeF m_scrollSpeed = QSizeF(1, 1);
67
68 QQuickSelectionRectangle::SelectionMode m_selectionMode = QQuickSelectionRectangle::Auto;
69 QQuickSelectionRectangle::SelectionMode m_effectiveSelectionMode = QQuickSelectionRectangle::Drag;
70
71 bool m_enabled = true;
72 bool m_active = false;
73 bool m_dragging = false;
74};
75
76QT_END_NAMESPACE
77
78#endif // QQUICKSELECTIONRECTANGLE_P_P_H
79

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