diff options
Diffstat (limited to 'src/libs/modelinglib')
5 files changed, 53 insertions, 69 deletions
diff --git a/src/libs/modelinglib/qmt/infrastructure/handle.h b/src/libs/modelinglib/qmt/infrastructure/handle.h index 7558ec96999..511638e9938 100644 --- a/src/libs/modelinglib/qmt/infrastructure/handle.h +++ b/src/libs/modelinglib/qmt/infrastructure/handle.h @@ -68,17 +68,13 @@ public: void clearTarget() { m_target = nullptr; } + friend auto qHash(const Handle<T> &handle) { return qHash(handle.uid()); } + private: Uid m_uid; T *m_target = nullptr; }; -template<class T> -inline auto qHash(const Handle<T> &handle) -{ - return qHash(handle.uid()); -} - template<class T, class U> bool operator==(const Handle<T> &lhs, const Handle<U> &rhs) { diff --git a/src/libs/modelinglib/qmt/infrastructure/handles.h b/src/libs/modelinglib/qmt/infrastructure/handles.h index 4b1d0e1c934..cb7714ef5c4 100644 --- a/src/libs/modelinglib/qmt/infrastructure/handles.h +++ b/src/libs/modelinglib/qmt/infrastructure/handles.h @@ -224,18 +224,16 @@ public: return take(indexOf(t)); } + friend bool operator==(const Handles<T> &lhs, const Handles<T> &rhs) + { + return lhs.get() == rhs.get(); + } + + friend bool operator!=(const Handles &lhs, const Handles &rhs) { return !(lhs == rhs); } + private: value_type m_handleList; bool m_takesOwnership = false; }; -template<typename T> -bool operator==(const Handles<T> &lhs, const Handles<T> &rhs) -{ - return lhs.get() == rhs.get(); -} - -template<typename T> -bool operator!=(const Handles<T> &lhs, const Handles<T> &rhs) { return !(lhs == rhs); } - } // namespace qmt diff --git a/src/libs/modelinglib/qmt/infrastructure/uid.h b/src/libs/modelinglib/qmt/infrastructure/uid.h index 852daea248f..04e1be3e390 100644 --- a/src/libs/modelinglib/qmt/infrastructure/uid.h +++ b/src/libs/modelinglib/qmt/infrastructure/uid.h @@ -51,37 +51,27 @@ public: QString toString() const { return m_uuid.toString(); } void fromString(const QString &s) { m_uuid = QUuid(s); } -private: - QUuid m_uuid; -}; + friend auto qHash(const Uid &uid) { return qHash(uid.get()); } -inline auto qHash(const Uid &uid) -{ - return qHash(uid.get()); -} - -inline bool operator==(const Uid &lhs, const Uid &rhs) -{ - return lhs.get() == rhs.get(); -} + friend bool operator==(const Uid &lhs, const Uid &rhs) { return lhs.get() == rhs.get(); } + friend bool operator!=(const Uid &lhs, const Uid &rhs) { return !operator==(lhs, rhs); } -inline bool operator!=(const Uid &lhs, const Uid &rhs) -{ - return !operator==(lhs, rhs); -} + friend QDataStream &operator<<(QDataStream &stream, const Uid &uid) + { + return stream << uid.get(); + } -inline QDataStream &operator<<(QDataStream &stream, const Uid &uid) -{ - return stream << uid.get(); -} + friend QDataStream &operator>>(QDataStream &stream, Uid &uid) + { + QUuid uuid; + stream >> uuid; + uid.setUuid(uuid); + return stream; + } -inline QDataStream &operator>>(QDataStream &stream, Uid &uid) -{ - QUuid uuid; - stream >> uuid; - uid.setUuid(uuid); - return stream; -} +private: + QUuid m_uuid; +}; } // namespace qmt diff --git a/src/libs/modelinglib/qmt/stereotype/customrelation.h b/src/libs/modelinglib/qmt/stereotype/customrelation.h index d74bd0dd4e4..31a1b62f985 100644 --- a/src/libs/modelinglib/qmt/stereotype/customrelation.h +++ b/src/libs/modelinglib/qmt/stereotype/customrelation.h @@ -136,6 +136,18 @@ public: QColor color() const { return m_color; } void setColor(const QColor &color); + friend auto qHash(CustomRelation::Relationship relationship) { + return ::qHash(static_cast<int>(relationship)); + } + + friend auto qHash(CustomRelation::ShaftPattern pattern) { + return ::qHash(static_cast<int>(pattern)); + } + + friend auto qHash(CustomRelation::Head head) { + return ::qHash(static_cast<int>(head)); + } + private: Element m_element = Element::Relation; QString m_id; @@ -151,16 +163,4 @@ private: QColor m_color; }; -inline auto qHash(CustomRelation::Relationship relationship) { - return ::qHash(static_cast<int>(relationship)); -} - -inline auto qHash(CustomRelation::ShaftPattern pattern) { - return ::qHash(static_cast<int>(pattern)); -} - -inline auto qHash(CustomRelation::Head head) { - return ::qHash(static_cast<int>(head)); -} - } // namespace qmt diff --git a/src/libs/modelinglib/qmt/stereotype/stereotypecontroller.cpp b/src/libs/modelinglib/qmt/stereotype/stereotypecontroller.cpp index 925b7bb19ab..b91ceb76ee1 100644 --- a/src/libs/modelinglib/qmt/stereotype/stereotypecontroller.cpp +++ b/src/libs/modelinglib/qmt/stereotype/stereotypecontroller.cpp @@ -58,6 +58,21 @@ struct IconKey { { } + friend bool operator==(const IconKey &lhs, const IconKey &rhs) { + return lhs.m_element == rhs.m_element + && lhs.m_stereotypes == rhs.m_stereotypes + && lhs.m_defaultIconPath == rhs.m_defaultIconPath + && lhs.m_styleUid == rhs.m_styleUid + && lhs.m_size == rhs.m_size + && lhs.m_margins == rhs.m_margins + && lhs.m_lineWidth == rhs.m_lineWidth; + } + + friend auto qHash(const IconKey &key) { + return ::qHash(key.m_element) + qHash(key.m_stereotypes) + qHash(key.m_defaultIconPath) + + qHash(key.m_styleUid) + ::qHash(key.m_size.width()) + ::qHash(key.m_size.height()); + } + const StereotypeIcon::Element m_element; const QList<QString> m_stereotypes; const QString m_defaultIconPath; @@ -67,21 +82,6 @@ struct IconKey { const qreal m_lineWidth; }; -bool operator==(const IconKey &lhs, const IconKey &rhs) { - return lhs.m_element == rhs.m_element - && lhs.m_stereotypes == rhs.m_stereotypes - && lhs.m_defaultIconPath == rhs.m_defaultIconPath - && lhs.m_styleUid == rhs.m_styleUid - && lhs.m_size == rhs.m_size - && lhs.m_margins == rhs.m_margins - && lhs.m_lineWidth == rhs.m_lineWidth; -} - -auto qHash(const IconKey &key) { - return ::qHash(key.m_element) + qHash(key.m_stereotypes) + qHash(key.m_defaultIconPath) - + qHash(key.m_styleUid) + ::qHash(key.m_size.width()) + ::qHash(key.m_size.height()); -} - } class StereotypeController::StereotypeControllerPrivate |