diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-10-27 23:54:08 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-10-28 20:36:12 +0100 |
commit | a3d71792ca018b1cff06dbefde20f6f4e06ee704 (patch) | |
tree | 6376412068fe583d2f9090c5f8afe69960c2be52 /src/gui | |
parent | 9b35f22b58bfdf0e88dfc5baa4387968a81c169a (diff) |
Make comparison operators hidden friends
Reduce ADL noise from QKeyEvent, QKeySequence::StandardKey, and
QPointingDeviceUniqueId.
Task-number: QTBUG-87973
Change-Id: Ib4a3190d03046949acb25b3fe68c611689b82565
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qevent.cpp | 17 | ||||
-rw-r--r-- | src/gui/kernel/qevent.h | 12 | ||||
-rw-r--r-- | src/gui/kernel/qpointingdevice.h | 10 |
3 files changed, 24 insertions, 15 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index b60672ce17..0c3b631608 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -5312,20 +5312,15 @@ qint64 QPointingDeviceUniqueId::numericId() const noexcept } /*! - \relates QPointingDeviceUniqueId + \fn bool QPointingDeviceUniqueId::operator==(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) \since 5.8 Returns whether the two unique pointer IDs \a lhs and \a rhs identify the same pointer (\c true) or not (\c false). */ -bool operator==(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) noexcept -{ - return lhs.numericId() == rhs.numericId(); -} /*! - \fn bool operator!=(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) - \relates QPointingDeviceUniqueId + \fn bool QPointingDeviceUniqueId::operator!=(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) \since 5.8 Returns whether the two unique pointer IDs \a lhs and \a rhs identify different pointers @@ -5333,6 +5328,14 @@ bool operator==(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) noexce */ /*! + \internal +*/ +bool QPointingDeviceUniqueId::equals(QPointingDeviceUniqueId other) const noexcept +{ + return numericId() == other.numericId(); +} + +/*! \relates QPointingDeviceUniqueId \since 5.8 diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index fe728bc40c..f4cbf6f7af 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -534,6 +534,13 @@ public: inline quint32 nativeVirtualKey() const { return m_virtualKey; } inline quint32 nativeModifiers() const { return m_modifiers; } +#if QT_CONFIG(shortcut) + friend inline bool operator==(QKeyEvent *e, QKeySequence::StandardKey key) + { return (e ? e->matches(key) : false); } + friend inline bool operator==(QKeySequence::StandardKey key, QKeyEvent *e) + { return (e ? e->matches(key) : false); } +#endif // QT_CONFIG(shortcut) + protected: QString m_text; int m_key; @@ -984,11 +991,6 @@ private: Q_GUI_EXPORT QDebug operator<<(QDebug, const QEvent *); #endif -#if QT_CONFIG(shortcut) -inline bool operator==(QKeyEvent *e, QKeySequence::StandardKey key){return (e ? e->matches(key) : false);} -inline bool operator==(QKeySequence::StandardKey key, QKeyEvent *e){return (e ? e->matches(key) : false);} -#endif // QT_CONFIG(shortcut) - class Q_GUI_EXPORT QTouchEvent : public QPointerEvent { public: diff --git a/src/gui/kernel/qpointingdevice.h b/src/gui/kernel/qpointingdevice.h index 30c7c8ca1a..c68039e88f 100644 --- a/src/gui/kernel/qpointingdevice.h +++ b/src/gui/kernel/qpointingdevice.h @@ -69,6 +69,13 @@ public: qint64 numericId() const noexcept; private: + bool equals(QPointingDeviceUniqueId other) const noexcept; + + friend inline bool operator==(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) noexcept + { return lhs.equals(rhs); } + friend inline bool operator!=(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) noexcept + { return !operator==(lhs, rhs); } + // TODO: for TUIO 2, or any other type of complex token ID, an internal // array (or hash) can be added to hold additional properties. // In this case, m_numericId will then turn into an index into that array (or hash). @@ -76,9 +83,6 @@ private: }; Q_DECLARE_TYPEINFO(QPointingDeviceUniqueId, Q_MOVABLE_TYPE); -Q_GUI_EXPORT bool operator==(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) noexcept; -inline bool operator!=(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) noexcept -{ return !operator==(lhs, rhs); } Q_GUI_EXPORT size_t qHash(QPointingDeviceUniqueId key, size_t seed = 0) noexcept; class Q_GUI_EXPORT QPointingDevice : public QInputDevice |