1// Copyright (C) 2020 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#include "qquickitemsmodule_p.h"
5
6#include "qquickitem.h"
7#include "qquickitem_p.h"
8#include "qquickevents_p_p.h"
9#include "qquickrectangle_p.h"
10#include "qquickfocusscope_p.h"
11#include "qquicktext_p.h"
12#include "qquicktextinput_p.h"
13#include "qquicktextedit_p.h"
14#include "qquicktextdocument.h"
15#include "qquickimage_p.h"
16#include "qquickborderimage_p.h"
17#include "qquickscalegrid_p_p.h"
18#include "qquickmousearea_p.h"
19#include "qquickpincharea_p.h"
20#include "qquickflickable_p.h"
21#include "qquickflickable_p_p.h"
22#if QT_CONFIG(quick_listview)
23#include "qquicklistview_p.h"
24#endif
25#if QT_CONFIG(quick_gridview)
26#include "qquickgridview_p.h"
27#endif
28#if QT_CONFIG(quick_pathview)
29#include "qquickpathview_p.h"
30#endif
31#if QT_CONFIG(quick_tableview)
32#include "qquicktableview_p.h"
33#endif
34#if QT_CONFIG(quick_viewtransitions)
35#include "qquickitemviewtransition_p.h"
36#endif
37#if QT_CONFIG(quick_path)
38#include <private/qquickpath_p.h>
39#include <private/qquickpathinterpolator_p.h>
40#endif
41#if QT_CONFIG(quick_positioners)
42#include "qquickpositioners_p.h"
43#endif
44#if QT_CONFIG(quick_repeater)
45#include "qquickrepeater_p.h"
46#endif
47#include "qquickloader_p.h"
48#if QT_CONFIG(quick_animatedimage)
49#include "qquickanimatedimage_p.h"
50#endif
51#if QT_CONFIG(quick_flipable)
52#include "qquickflipable_p.h"
53#endif
54#include "qquicktranslate_p.h"
55#include "qquickstateoperations_p.h"
56#include "qquickitemanimation_p.h"
57//#include <private/qquickpincharea_p.h>
58#if QT_CONFIG(quick_canvas)
59#include <QtQuick/private/qquickcanvasitem_p.h>
60#include <QtQuick/private/qquickcontext2d_p.h>
61#endif
62#include "qquickitemgrabresult.h"
63#if QT_CONFIG(quick_sprite)
64#include "qquicksprite_p.h"
65#include "qquickspritesequence_p.h"
66#include "qquickanimatedsprite_p.h"
67#endif
68#include "qquickgraphicsinfo_p.h"
69#if QT_CONFIG(quick_shadereffect)
70#include <QtQuick/private/qquickshadereffectsource_p.h>
71#include "qquickshadereffect_p.h"
72#include "qquickshadereffectmesh_p.h"
73#endif
74#if QT_CONFIG(quick_draganddrop)
75#include "qquickdrag_p.h"
76#include "qquickdroparea_p.h"
77#endif
78#include "qquickmultipointtoucharea_p.h"
79#include <QtQuick/private/qquickaccessibleattached_p.h>
80
81#include "handlers/qquickdraghandler_p.h"
82#include "handlers/qquickhoverhandler_p.h"
83#include "handlers/qquickpinchhandler_p.h"
84#include "handlers/qquickpointhandler_p.h"
85#include "handlers/qquicktaphandler_p.h"
86#include "handlers/qquickwheelhandler_p.h"
87
88#include "moc_qquickitemsmodule_p.cpp"
89
90static QQmlPrivate::AutoParentResult qquickitem_autoParent(QObject *obj, QObject *parent)
91{
92 if (QQuickItem *parentItem = qmlobject_cast<QQuickItem *>(parent)) {
93 if (QQuickItem *item = qmlobject_cast<QQuickItem *>(obj)) {
94 // An Item has another Item
95 item->setParentItem(parentItem);
96 return QQmlPrivate::Parented;
97 } else if (QQuickPointerHandler *handler = qmlobject_cast<QQuickPointerHandler *>(obj)) {
98 QQuickItemPrivate::get(item: parentItem)->addPointerHandler(h: handler);
99 handler->setParent(parent);
100 return QQmlPrivate::Parented;
101 }
102 return QQmlPrivate::IncompatibleObject;
103 } else if (QQuickWindow *parentWindow = qmlobject_cast<QQuickWindow *>(parent)) {
104 if (QQuickItem *item = qmlobject_cast<QQuickItem *>(obj)) {
105 // The parent of an Item inside a Window is actually the implicit content Item
106 item->setParentItem(parentWindow->contentItem());
107 return QQmlPrivate::Parented;
108 } else if (QQuickPointerHandler *handler = qmlobject_cast<QQuickPointerHandler *>(obj)) {
109 QQuickItemPrivate::get(item: parentWindow->contentItem())->addPointerHandler(h: handler);
110 handler->setParent(parentWindow->contentItem());
111 return QQmlPrivate::Parented;
112 }
113 return QQmlPrivate::IncompatibleObject;
114 } else if (qmlobject_cast<QQuickItem *>(obj)) {
115 return QQmlPrivate::IncompatibleParent;
116 }
117 return QQmlPrivate::IncompatibleObject;
118}
119
120static void qt_quickitems_defineModule()
121{
122 QQmlPrivate::RegisterAutoParent autoparent = { .structVersion: 0, .function: &qquickitem_autoParent };
123 QQmlPrivate::qmlregister(QQmlPrivate::AutoParentRegistration, &autoparent);
124
125 qRegisterMetaType<QQuickAnchorLine>(typeName: "QQuickAnchorLine");
126 qRegisterMetaType<QQuickHandlerPoint>();
127}
128
129//static void initResources()
130//{
131// Q_INIT_RESOURCE(items);
132//}
133
134QT_BEGIN_NAMESPACE
135
136void QQuickItemsModule::defineModule()
137{
138// initResources();
139 qt_quickitems_defineModule();
140}
141
142/*!
143 \qmltype PointerEvent
144 \nativetype QPointerEvent
145 \inqmlmodule QtQuick
146 \brief QML equivalent for \l QPointerEvent.
147
148 PointerEvent is the QML name of the QPointerEvent class.
149*/
150
151/*!
152 \qmltype PointerDevice
153 \nativetype QPointingDevice
154 \inqmlmodule QtQuick
155 \brief QML equivalent for \l QPointingDevice.
156
157 PointerDevice is the QML name of the QPointingDevice class.
158 It has the same properties and enums as \l QPointingDevice.
159*/
160
161/*!
162 \qmlproperty enumeration PointerDevice::deviceType
163
164 This property tells the type of device that generated a PointerEvent.
165
166 Valid values are:
167
168 \value PointerDevice.Unknown The device cannot be identified.
169 \value PointerDevice.Mouse A mouse.
170 \value PointerDevice.TouchScreen A touchscreen.
171 \value PointerDevice.TouchPad A touchpad or trackpad.
172 \value PointerDevice.Stylus A stylus on a graphics tablet.
173 \value PointerDevice.Airbrush An airbrush on a graphics tablet.
174 \value PointerDevice.Puck A digitizer with crosshairs, on a graphics tablet.
175
176 \sa QInputDevice::DeviceType, PointerDeviceHandler::acceptedDevices
177*/
178
179/*!
180 \qmlproperty enumeration PointerDevice::pointerType
181
182 This property tells what is interacting with the PointerDevice.
183
184 There is some redundancy between this property and \l deviceType.
185 For example, if a touchscreen is used, then \c deviceType is
186 \c TouchScreen and \c pointerType is \c Finger. But on a graphics
187 tablet, it's often possible for both ends of the stylus to be used,
188 and programs need to distinguish them.
189 \l PointerDeviceHandler::acceptedDevices and
190 \l PointerDeviceHandler::acceptedPointerTypes can be used in combination
191 to filter the subset of events that a particular handler should react to.
192
193 Valid values are:
194
195 \value PointerDevice.Unknown The device cannot be identified.
196 \value PointerDevice.Generic A mouse or a device that emulates a mouse.
197 \value PointerDevice.Finger A finger on a touchscreen.
198 \value PointerDevice.Pen A stylus on a graphics tablet.
199 \value PointerDevice.Eraser An eraser on a graphics tablet.
200 \value PointerDevice.Cursor A digitizer with crosshairs, on a graphics tablet.
201
202 \sa QPointingDevice::PointerType, PointerDeviceHandler::acceptedPointerTypes
203*/
204
205/*!
206 \qmlproperty int PointerDevice::maximumPoints
207
208 This property tells the maximum number of simultaneous touch points
209 (fingers) that can be detected.
210*/
211
212/*!
213 \qmlproperty int PointerDevice::buttonCount
214
215 This property tells the maximum number of on-device buttons that can be
216 detected.
217*/
218
219/*!
220 \qmltype pointingDeviceUniqueId
221 \nativetype QPointingDeviceUniqueId
222 \inqmlmodule QtQuick
223 \brief QML equivalent for \l QPointingDeviceUniqueId.
224
225 pointingDeviceUniqueId is the QML name of the QPointingDeviceUniqueId class.
226*/
227
228/*!
229 \qmlproperty qint64 pointingDeviceUniqueId::numericId
230
231 This property gives the numeric ID of the \l PointerDevice, if available;
232 otherwise it is \c -1.
233*/
234
235/*!
236 \qmlproperty pointingDeviceUniqueId PointerDevice::uniqueId
237
238 This property may provide a unique ID for the device, if available. For
239 example, a graphics tablet stylus device may have a unique serial number.
240
241 \sa eventPoint, QEventPoint::uniqueId()
242*/
243
244/*!
245 \qmlsignal PointerDevice::grabChanged(QtObject grabber, enumeration transition, PointerEvent event, eventPoint point)
246
247 This signal is emitted when the \a grabber object gains or loses an
248 exclusive or passive grab of \a point during delivery of \a event.
249 The \a transition tells what happened, from the perspective of the
250 \c grabber object, which may be either an \l Item or an
251 \l {Qt Quick Input Handlers}{Input Handler}.
252
253 Valid values for \a transition are:
254
255 \value PointerDevice.GrabExclusive
256 The \a grabber has taken primary responsibility for handling the \a point.
257 \value PointerDevice.UngrabExclusive
258 The \a grabber has given up its previous exclusive grab.
259 \value PointerDevice.CancelGrabExclusive
260 The exclusive grab of \a grabber has been taken over or cancelled.
261 \value PointerDevice.GrabPassive
262 The \a grabber has acquired a passive grab, to monitor the \a point.
263 \value PointerDevice.UngrabPassive
264 The \a grabber has given up its previous passive grab.
265 \value PointerDevice.CancelGrabPassive
266 The previous passive grab has terminated abnormally.
267
268 \note A grab transition from one object to another results in two signals,
269 to notify that one object has lost its grab, and to notify that there is
270 another grabber. In other cases, when transitioning to or from a non-grabbing
271 state, only one signal is emitted.
272
273 \sa QPointerEvent::setExclusiveGrabber(), QPointerEvent::addPassiveGrabber(),
274 QPointerEvent::removePassiveGrabber(), PointerHandler::grabChanged()
275*/
276
277QT_END_NAMESPACE
278

source code of qtdeclarative/src/quick/items/qquickitemsmodule.cpp