diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2020-03-04 14:54:54 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2020-04-03 12:35:23 +0200 |
commit | 448b2a5d838d082c66ab649cc7b71c31761bf409 (patch) | |
tree | 17888b90b9e03eb52e2ba03611146a66a87e31a1 /src/quick/items/qquickitem_p.h | |
parent | f1fd2b982a2ceae92da9b4a3875c65ed8a49560d (diff) |
Replace QFlagPointer with QTaggedPointer
The latter has the advantage of allowing the use of a real type for the
tag, instead of the generic flag/flag2 boolean accessors.
Change-Id: Icc9e854ce4af3eb5808a4bed45aa22f377e223da
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/quick/items/qquickitem_p.h')
-rw-r--r-- | src/quick/items/qquickitem_p.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h index 6f39f3bdd2..395dfee496 100644 --- a/src/quick/items/qquickitem_p.h +++ b/src/quick/items/qquickitem_p.h @@ -397,7 +397,7 @@ public: QObjectList resourcesList; // Although acceptedMouseButtons is inside ExtraData, we actually store - // the LeftButton flag in the extra.flag() bit. This is because it is + // the LeftButton flag in the extra.tag() bit. This is because it is // extremely common to set acceptedMouseButtons to LeftButton, but very // rare to use any of the other buttons. Qt::MouseButtons acceptedMouseButtons; @@ -407,7 +407,14 @@ public: // 26 bits padding }; - QLazilyAllocated<ExtraData> extra; + + enum ExtraDataTag { + NoTag = 0x1, + LeftMouseButtonAccepted = 0x2 + }; + Q_DECLARE_FLAGS(ExtraDataTags, ExtraDataTag) + + QLazilyAllocated<ExtraData, ExtraDataTags> extra; // Contains mask QPointer<QObject> mask; // If the mask is an Item, inform it that it's being used as a mask (true) or is no longer being used (false) @@ -663,6 +670,8 @@ public: virtual void updatePolish() { } }; +Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickItemPrivate::ExtraDataTags) + /* Key filters can be installed on a QQuickItem, but not removed. Currently they are only used by attached objects (which are only destroyed on Item @@ -947,7 +956,7 @@ private: Qt::MouseButtons QQuickItemPrivate::acceptedMouseButtons() const { - return ((extra.flag() ? Qt::LeftButton : Qt::MouseButton(0)) | + return ((extra.tag().testFlag(LeftMouseButtonAccepted) ? Qt::LeftButton : Qt::MouseButton(0)) | (extra.isAllocated() ? extra->acceptedMouseButtons : Qt::MouseButtons{})); } |