diff options
Diffstat (limited to 'src/quick/items/qquickitem.h')
-rw-r--r-- | src/quick/items/qquickitem.h | 150 |
1 files changed, 91 insertions, 59 deletions
diff --git a/src/quick/items/qquickitem.h b/src/quick/items/qquickitem.h index 887318c23f..6b54b1af24 100644 --- a/src/quick/items/qquickitem.h +++ b/src/quick/items/qquickitem.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQuick module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QQUICKITEM_H #define QQUICKITEM_H @@ -46,6 +10,7 @@ #include <QtCore/QObject> #include <QtCore/QList> +#include <QtCore/qproperty.h> #include <QtGui/qevent.h> #include <QtGui/qfont.h> #include <QtGui/qaccessible.h> @@ -80,7 +45,6 @@ private: class QCursor; class QQuickItemLayer; -class QQmlV4Function; class QQuickState; class QQuickAnchorLine; class QQuickTransition; @@ -105,11 +69,11 @@ class Q_QUICK_EXPORT QQuickItem : public QObject, public QQmlParserStatus Q_PRIVATE_PROPERTY(QQuickItem::d_func(), QQmlListProperty<QObject> resources READ resources DESIGNABLE false) Q_PRIVATE_PROPERTY(QQuickItem::d_func(), QQmlListProperty<QQuickItem> children READ children NOTIFY childrenChanged DESIGNABLE false) - Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged FINAL) - Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged FINAL) + Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged BINDABLE bindableX FINAL) + Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged BINDABLE bindableY FINAL) Q_PROPERTY(qreal z READ z WRITE setZ NOTIFY zChanged FINAL) - Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged RESET resetWidth FINAL) - Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged RESET resetHeight FINAL) + Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged RESET resetWidth BINDABLE bindableWidth FINAL) + Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged RESET resetHeight BINDABLE bindableHeight FINAL) Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged FINAL) Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) @@ -137,6 +101,8 @@ class Q_QUICK_EXPORT QQuickItem : public QObject, public QQmlParserStatus Q_PROPERTY(bool activeFocus READ hasActiveFocus NOTIFY activeFocusChanged FINAL) Q_PROPERTY(bool activeFocusOnTab READ activeFocusOnTab WRITE setActiveFocusOnTab NOTIFY activeFocusOnTabChanged FINAL REVISION(2, 1)) + Q_PROPERTY(Qt::FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy NOTIFY focusPolicyChanged REVISION(6, 7)) + Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged) Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged) Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin NOTIFY transformOriginChanged) @@ -149,10 +115,13 @@ class Q_QUICK_EXPORT QQuickItem : public QObject, public QQmlParserStatus Q_PROPERTY(qreal implicitHeight READ implicitHeight WRITE setImplicitHeight NOTIFY implicitHeightChanged) Q_PROPERTY(QObject *containmentMask READ containmentMask WRITE setContainmentMask NOTIFY containmentMaskChanged REVISION(2, 11)) +#if QT_CONFIG(quick_shadereffect) Q_PRIVATE_PROPERTY(QQuickItem::d_func(), QQuickItemLayer *layer READ layer DESIGNABLE false CONSTANT FINAL) +#endif Q_CLASSINFO("DefaultProperty", "data") - Q_CLASSINFO("qt_QmlJSWrapperFactoryMethod", "_q_createJSWrapper(QV4::ExecutionEngine*)") + Q_CLASSINFO("ParentProperty", "parent") + Q_CLASSINFO("qt_QmlJSWrapperFactoryMethod", "_q_createJSWrapper(QQmlV4ExecutionEnginePtr)") QML_NAMED_ELEMENT(Item) QML_ADDED_IN_VERSION(2, 0) @@ -164,7 +133,9 @@ public: #endif ItemIsFocusScope = 0x04, ItemHasContents = 0x08, - ItemAcceptsDrops = 0x10 + ItemAcceptsDrops = 0x10, + ItemIsViewport = 0x20, + ItemObservesViewport = 0x40, // Remember to increment the size of QQuickItemPrivate::flags }; Q_DECLARE_FLAGS(Flags, Flag) @@ -183,6 +154,7 @@ public: ItemDevicePixelRatioHasChanged, // value.realValue ItemEnabledHasChanged // value.boolValue }; + Q_ENUM(ItemChange) union ItemChangeData { ItemChangeData(QQuickItem *v) : item(v) {} @@ -232,18 +204,22 @@ public: void setX(qreal); void setY(qreal); void setPosition(const QPointF &); + QBindable<qreal> bindableX(); + QBindable<qreal> bindableY(); qreal width() const; void setWidth(qreal); void resetWidth(); void setImplicitWidth(qreal); qreal implicitWidth() const; + QBindable<qreal> bindableWidth(); qreal height() const; void setHeight(qreal); void resetHeight(); void setImplicitHeight(qreal); qreal implicitHeight() const; + QBindable<qreal> bindableHeight(); QSizeF size() const; void setSize(const QSizeF &size); @@ -286,6 +262,7 @@ public: virtual QRectF boundingRect() const; virtual QRectF clipRect() const; + QQuickItem *viewportItem() const; bool hasActiveFocus() const; bool hasFocus() const; @@ -294,6 +271,9 @@ public: bool isFocusScope() const; QQuickItem *scopedFocusItem() const; + Qt::FocusPolicy focusPolicy() const; + void setFocusPolicy(Qt::FocusPolicy policy); + bool isAncestorOf(const QQuickItem *child) const; Qt::MouseButtons acceptedMouseButtons() const; @@ -331,27 +311,58 @@ public: void setContainmentMask(QObject *mask); QTransform itemTransform(QQuickItem *, bool *) const; - QPointF mapToItem(const QQuickItem *item, const QPointF &point) const; QPointF mapToScene(const QPointF &point) const; - QPointF mapToGlobal(const QPointF &point) const; QRectF mapRectToItem(const QQuickItem *item, const QRectF &rect) const; QRectF mapRectToScene(const QRectF &rect) const; - QPointF mapFromItem(const QQuickItem *item, const QPointF &point) const; QPointF mapFromScene(const QPointF &point) const; - QPointF mapFromGlobal(const QPointF &point) const; QRectF mapRectFromItem(const QQuickItem *item, const QRectF &rect) const; QRectF mapRectFromScene(const QRectF &rect) const; void polish(); - Q_INVOKABLE void mapFromItem(QQmlV4Function*) const; - Q_INVOKABLE void mapToItem(QQmlV4Function*) const; - Q_REVISION(2, 7) Q_INVOKABLE void mapFromGlobal(QQmlV4Function*) const; - Q_REVISION(2, 7) Q_INVOKABLE void mapToGlobal(QQmlV4Function*) const; +#if QT_DEPRECATED_SINCE(6, 5) + QT_DEPRECATED_VERSION_X_6_5("Use typed overload or mapRectFromItem") + void mapFromItem(QQmlV4FunctionPtr) const; +#endif + Q_INVOKABLE QPointF mapFromItem(const QQuickItem *item, const QPointF &point) const; + // overloads mainly exist for QML + Q_INVOKABLE QPointF mapFromItem(const QQuickItem *item, qreal x, qreal y); + Q_INVOKABLE QRectF mapFromItem(const QQuickItem *item, const QRectF &rect) const; + Q_INVOKABLE QRectF mapFromItem(const QQuickItem *item, qreal x, qreal y, qreal width, qreal height) const; + +#if QT_DEPRECATED_SINCE(6, 5) + QT_DEPRECATED_VERSION_X_6_5("Use typed overload or mapRectToItem") + void mapToItem(QQmlV4FunctionPtr) const; +#endif + Q_INVOKABLE QPointF mapToItem(const QQuickItem *item, const QPointF &point) const; + // overloads mainly exist for QML + Q_INVOKABLE QPointF mapToItem(const QQuickItem *item, qreal x, qreal y); + Q_INVOKABLE QRectF mapToItem(const QQuickItem *item, const QRectF &rect) const; + Q_INVOKABLE QRectF mapToItem(const QQuickItem *item, qreal x, qreal y, qreal width, qreal height) const; + +#if QT_DEPRECATED_SINCE(6, 5) + QT_DEPRECATED_VERSION_X_6_5("Use the typed overload") + Q_REVISION(2, 7) void mapFromGlobal(QQmlV4FunctionPtr) const; +#endif + Q_REVISION(2, 7) Q_INVOKABLE QPointF mapFromGlobal(qreal x, qreal y) const; + // overload mainly exists for QML + Q_REVISION(2, 7) Q_INVOKABLE QPointF mapFromGlobal(const QPointF &point) const; + +#if QT_DEPRECATED_SINCE(6, 5) + QT_DEPRECATED_VERSION_X_6_5("Use the typed overload") + Q_REVISION(2, 7) void mapToGlobal(QQmlV4FunctionPtr) const; +#endif + Q_REVISION(2, 7) Q_INVOKABLE QPointF mapToGlobal(qreal x, qreal y) const; + // overload only exist for QML + Q_REVISION(2, 7) Q_INVOKABLE QPointF mapToGlobal(const QPointF &point) const; + Q_INVOKABLE void forceActiveFocus(); Q_INVOKABLE void forceActiveFocus(Qt::FocusReason reason); Q_REVISION(2, 1) Q_INVOKABLE QQuickItem *nextItemInFocusChain(bool forward = true); Q_INVOKABLE QQuickItem *childAt(qreal x, qreal y) const; + Q_REVISION(6, 3) Q_INVOKABLE void ensurePolished(); + + Q_REVISION(6, 3) Q_INVOKABLE void dumpItemTree() const; #if QT_CONFIG(im) virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; @@ -376,6 +387,7 @@ Q_SIGNALS: void stateChanged(const QString &); void focusChanged(bool); void activeFocusChanged(bool); + Q_REVISION(6, 7) void focusPolicyChanged(Qt::FocusPolicy); Q_REVISION(2, 1) void activeFocusOnTabChanged(bool); void parentChanged(QQuickItem *); void transformOriginChanged(TransformOrigin); @@ -454,31 +466,51 @@ protected: virtual void releaseResources(); virtual void updatePolish(); -protected: QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent = nullptr); private: Q_PRIVATE_SLOT(d_func(), void _q_resourceObjectDeleted(QObject *)) - Q_PRIVATE_SLOT(d_func(), quint64 _q_createJSWrapper(QV4::ExecutionEngine *)) + Q_PRIVATE_SLOT(d_func(), quint64 _q_createJSWrapper(QQmlV4ExecutionEnginePtr)) friend class QQuickWindowPrivate; friend class QQuickDeliveryAgentPrivate; friend class QSGRenderer; friend class QAccessibleQuickItem; friend class QQuickAccessibleAttached; + friend class QQuickAnchorChanges; +#ifndef QT_NO_DEBUG_STREAM + friend Q_QUICK_EXPORT QDebug operator<<(QDebug debug, QQuickItem *item); +#endif + Q_DISABLE_COPY(QQuickItem) Q_DECLARE_PRIVATE(QQuickItem) }; Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickItem::Flags) +#ifndef Q_QDOC +template <> inline QQuickItem *qobject_cast<QQuickItem *>(QObject *o) +{ + if (!o || !o->isQuickItemType()) + return nullptr; + return static_cast<QQuickItem *>(o); +} +template <> inline const QQuickItem *qobject_cast<const QQuickItem *>(const QObject *o) +{ + if (!o || !o->isQuickItemType()) + return nullptr; + return static_cast<const QQuickItem *>(o); +} +#endif // !Q_QDOC + #ifndef QT_NO_DEBUG_STREAM -QDebug Q_QUICK_EXPORT operator<<(QDebug debug, QQuickItem *item); +QDebug Q_QUICK_EXPORT operator<<(QDebug debug, +#if QT_VERSION >= QT_VERSION_CHECK(7, 0, 0) + const #endif + QQuickItem *item); +#endif // QT_NO_DEBUG_STREAM QT_END_NAMESPACE -QML_DECLARE_TYPE(QQuickItem) -QML_DECLARE_TYPE(QQuickTransform) - #endif // QQUICKITEM_H |