| 1 | // Copyright (C) 2016 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 QQUICKITEM_P_H |
| 5 | #define QQUICKITEM_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/private/qquickanchors_p.h> |
| 19 | #include <QtQuick/private/qquickanchors_p_p.h> |
| 20 | #include <QtQuick/private/qquickitemchangelistener_p.h> |
| 21 | #include <QtQuick/private/qquickevents_p_p.h> |
| 22 | #include <QtQuick/private/qquickclipnode_p.h> |
| 23 | #include <QtQuick/private/qquickstate_p.h> |
| 24 | #include <QtQuick/private/qquickpaletteproviderprivatebase_p.h> |
| 25 | #include <QtQuick/private/qquickwindow_p.h> |
| 26 | #include <QtCore/private/qproperty_p.h> |
| 27 | |
| 28 | #if QT_CONFIG(quick_shadereffect) |
| 29 | #include <QtQuick/private/qquickshadereffectsource_p.h> |
| 30 | #endif |
| 31 | |
| 32 | #include <QtQuick/qquickitem.h> |
| 33 | #include <QtQuick/qsgnode.h> |
| 34 | |
| 35 | #include <QtQml/private/qqmlnullablevalue_p.h> |
| 36 | #include <QtQml/private/qqmlnotifier_p.h> |
| 37 | #include <QtQml/private/qqmlglobal_p.h> |
| 38 | #include <QtQml/private/qlazilyallocated_p.h> |
| 39 | #include <QtQml/qqml.h> |
| 40 | #include <QtQml/qqmlcontext.h> |
| 41 | |
| 42 | #include <QtCore/qlist.h> |
| 43 | #include <QtCore/qdebug.h> |
| 44 | #include <QtCore/qelapsedtimer.h> |
| 45 | #include <QtCore/qpointer.h> |
| 46 | |
| 47 | #include <QtGui/private/qlayoutpolicy_p.h> |
| 48 | |
| 49 | QT_BEGIN_NAMESPACE |
| 50 | |
| 51 | class QNetworkReply; |
| 52 | class QQuickItemKeyFilter; |
| 53 | class QQuickLayoutMirroringAttached; |
| 54 | class QQuickEnterKeyAttached; |
| 55 | class QQuickScreenAttached; |
| 56 | class QQuickPointerHandler; |
| 57 | |
| 58 | class QQuickContents : public QQuickItemChangeListener |
| 59 | { |
| 60 | public: |
| 61 | QQuickContents(QQuickItem *item); |
| 62 | ~QQuickContents() override; |
| 63 | |
| 64 | QRectF rectF() const { return m_contents; } |
| 65 | |
| 66 | inline void calcGeometry(QQuickItem *changed = nullptr); |
| 67 | void complete(); |
| 68 | |
| 69 | protected: |
| 70 | void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &) override; |
| 71 | void itemDestroyed(QQuickItem *item) override; |
| 72 | void itemChildAdded(QQuickItem *, QQuickItem *) override; |
| 73 | void itemChildRemoved(QQuickItem *, QQuickItem *) override; |
| 74 | //void itemVisibilityChanged(QQuickItem *item) |
| 75 | |
| 76 | private: |
| 77 | bool calcHeight(QQuickItem *changed = nullptr); |
| 78 | bool calcWidth(QQuickItem *changed = nullptr); |
| 79 | void updateRect(); |
| 80 | |
| 81 | QQuickItem *m_item; |
| 82 | QRectF m_contents; |
| 83 | }; |
| 84 | |
| 85 | void QQuickContents::calcGeometry(QQuickItem *changed) |
| 86 | { |
| 87 | bool wChanged = calcWidth(changed); |
| 88 | bool hChanged = calcHeight(changed); |
| 89 | if (wChanged || hChanged) |
| 90 | updateRect(); |
| 91 | } |
| 92 | |
| 93 | class QQuickTransformPrivate : public QObjectPrivate |
| 94 | { |
| 95 | Q_DECLARE_PUBLIC(QQuickTransform) |
| 96 | public: |
| 97 | static QQuickTransformPrivate* get(QQuickTransform *transform) { return transform->d_func(); } |
| 98 | |
| 99 | QQuickTransformPrivate(); |
| 100 | |
| 101 | QList<QQuickItem *> items; |
| 102 | }; |
| 103 | |
| 104 | #if QT_CONFIG(quick_shadereffect) |
| 105 | |
| 106 | class Q_QUICK_EXPORT QQuickItemLayer : public QObject, public QQuickItemChangeListener |
| 107 | { |
| 108 | Q_OBJECT |
| 109 | Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged FINAL) |
| 110 | Q_PROPERTY(QSize textureSize READ size WRITE setSize NOTIFY sizeChanged FINAL) |
| 111 | Q_PROPERTY(QRectF sourceRect READ sourceRect WRITE setSourceRect NOTIFY sourceRectChanged FINAL) |
| 112 | Q_PROPERTY(bool mipmap READ mipmap WRITE setMipmap NOTIFY mipmapChanged FINAL) |
| 113 | Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged FINAL) |
| 114 | Q_PROPERTY(bool live READ live WRITE setLive NOTIFY liveChanged REVISION(6, 5) FINAL) |
| 115 | Q_PROPERTY(QQuickShaderEffectSource::WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged FINAL) |
| 116 | Q_PROPERTY(QQuickShaderEffectSource::Format format READ format WRITE setFormat NOTIFY formatChanged FINAL) |
| 117 | Q_PROPERTY(QByteArray samplerName READ name WRITE setName NOTIFY nameChanged FINAL) |
| 118 | Q_PROPERTY(QQmlComponent *effect READ effect WRITE setEffect NOTIFY effectChanged FINAL) |
| 119 | Q_PROPERTY(QQuickShaderEffectSource::TextureMirroring textureMirroring READ textureMirroring WRITE setTextureMirroring NOTIFY textureMirroringChanged FINAL) |
| 120 | Q_PROPERTY(int samples READ samples WRITE setSamples NOTIFY samplesChanged FINAL) |
| 121 | QML_ANONYMOUS |
| 122 | QML_ADDED_IN_VERSION(2, 0) |
| 123 | |
| 124 | public: |
| 125 | QQuickItemLayer(QQuickItem *item); |
| 126 | ~QQuickItemLayer() override; |
| 127 | |
| 128 | void classBegin(); |
| 129 | void componentComplete(); |
| 130 | |
| 131 | bool enabled() const { return m_enabled; } |
| 132 | void setEnabled(bool enabled); |
| 133 | |
| 134 | bool mipmap() const { return m_mipmap; } |
| 135 | void setMipmap(bool mipmap); |
| 136 | |
| 137 | bool smooth() const { return m_smooth; } |
| 138 | void setSmooth(bool s); |
| 139 | |
| 140 | bool live() const { return m_live; } |
| 141 | void setLive(bool live); |
| 142 | |
| 143 | QSize size() const { return m_size; } |
| 144 | void setSize(const QSize &size); |
| 145 | |
| 146 | QQuickShaderEffectSource::Format format() const { return m_format; } |
| 147 | void setFormat(QQuickShaderEffectSource::Format f); |
| 148 | |
| 149 | QRectF sourceRect() const { return m_sourceRect; } |
| 150 | void setSourceRect(const QRectF &sourceRect); |
| 151 | |
| 152 | QQuickShaderEffectSource::WrapMode wrapMode() const { return m_wrapMode; } |
| 153 | void setWrapMode(QQuickShaderEffectSource::WrapMode mode); |
| 154 | |
| 155 | QByteArray name() const { return m_name; } |
| 156 | void setName(const QByteArray &name); |
| 157 | |
| 158 | QQmlComponent *effect() const { return m_effectComponent; } |
| 159 | void setEffect(QQmlComponent *effect); |
| 160 | |
| 161 | QQuickShaderEffectSource::TextureMirroring textureMirroring() const { return m_textureMirroring; } |
| 162 | void setTextureMirroring(QQuickShaderEffectSource::TextureMirroring mirroring); |
| 163 | |
| 164 | int samples() const { return m_samples; } |
| 165 | void setSamples(int count); |
| 166 | |
| 167 | QQuickShaderEffectSource *effectSource() const { return m_effectSource; } |
| 168 | |
| 169 | void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) override; |
| 170 | void itemOpacityChanged(QQuickItem *) override; |
| 171 | void itemParentChanged(QQuickItem *, QQuickItem *) override; |
| 172 | void itemSiblingOrderChanged(QQuickItem *) override; |
| 173 | void itemVisibilityChanged(QQuickItem *) override; |
| 174 | |
| 175 | void updateMatrix(); |
| 176 | void updateGeometry(); |
| 177 | void updateOpacity(); |
| 178 | void updateZ(); |
| 179 | |
| 180 | Q_SIGNALS: |
| 181 | void enabledChanged(bool enabled); |
| 182 | void sizeChanged(const QSize &size); |
| 183 | void mipmapChanged(bool mipmap); |
| 184 | void wrapModeChanged(QQuickShaderEffectSource::WrapMode mode); |
| 185 | void nameChanged(const QByteArray &name); |
| 186 | void effectChanged(QQmlComponent *component); |
| 187 | void smoothChanged(bool smooth); |
| 188 | void liveChanged(bool live); |
| 189 | void formatChanged(QQuickShaderEffectSource::Format format); |
| 190 | void sourceRectChanged(const QRectF &sourceRect); |
| 191 | void textureMirroringChanged(QQuickShaderEffectSource::TextureMirroring mirroring); |
| 192 | void samplesChanged(int count); |
| 193 | |
| 194 | private: |
| 195 | friend class QQuickTransformAnimatorJob; |
| 196 | friend class QQuickOpacityAnimatorJob; |
| 197 | |
| 198 | void activate(); |
| 199 | void deactivate(); |
| 200 | void activateEffect(); |
| 201 | void deactivateEffect(); |
| 202 | |
| 203 | QQuickItem *m_item; |
| 204 | bool m_enabled; |
| 205 | bool m_mipmap; |
| 206 | bool m_smooth; |
| 207 | bool m_live; |
| 208 | bool m_componentComplete; |
| 209 | QQuickShaderEffectSource::WrapMode m_wrapMode; |
| 210 | QQuickShaderEffectSource::Format m_format; |
| 211 | QSize m_size; |
| 212 | QRectF m_sourceRect; |
| 213 | QByteArray m_name; |
| 214 | QQmlComponent *m_effectComponent; |
| 215 | QQuickItem *m_effect; |
| 216 | QQuickShaderEffectSource *m_effectSource; |
| 217 | QQuickShaderEffectSource::TextureMirroring m_textureMirroring; |
| 218 | int m_samples; |
| 219 | }; |
| 220 | |
| 221 | #endif |
| 222 | |
| 223 | class Q_QUICK_EXPORT QQuickItemPrivate |
| 224 | : public QObjectPrivate |
| 225 | , public QQuickPaletteProviderPrivateBase<QQuickItem, QQuickItemPrivate> |
| 226 | { |
| 227 | Q_DECLARE_PUBLIC(QQuickItem) |
| 228 | |
| 229 | public: |
| 230 | static QQuickItemPrivate* get(QQuickItem *item) { return item->d_func(); } |
| 231 | static const QQuickItemPrivate* get(const QQuickItem *item) { return item->d_func(); } |
| 232 | |
| 233 | QQuickItemPrivate(); |
| 234 | ~QQuickItemPrivate() override; |
| 235 | void init(QQuickItem *parent); |
| 236 | |
| 237 | QQmlListProperty<QObject> data(); |
| 238 | QQmlListProperty<QObject> resources(); |
| 239 | QQmlListProperty<QQuickItem> children(); |
| 240 | QQmlListProperty<QQuickItem> visibleChildren(); |
| 241 | |
| 242 | QQmlListProperty<QQuickState> states(); |
| 243 | QQmlListProperty<QQuickTransition> transitions(); |
| 244 | |
| 245 | QString state() const; |
| 246 | void setState(const QString &); |
| 247 | |
| 248 | QQuickAnchorLine left() const; |
| 249 | QQuickAnchorLine right() const; |
| 250 | QQuickAnchorLine horizontalCenter() const; |
| 251 | QQuickAnchorLine top() const; |
| 252 | QQuickAnchorLine bottom() const; |
| 253 | QQuickAnchorLine verticalCenter() const; |
| 254 | QQuickAnchorLine baseline() const; |
| 255 | |
| 256 | #if QT_CONFIG(quick_shadereffect) |
| 257 | QQuickItemLayer *layer() const; |
| 258 | #endif |
| 259 | |
| 260 | void localizedTouchEvent(const QTouchEvent *event, bool isFiltering, QMutableTouchEvent *localized); |
| 261 | bool hasPointerHandlers() const; |
| 262 | bool hasEnabledHoverHandlers() const; |
| 263 | virtual void addPointerHandler(QQuickPointerHandler *h); |
| 264 | virtual void removePointerHandler(QQuickPointerHandler *h); |
| 265 | |
| 266 | // data property |
| 267 | static void data_append(QQmlListProperty<QObject> *, QObject *); |
| 268 | static qsizetype data_count(QQmlListProperty<QObject> *); |
| 269 | static QObject *data_at(QQmlListProperty<QObject> *, qsizetype); |
| 270 | static void data_clear(QQmlListProperty<QObject> *); |
| 271 | static void data_removeLast(QQmlListProperty<QObject> *); |
| 272 | |
| 273 | // resources property |
| 274 | static QObject *resources_at(QQmlListProperty<QObject> *, qsizetype); |
| 275 | static void resources_append(QQmlListProperty<QObject> *, QObject *); |
| 276 | static qsizetype resources_count(QQmlListProperty<QObject> *); |
| 277 | static void resources_clear(QQmlListProperty<QObject> *); |
| 278 | static void resources_removeLast(QQmlListProperty<QObject> *); |
| 279 | |
| 280 | // children property |
| 281 | static void children_append(QQmlListProperty<QQuickItem> *, QQuickItem *); |
| 282 | static qsizetype children_count(QQmlListProperty<QQuickItem> *); |
| 283 | static QQuickItem *children_at(QQmlListProperty<QQuickItem> *, qsizetype); |
| 284 | static void children_clear(QQmlListProperty<QQuickItem> *); |
| 285 | static void children_removeLast(QQmlListProperty<QQuickItem> *); |
| 286 | |
| 287 | // visibleChildren property |
| 288 | static qsizetype visibleChildren_count(QQmlListProperty<QQuickItem> *prop); |
| 289 | static QQuickItem *visibleChildren_at(QQmlListProperty<QQuickItem> *prop, qsizetype index); |
| 290 | |
| 291 | // transform property |
| 292 | static qsizetype transform_count(QQmlListProperty<QQuickTransform> *list); |
| 293 | static void transform_append(QQmlListProperty<QQuickTransform> *list, QQuickTransform *); |
| 294 | static QQuickTransform *transform_at(QQmlListProperty<QQuickTransform> *list, qsizetype); |
| 295 | static void transform_clear(QQmlListProperty<QQuickTransform> *list); |
| 296 | |
| 297 | void _q_resourceObjectDeleted(QObject *); |
| 298 | quint64 _q_createJSWrapper(QQmlV4ExecutionEnginePtr engine); |
| 299 | |
| 300 | enum ChangeType { |
| 301 | Geometry = 0x01, |
| 302 | SiblingOrder = 0x02, |
| 303 | Visibility = 0x04, |
| 304 | Opacity = 0x08, |
| 305 | Destroyed = 0x10, |
| 306 | Parent = 0x20, |
| 307 | Children = 0x40, |
| 308 | Rotation = 0x80, |
| 309 | ImplicitWidth = 0x100, |
| 310 | ImplicitHeight = 0x200, |
| 311 | Enabled = 0x400, |
| 312 | Focus = 0x800, |
| 313 | AllChanges = 0xFFFFFFFF |
| 314 | }; |
| 315 | |
| 316 | Q_DECLARE_FLAGS(ChangeTypes, ChangeType) |
| 317 | |
| 318 | struct ChangeListener { |
| 319 | using ChangeTypes = QQuickItemPrivate::ChangeTypes; |
| 320 | |
| 321 | ChangeListener(QQuickItemChangeListener *l = nullptr, ChangeTypes t = { }) |
| 322 | : listener(l) |
| 323 | , types(t) |
| 324 | , gTypes(QQuickGeometryChange::All) |
| 325 | {} |
| 326 | |
| 327 | ChangeListener(QQuickItemChangeListener *l, QQuickGeometryChange gt) |
| 328 | : listener(l) |
| 329 | , types(Geometry) |
| 330 | , gTypes(gt) |
| 331 | {} |
| 332 | |
| 333 | bool operator==(const ChangeListener &other) const |
| 334 | { return listener == other.listener && types == other.types; } |
| 335 | |
| 336 | QQuickItemChangeListener *listener; |
| 337 | ChangeTypes types; |
| 338 | QQuickGeometryChange gTypes; //NOTE: not used for == |
| 339 | |
| 340 | #ifndef QT_NO_DEBUG_STREAM |
| 341 | private: |
| 342 | friend QDebug operator<<(QDebug debug, const QQuickItemPrivate::ChangeListener &listener); |
| 343 | #endif // QT_NO_DEBUG_STREAM |
| 344 | }; |
| 345 | |
| 346 | // call QQuickItemChangeListener |
| 347 | template <typename Fn, typename ...Args> |
| 348 | void notifyChangeListeners(QQuickItemPrivate::ChangeTypes changeTypes, Fn &&function, Args &&...args) |
| 349 | { |
| 350 | if (changeListeners.isEmpty()) |
| 351 | return; |
| 352 | |
| 353 | const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732) |
| 354 | for (const QQuickItemPrivate::ChangeListener &change : listeners) { |
| 355 | if (change.types & changeTypes) { |
| 356 | if constexpr (std::is_member_function_pointer_v<Fn>) |
| 357 | (change.listener->*function)(args...); |
| 358 | else |
| 359 | function(change, args...); |
| 360 | } |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | struct { |
| 365 | (); |
| 366 | |
| 367 | qreal ; |
| 368 | qreal ; |
| 369 | qreal ; |
| 370 | qreal ; |
| 371 | |
| 372 | QQuickContents *; |
| 373 | QQuickScreenAttached *; |
| 374 | QQuickLayoutMirroringAttached* ; |
| 375 | QQuickEnterKeyAttached *; |
| 376 | QQuickItemKeyFilter *keyHandler; |
| 377 | QVector<QQuickPointerHandler *> pointerHandlers; |
| 378 | #if QT_CONFIG(quick_shadereffect) |
| 379 | mutable QQuickItemLayer *; |
| 380 | #endif |
| 381 | #if QT_CONFIG(cursor) |
| 382 | QCursor ; |
| 383 | #endif |
| 384 | QPointF ; |
| 385 | |
| 386 | // these do not include child items |
| 387 | int ; |
| 388 | int ; |
| 389 | // updated recursively for child items as well |
| 390 | int ; |
| 391 | // Mask contains() method index |
| 392 | int ; |
| 393 | |
| 394 | // Contains mask |
| 395 | QPointer<QObject> ; |
| 396 | |
| 397 | QSGOpacityNode *; |
| 398 | QQuickDefaultClipNode *; |
| 399 | QSGRootNode *; |
| 400 | // subsceneDeliveryAgent is set only if this item is the root of a subscene, not on all items within. |
| 401 | QQuickDeliveryAgent * = nullptr; |
| 402 | |
| 403 | QObjectList ; |
| 404 | |
| 405 | // Although acceptedMouseButtons is inside ExtraData, we actually store |
| 406 | // the LeftButton flag in the extra.tag() bit. This is because it is |
| 407 | // extremely common to set acceptedMouseButtons to LeftButton, but very |
| 408 | // rare to use any of the other buttons. |
| 409 | Qt::MouseButtons ; |
| 410 | Qt::MouseButtons acceptedMouseButtonsWithoutHandlers; |
| 411 | |
| 412 | uint :5; // QQuickItem::TransformOrigin |
| 413 | uint : 1; |
| 414 | |
| 415 | // 26 bits padding |
| 416 | }; |
| 417 | |
| 418 | enum { |
| 419 | NoTag = 0x1, |
| 420 | LeftMouseButtonAccepted = 0x2 |
| 421 | }; |
| 422 | Q_DECLARE_FLAGS(, ExtraDataTag) |
| 423 | |
| 424 | QLazilyAllocated<ExtraData, ExtraDataTags> ; |
| 425 | // If the mask is an Item, inform it that it's being used as a mask (true) or is no longer being used (false) |
| 426 | virtual void registerAsContainmentMask(QQuickItem * /* maskedItem */, bool /* set */) { } |
| 427 | |
| 428 | QQuickAnchors *anchors() const; |
| 429 | mutable QQuickAnchors *_anchors; |
| 430 | |
| 431 | inline Qt::MouseButtons acceptedMouseButtons() const; |
| 432 | |
| 433 | QVector<QQuickItemPrivate::ChangeListener> changeListeners; |
| 434 | |
| 435 | void addItemChangeListener(QQuickItemChangeListener *listener, ChangeTypes types); |
| 436 | void updateOrAddItemChangeListener(QQuickItemChangeListener *listener, ChangeTypes types); |
| 437 | void removeItemChangeListener(QQuickItemChangeListener *, ChangeTypes types); |
| 438 | void updateOrAddGeometryChangeListener(QQuickItemChangeListener *listener, QQuickGeometryChange types); |
| 439 | void updateOrRemoveGeometryChangeListener(QQuickItemChangeListener *listener, QQuickGeometryChange types); |
| 440 | |
| 441 | QQuickStateGroup *_states(); |
| 442 | QQuickStateGroup *_stateGroup; |
| 443 | |
| 444 | inline QQuickItem::TransformOrigin origin() const; |
| 445 | |
| 446 | // Bit 0 |
| 447 | quint32 flags:7; |
| 448 | quint32 widthValidFlag:1; |
| 449 | quint32 heightValidFlag:1; |
| 450 | quint32 componentComplete:1; |
| 451 | quint32 keepMouse:1; |
| 452 | quint32 keepTouch:1; |
| 453 | quint32 hoverEnabled:1; |
| 454 | quint32 smooth:1; |
| 455 | quint32 antialiasing:1; |
| 456 | quint32 focus:1; |
| 457 | // Bit 16 |
| 458 | quint32 activeFocus:1; |
| 459 | quint32 notifiedFocus:1; |
| 460 | quint32 notifiedActiveFocus:1; |
| 461 | quint32 filtersChildMouseEvents:1; |
| 462 | quint32 explicitVisible:1; |
| 463 | quint32 effectiveVisible:1; |
| 464 | quint32 explicitEnable:1; |
| 465 | quint32 effectiveEnable:1; |
| 466 | quint32 polishScheduled:1; |
| 467 | quint32 inheritedLayoutMirror:1; |
| 468 | quint32 effectiveLayoutMirror:1; |
| 469 | quint32 isMirrorImplicit:1; |
| 470 | quint32 inheritMirrorFromParent:1; |
| 471 | quint32 inheritMirrorFromItem:1; |
| 472 | quint32 isAccessible:1; |
| 473 | quint32 culled:1; |
| 474 | // Bit 32 |
| 475 | quint32 hasCursor:1; |
| 476 | quint32 subtreeCursorEnabled:1; |
| 477 | quint32 subtreeHoverEnabled:1; |
| 478 | quint32 activeFocusOnTab:1; |
| 479 | quint32 implicitAntialiasing:1; |
| 480 | quint32 antialiasingValid:1; |
| 481 | // isTabFence: When true, the item acts as a fence within the tab focus chain. |
| 482 | // This means that the item and its children will be skipped from the tab focus |
| 483 | // chain when navigating from its parent or any of its siblings. Similarly, |
| 484 | // when any of the item's descendants gets focus, the item constrains the tab |
| 485 | // focus chain and prevents tabbing outside. |
| 486 | quint32 isTabFence:1; |
| 487 | quint32 replayingPressEvent:1; |
| 488 | // Bit 40 |
| 489 | quint32 touchEnabled:1; |
| 490 | quint32 hasCursorHandler:1; |
| 491 | // set true when this item does not expect events via a subscene delivery agent; false otherwise |
| 492 | quint32 maybeHasSubsceneDeliveryAgent:1; |
| 493 | // set true if this item or any child wants QQuickItemPrivate::transformChanged() to visit all children |
| 494 | // (e.g. when parent has ItemIsViewport and child has ItemObservesViewport) |
| 495 | quint32 subtreeTransformChangedEnabled:1; |
| 496 | quint32 inDestructor:1; // has entered ~QQuickItem |
| 497 | quint32 focusReason:4; |
| 498 | quint32 focusPolicy:4; |
| 499 | // Bit 53 |
| 500 | |
| 501 | enum DirtyType { |
| 502 | TransformOrigin = 0x00000001, |
| 503 | Transform = 0x00000002, |
| 504 | BasicTransform = 0x00000004, |
| 505 | Position = 0x00000008, |
| 506 | Size = 0x00000010, |
| 507 | |
| 508 | ZValue = 0x00000020, |
| 509 | Content = 0x00000040, |
| 510 | Smooth = 0x00000080, |
| 511 | OpacityValue = 0x00000100, |
| 512 | ChildrenChanged = 0x00000200, |
| 513 | ChildrenStackingChanged = 0x00000400, |
| 514 | ParentChanged = 0x00000800, |
| 515 | |
| 516 | Clip = 0x00001000, |
| 517 | Window = 0x00002000, |
| 518 | |
| 519 | EffectReference = 0x00008000, |
| 520 | Visible = 0x00010000, |
| 521 | HideReference = 0x00020000, |
| 522 | Antialiasing = 0x00040000, |
| 523 | // When you add an attribute here, don't forget to update |
| 524 | // dirtyToString() |
| 525 | |
| 526 | TransformUpdateMask = TransformOrigin | Transform | BasicTransform | Position | |
| 527 | Window, |
| 528 | = Transform | Window, |
| 529 | ContentUpdateMask = Size | Content | Smooth | Window | Antialiasing, |
| 530 | ChildrenUpdateMask = ChildrenChanged | ChildrenStackingChanged | EffectReference | Window |
| 531 | }; |
| 532 | |
| 533 | quint32 dirtyAttributes; |
| 534 | QString dirtyToString() const; |
| 535 | void dirty(DirtyType); |
| 536 | void addToDirtyList(); |
| 537 | void removeFromDirtyList(); |
| 538 | QQuickItem *nextDirtyItem; |
| 539 | QQuickItem**prevDirtyItem; |
| 540 | |
| 541 | void setCulled(bool); |
| 542 | |
| 543 | QQuickWindow *window; |
| 544 | int windowRefCount; |
| 545 | inline QSGContext *sceneGraphContext() const; |
| 546 | inline QSGRenderContext *sceneGraphRenderContext() const; |
| 547 | |
| 548 | QQuickItem *parentItem; |
| 549 | |
| 550 | QList<QQuickItem *> childItems; |
| 551 | mutable QList<QQuickItem *> *sortedChildItems; |
| 552 | QList<QQuickItem *> paintOrderChildItems() const; |
| 553 | void addChild(QQuickItem *); |
| 554 | void removeChild(QQuickItem *); |
| 555 | void siblingOrderChanged(); |
| 556 | |
| 557 | inline void markSortedChildrenDirty(QQuickItem *child); |
| 558 | |
| 559 | void refWindow(QQuickWindow *); |
| 560 | void derefWindow(); |
| 561 | |
| 562 | QPointer<QQuickItem> subFocusItem; |
| 563 | void updateSubFocusItem(QQuickItem *scope, bool focus); |
| 564 | |
| 565 | bool setFocusIfNeeded(QEvent::Type); |
| 566 | Qt::FocusReason lastFocusChangeReason() const; |
| 567 | virtual bool setLastFocusChangeReason(Qt::FocusReason reason); |
| 568 | |
| 569 | QTransform windowToItemTransform() const; |
| 570 | QTransform itemToWindowTransform() const; |
| 571 | void itemToParentTransform(QTransform *) const; |
| 572 | |
| 573 | static bool focusNextPrev(QQuickItem *item, bool forward); |
| 574 | static QQuickItem *nextTabChildItem(const QQuickItem *item, int start); |
| 575 | static QQuickItem *prevTabChildItem(const QQuickItem *item, int start); |
| 576 | static QQuickItem *nextPrevItemInTabFocusChain(QQuickItem *item, bool forward, bool wrap = true); |
| 577 | |
| 578 | static bool canAcceptTabFocus(QQuickItem *item); |
| 579 | |
| 580 | void setX(qreal x) {q_func()->setX(x);} |
| 581 | void xChanged() { Q_EMIT q_func()->xChanged(); } |
| 582 | Q_OBJECT_COMPAT_PROPERTY(QQuickItemPrivate, qreal, x, &QQuickItemPrivate::setX, &QQuickItemPrivate::xChanged); |
| 583 | void setY(qreal y) {q_func()->setY(y);} |
| 584 | void yChanged() { Q_EMIT q_func()->yChanged(); } |
| 585 | Q_OBJECT_COMPAT_PROPERTY(QQuickItemPrivate, qreal, y, &QQuickItemPrivate::setY, &QQuickItemPrivate::yChanged); |
| 586 | void setWidth(qreal width) {q_func()->setWidth(width);} |
| 587 | void widthChanged() { Q_EMIT q_func()->widthChanged(); } |
| 588 | Q_OBJECT_COMPAT_PROPERTY(QQuickItemPrivate, qreal, width, &QQuickItemPrivate::setWidth, &QQuickItemPrivate::widthChanged); |
| 589 | void setHeight(qreal height) {q_func()->setHeight(height);} |
| 590 | void heightChanged() { Q_EMIT q_func()->heightChanged(); } |
| 591 | Q_OBJECT_COMPAT_PROPERTY(QQuickItemPrivate, qreal, height, &QQuickItemPrivate::setHeight, &QQuickItemPrivate::heightChanged); |
| 592 | qreal implicitWidth; |
| 593 | qreal implicitHeight; |
| 594 | |
| 595 | bool widthValid() const { return widthValidFlag || (width.hasBinding() && !QQmlPropertyBinding::isUndefined(binding: width.binding()) ); } |
| 596 | bool heightValid() const { return heightValidFlag || (height.hasBinding() && !QQmlPropertyBinding::isUndefined(binding: height.binding()) ); } |
| 597 | |
| 598 | qreal baselineOffset; |
| 599 | |
| 600 | QList<QQuickTransform *> transforms; |
| 601 | |
| 602 | inline qreal z() const { return extra.isAllocated()?extra->z:0; } |
| 603 | inline qreal scale() const { return extra.isAllocated()?extra->scale:1; } |
| 604 | inline qreal rotation() const { return extra.isAllocated()?extra->rotation:0; } |
| 605 | inline qreal opacity() const { return extra.isAllocated()?extra->opacity:1; } |
| 606 | |
| 607 | void setAccessible(); |
| 608 | |
| 609 | virtual qreal getImplicitWidth() const; |
| 610 | virtual qreal getImplicitHeight() const; |
| 611 | virtual void implicitWidthChanged(); |
| 612 | virtual void implicitHeightChanged(); |
| 613 | |
| 614 | #if QT_CONFIG(accessibility) |
| 615 | QAccessible::Role effectiveAccessibleRole() const; |
| 616 | private: |
| 617 | virtual QAccessible::Role accessibleRole() const; |
| 618 | public: |
| 619 | #endif |
| 620 | |
| 621 | void setImplicitAntialiasing(bool antialiasing); |
| 622 | |
| 623 | void resolveLayoutMirror(); |
| 624 | void setImplicitLayoutMirror(bool mirror, bool inherit); |
| 625 | void setLayoutMirror(bool mirror); |
| 626 | bool isMirrored() const { |
| 627 | return effectiveLayoutMirror; |
| 628 | } |
| 629 | |
| 630 | void emitChildrenRectChanged(const QRectF &rect) { |
| 631 | Q_Q(QQuickItem); |
| 632 | Q_EMIT q->childrenRectChanged(rect); |
| 633 | } |
| 634 | |
| 635 | QPointF computeTransformOrigin() const; |
| 636 | virtual bool transformChanged(QQuickItem *transformedItem); |
| 637 | |
| 638 | QPointF adjustedPosForTransform(const QPointF ¢roid, |
| 639 | const QPointF &startPos, const QVector2D &activeTranslatation, |
| 640 | qreal startScale, qreal activeScale, |
| 641 | qreal startRotation, qreal activeRotation); |
| 642 | |
| 643 | QQuickDeliveryAgent *deliveryAgent(); |
| 644 | QQuickDeliveryAgentPrivate *deliveryAgentPrivate(); |
| 645 | QQuickDeliveryAgent *ensureSubsceneDeliveryAgent(); |
| 646 | |
| 647 | void deliverKeyEvent(QKeyEvent *); |
| 648 | bool filterKeyEvent(QKeyEvent *, bool post); |
| 649 | #if QT_CONFIG(im) |
| 650 | void deliverInputMethodEvent(QInputMethodEvent *); |
| 651 | #endif |
| 652 | void deliverShortcutOverrideEvent(QKeyEvent *); |
| 653 | |
| 654 | void deliverPointerEvent(QEvent *); |
| 655 | |
| 656 | bool anyPointerHandlerWants(const QPointerEvent *event, const QEventPoint &point) const; |
| 657 | virtual bool handlePointerEvent(QPointerEvent *, bool avoidGrabbers = false); |
| 658 | |
| 659 | virtual void setVisible(bool visible); |
| 660 | |
| 661 | bool isTransparentForPositioner() const; |
| 662 | void setTransparentForPositioner(bool trans); |
| 663 | |
| 664 | bool calcEffectiveVisible() const; |
| 665 | bool setEffectiveVisibleRecur(bool); |
| 666 | bool calcEffectiveEnable() const; |
| 667 | void setEffectiveEnableRecur(QQuickItem *scope, bool); |
| 668 | |
| 669 | |
| 670 | inline QSGTransformNode *itemNode(); |
| 671 | inline QSGNode *childContainerNode(); |
| 672 | |
| 673 | /* |
| 674 | QSGNode order is: |
| 675 | - itemNode |
| 676 | - (opacityNode) |
| 677 | - (clipNode) |
| 678 | - (rootNode) (shader effect source's root node) |
| 679 | */ |
| 680 | |
| 681 | QSGOpacityNode *opacityNode() const { return extra.isAllocated()?extra->opacityNode:nullptr; } |
| 682 | QQuickDefaultClipNode *clipNode() const { return extra.isAllocated()?extra->clipNode:nullptr; } |
| 683 | QSGRootNode *rootNode() const { return extra.isAllocated()?extra->rootNode:nullptr; } |
| 684 | |
| 685 | QSGTransformNode *itemNodeInstance; |
| 686 | QSGNode *paintNode; |
| 687 | |
| 688 | virtual QSGTransformNode *createTransformNode(); |
| 689 | |
| 690 | // A reference from an effect item means that this item is used by the effect, so |
| 691 | // it should insert a root node. |
| 692 | void refFromEffectItem(bool hide); |
| 693 | void recursiveRefFromEffectItem(int refs); |
| 694 | void derefFromEffectItem(bool unhide); |
| 695 | |
| 696 | void itemChange(QQuickItem::ItemChange, const QQuickItem::ItemChangeData &); |
| 697 | |
| 698 | void enableSubtreeChangeNotificationsForParentHierachy(); |
| 699 | |
| 700 | virtual void mirrorChange() {} |
| 701 | |
| 702 | void setHasCursorInChild(bool hasCursor); |
| 703 | void setHasHoverInChild(bool hasHover); |
| 704 | #if QT_CONFIG(cursor) |
| 705 | QCursor effectiveCursor(const QQuickPointerHandler *handler) const; |
| 706 | QQuickPointerHandler *effectiveCursorHandler() const; |
| 707 | #endif |
| 708 | |
| 709 | virtual void updatePolish() { } |
| 710 | virtual void dumpItemTree(int indent) const; |
| 711 | |
| 712 | QLayoutPolicy sizePolicy() const; |
| 713 | void setSizePolicy(const QLayoutPolicy::Policy &horizontalPolicy, const QLayoutPolicy::Policy &verticalPolicy); |
| 714 | QLayoutPolicy szPolicy; |
| 715 | }; |
| 716 | |
| 717 | Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickItemPrivate::ExtraDataTags) |
| 718 | |
| 719 | /* |
| 720 | Key filters can be installed on a QQuickItem, but not removed. Currently they |
| 721 | are only used by attached objects (which are only destroyed on Item |
| 722 | destruction), so this isn't a problem. If in future this becomes any form |
| 723 | of public API, they will have to support removal too. |
| 724 | */ |
| 725 | class QQuickItemKeyFilter |
| 726 | { |
| 727 | public: |
| 728 | QQuickItemKeyFilter(QQuickItem * = nullptr); |
| 729 | virtual ~QQuickItemKeyFilter(); |
| 730 | |
| 731 | virtual void keyPressed(QKeyEvent *event, bool post); |
| 732 | virtual void keyReleased(QKeyEvent *event, bool post); |
| 733 | #if QT_CONFIG(im) |
| 734 | virtual void inputMethodEvent(QInputMethodEvent *event, bool post); |
| 735 | virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; |
| 736 | #endif |
| 737 | virtual void shortcutOverrideEvent(QKeyEvent *event); |
| 738 | virtual void componentComplete(); |
| 739 | |
| 740 | bool m_processPost; |
| 741 | |
| 742 | private: |
| 743 | QQuickItemKeyFilter *m_next; |
| 744 | }; |
| 745 | |
| 746 | class QQuickKeyNavigationAttachedPrivate : public QObjectPrivate |
| 747 | { |
| 748 | public: |
| 749 | QQuickKeyNavigationAttachedPrivate() |
| 750 | : leftSet(false), rightSet(false), upSet(false), downSet(false), |
| 751 | tabSet(false), backtabSet(false) {} |
| 752 | |
| 753 | QPointer<QQuickItem> left; |
| 754 | QPointer<QQuickItem> right; |
| 755 | QPointer<QQuickItem> up; |
| 756 | QPointer<QQuickItem> down; |
| 757 | QPointer<QQuickItem> tab; |
| 758 | QPointer<QQuickItem> backtab; |
| 759 | bool leftSet : 1; |
| 760 | bool rightSet : 1; |
| 761 | bool upSet : 1; |
| 762 | bool downSet : 1; |
| 763 | bool tabSet : 1; |
| 764 | bool backtabSet : 1; |
| 765 | }; |
| 766 | |
| 767 | class Q_QUICK_EXPORT QQuickKeyNavigationAttached : public QObject, public QQuickItemKeyFilter |
| 768 | { |
| 769 | Q_OBJECT |
| 770 | Q_DECLARE_PRIVATE(QQuickKeyNavigationAttached) |
| 771 | |
| 772 | Q_PROPERTY(QQuickItem *left READ left WRITE setLeft NOTIFY leftChanged FINAL) |
| 773 | Q_PROPERTY(QQuickItem *right READ right WRITE setRight NOTIFY rightChanged FINAL) |
| 774 | Q_PROPERTY(QQuickItem *up READ up WRITE setUp NOTIFY upChanged FINAL) |
| 775 | Q_PROPERTY(QQuickItem *down READ down WRITE setDown NOTIFY downChanged FINAL) |
| 776 | Q_PROPERTY(QQuickItem *tab READ tab WRITE setTab NOTIFY tabChanged FINAL) |
| 777 | Q_PROPERTY(QQuickItem *backtab READ backtab WRITE setBacktab NOTIFY backtabChanged FINAL) |
| 778 | Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged FINAL) |
| 779 | |
| 780 | QML_NAMED_ELEMENT(KeyNavigation) |
| 781 | QML_ADDED_IN_VERSION(2, 0) |
| 782 | QML_UNCREATABLE("KeyNavigation is only available via attached properties." ) |
| 783 | QML_ATTACHED(QQuickKeyNavigationAttached) |
| 784 | |
| 785 | public: |
| 786 | QQuickKeyNavigationAttached(QObject * = nullptr); |
| 787 | |
| 788 | QQuickItem *left() const; |
| 789 | void setLeft(QQuickItem *); |
| 790 | QQuickItem *right() const; |
| 791 | void setRight(QQuickItem *); |
| 792 | QQuickItem *up() const; |
| 793 | void setUp(QQuickItem *); |
| 794 | QQuickItem *down() const; |
| 795 | void setDown(QQuickItem *); |
| 796 | QQuickItem *tab() const; |
| 797 | void setTab(QQuickItem *); |
| 798 | QQuickItem *backtab() const; |
| 799 | void setBacktab(QQuickItem *); |
| 800 | |
| 801 | enum Priority { BeforeItem, AfterItem }; |
| 802 | Q_ENUM(Priority) |
| 803 | Priority priority() const; |
| 804 | void setPriority(Priority); |
| 805 | |
| 806 | static QQuickKeyNavigationAttached *qmlAttachedProperties(QObject *); |
| 807 | |
| 808 | Q_SIGNALS: |
| 809 | void leftChanged(); |
| 810 | void rightChanged(); |
| 811 | void upChanged(); |
| 812 | void downChanged(); |
| 813 | void tabChanged(); |
| 814 | void backtabChanged(); |
| 815 | void priorityChanged(); |
| 816 | |
| 817 | private: |
| 818 | void keyPressed(QKeyEvent *event, bool post) override; |
| 819 | void keyReleased(QKeyEvent *event, bool post) override; |
| 820 | void setFocusNavigation(QQuickItem *currentItem, const char *dir, |
| 821 | Qt::FocusReason reason = Qt::OtherFocusReason); |
| 822 | }; |
| 823 | |
| 824 | class QQuickLayoutMirroringAttached : public QObject |
| 825 | { |
| 826 | Q_OBJECT |
| 827 | Q_PROPERTY(bool enabled READ enabled WRITE setEnabled RESET resetEnabled NOTIFY enabledChanged FINAL) |
| 828 | Q_PROPERTY(bool childrenInherit READ childrenInherit WRITE setChildrenInherit NOTIFY childrenInheritChanged FINAL) |
| 829 | |
| 830 | QML_NAMED_ELEMENT(LayoutMirroring) |
| 831 | QML_ADDED_IN_VERSION(2, 0) |
| 832 | QML_UNCREATABLE("LayoutMirroring is only available via attached properties." ) |
| 833 | QML_ATTACHED(QQuickLayoutMirroringAttached) |
| 834 | |
| 835 | public: |
| 836 | explicit QQuickLayoutMirroringAttached(QObject *parent = nullptr); |
| 837 | |
| 838 | bool enabled() const; |
| 839 | void setEnabled(bool); |
| 840 | void resetEnabled(); |
| 841 | |
| 842 | bool childrenInherit() const; |
| 843 | void setChildrenInherit(bool); |
| 844 | |
| 845 | static QQuickLayoutMirroringAttached *qmlAttachedProperties(QObject *); |
| 846 | Q_SIGNALS: |
| 847 | void enabledChanged(); |
| 848 | void childrenInheritChanged(); |
| 849 | private: |
| 850 | friend class QQuickItemPrivate; |
| 851 | QQuickItemPrivate *itemPrivate; |
| 852 | }; |
| 853 | |
| 854 | class QQuickEnterKeyAttached : public QObject |
| 855 | { |
| 856 | Q_OBJECT |
| 857 | Q_PROPERTY(Qt::EnterKeyType type READ type WRITE setType NOTIFY typeChanged FINAL) |
| 858 | |
| 859 | QML_NAMED_ELEMENT(EnterKey) |
| 860 | QML_UNCREATABLE("EnterKey is only available via attached properties" ) |
| 861 | QML_ADDED_IN_VERSION(2, 6) |
| 862 | QML_ATTACHED(QQuickEnterKeyAttached) |
| 863 | |
| 864 | public: |
| 865 | explicit QQuickEnterKeyAttached(QObject *parent = nullptr); |
| 866 | |
| 867 | Qt::EnterKeyType type() const; |
| 868 | void setType(Qt::EnterKeyType type); |
| 869 | |
| 870 | static QQuickEnterKeyAttached *qmlAttachedProperties(QObject *); |
| 871 | Q_SIGNALS: |
| 872 | void typeChanged(); |
| 873 | private: |
| 874 | friend class QQuickItemPrivate; |
| 875 | QQuickItemPrivate *itemPrivate; |
| 876 | |
| 877 | Qt::EnterKeyType keyType; |
| 878 | }; |
| 879 | |
| 880 | class QQuickKeysAttachedPrivate : public QObjectPrivate |
| 881 | { |
| 882 | public: |
| 883 | QQuickKeysAttachedPrivate() |
| 884 | : inPress(false), inRelease(false), inIM(false), enabled(true) |
| 885 | {} |
| 886 | |
| 887 | //loop detection |
| 888 | bool inPress:1; |
| 889 | bool inRelease:1; |
| 890 | bool inIM:1; |
| 891 | |
| 892 | bool enabled : 1; |
| 893 | |
| 894 | QQuickItem *imeItem = nullptr; |
| 895 | QList<QQuickItem *> targets; |
| 896 | QQuickItem *item = nullptr; |
| 897 | QQuickKeyEvent theKeyEvent; |
| 898 | }; |
| 899 | |
| 900 | class Q_QUICK_EXPORT QQuickKeysAttached : public QObject, public QQuickItemKeyFilter |
| 901 | { |
| 902 | Q_OBJECT |
| 903 | Q_DECLARE_PRIVATE(QQuickKeysAttached) |
| 904 | |
| 905 | Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged FINAL) |
| 906 | Q_PROPERTY(QQmlListProperty<QQuickItem> forwardTo READ forwardTo FINAL) |
| 907 | Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged FINAL) |
| 908 | |
| 909 | QML_NAMED_ELEMENT(Keys) |
| 910 | QML_ADDED_IN_VERSION(2, 0) |
| 911 | QML_UNCREATABLE("Keys is only available via attached properties" ) |
| 912 | QML_ATTACHED(QQuickKeysAttached) |
| 913 | |
| 914 | public: |
| 915 | QQuickKeysAttached(QObject *parent=nullptr); |
| 916 | ~QQuickKeysAttached() override; |
| 917 | |
| 918 | bool enabled() const { Q_D(const QQuickKeysAttached); return d->enabled; } |
| 919 | void setEnabled(bool enabled) { |
| 920 | Q_D(QQuickKeysAttached); |
| 921 | if (enabled != d->enabled) { |
| 922 | d->enabled = enabled; |
| 923 | Q_EMIT enabledChanged(); |
| 924 | } |
| 925 | } |
| 926 | |
| 927 | enum Priority { BeforeItem, AfterItem}; |
| 928 | Q_ENUM(Priority) |
| 929 | Priority priority() const; |
| 930 | void setPriority(Priority); |
| 931 | |
| 932 | QQmlListProperty<QQuickItem> forwardTo() { |
| 933 | Q_D(QQuickKeysAttached); |
| 934 | return QQmlListProperty<QQuickItem>(this, &(d->targets)); |
| 935 | } |
| 936 | |
| 937 | void componentComplete() override; |
| 938 | |
| 939 | static QQuickKeysAttached *qmlAttachedProperties(QObject *); |
| 940 | |
| 941 | Q_SIGNALS: |
| 942 | void enabledChanged(); |
| 943 | void priorityChanged(); |
| 944 | void pressed(QQuickKeyEvent *event); |
| 945 | void released(QQuickKeyEvent *event); |
| 946 | void shortcutOverride(QQuickKeyEvent *event); |
| 947 | void digit0Pressed(QQuickKeyEvent *event); |
| 948 | void digit1Pressed(QQuickKeyEvent *event); |
| 949 | void digit2Pressed(QQuickKeyEvent *event); |
| 950 | void digit3Pressed(QQuickKeyEvent *event); |
| 951 | void digit4Pressed(QQuickKeyEvent *event); |
| 952 | void digit5Pressed(QQuickKeyEvent *event); |
| 953 | void digit6Pressed(QQuickKeyEvent *event); |
| 954 | void digit7Pressed(QQuickKeyEvent *event); |
| 955 | void digit8Pressed(QQuickKeyEvent *event); |
| 956 | void digit9Pressed(QQuickKeyEvent *event); |
| 957 | |
| 958 | void leftPressed(QQuickKeyEvent *event); |
| 959 | void rightPressed(QQuickKeyEvent *event); |
| 960 | void upPressed(QQuickKeyEvent *event); |
| 961 | void downPressed(QQuickKeyEvent *event); |
| 962 | void tabPressed(QQuickKeyEvent *event); |
| 963 | void backtabPressed(QQuickKeyEvent *event); |
| 964 | |
| 965 | void asteriskPressed(QQuickKeyEvent *event); |
| 966 | void numberSignPressed(QQuickKeyEvent *event); |
| 967 | void escapePressed(QQuickKeyEvent *event); |
| 968 | void returnPressed(QQuickKeyEvent *event); |
| 969 | void enterPressed(QQuickKeyEvent *event); |
| 970 | void deletePressed(QQuickKeyEvent *event); |
| 971 | void spacePressed(QQuickKeyEvent *event); |
| 972 | void backPressed(QQuickKeyEvent *event); |
| 973 | void cancelPressed(QQuickKeyEvent *event); |
| 974 | void selectPressed(QQuickKeyEvent *event); |
| 975 | void yesPressed(QQuickKeyEvent *event); |
| 976 | void noPressed(QQuickKeyEvent *event); |
| 977 | void context1Pressed(QQuickKeyEvent *event); |
| 978 | void context2Pressed(QQuickKeyEvent *event); |
| 979 | void context3Pressed(QQuickKeyEvent *event); |
| 980 | void context4Pressed(QQuickKeyEvent *event); |
| 981 | void callPressed(QQuickKeyEvent *event); |
| 982 | void hangupPressed(QQuickKeyEvent *event); |
| 983 | void flipPressed(QQuickKeyEvent *event); |
| 984 | void (QQuickKeyEvent *event); |
| 985 | void volumeUpPressed(QQuickKeyEvent *event); |
| 986 | void volumeDownPressed(QQuickKeyEvent *event); |
| 987 | |
| 988 | private: |
| 989 | void keyPressed(QKeyEvent *event, bool post) override; |
| 990 | void keyReleased(QKeyEvent *event, bool post) override; |
| 991 | #if QT_CONFIG(im) |
| 992 | void inputMethodEvent(QInputMethodEvent *, bool post) override; |
| 993 | QVariant inputMethodQuery(Qt::InputMethodQuery query) const override; |
| 994 | #endif |
| 995 | void shortcutOverrideEvent(QKeyEvent *event) override; |
| 996 | static QByteArray keyToSignal(int key); |
| 997 | |
| 998 | bool isConnected(const char *signalName) const; |
| 999 | }; |
| 1000 | |
| 1001 | Qt::MouseButtons QQuickItemPrivate::acceptedMouseButtons() const |
| 1002 | { |
| 1003 | return ((extra.tag().testFlag(flag: LeftMouseButtonAccepted) ? Qt::LeftButton : Qt::MouseButton(0)) | |
| 1004 | (extra.isAllocated() ? extra->acceptedMouseButtons : Qt::MouseButtons{})); |
| 1005 | } |
| 1006 | |
| 1007 | QSGContext *QQuickItemPrivate::sceneGraphContext() const |
| 1008 | { |
| 1009 | Q_ASSERT(window); |
| 1010 | return static_cast<QQuickWindowPrivate *>(QObjectPrivate::get(o: window))->context->sceneGraphContext(); |
| 1011 | } |
| 1012 | |
| 1013 | QSGRenderContext *QQuickItemPrivate::sceneGraphRenderContext() const |
| 1014 | { |
| 1015 | Q_ASSERT(window); |
| 1016 | return static_cast<QQuickWindowPrivate *>(QObjectPrivate::get(o: window))->context; |
| 1017 | } |
| 1018 | |
| 1019 | void QQuickItemPrivate::markSortedChildrenDirty(QQuickItem *child) |
| 1020 | { |
| 1021 | // If sortedChildItems == &childItems then all in childItems have z == 0 |
| 1022 | // and we don't need to invalidate if the changed item also has z == 0. |
| 1023 | if (child->z() != 0. || sortedChildItems != &childItems) { |
| 1024 | if (sortedChildItems != &childItems) |
| 1025 | delete sortedChildItems; |
| 1026 | sortedChildItems = nullptr; |
| 1027 | } |
| 1028 | } |
| 1029 | |
| 1030 | QQuickItem::TransformOrigin QQuickItemPrivate::origin() const |
| 1031 | { |
| 1032 | return extra.isAllocated() ? QQuickItem::TransformOrigin(extra->origin) |
| 1033 | : QQuickItem::Center; |
| 1034 | } |
| 1035 | |
| 1036 | QSGTransformNode *QQuickItemPrivate::itemNode() |
| 1037 | { |
| 1038 | if (!itemNodeInstance) { |
| 1039 | itemNodeInstance = createTransformNode(); |
| 1040 | itemNodeInstance->setFlag(QSGNode::OwnedByParent, false); |
| 1041 | #ifdef QSG_RUNTIME_DESCRIPTION |
| 1042 | Q_Q(QQuickItem); |
| 1043 | qsgnode_set_description(node: itemNodeInstance, description: QString::fromLatin1(ba: "QQuickItem(%1:%2)" ).arg(a: QString::fromLatin1(ba: q->metaObject()->className())).arg(a: q->objectName())); |
| 1044 | #endif |
| 1045 | } |
| 1046 | return itemNodeInstance; |
| 1047 | } |
| 1048 | |
| 1049 | QSGNode *QQuickItemPrivate::childContainerNode() |
| 1050 | { |
| 1051 | if (rootNode()) |
| 1052 | return rootNode(); |
| 1053 | else if (clipNode()) |
| 1054 | return clipNode(); |
| 1055 | else if (opacityNode()) |
| 1056 | return opacityNode(); |
| 1057 | else |
| 1058 | return itemNode(); |
| 1059 | } |
| 1060 | |
| 1061 | Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickItemPrivate::ChangeTypes) |
| 1062 | Q_DECLARE_TYPEINFO(QQuickItemPrivate::ChangeListener, Q_PRIMITIVE_TYPE); |
| 1063 | |
| 1064 | QT_END_NAMESPACE |
| 1065 | |
| 1066 | #endif // QQUICKITEM_P_H |
| 1067 | |