From 104ea4accc8bf7d2e317c10638a299c3af267ede Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 6 Dec 2021 05:11:04 +0100 Subject: Make some qHash and comparison operators overloads hidden friends Restricts lookup scope more to necessary bits. Change-Id: Ia42c95aaa70534843b7f6a90bfc56d2a1202c612 Reviewed-by: Eike Ziller --- src/libs/clangsupport/alivemessage.h | 4 +- src/libs/clangsupport/annotationsmessage.h | 4 +- src/libs/clangsupport/filecontainer.h | 4 +- src/libs/extensionsystem/pluginspec.cpp | 11 +++-- src/libs/extensionsystem/pluginspec.h | 4 +- src/libs/languageserverprotocol/icontent.h | 18 +++---- src/libs/languageutils/componentversion.cpp | 6 +-- src/libs/languageutils/componentversion.h | 20 ++++---- src/libs/modelinglib/qmt/infrastructure/handle.h | 8 +--- src/libs/modelinglib/qmt/infrastructure/handles.h | 16 +++---- src/libs/modelinglib/qmt/infrastructure/uid.h | 44 +++++++---------- .../modelinglib/qmt/stereotype/customrelation.h | 24 +++++----- .../qmt/stereotype/stereotypecontroller.cpp | 30 ++++++------ src/libs/utils/id.cpp | 30 +++++------- src/libs/utils/id.h | 13 ++--- src/libs/utils/mimetypes/mimetype.h | 4 +- src/libs/utils/namevalueitem.h | 5 +- src/libs/utils/qtcprocess.h | 2 - src/plugins/clangtools/clangfileinfo.h | 9 ++-- src/plugins/clangtools/clangtoolsdiagnostic.h | 7 ++- src/plugins/clangtools/clangtoolsprojectsettings.h | 14 +++--- src/plugins/classview/classviewsymbolinformation.h | 10 +--- src/plugins/clearcase/clearcasesettings.h | 10 ++-- src/plugins/cmakeprojectmanager/cmakeconfigitem.h | 3 +- .../cmakeprojectmanager/fileapidataextractor.h | 3 +- src/plugins/coreplugin/find/findplugin.cpp | 20 ++++---- src/plugins/coreplugin/find/searchresultcolor.h | 14 +++--- src/plugins/coreplugin/icontext.h | 3 +- src/plugins/cppeditor/cppcodemodelsettings.h | 27 +++++------ src/plugins/cppeditor/cppprojectfile.h | 10 ++-- src/plugins/cppeditor/cppuseselections_test.cpp | 10 ++-- .../followsymbol_switchmethoddecldef_test.cpp | 14 +++--- src/plugins/debugger/analyzer/diagnosticlocation.h | 8 ++-- src/plugins/debugger/cdb/cdbparsehelpers.h | 4 +- src/plugins/git/gerrit/gerritparameters.h | 10 ++-- .../languageclient/semantichighlightsupport.h | 12 +++-- src/plugins/marketplace/productlistmodel.h | 24 +++++----- src/plugins/nim/suggest/clientrequests.cpp | 9 ++-- src/plugins/nim/suggest/clientrequests.h | 4 +- src/plugins/projectexplorer/abi.h | 19 ++++---- src/plugins/projectexplorer/buildtargetinfo.h | 40 ++++++++-------- src/plugins/projectexplorer/deployablefile.h | 24 +++++----- src/plugins/projectexplorer/headerpath.h | 10 ++-- .../projectexplorer/projectexplorersettings.h | 38 +++++++-------- src/plugins/projectexplorer/projectmacro.h | 28 +++++------ src/plugins/projectexplorer/task.h | 9 ++-- src/plugins/qmakeprojectmanager/qmakestep.h | 40 ++++++++-------- src/plugins/qmljseditor/qmljseditingsettingspage.h | 56 +++++++++++----------- src/plugins/qmlprofiler/qmleventlocation.h | 43 ++++++++--------- src/plugins/qmlprofiler/qmleventtype.h | 3 -- src/plugins/qmlprofiler/qmlnote.h | 11 ++--- src/plugins/qtsupport/codegensettings.h | 6 +-- src/plugins/remotelinux/deploymenttimeinfo.cpp | 7 ++- src/plugins/texteditor/behaviorsettings.h | 6 +-- src/plugins/texteditor/colorscheme.h | 18 ++++--- src/plugins/texteditor/commentssettings.h | 12 ++--- src/plugins/texteditor/completionsettings.h | 6 +-- src/plugins/texteditor/displaysettings.h | 6 +-- src/plugins/texteditor/extraencodingsettings.h | 12 ++--- src/plugins/texteditor/fontsettings.h | 6 +-- src/plugins/texteditor/marginsettings.h | 10 ++-- src/plugins/texteditor/snippets/snippetssettings.h | 11 ++--- src/plugins/texteditor/storagesettings.h | 7 +-- src/plugins/texteditor/tabsettings.h | 6 +-- src/plugins/texteditor/textdocumentlayout.h | 10 ++-- src/plugins/texteditor/typingsettings.h | 6 +-- src/plugins/vcsbase/commonvcssettings.h | 5 +- src/plugins/vcsbase/vcsbaseplugin.h | 12 ++--- src/shared/proparser/proitems.h | 4 +- src/shared/proparser/qmakeglobals.h | 6 +-- src/tools/clangbackend/source/clangdocument.h | 5 +- src/tools/clangbackend/source/clangjobrequest.h | 3 +- src/tools/clangbackend/source/clangtype.h | 4 +- src/tools/clangbackend/source/sourcerange.h | 3 +- tests/auto/qml/qmldesigner/testview.h | 9 ++-- 75 files changed, 458 insertions(+), 515 deletions(-) diff --git a/src/libs/clangsupport/alivemessage.h b/src/libs/clangsupport/alivemessage.h index 3e8f5c70f4..d5f519ac2d 100644 --- a/src/libs/clangsupport/alivemessage.h +++ b/src/libs/clangsupport/alivemessage.h @@ -48,9 +48,9 @@ public: { return true; } -}; -CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const AliveMessage &message); + friend CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const AliveMessage &message); +}; DECLARE_MESSAGE(AliveMessage) } diff --git a/src/libs/clangsupport/annotationsmessage.h b/src/libs/clangsupport/annotationsmessage.h index c3a19a82b4..fcafd00266 100644 --- a/src/libs/clangsupport/annotationsmessage.h +++ b/src/libs/clangsupport/annotationsmessage.h @@ -97,6 +97,8 @@ public: && first.skippedPreprocessorRanges == second.skippedPreprocessorRanges; } + friend CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const AnnotationsMessage &message); + public: FileContainer fileContainer; QVector tokenInfos; @@ -106,7 +108,5 @@ public: bool onlyTokenInfos = false; }; -CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const AnnotationsMessage &message); - DECLARE_MESSAGE(AnnotationsMessage) } // namespace ClangBackEnd diff --git a/src/libs/clangsupport/filecontainer.h b/src/libs/clangsupport/filecontainer.h index 4f9595f5ba..64180e2141 100644 --- a/src/libs/clangsupport/filecontainer.h +++ b/src/libs/clangsupport/filecontainer.h @@ -109,6 +109,8 @@ public: return first.filePath == second.filePath; } + friend CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const FileContainer &container); + public: Utf8String filePath; Utf8StringVector compilationArguments; @@ -119,6 +121,4 @@ public: bool hasUnsavedFileContent = false; }; -CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const FileContainer &container); - } // namespace ClangBackEnd diff --git a/src/libs/extensionsystem/pluginspec.cpp b/src/libs/extensionsystem/pluginspec.cpp index e3b2b07080..f4b1b93c86 100644 --- a/src/libs/extensionsystem/pluginspec.cpp +++ b/src/libs/extensionsystem/pluginspec.cpp @@ -46,6 +46,10 @@ #include #include +using namespace ExtensionSystem::Internal; + +namespace ExtensionSystem { + /*! \class ExtensionSystem::PluginDependency \inheaderfile extensionsystem/pluginspec.h @@ -148,14 +152,11 @@ \sa PluginSpec::argumentDescriptions() */ -using namespace ExtensionSystem; -using namespace ExtensionSystem::Internal; - /*! \fn uint ExtensionSystem::qHash(const ExtensionSystem::PluginDependency &value) \internal */ -Utils::QHashValueType ExtensionSystem::qHash(const PluginDependency &value) +Utils::QHashValueType qHash(const PluginDependency &value) { return qHash(value.name); } @@ -1125,3 +1126,5 @@ void PluginSpecPrivate::kill() plugin = nullptr; state = PluginSpec::Deleted; } + +} // ExtensionSystem diff --git a/src/libs/extensionsystem/pluginspec.h b/src/libs/extensionsystem/pluginspec.h index 4b2bcc1306..c8737c8aba 100644 --- a/src/libs/extensionsystem/pluginspec.h +++ b/src/libs/extensionsystem/pluginspec.h @@ -60,6 +60,8 @@ struct EXTENSIONSYSTEM_EXPORT PluginDependency PluginDependency() : type(Required) {} + friend Utils::QHashValueType qHash(const PluginDependency &value); + QString name; QString version; Type type; @@ -67,8 +69,6 @@ struct EXTENSIONSYSTEM_EXPORT PluginDependency QString toString() const; }; -Utils::QHashValueType qHash(const ExtensionSystem::PluginDependency &value); - struct EXTENSIONSYSTEM_EXPORT PluginArgumentDescription { QString name; diff --git a/src/libs/languageserverprotocol/icontent.h b/src/libs/languageserverprotocol/icontent.h index a19d9cc48c..35cc84382a 100644 --- a/src/libs/languageserverprotocol/icontent.h +++ b/src/libs/languageserverprotocol/icontent.h @@ -79,6 +79,15 @@ public: return {}; } + friend auto qHash(const MessageId &id) + { + if (Utils::holds_alternative(id)) + return QT_PREPEND_NAMESPACE(qHash(Utils::get(id))); + if (Utils::holds_alternative(id)) + return QT_PREPEND_NAMESPACE(qHash(Utils::get(id))); + return QT_PREPEND_NAMESPACE(qHash(0)); + } + private: bool m_valid = true; }; @@ -93,15 +102,6 @@ struct ResponseHandler using ResponseHandlers = std::function; using MethodHandler = std::function; -inline auto qHash(const LanguageServerProtocol::MessageId &id) -{ - if (Utils::holds_alternative(id)) - return QT_PREPEND_NAMESPACE(qHash(Utils::get(id))); - if (Utils::holds_alternative(id)) - return QT_PREPEND_NAMESPACE(qHash(Utils::get(id))); - return QT_PREPEND_NAMESPACE(qHash(0)); -} - template inline QDebug operator<<(QDebug stream, const LanguageServerProtocol::MessageId &id) { diff --git a/src/libs/languageutils/componentversion.cpp b/src/libs/languageutils/componentversion.cpp index 3d1a0e6e79..b5e355fc61 100644 --- a/src/libs/languageutils/componentversion.cpp +++ b/src/libs/languageutils/componentversion.cpp @@ -30,7 +30,7 @@ #include -using namespace LanguageUtils; +namespace LanguageUtils { const int ComponentVersion::NoVersion = -1; const int ComponentVersion::MaxVersion = std::numeric_limits::max(); @@ -87,8 +87,6 @@ void ComponentVersion::addToHash(QCryptographicHash &hash) const hash.addData(reinterpret_cast(&_minor), sizeof(_minor)); } -namespace LanguageUtils { - bool operator<(const ComponentVersion &lhs, const ComponentVersion &rhs) { return lhs.majorVersion() < rhs.majorVersion() @@ -121,4 +119,4 @@ bool operator!=(const ComponentVersion &lhs, const ComponentVersion &rhs) return !(lhs == rhs); } -} +} // namespace LanguageUtils diff --git a/src/libs/languageutils/componentversion.h b/src/libs/languageutils/componentversion.h index 8e271bccab..86273e3c99 100644 --- a/src/libs/languageutils/componentversion.h +++ b/src/libs/languageutils/componentversion.h @@ -47,21 +47,19 @@ public: explicit ComponentVersion(const QString &versionString); ~ComponentVersion(); - int majorVersion() const - { return _major; } - int minorVersion() const - { return _minor; } + int majorVersion() const { return _major; } + int minorVersion() const { return _minor; } + + friend bool LANGUAGEUTILS_EXPORT operator<(const ComponentVersion &lhs, const ComponentVersion &rhs); + friend bool LANGUAGEUTILS_EXPORT operator<=(const ComponentVersion &lhs, const ComponentVersion &rhs); + friend bool LANGUAGEUTILS_EXPORT operator>(const ComponentVersion &lhs, const ComponentVersion &rhs); + friend bool LANGUAGEUTILS_EXPORT operator>=(const ComponentVersion &lhs, const ComponentVersion &rhs); + friend bool LANGUAGEUTILS_EXPORT operator==(const ComponentVersion &lhs, const ComponentVersion &rhs); + friend bool LANGUAGEUTILS_EXPORT operator!=(const ComponentVersion &lhs, const ComponentVersion &rhs); bool isValid() const; QString toString() const; void addToHash(QCryptographicHash &hash) const; }; -bool LANGUAGEUTILS_EXPORT operator<(const ComponentVersion &lhs, const ComponentVersion &rhs); -bool LANGUAGEUTILS_EXPORT operator<=(const ComponentVersion &lhs, const ComponentVersion &rhs); -bool LANGUAGEUTILS_EXPORT operator>(const ComponentVersion &lhs, const ComponentVersion &rhs); -bool LANGUAGEUTILS_EXPORT operator>=(const ComponentVersion &lhs, const ComponentVersion &rhs); -bool LANGUAGEUTILS_EXPORT operator==(const ComponentVersion &lhs, const ComponentVersion &rhs); -bool LANGUAGEUTILS_EXPORT operator!=(const ComponentVersion &lhs, const ComponentVersion &rhs); - } // namespace LanguageUtils diff --git a/src/libs/modelinglib/qmt/infrastructure/handle.h b/src/libs/modelinglib/qmt/infrastructure/handle.h index 7558ec9699..511638e993 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 &handle) { return qHash(handle.uid()); } + private: Uid m_uid; T *m_target = nullptr; }; -template -inline auto qHash(const Handle &handle) -{ - return qHash(handle.uid()); -} - template bool operator==(const Handle &lhs, const Handle &rhs) { diff --git a/src/libs/modelinglib/qmt/infrastructure/handles.h b/src/libs/modelinglib/qmt/infrastructure/handles.h index 4b1d0e1c93..cb7714ef5c 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 &lhs, const Handles &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 -bool operator==(const Handles &lhs, const Handles &rhs) -{ - return lhs.get() == rhs.get(); -} - -template -bool operator!=(const Handles &lhs, const Handles &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 852daea248..04e1be3e39 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 d74bd0dd4e..31a1b62f98 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(relationship)); + } + + friend auto qHash(CustomRelation::ShaftPattern pattern) { + return ::qHash(static_cast(pattern)); + } + + friend auto qHash(CustomRelation::Head head) { + return ::qHash(static_cast(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(relationship)); -} - -inline auto qHash(CustomRelation::ShaftPattern pattern) { - return ::qHash(static_cast(pattern)); -} - -inline auto qHash(CustomRelation::Head head) { - return ::qHash(static_cast(head)); -} - } // namespace qmt diff --git a/src/libs/modelinglib/qmt/stereotype/stereotypecontroller.cpp b/src/libs/modelinglib/qmt/stereotype/stereotypecontroller.cpp index 925b7bb19a..b91ceb76ee 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 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 diff --git a/src/libs/utils/id.cpp b/src/libs/utils/id.cpp index 1349dd8488..9757a95250 100644 --- a/src/libs/utils/id.cpp +++ b/src/libs/utils/id.cpp @@ -72,23 +72,23 @@ public: h &= 0x0fffffff; } } + + friend auto qHash(const StringHolder &sh) + { + return QT_PREPEND_NAMESPACE(qHash)(sh.h, 0); + } + + friend bool operator==(const StringHolder &sh1, const StringHolder &sh2) + { + // sh.n is unlikely to discriminate better than the hash. + return sh1.h == sh2.h && sh1.str && sh2.str && strcmp(sh1.str, sh2.str) == 0; + } + int n = 0; const char *str = nullptr; quintptr h; }; -static bool operator==(const StringHolder &sh1, const StringHolder &sh2) -{ - // sh.n is unlikely to discriminate better than the hash. - return sh1.h == sh2.h && sh1.str && sh2.str && strcmp(sh1.str, sh2.str) == 0; -} - - -static auto qHash(const StringHolder &sh) -{ - return QT_PREPEND_NAMESPACE(qHash)(sh.h, 0); -} - struct IdCache : public QHash { #ifndef QTC_ALLOW_STATIC_LEAKS @@ -338,10 +338,6 @@ QString Id::suffixAfter(Id baseId) const return n.startsWith(b) ? QString::fromUtf8(n.mid(b.size())) : QString(); } -} // namespace Utils - -QT_BEGIN_NAMESPACE - QDataStream &operator<<(QDataStream &ds, Utils::Id id) { return ds << id.name(); @@ -360,4 +356,4 @@ QDebug operator<<(QDebug dbg, const Utils::Id &id) return dbg << id.name(); } -QT_END_NAMESPACE +} // namespace Utils diff --git a/src/libs/utils/id.h b/src/libs/utils/id.h index 5c6440bd56..b1b49fe2a8 100644 --- a/src/libs/utils/id.h +++ b/src/libs/utils/id.h @@ -74,21 +74,18 @@ public: static QSet fromStringList(const QStringList &list); static QStringList toStringList(const QSet &ids); + friend QHashValueType qHash(Id id) { return static_cast(id.uniqueIdentifier()); } + friend QTCREATOR_UTILS_EXPORT QDataStream &operator<<(QDataStream &ds, Utils::Id id); + friend QTCREATOR_UTILS_EXPORT QDataStream &operator>>(QDataStream &ds, Utils::Id &id); + friend QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug dbg, const Utils::Id &id); + private: explicit Id(quintptr uid) : m_id(uid) {} quintptr m_id = 0; }; -inline QHashValueType qHash(Id id) { return static_cast(id.uniqueIdentifier()); } - } // namespace Utils Q_DECLARE_METATYPE(Utils::Id) Q_DECLARE_METATYPE(QList) - -QT_BEGIN_NAMESPACE -QTCREATOR_UTILS_EXPORT QDataStream &operator<<(QDataStream &ds, Utils::Id id); -QTCREATOR_UTILS_EXPORT QDataStream &operator>>(QDataStream &ds, Utils::Id &id); -QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug dbg, const Utils::Id &id); -QT_END_NAMESPACE diff --git a/src/libs/utils/mimetypes/mimetype.h b/src/libs/utils/mimetypes/mimetype.h index ff0acaae34..86a1f6c9fa 100644 --- a/src/libs/utils/mimetypes/mimetype.h +++ b/src/libs/utils/mimetypes/mimetype.h @@ -109,6 +109,8 @@ public: bool matchesName(const QString &nameOrAlias) const; void setPreferredSuffix(const QString &suffix); + friend auto qHash(const MimeType &mime) { return qHash(mime.name()); } + protected: friend class Internal::MimeTypeParserBase; friend class Internal::MimeTypeMapEntry; @@ -120,8 +122,6 @@ protected: QExplicitlySharedDataPointer d; }; -inline auto qHash(const MimeType &mime) { return qHash(mime.name()); } - } // Utils //Q_DECLARE_SHARED(Utils::MimeType) diff --git a/src/libs/utils/namevalueitem.h b/src/libs/utils/namevalueitem.h index 1ec203115a..654b4be5bf 100644 --- a/src/libs/utils/namevalueitem.h +++ b/src/libs/utils/namevalueitem.h @@ -60,12 +60,13 @@ public: return first.operation == second.operation && first.name == second.name && first.value == second.value; } - friend bool operator!=(const NameValueItem &first, const NameValueItem &second) { return !(first == second); } + friend QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug debug, const NameValueItem &i); + public: QString name; QString value; @@ -75,6 +76,4 @@ private: void apply(NameValueDictionary *dictionary, Operation op) const; }; -QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug debug, const NameValueItem &i); - } // namespace Utils diff --git a/src/libs/utils/qtcprocess.h b/src/libs/utils/qtcprocess.h index bfe597a4fd..59c1769af6 100644 --- a/src/libs/utils/qtcprocess.h +++ b/src/libs/utils/qtcprocess.h @@ -218,6 +218,4 @@ private: using ExitCodeInterpreter = std::function; -QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug str, const QtcProcess &); - } // namespace Utils diff --git a/src/plugins/clangtools/clangfileinfo.h b/src/plugins/clangtools/clangfileinfo.h index 5052af23ad..7f2e94a82f 100644 --- a/src/plugins/clangtools/clangfileinfo.h +++ b/src/plugins/clangtools/clangfileinfo.h @@ -46,16 +46,17 @@ public: , kind(kind) , projectPart(projectPart) {} + + friend bool operator==(const FileInfo &lhs, const FileInfo &rhs) { + return lhs.file == rhs.file; + } + Utils::FilePath file; CppEditor::ProjectFile::Kind kind; CppEditor::ProjectPart::ConstPtr projectPart; }; using FileInfos = std::vector; -inline bool operator==(const FileInfo &lhs, const FileInfo &rhs) { - return lhs.file == rhs.file; -} - class FileInfoSelection { public: QSet dirs; diff --git a/src/plugins/clangtools/clangtoolsdiagnostic.h b/src/plugins/clangtools/clangtoolsdiagnostic.h index 10534ff0b2..58961d0ca9 100644 --- a/src/plugins/clangtools/clangtoolsdiagnostic.h +++ b/src/plugins/clangtools/clangtoolsdiagnostic.h @@ -57,6 +57,9 @@ public: bool isValid() const; QIcon icon() const; + friend bool operator==(const Diagnostic &lhs, const Diagnostic &rhs); + friend Utils::QHashValueType qHash(const Diagnostic &diagnostic); + QString name; QString description; QString category; @@ -66,12 +69,8 @@ public: bool hasFixits = false; }; -bool operator==(const Diagnostic &lhs, const Diagnostic &rhs); - using Diagnostics = QList; -Utils::QHashValueType qHash(const Diagnostic &diagnostic); - } // namespace Internal } // namespace ClangTools diff --git a/src/plugins/clangtools/clangtoolsprojectsettings.h b/src/plugins/clangtools/clangtoolsprojectsettings.h index 686aafedfb..be68e5d80b 100644 --- a/src/plugins/clangtools/clangtoolsprojectsettings.h +++ b/src/plugins/clangtools/clangtoolsprojectsettings.h @@ -47,18 +47,18 @@ public: SuppressedDiagnostic(const Diagnostic &diag); + friend bool operator==(const SuppressedDiagnostic &d1, const SuppressedDiagnostic &d2) + { + return d1.filePath == d2.filePath + && d1.description == d2.description + && d1.uniquifier == d2.uniquifier; + } + Utils::FilePath filePath; // Relative for files in project, absolute otherwise. QString description; int uniquifier; }; -inline bool operator==(const SuppressedDiagnostic &d1, const SuppressedDiagnostic &d2) -{ - return d1.filePath == d2.filePath - && d1.description == d2.description - && d1.uniquifier == d2.uniquifier; -} - using SuppressedDiagnosticsList = QList; class ClangToolsProjectSettings : public QObject diff --git a/src/plugins/classview/classviewsymbolinformation.h b/src/plugins/classview/classviewsymbolinformation.h index c6189c0b39..3e719bf89b 100644 --- a/src/plugins/classview/classviewsymbolinformation.h +++ b/src/plugins/classview/classviewsymbolinformation.h @@ -55,21 +55,15 @@ public: int iconTypeSortOrder() const; + friend auto qHash(const SymbolInformation &information) { return information.hash(); } + private: const int m_iconType; const Utils::QHashValueType m_hash; // precalculated hash value - to speed up qHash const QString m_name; // symbol name (e.g. SymbolInformation) const QString m_type; // symbol type (e.g. (int char)) - }; -//! qHash overload for QHash/QSet -inline auto qHash(const SymbolInformation &information) -{ - return information.hash(); -} - - } // namespace Internal } // namespace ClassView diff --git a/src/plugins/clearcase/clearcasesettings.h b/src/plugins/clearcase/clearcasesettings.h index e3700239f3..03391af6ae 100644 --- a/src/plugins/clearcase/clearcasesettings.h +++ b/src/plugins/clearcase/clearcasesettings.h @@ -54,6 +54,11 @@ public: bool equals(const ClearCaseSettings &s) const; + friend bool operator==(const ClearCaseSettings &p1, const ClearCaseSettings &p2) + { return p1.equals(p2); } + friend bool operator!=(const ClearCaseSettings &p1, const ClearCaseSettings &p2) + { return !p1.equals(p2); } + QString ccCommand; QString ccBinaryPath; DiffType diffType = GraphicalDiff; @@ -71,10 +76,5 @@ public: int timeOutS; }; -inline bool operator==(const ClearCaseSettings &p1, const ClearCaseSettings &p2) -{ return p1.equals(p2); } -inline bool operator!=(const ClearCaseSettings &p1, const ClearCaseSettings &p2) -{ return !p1.equals(p2); } - } // namespace Internal } // namespace ClearCase diff --git a/src/plugins/cmakeprojectmanager/cmakeconfigitem.h b/src/plugins/cmakeprojectmanager/cmakeconfigitem.h index 19bbbfd7d6..f94674f623 100644 --- a/src/plugins/cmakeprojectmanager/cmakeconfigitem.h +++ b/src/plugins/cmakeprojectmanager/cmakeconfigitem.h @@ -68,6 +68,7 @@ public: QString toCMakeSetLine(const Utils::MacroExpander *expander = nullptr) const; bool operator==(const CMakeConfigItem &o) const; + friend Utils::QHashValueType qHash(const CMakeConfigItem &it); // needed for MSVC QByteArray key; Type type = STRING; @@ -79,8 +80,6 @@ public: QStringList values; }; -Utils::QHashValueType qHash(const CMakeConfigItem &it); // needed for MSVC - class CMAKE_EXPORT CMakeConfig : public QList { public: diff --git a/src/plugins/cmakeprojectmanager/fileapidataextractor.h b/src/plugins/cmakeprojectmanager/fileapidataextractor.h index 1bc99bf1a8..6a5b905a6e 100644 --- a/src/plugins/cmakeprojectmanager/fileapidataextractor.h +++ b/src/plugins/cmakeprojectmanager/fileapidataextractor.h @@ -48,6 +48,7 @@ class CMakeFileInfo { public: bool operator==(const CMakeFileInfo& other) const { return path == other.path; } + friend auto qHash(const CMakeFileInfo &info, uint seed = 0) { return info.path.hash(seed); } Utils::FilePath path; bool isCMake = false; @@ -56,8 +57,6 @@ public: bool isGenerated = false; }; -inline auto qHash(const CMakeFileInfo &info, uint seed = 0) { return info.path.hash(seed); } - class FileApiQtcData { public: diff --git a/src/plugins/coreplugin/find/findplugin.cpp b/src/plugins/coreplugin/find/findplugin.cpp index 4376553bee..57b6a5649e 100644 --- a/src/plugins/coreplugin/find/findplugin.cpp +++ b/src/plugins/coreplugin/find/findplugin.cpp @@ -75,20 +75,20 @@ namespace Core { struct CompletionEntry { + friend QDebug operator<<(QDebug d, const CompletionEntry &e) + { + QDebugStateSaver saver(d); + d.noquote(); + d.nospace(); + d << "CompletionEntry(\"" << e.text << "\", flags=" + << "0x" << QString::number(e.findFlags, 16) << ')'; + return d; + } + QString text; FindFlags findFlags; }; -QDebug operator<<(QDebug d, const CompletionEntry &e) -{ - QDebugStateSaver saver(d); - d.noquote(); - d.nospace(); - d << "CompletionEntry(\"" << e.text << "\", flags=" - << "0x" << QString::number(e.findFlags, 16) << ')'; - return d; -} - class CompletionModel : public QAbstractListModel { public: diff --git a/src/plugins/coreplugin/find/searchresultcolor.h b/src/plugins/coreplugin/find/searchresultcolor.h index ec1b4c1bd4..9a68f1c35a 100644 --- a/src/plugins/coreplugin/find/searchresultcolor.h +++ b/src/plugins/coreplugin/find/searchresultcolor.h @@ -32,7 +32,8 @@ namespace Core { -class CORE_EXPORT SearchResultColor { +class CORE_EXPORT SearchResultColor +{ public: enum class Style { Default, Alt1, Alt2 }; @@ -48,18 +49,17 @@ public: highlightForeground = textForeground; } + friend auto qHash(SearchResultColor::Style style) + { + return QT_PREPEND_NAMESPACE(qHash(int(style))); + } + QColor textBackground; QColor textForeground; QColor highlightBackground; QColor highlightForeground; }; - -inline auto qHash(SearchResultColor::Style style) -{ - return QT_PREPEND_NAMESPACE(qHash(int(style))); -} - using SearchResultColors = QHash; } // namespace Core diff --git a/src/plugins/coreplugin/icontext.h b/src/plugins/coreplugin/icontext.h index 792217edb9..9ba7f5c219 100644 --- a/src/plugins/coreplugin/icontext.h +++ b/src/plugins/coreplugin/icontext.h @@ -82,6 +82,8 @@ public: virtual void setWidget(QWidget *widget) { m_widget = widget; } virtual void setContextHelp(const HelpItem &id) { m_contextHelp = id; } + friend CORE_EXPORT QDebug operator<<(QDebug debug, const Core::Context &context); + protected: Context m_context; QPointer m_widget; @@ -89,4 +91,3 @@ protected: }; } // namespace Core -CORE_EXPORT QDebug operator<<(QDebug debug, const Core::Context &context); diff --git a/src/plugins/cppeditor/cppcodemodelsettings.h b/src/plugins/cppeditor/cppcodemodelsettings.h index afebead552..3508233575 100644 --- a/src/plugins/cppeditor/cppcodemodelsettings.h +++ b/src/plugins/cppeditor/cppcodemodelsettings.h @@ -107,6 +107,18 @@ public: QVariantMap toMap() const; void fromMap(const QVariantMap &map); + friend bool operator==(const Data &s1, const Data &s2) + { + return s1.useClangd == s2.useClangd + && s1.executableFilePath == s2.executableFilePath + && s1.sessionsWithOneClangd == s2.sessionsWithOneClangd + && s1.workerThreadLimit == s2.workerThreadLimit + && s1.enableIndexing == s2.enableIndexing + && s1.autoIncludeHeaders == s2.autoIncludeHeaders + && s1.documentUpdateThreshold == s2.documentUpdateThreshold; + } + friend bool operator!=(const Data &s1, const Data &s2) { return !(s1 == s2); } + Utils::FilePath executableFilePath; QStringList sessionsWithOneClangd; int workerThreadLimit = 0; @@ -153,21 +165,6 @@ private: Data m_data; }; -inline bool operator==(const ClangdSettings::Data &s1, const ClangdSettings::Data &s2) -{ - return s1.useClangd == s2.useClangd - && s1.executableFilePath == s2.executableFilePath - && s1.sessionsWithOneClangd == s2.sessionsWithOneClangd - && s1.workerThreadLimit == s2.workerThreadLimit - && s1.enableIndexing == s2.enableIndexing - && s1.autoIncludeHeaders == s2.autoIncludeHeaders - && s1.documentUpdateThreshold == s2.documentUpdateThreshold; -} -inline bool operator!=(const ClangdSettings::Data &s1, const ClangdSettings::Data &s2) -{ - return !(s1 == s2); -} - class CPPEDITOR_EXPORT ClangdProjectSettings { public: diff --git a/src/plugins/cppeditor/cppprojectfile.h b/src/plugins/cppeditor/cppprojectfile.h index 1bd80fdf65..52b3f5b4c3 100644 --- a/src/plugins/cppeditor/cppprojectfile.h +++ b/src/plugins/cppeditor/cppprojectfile.h @@ -50,6 +50,9 @@ public: OpenCLSource, }; + ProjectFile() = default; + ProjectFile(const QString &filePath, Kind kind, bool active = true); + static Kind classifyByMimeType(const QString &mt); static Kind classify(const QString &filePath); @@ -69,12 +72,10 @@ public: bool isC() const; bool isCxx() const; -public: - ProjectFile() = default; - ProjectFile(const QString &filePath, Kind kind, bool active = true); - bool operator==(const ProjectFile &other) const; + friend QDebug operator<<(QDebug stream, const CppEditor::ProjectFile &projectFile); +public: QString path; Kind kind = Unclassified; bool active = true; @@ -83,6 +84,5 @@ public: using ProjectFiles = QVector; const char *projectFileKindToText(ProjectFile::Kind kind); -QDebug operator<<(QDebug stream, const CppEditor::ProjectFile &projectFile); } // namespace CppEditor diff --git a/src/plugins/cppeditor/cppuseselections_test.cpp b/src/plugins/cppeditor/cppuseselections_test.cpp index ecf27e406a..2bf5e6271c 100644 --- a/src/plugins/cppeditor/cppuseselections_test.cpp +++ b/src/plugins/cppeditor/cppuseselections_test.cpp @@ -33,8 +33,13 @@ #include // Uses 1-based line and 0-based column. -struct Selection { +struct Selection +{ Selection(int line, int column, int length) : line(line), column(column), length(length) {} + + friend bool operator==(const Selection &l, const Selection &r) + { return l.line == r.line && l.column == r.column && l.length == r.length; } + int line; int column; int length; @@ -42,9 +47,6 @@ struct Selection { typedef QList SelectionList; Q_DECLARE_METATYPE(SelectionList) -inline bool operator==(const Selection &l, const Selection &r) -{ return l.line == r.line && l.column == r.column && l.length == r.length; } - QT_BEGIN_NAMESPACE namespace QTest { template<> char *toString(const Selection &selection) diff --git a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp index 59bd65c092..8cfff10c65 100644 --- a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp +++ b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp @@ -82,27 +82,29 @@ using namespace TextEditor; using namespace Core; using namespace ProjectExplorer; -class OverrideItem { +class OverrideItem +{ public: OverrideItem() : line(0) {} OverrideItem(const QString &text, int line = 0) : text(text), line(line) {} + bool isValid() { return line != 0; } QByteArray toByteArray() const { return "OverrideItem(" + text.toLatin1() + ", " + QByteArray::number(line) + ')'; } + friend bool operator==(const OverrideItem &lhs, const OverrideItem &rhs) + { + return lhs.text == rhs.text && lhs.line == rhs.line; + } + QString text; int line; }; typedef QList OverrideItemList; Q_DECLARE_METATYPE(OverrideItem) -inline bool operator==(const OverrideItem &lhs, const OverrideItem &rhs) -{ - return lhs.text == rhs.text && lhs.line == rhs.line; -} - QT_BEGIN_NAMESPACE namespace QTest { template<> char *toString(const OverrideItem &data) diff --git a/src/plugins/debugger/analyzer/diagnosticlocation.h b/src/plugins/debugger/analyzer/diagnosticlocation.h index 76459d7661..fe52fe9248 100644 --- a/src/plugins/debugger/analyzer/diagnosticlocation.h +++ b/src/plugins/debugger/analyzer/diagnosticlocation.h @@ -43,6 +43,10 @@ public: bool isValid() const; + DEBUGGER_EXPORT friend bool operator==(const DiagnosticLocation &first, const DiagnosticLocation &second); + DEBUGGER_EXPORT friend bool operator<(const DiagnosticLocation &first, const DiagnosticLocation &second); + DEBUGGER_EXPORT friend QDebug operator<<(QDebug dbg, const DiagnosticLocation &location); + Utils::FilePath filePath; // Both values start at 1. @@ -50,10 +54,6 @@ public: int column = 0; }; -DEBUGGER_EXPORT bool operator==(const DiagnosticLocation &first, const DiagnosticLocation &second); -DEBUGGER_EXPORT bool operator<(const DiagnosticLocation &first, const DiagnosticLocation &second); -DEBUGGER_EXPORT QDebug operator<<(QDebug dbg, const DiagnosticLocation &location); - } // namespace Debugger Q_DECLARE_METATYPE(Debugger::DiagnosticLocation) diff --git a/src/plugins/debugger/cdb/cdbparsehelpers.h b/src/plugins/debugger/cdb/cdbparsehelpers.h index 5053a6de7e..ab39ebc612 100644 --- a/src/plugins/debugger/cdb/cdbparsehelpers.h +++ b/src/plugins/debugger/cdb/cdbparsehelpers.h @@ -79,6 +79,8 @@ struct WinException void fromGdbMI(const GdbMi &); QString toString(bool includeLocation = false) const; + friend QDebug operator<<(QDebug s, const WinException &e); + unsigned exceptionCode = 0; unsigned exceptionFlags = 0; quint64 exceptionAddress = 0; @@ -90,7 +92,5 @@ struct WinException QString function; }; -QDebug operator<<(QDebug s, const WinException &e); - } // namespace Internal } // namespace Debugger diff --git a/src/plugins/git/gerrit/gerritparameters.h b/src/plugins/git/gerrit/gerritparameters.h index 96e03fd559..5c0d89a3e4 100644 --- a/src/plugins/git/gerrit/gerritparameters.h +++ b/src/plugins/git/gerrit/gerritparameters.h @@ -46,6 +46,11 @@ public: void fromSettings(const QSettings *); void setPortFlagBySshType(); + friend bool operator==(const GerritParameters &p1, const GerritParameters &p2) + { return p1.equals(p2); } + friend bool operator!=(const GerritParameters &p1, const GerritParameters &p2) + { return !p1.equals(p2); } + GerritServer server; Utils::FilePath ssh; Utils::FilePath curl; @@ -54,10 +59,5 @@ public: QString portFlag; }; -inline bool operator==(const GerritParameters &p1, const GerritParameters &p2) -{ return p1.equals(p2); } -inline bool operator!=(const GerritParameters &p1, const GerritParameters &p2) -{ return !p1.equals(p2); } - } // namespace Internal } // namespace Gerrit diff --git a/src/plugins/languageclient/semantichighlightsupport.h b/src/plugins/languageclient/semantichighlightsupport.h index 724e85f837..d6a9fc314d 100644 --- a/src/plugins/languageclient/semantichighlightsupport.h +++ b/src/plugins/languageclient/semantichighlightsupport.h @@ -44,17 +44,19 @@ class Client; class LANGUAGECLIENT_EXPORT ExpandedSemanticToken { public: + friend bool operator==(const ExpandedSemanticToken &t1, const ExpandedSemanticToken &t2) + { + return t1.line == t2.line && t1.column == t2.column && t1.length == t2.length + && t1.type == t2.type && t1.modifiers == t2.modifiers; + } + int line = -1; int column = -1; int length = -1; QString type; QStringList modifiers; }; -inline bool operator==(const ExpandedSemanticToken &t1, const ExpandedSemanticToken &t2) -{ - return t1.line == t2.line && t1.column == t2.column && t1.length == t2.length - && t1.type == t2.type && t1.modifiers == t2.modifiers; -} + using SemanticTokensHandler = std::function &, int, bool)>; diff --git a/src/plugins/marketplace/productlistmodel.h b/src/plugins/marketplace/productlistmodel.h index df2070f213..6581bc344a 100644 --- a/src/plugins/marketplace/productlistmodel.h +++ b/src/plugins/marketplace/productlistmodel.h @@ -60,22 +60,22 @@ protected: struct Section { + friend bool operator<(const Section &lhs, const Section &rhs) + { + if (lhs.priority < rhs.priority) + return true; + return lhs.priority > rhs.priority ? false : lhs.name < rhs.name; + } + + friend bool operator==(const Section &lhs, const Section &rhs) + { + return lhs.priority == rhs.priority && lhs.name == rhs.name; + } + QString name; int priority; }; -inline bool operator<(const Section &lhs, const Section &rhs) -{ - if (lhs.priority < rhs.priority) - return true; - return lhs.priority > rhs.priority ? false : lhs.name < rhs.name; -} - -inline bool operator==(const Section &lhs, const Section &rhs) -{ - return lhs.priority == rhs.priority && lhs.name == rhs.name; -} - class SectionedProducts : public QStackedWidget { Q_OBJECT diff --git a/src/plugins/nim/suggest/clientrequests.cpp b/src/plugins/nim/suggest/clientrequests.cpp index 4b1429a204..7dc7d9260f 100644 --- a/src/plugins/nim/suggest/clientrequests.cpp +++ b/src/plugins/nim/suggest/clientrequests.cpp @@ -51,14 +51,13 @@ NimSuggestClientRequest::NimSuggestClientRequest(quint64 id) : m_id(id) {} - -} // namespace Suggest -} // namespace Nim - -QDebug operator<<(QDebug debug, const Nim::Suggest::Line &c) +QDebug operator<<(QDebug debug, const Line &c) { QDebugStateSaver saver(debug); debug.space() << c.line_type << c.symbol_kind << c.symbol_type << c.data << c.row << c.column << c.abs_path; return debug; } + +} // namespace Suggest +} // namespace Nim diff --git a/src/plugins/nim/suggest/clientrequests.h b/src/plugins/nim/suggest/clientrequests.h index 39c6719929..e9ca91b205 100644 --- a/src/plugins/nim/suggest/clientrequests.h +++ b/src/plugins/nim/suggest/clientrequests.h @@ -83,6 +83,8 @@ public: static bool fromString(LineType &type, const std::string &str); static bool fromString(SymbolKind &type, const std::string &str); + friend QDebug operator<<(QDebug debug, const Line &c); + LineType line_type; SymbolKind symbol_kind; QString abs_path; @@ -133,5 +135,3 @@ private: } // namespace Suggest } // namespace Nim - -QDebug operator<<(QDebug debug, const Nim::Suggest::Line &c); diff --git a/src/plugins/projectexplorer/abi.h b/src/plugins/projectexplorer/abi.h index 56272baced..a1f7142991 100644 --- a/src/plugins/projectexplorer/abi.h +++ b/src/plugins/projectexplorer/abi.h @@ -184,6 +184,15 @@ public: static Abi hostAbi(); static Abis abisOfBinary(const Utils::FilePath &path); + friend auto qHash(const ProjectExplorer::Abi &abi) + { + int h = abi.architecture() + + (abi.os() << 3) + + (abi.osFlavor() << 6) + + (abi.binaryFormat() << 10) + + (abi.wordWidth() << 13); + return QT_PREPEND_NAMESPACE(qHash)(h); + } private: Architecture m_architecture; @@ -194,14 +203,4 @@ private: QString m_param; }; -inline auto qHash(const ProjectExplorer::Abi &abi) -{ - int h = abi.architecture() - + (abi.os() << 3) - + (abi.osFlavor() << 6) - + (abi.binaryFormat() << 10) - + (abi.wordWidth() << 13); - return QT_PREPEND_NAMESPACE(qHash)(h); -} - } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/buildtargetinfo.h b/src/plugins/projectexplorer/buildtargetinfo.h index 34d5f19624..7b5ef1984b 100644 --- a/src/plugins/projectexplorer/buildtargetinfo.h +++ b/src/plugins/projectexplorer/buildtargetinfo.h @@ -52,28 +52,28 @@ public: Utils::QHashValueType runEnvModifierHash = 0; // Make sure to update this when runEnvModifier changes! std::function runEnvModifier; -}; -inline bool operator==(const BuildTargetInfo &ti1, const BuildTargetInfo &ti2) -{ - return ti1.buildKey == ti2.buildKey - && ti1.displayName == ti2.displayName - && ti1.targetFilePath == ti2.targetFilePath - && ti1.projectFilePath == ti2.projectFilePath - && ti1.workingDirectory == ti2.workingDirectory - && ti1.isQtcRunnable == ti2.isQtcRunnable - && ti1.usesTerminal == ti2.usesTerminal - && ti1.runEnvModifierHash == ti2.runEnvModifierHash; -} + friend bool operator==(const BuildTargetInfo &ti1, const BuildTargetInfo &ti2) + { + return ti1.buildKey == ti2.buildKey + && ti1.displayName == ti2.displayName + && ti1.targetFilePath == ti2.targetFilePath + && ti1.projectFilePath == ti2.projectFilePath + && ti1.workingDirectory == ti2.workingDirectory + && ti1.isQtcRunnable == ti2.isQtcRunnable + && ti1.usesTerminal == ti2.usesTerminal + && ti1.runEnvModifierHash == ti2.runEnvModifierHash; + } -inline bool operator!=(const BuildTargetInfo &ti1, const BuildTargetInfo &ti2) -{ - return !(ti1 == ti2); -} + friend bool operator!=(const BuildTargetInfo &ti1, const BuildTargetInfo &ti2) + { + return !(ti1 == ti2); + } -inline auto qHash(const BuildTargetInfo &ti) -{ - return qHash(ti.displayName) ^ qHash(ti.buildKey); -} + friend auto qHash(const BuildTargetInfo &ti) + { + return qHash(ti.displayName) ^ qHash(ti.buildKey); + } +}; } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/deployablefile.h b/src/plugins/projectexplorer/deployablefile.h index e3760e4a02..cc3273623e 100644 --- a/src/plugins/projectexplorer/deployablefile.h +++ b/src/plugins/projectexplorer/deployablefile.h @@ -55,23 +55,21 @@ public: bool isExecutable() const; + friend bool operator==(const DeployableFile &d1, const DeployableFile &d2) + { + return d1.localFilePath() == d2.localFilePath() && d1.remoteDirectory() == d2.remoteDirectory(); + } + + friend bool operator!=(const DeployableFile &d1, const DeployableFile &d2) + { + return !(d1 == d2); + } + friend PROJECTEXPLORER_EXPORT Utils::QHashValueType qHash(const DeployableFile &d); + private: Utils::FilePath m_localFilePath; QString m_remoteDir; Type m_type = TypeNormal; }; - -inline bool operator==(const DeployableFile &d1, const DeployableFile &d2) -{ - return d1.localFilePath() == d2.localFilePath() && d1.remoteDirectory() == d2.remoteDirectory(); -} - -inline bool operator!=(const DeployableFile &d1, const DeployableFile &d2) -{ - return !(d1 == d2); -} - -PROJECTEXPLORER_EXPORT Utils::QHashValueType qHash(const DeployableFile &d); - } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/headerpath.h b/src/plugins/projectexplorer/headerpath.h index 37492fe9f1..ef7d7b3d7d 100644 --- a/src/plugins/projectexplorer/headerpath.h +++ b/src/plugins/projectexplorer/headerpath.h @@ -76,15 +76,15 @@ public: return {fp, HeaderPathType::Framework}; } + friend auto qHash(const HeaderPath &key, uint seed = 0) + { + return ((qHash(key.path) << 2) | uint(key.type)) ^ seed; + } + QString path; HeaderPathType type = HeaderPathType::User; }; -inline auto qHash(const HeaderPath &key, uint seed = 0) -{ - return ((qHash(key.path) << 2) | uint(key.type)) ^ seed; -} - using HeaderPaths = QVector; template HeaderPaths toHeaderPaths(const C &list, HeaderPathType type) { diff --git a/src/plugins/projectexplorer/projectexplorersettings.h b/src/plugins/projectexplorer/projectexplorersettings.h index b5cbd7db3f..818651e7da 100644 --- a/src/plugins/projectexplorer/projectexplorersettings.h +++ b/src/plugins/projectexplorer/projectexplorersettings.h @@ -43,6 +43,25 @@ enum class StopBeforeBuild { None, SameProject, All, SameBuildDir, SameApp }; class ProjectExplorerSettings { public: + friend bool operator==(const ProjectExplorerSettings &p1, const ProjectExplorerSettings &p2) + { + return p1.buildBeforeDeploy == p2.buildBeforeDeploy + && p1.deployBeforeRun == p2.deployBeforeRun + && p1.saveBeforeBuild == p2.saveBeforeBuild + && p1.useJom == p2.useJom + && p1.autorestoreLastSession == p2.autorestoreLastSession + && p1.prompToStopRunControl == p2.prompToStopRunControl + && p1.automaticallyCreateRunConfigurations == p2.automaticallyCreateRunConfigurations + && p1.addLibraryPathsToRunEnv == p2.addLibraryPathsToRunEnv + && p1.environmentId == p2.environmentId + && p1.stopBeforeBuild == p2.stopBeforeBuild + && p1.terminalMode == p2.terminalMode + && p1.closeSourceFilesWithProject == p2.closeSourceFilesWithProject + && p1.clearIssuesOnRebuild == p2.clearIssuesOnRebuild + && p1.abortBuildAllOnError == p2.abortBuildAllOnError + && p1.lowBuildPriority == p2.lowBuildPriority; + } + BuildBeforeRunMode buildBeforeDeploy = BuildBeforeRunMode::WholeProject; bool deployBeforeRun = true; bool saveBeforeBuild = false; @@ -66,25 +85,6 @@ public: QUuid environmentId; }; -inline bool operator==(const ProjectExplorerSettings &p1, const ProjectExplorerSettings &p2) -{ - return p1.buildBeforeDeploy == p2.buildBeforeDeploy - && p1.deployBeforeRun == p2.deployBeforeRun - && p1.saveBeforeBuild == p2.saveBeforeBuild - && p1.useJom == p2.useJom - && p1.autorestoreLastSession == p2.autorestoreLastSession - && p1.prompToStopRunControl == p2.prompToStopRunControl - && p1.automaticallyCreateRunConfigurations == p2.automaticallyCreateRunConfigurations - && p1.addLibraryPathsToRunEnv == p2.addLibraryPathsToRunEnv - && p1.environmentId == p2.environmentId - && p1.stopBeforeBuild == p2.stopBeforeBuild - && p1.terminalMode == p2.terminalMode - && p1.closeSourceFilesWithProject == p2.closeSourceFilesWithProject - && p1.clearIssuesOnRebuild == p2.clearIssuesOnRebuild - && p1.abortBuildAllOnError == p2.abortBuildAllOnError - && p1.lowBuildPriority == p2.lowBuildPriority; -} - class AppOutputSettings { public: diff --git a/src/plugins/projectexplorer/projectmacro.h b/src/plugins/projectexplorer/projectmacro.h index 76125b53af..0cdef8fee3 100644 --- a/src/plugins/projectexplorer/projectmacro.h +++ b/src/plugins/projectexplorer/projectmacro.h @@ -70,6 +70,19 @@ public: static Macro fromKeyValue(const QByteArray &text); QByteArray toKeyValue(const QByteArray &prefix) const; + friend auto qHash(const Macro ¯o) + { + using QT_PREPEND_NAMESPACE(qHash); + return qHash(macro.key) ^ qHash(macro.value) ^ qHash(int(macro.type)); + } + + friend bool operator==(const Macro &first, const Macro &second) + { + return first.type == second.type + && first.key == second.key + && first.value == second.value; + } + public: QByteArray key; QByteArray value; @@ -84,19 +97,4 @@ private: static Macros tokensLinesToMacros(const QList> &tokensLines); }; -inline -auto qHash(const Macro ¯o) -{ - using QT_PREPEND_NAMESPACE(qHash); - return qHash(macro.key) ^ qHash(macro.value) ^ qHash(int(macro.type)); -} - -inline -bool operator==(const Macro &first, const Macro &second) -{ - return first.type == second.type - && first.key == second.key - && first.value == second.value; -} - } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/task.h b/src/plugins/projectexplorer/task.h index b95d51d34e..52cebcfc04 100644 --- a/src/plugins/projectexplorer/task.h +++ b/src/plugins/projectexplorer/task.h @@ -77,6 +77,10 @@ public: QString description() const; QIcon icon() const; + friend PROJECTEXPLORER_EXPORT bool operator==(const Task &t1, const Task &t2); + friend PROJECTEXPLORER_EXPORT bool operator<(const Task &a, const Task &b); + friend PROJECTEXPLORER_EXPORT Utils::QHashValueType qHash(const Task &task); + unsigned int taskId = 0; TaskType type = Unknown; Options options = AddTextMark | FlashWorthy; @@ -136,11 +140,6 @@ public: using Tasks = QVector; -PROJECTEXPLORER_EXPORT bool operator==(const Task &t1, const Task &t2); -PROJECTEXPLORER_EXPORT Utils::QHashValueType qHash(const Task &task); - -PROJECTEXPLORER_EXPORT bool operator<(const Task &a, const Task &b); - PROJECTEXPLORER_EXPORT QString toHtml(const Tasks &issues); PROJECTEXPLORER_EXPORT bool containsType(const Tasks &issues, Task::TaskType); diff --git a/src/plugins/qmakeprojectmanager/qmakestep.h b/src/plugins/qmakeprojectmanager/qmakestep.h index 17e1fe2f13..c028dbce18 100644 --- a/src/plugins/qmakeprojectmanager/qmakestep.h +++ b/src/plugins/qmakeprojectmanager/qmakestep.h @@ -78,6 +78,25 @@ public: QStringList toArguments() const; + friend bool operator==(const QMakeStepConfig &a, const QMakeStepConfig &b) + { + return std::tie(a.archConfig, a.osType, a.linkQmlDebuggingQQ2) + == std::tie(b.archConfig, b.osType, b.linkQmlDebuggingQQ2) + && std::tie(a.useQtQuickCompiler, a.separateDebugInfo) + == std::tie(b.useQtQuickCompiler, b.separateDebugInfo); + } + + friend bool operator!=(const QMakeStepConfig &a, const QMakeStepConfig &b) { return !(a == b); } + + friend QDebug operator<<(QDebug dbg, const QMakeStepConfig &c) + { + dbg << c.archConfig << c.osType + << (c.linkQmlDebuggingQQ2 == Utils::TriState::Enabled) + << (c.useQtQuickCompiler == Utils::TriState::Enabled) + << (c.separateDebugInfo == Utils::TriState::Enabled); + return dbg; + } + // Actual data QString sysRoot; QString targetTriple; @@ -89,27 +108,6 @@ public: Utils::TriState useQtQuickCompiler; }; - -inline bool operator ==(const QMakeStepConfig &a, const QMakeStepConfig &b) { - return std::tie(a.archConfig, a.osType, a.linkQmlDebuggingQQ2) - == std::tie(b.archConfig, b.osType, b.linkQmlDebuggingQQ2) - && std::tie(a.useQtQuickCompiler, a.separateDebugInfo) - == std::tie(b.useQtQuickCompiler, b.separateDebugInfo); -} - -inline bool operator !=(const QMakeStepConfig &a, const QMakeStepConfig &b) { - return !(a == b); -} - -inline QDebug operator<<(QDebug dbg, const QMakeStepConfig &c) -{ - dbg << c.archConfig << c.osType - << (c.linkQmlDebuggingQQ2 == Utils::TriState::Enabled) - << (c.useQtQuickCompiler == Utils::TriState::Enabled) - << (c.separateDebugInfo == Utils::TriState::Enabled); - return dbg; -} - class QMAKEPROJECTMANAGER_EXPORT QMakeStep : public ProjectExplorer::AbstractProcessStep { Q_OBJECT diff --git a/src/plugins/qmljseditor/qmljseditingsettingspage.h b/src/plugins/qmljseditor/qmljseditingsettingspage.h index e3536a44ef..296bc64b41 100644 --- a/src/plugins/qmljseditor/qmljseditingsettingspage.h +++ b/src/plugins/qmljseditor/qmljseditingsettingspage.h @@ -36,46 +36,46 @@ QT_END_NAMESPACE namespace QmlJSEditor { - class QmlJsEditingSettings { - public: - QmlJsEditingSettings(); - - static QmlJsEditingSettings get(); - void set(); +class QmlJsEditingSettings +{ +public: + QmlJsEditingSettings(); - void fromSettings(QSettings *); - void toSettings(QSettings *) const; + static QmlJsEditingSettings get(); + void set(); - bool equals(const QmlJsEditingSettings &other) const; + void fromSettings(QSettings *); + void toSettings(QSettings *) const; - bool enableContextPane() const; - void setEnableContextPane(const bool enableContextPane); + bool equals(const QmlJsEditingSettings &other) const; - bool pinContextPane() const; - void setPinContextPane(const bool pinContextPane); + bool enableContextPane() const; + void setEnableContextPane(const bool enableContextPane); - bool autoFormatOnSave() const; - void setAutoFormatOnSave(const bool autoFormatOnSave); + bool pinContextPane() const; + void setPinContextPane(const bool pinContextPane); - bool autoFormatOnlyCurrentProject() const; - void setAutoFormatOnlyCurrentProject(const bool autoFormatOnlyCurrentProject); + bool autoFormatOnSave() const; + void setAutoFormatOnSave(const bool autoFormatOnSave); - bool foldAuxData() const; - void setFoldAuxData(const bool foldAuxData); + bool autoFormatOnlyCurrentProject() const; + void setAutoFormatOnlyCurrentProject(const bool autoFormatOnlyCurrentProject); - private: - bool m_enableContextPane; - bool m_pinContextPane; - bool m_autoFormatOnSave; - bool m_autoFormatOnlyCurrentProject; - bool m_foldAuxData; - }; + bool foldAuxData() const; + void setFoldAuxData(const bool foldAuxData); - inline bool operator==(const QmlJsEditingSettings &s1, const QmlJsEditingSettings &s2) + friend bool operator==(const QmlJsEditingSettings &s1, const QmlJsEditingSettings &s2) { return s1.equals(s2); } - inline bool operator!=(const QmlJsEditingSettings &s1, const QmlJsEditingSettings &s2) + friend bool operator!=(const QmlJsEditingSettings &s1, const QmlJsEditingSettings &s2) { return !s1.equals(s2); } +private: + bool m_enableContextPane; + bool m_pinContextPane; + bool m_autoFormatOnSave; + bool m_autoFormatOnlyCurrentProject; + bool m_foldAuxData; +}; namespace Internal { diff --git a/src/plugins/qmlprofiler/qmleventlocation.h b/src/plugins/qmlprofiler/qmleventlocation.h index 5faf907101..0c6fb2007d 100644 --- a/src/plugins/qmlprofiler/qmleventlocation.h +++ b/src/plugins/qmlprofiler/qmleventlocation.h @@ -55,6 +55,26 @@ public: int line() const { return m_line; } int column() const { return m_column; } + friend bool operator==(const QmlEventLocation &location1, const QmlEventLocation &location2) + { + // compare filename last as it's expensive. + return location1.line() == location2.line() && location1.column() == location2.column() + && location1.filename() == location2.filename(); + } + + friend bool operator!=(const QmlEventLocation &location1, const QmlEventLocation &location2) + { + return !(location1 == location2); + } + + friend auto qHash(const QmlEventLocation &location) + { + return qHash(location.filename()) + ^ ((location.line() & 0xfff) // 12 bits of line number + | ((location.column() << 16) & 0xff0000)); // 8 bits of column + + } + private: friend QDataStream &operator>>(QDataStream &stream, QmlEventLocation &location); friend QDataStream &operator<<(QDataStream &stream, const QmlEventLocation &location); @@ -64,29 +84,6 @@ private: int m_column = -1; }; -inline bool operator==(const QmlEventLocation &location1, const QmlEventLocation &location2) -{ - // compare filename last as it's expensive. - return location1.line() == location2.line() && location1.column() == location2.column() - && location1.filename() == location2.filename(); -} - -inline bool operator!=(const QmlEventLocation &location1, const QmlEventLocation &location2) -{ - return !(location1 == location2); -} - -inline auto qHash(const QmlEventLocation &location) -{ - return qHash(location.filename()) - ^ ((location.line() & 0xfff) // 12 bits of line number - | ((location.column() << 16) & 0xff0000)); // 8 bits of column - -} - -QDataStream &operator>>(QDataStream &stream, QmlEventLocation &location); -QDataStream &operator<<(QDataStream &stream, const QmlEventLocation &location); - } // namespace QmlProfiler QT_BEGIN_NAMESPACE diff --git a/src/plugins/qmlprofiler/qmleventtype.h b/src/plugins/qmlprofiler/qmleventtype.h index ee87dc94d2..9eb9954075 100644 --- a/src/plugins/qmlprofiler/qmleventtype.h +++ b/src/plugins/qmlprofiler/qmleventtype.h @@ -63,9 +63,6 @@ private: int m_detailType; // can be EventType, BindingType, PixmapEventType or SceneGraphFrameType }; -QDataStream &operator>>(QDataStream &stream, QmlEventType &type); -QDataStream &operator<<(QDataStream &stream, const QmlEventType &type); - } // namespace QmlProfiler Q_DECLARE_METATYPE(QmlProfiler::QmlEventType) diff --git a/src/plugins/qmlprofiler/qmlnote.h b/src/plugins/qmlprofiler/qmlnote.h index 1178ccaca6..919d215faf 100644 --- a/src/plugins/qmlprofiler/qmlnote.h +++ b/src/plugins/qmlprofiler/qmlnote.h @@ -48,10 +48,13 @@ public: void setText(const QString &text) { m_text = text; } void setLoaded(bool loaded) { m_loaded = loaded; } -private: + friend bool operator==(const QmlNote ¬e1, const QmlNote ¬e2); + friend bool operator!=(const QmlNote ¬e1, const QmlNote ¬e2); + friend QDataStream &operator>>(QDataStream &stream, QmlNote ¬e); friend QDataStream &operator<<(QDataStream &stream, const QmlNote ¬e); +private: int m_typeIndex; int m_collapsedRow; qint64 m_startTime; @@ -60,12 +63,6 @@ private: bool m_loaded; }; -bool operator==(const QmlNote ¬e1, const QmlNote ¬e2); -bool operator!=(const QmlNote ¬e1, const QmlNote ¬e2); - -QDataStream &operator>>(QDataStream &stream, QmlNote ¬e); -QDataStream &operator<<(QDataStream &stream, const QmlNote ¬e); - } // namespace QmlProfiler Q_DECLARE_METATYPE(QmlProfiler::QmlNote) diff --git a/src/plugins/qtsupport/codegensettings.h b/src/plugins/qtsupport/codegensettings.h index a5973683a2..22187df9de 100644 --- a/src/plugins/qtsupport/codegensettings.h +++ b/src/plugins/qtsupport/codegensettings.h @@ -48,13 +48,13 @@ public: void fromSettings(const QSettings *settings); void toSettings(QSettings *settings) const; + friend bool operator==(const CodeGenSettings &p1, const CodeGenSettings &p2) { return p1.equals(p2); } + friend bool operator!=(const CodeGenSettings &p1, const CodeGenSettings &p2) { return !p1.equals(p2); } + UiClassEmbedding embedding; bool retranslationSupport; // Add handling for language change events bool includeQtModule; // Include "" or just "<[Class]>" bool addQtVersionCheck; // Include #ifdef when using "#include m_formats; QString m_displayName; }; -inline bool operator==(const ColorScheme &cs1, const ColorScheme &cs2) { return cs1.equals(cs2); } -inline bool operator!=(const ColorScheme &cs1, const ColorScheme &cs2) { return !cs1.equals(cs2); } - } // namespace TextEditor diff --git a/src/plugins/texteditor/commentssettings.h b/src/plugins/texteditor/commentssettings.h index 23a7545122..c1a20a650f 100644 --- a/src/plugins/texteditor/commentssettings.h +++ b/src/plugins/texteditor/commentssettings.h @@ -43,15 +43,15 @@ public: bool equals(const CommentsSettings &other) const; + friend bool operator==(const CommentsSettings &a, const CommentsSettings &b) + { return a.equals(b); } + + friend bool operator!=(const CommentsSettings &a, const CommentsSettings &b) + { return !(a == b); } + bool m_enableDoxygen; bool m_generateBrief; bool m_leadingAsterisks; }; -inline bool operator==(const CommentsSettings &a, const CommentsSettings &b) -{ return a.equals(b); } - -inline bool operator!=(const CommentsSettings &a, const CommentsSettings &b) -{ return !(a == b); } - } // namespace TextEditor diff --git a/src/plugins/texteditor/completionsettings.h b/src/plugins/texteditor/completionsettings.h index fd274a42c0..fb153f85f5 100644 --- a/src/plugins/texteditor/completionsettings.h +++ b/src/plugins/texteditor/completionsettings.h @@ -56,6 +56,9 @@ public: bool equals(const CompletionSettings &bs) const; + friend bool operator==(const CompletionSettings &t1, const CompletionSettings &t2) { return t1.equals(t2); } + friend bool operator!=(const CompletionSettings &t1, const CompletionSettings &t2) { return !t1.equals(t2); } + CaseSensitivity m_caseSensitivity = CaseInsensitive; CompletionTrigger m_completionTrigger = AutomaticCompletion; int m_automaticProposalTimeoutInMs = 400; @@ -74,7 +77,4 @@ public: bool m_overwriteClosingChars = false; }; -inline bool operator==(const CompletionSettings &t1, const CompletionSettings &t2) { return t1.equals(t2); } -inline bool operator!=(const CompletionSettings &t1, const CompletionSettings &t2) { return !t1.equals(t2); } - } // namespace TextEditor diff --git a/src/plugins/texteditor/displaysettings.h b/src/plugins/texteditor/displaysettings.h index 73114e6538..ae87f76dfb 100644 --- a/src/plugins/texteditor/displaysettings.h +++ b/src/plugins/texteditor/displaysettings.h @@ -52,6 +52,9 @@ public: void toSettings(const QString &category, QSettings *s) const; void fromSettings(const QString &category, const QSettings *s); + friend bool operator==(const DisplaySettings &t1, const DisplaySettings &t2) { return t1.equals(t2); } + friend bool operator!=(const DisplaySettings &t1, const DisplaySettings &t2) { return !t1.equals(t2); } + bool m_displayLineNumbers = true; bool m_textWrapping = false; bool m_visualizeWhitespace = false; @@ -78,9 +81,6 @@ public: static QLabel *createAnnotationSettingsLink(); }; -inline bool operator==(const DisplaySettings &t1, const DisplaySettings &t2) { return t1.equals(t2); } -inline bool operator!=(const DisplaySettings &t1, const DisplaySettings &t2) { return !t1.equals(t2); } - } // namespace TextEditor Q_DECLARE_METATYPE(TextEditor::AnnotationAlignment) diff --git a/src/plugins/texteditor/extraencodingsettings.h b/src/plugins/texteditor/extraencodingsettings.h index ee45b58ace..ce16ae46fc 100644 --- a/src/plugins/texteditor/extraencodingsettings.h +++ b/src/plugins/texteditor/extraencodingsettings.h @@ -49,6 +49,12 @@ public: bool equals(const ExtraEncodingSettings &s) const; + friend bool operator==(const ExtraEncodingSettings &a, const ExtraEncodingSettings &b) + { return a.equals(b); } + + friend bool operator!=(const ExtraEncodingSettings &a, const ExtraEncodingSettings &b) + { return !a.equals(b); } + static QStringList lineTerminationModeNames(); enum Utf8BomSetting { @@ -59,10 +65,4 @@ public: Utf8BomSetting m_utf8BomSetting; }; -inline bool operator==(const ExtraEncodingSettings &a, const ExtraEncodingSettings &b) -{ return a.equals(b); } - -inline bool operator!=(const ExtraEncodingSettings &a, const ExtraEncodingSettings &b) -{ return !a.equals(b); } - } // TextEditor diff --git a/src/plugins/texteditor/fontsettings.h b/src/plugins/texteditor/fontsettings.h index 9447141434..e476951eac 100644 --- a/src/plugins/texteditor/fontsettings.h +++ b/src/plugins/texteditor/fontsettings.h @@ -98,6 +98,9 @@ public: static QString defaultSchemeFileName(const QString &fileName = QString()); + friend bool operator==(const FontSettings &f1, const FontSettings &f2) { return f1.equals(f2); } + friend bool operator!=(const FontSettings &f1, const FontSettings &f2) { return !f1.equals(f2); } + private: void addMixinStyle(QTextCharFormat &textCharFormat, const MixinTextStyles &mixinStyles) const; @@ -112,7 +115,4 @@ private: mutable QHash m_textCharFormatCache; }; -inline bool operator==(const FontSettings &f1, const FontSettings &f2) { return f1.equals(f2); } -inline bool operator!=(const FontSettings &f1, const FontSettings &f2) { return !f1.equals(f2); } - } // namespace TextEditor diff --git a/src/plugins/texteditor/marginsettings.h b/src/plugins/texteditor/marginsettings.h index e7f6d3bac6..d9c5eeed7f 100644 --- a/src/plugins/texteditor/marginsettings.h +++ b/src/plugins/texteditor/marginsettings.h @@ -48,14 +48,14 @@ public: bool equals(const MarginSettings &other) const; + friend bool operator==(const MarginSettings &one, const MarginSettings &two) + { return one.equals(two); } + friend bool operator!=(const MarginSettings &one, const MarginSettings &two) + { return !one.equals(two); } + bool m_showMargin; bool m_useIndenter; int m_marginColumn; }; -inline bool operator==(const MarginSettings &one, const MarginSettings &two) -{ return one.equals(two); } -inline bool operator!=(const MarginSettings &one, const MarginSettings &two) -{ return !one.equals(two); } - } // namespace TextEditor diff --git a/src/plugins/texteditor/snippets/snippetssettings.h b/src/plugins/texteditor/snippets/snippetssettings.h index 88df3ad0e8..f8e27ee11e 100644 --- a/src/plugins/texteditor/snippets/snippetssettings.h +++ b/src/plugins/texteditor/snippets/snippetssettings.h @@ -46,14 +46,13 @@ public: bool equals(const SnippetsSettings &snippetsSettings) const; + friend bool operator==(const SnippetsSettings &a, const SnippetsSettings &b) + { return a.equals(b); } + friend bool operator!=(const SnippetsSettings &a, const SnippetsSettings &b) + { return !a.equals(b); } + private: QString m_lastUsedSnippetGroup; }; -inline bool operator==(const SnippetsSettings &a, const SnippetsSettings &b) -{ return a.equals(b); } - -inline bool operator!=(const SnippetsSettings &a, const SnippetsSettings &b) -{ return !a.equals(b); } - } // TextEditor diff --git a/src/plugins/texteditor/storagesettings.h b/src/plugins/texteditor/storagesettings.h index 70dc5b784b..6755dffa67 100644 --- a/src/plugins/texteditor/storagesettings.h +++ b/src/plugins/texteditor/storagesettings.h @@ -50,6 +50,10 @@ public: bool removeTrailingWhitespace(const QString &filePattern) const; bool equals(const StorageSettings &ts) const; + friend bool operator==(const StorageSettings &t1, const StorageSettings &t2) + { return t1.equals(t2); } + friend bool operator!=(const StorageSettings &t1, const StorageSettings &t2) + { return !t1.equals(t2); } QString m_ignoreFileTypes; bool m_cleanWhitespace; @@ -59,7 +63,4 @@ public: bool m_skipTrailingWhitespace; }; -inline bool operator==(const StorageSettings &t1, const StorageSettings &t2) { return t1.equals(t2); } -inline bool operator!=(const StorageSettings &t1, const StorageSettings &t2) { return !t1.equals(t2); } - } // namespace TextEditor diff --git a/src/plugins/texteditor/tabsettings.h b/src/plugins/texteditor/tabsettings.h index 731dd75caf..274dd44576 100644 --- a/src/plugins/texteditor/tabsettings.h +++ b/src/plugins/texteditor/tabsettings.h @@ -81,6 +81,9 @@ public: bool isIndentationClean(const QTextBlock &block, const int indent) const; bool guessSpacesForTabs(const QTextBlock &block) const; + friend bool operator==(const TabSettings &t1, const TabSettings &t2) { return t1.equals(t2); } + friend bool operator!=(const TabSettings &t1, const TabSettings &t2) { return !t1.equals(t2); } + static int firstNonSpace(const QString &text); static inline bool onlySpace(const QString &text) { return firstNonSpace(text) == text.length(); } static int spacesLeftFromPosition(const QString &text, int position); @@ -96,9 +99,6 @@ public: bool equals(const TabSettings &ts) const; }; -inline bool operator==(const TabSettings &t1, const TabSettings &t2) { return t1.equals(t2); } -inline bool operator!=(const TabSettings &t1, const TabSettings &t2) { return !t1.equals(t2); } - } // namespace TextEditor Q_DECLARE_METATYPE(TextEditor::TabSettings) diff --git a/src/plugins/texteditor/textdocumentlayout.h b/src/plugins/texteditor/textdocumentlayout.h index ce86ad4296..5b8a0447c2 100644 --- a/src/plugins/texteditor/textdocumentlayout.h +++ b/src/plugins/texteditor/textdocumentlayout.h @@ -43,9 +43,11 @@ struct TEXTEDITOR_EXPORT Parenthesis { enum Type : char { Opened, Closed }; - inline Parenthesis() = default; - inline Parenthesis(Type t, QChar c, int position) - : pos(position), chr(c), type(t) {} + Parenthesis() = default; + Parenthesis(Type t, QChar c, int position) : pos(position), chr(c), type(t) {} + + friend TEXTEDITOR_EXPORT QDebug operator<<(QDebug debug, const Parenthesis &parenthesis); + int pos = -1; QChar chr; Utils::Id source; @@ -56,8 +58,6 @@ struct TEXTEDITOR_EXPORT Parenthesis using Parentheses = QVector; TEXTEDITOR_EXPORT void insertSorted(Parentheses &list, const Parenthesis &elem); -TEXTEDITOR_EXPORT QDebug operator<<(QDebug debug, const Parenthesis &parenthesis); - class TEXTEDITOR_EXPORT CodeFormatterData { public: diff --git a/src/plugins/texteditor/typingsettings.h b/src/plugins/texteditor/typingsettings.h index 39254b14a8..2a023d39fa 100644 --- a/src/plugins/texteditor/typingsettings.h +++ b/src/plugins/texteditor/typingsettings.h @@ -66,6 +66,9 @@ public: bool equals(const TypingSettings &ts) const; + friend bool operator==(const TypingSettings &t1, const TypingSettings &t2) { return t1.equals(t2); } + friend bool operator!=(const TypingSettings &t1, const TypingSettings &t2) { return !t1.equals(t2); } + bool m_autoIndent; TabKeyBehavior m_tabKeyBehavior; SmartBackspaceBehavior m_smartBackspaceBehavior; @@ -73,9 +76,6 @@ public: bool m_preferSingleLineComments; }; -inline bool operator==(const TypingSettings &t1, const TypingSettings &t2) { return t1.equals(t2); } -inline bool operator!=(const TypingSettings &t1, const TypingSettings &t2) { return !t1.equals(t2); } - } // namespace TextEditor Q_DECLARE_METATYPE(TextEditor::TypingSettings) diff --git a/src/plugins/vcsbase/commonvcssettings.h b/src/plugins/vcsbase/commonvcssettings.h index fdcafb0f49..975e2c6060 100644 --- a/src/plugins/vcsbase/commonvcssettings.h +++ b/src/plugins/vcsbase/commonvcssettings.h @@ -40,6 +40,8 @@ class CommonVcsSettings : public Utils::AspectContainer public: CommonVcsSettings(); + friend QDebug operator<<(QDebug, const CommonVcsSettings &); + Utils::StringAspect nickNameMailMap; Utils::StringAspect nickNameFieldListFile; @@ -52,9 +54,6 @@ public: Utils::IntegerAspect lineWrapWidth; }; - -QDebug operator<<(QDebug, const CommonVcsSettings &); - class CommonOptionsPage final : public Core::IOptionsPage { Q_OBJECT diff --git a/src/plugins/vcsbase/vcsbaseplugin.h b/src/plugins/vcsbase/vcsbaseplugin.h index 461b902c12..03f70603df 100644 --- a/src/plugins/vcsbase/vcsbaseplugin.h +++ b/src/plugins/vcsbase/vcsbaseplugin.h @@ -106,6 +106,11 @@ public: friend VCSBASE_EXPORT QDebug operator<<(QDebug in, const VcsBasePluginState &state); + friend bool operator==(const VcsBasePluginState &s1, const VcsBasePluginState &s2) + { return s1.equals(s2); } + friend bool operator!=(const VcsBasePluginState &s1, const VcsBasePluginState &s2) + { return !s1.equals(s2); } + private: friend class VcsBasePluginPrivate; bool equals(const Internal::State &s) const; @@ -114,13 +119,6 @@ private: QSharedDataPointer data; }; -VCSBASE_EXPORT QDebug operator<<(QDebug in, const VcsBasePluginState &state); - -inline bool operator==(const VcsBasePluginState &s1, const VcsBasePluginState &s2) -{ return s1.equals(s2); } -inline bool operator!=(const VcsBasePluginState &s1, const VcsBasePluginState &s2) -{ return !s1.equals(s2); } - // Convenience that searches for the repository specifically for version control // systems that do not have directories like "CVS" in each managed subdirectory // but have a directory at the top of the repository like ".git" containing diff --git a/src/shared/proparser/proitems.h b/src/shared/proparser/proitems.h index 4da7e5444b..d665798912 100644 --- a/src/shared/proparser/proitems.h +++ b/src/shared/proparser/proitems.h @@ -164,6 +164,8 @@ public: QByteArray toLatin1() const { return toStringView().toLatin1(); } + friend QDebug operator<<(QDebug debug, const ProString &str); + private: ProString(const ProKey &other); ProString &operator=(const ProKey &other); @@ -512,6 +514,4 @@ struct ProFunctionDefs { QHash replaceFunctions; }; -QDebug operator<<(QDebug debug, const ProString &str); - QT_END_NAMESPACE diff --git a/src/shared/proparser/qmakeglobals.h b/src/shared/proparser/qmakeglobals.h index 36b1c08c41..87e7fefd9f 100644 --- a/src/shared/proparser/qmakeglobals.h +++ b/src/shared/proparser/qmakeglobals.h @@ -54,14 +54,14 @@ class QMakeBaseKey public: QMakeBaseKey(const QString &_root, const QString &_stash, bool _hostBuild); + friend Utils::QHashValueType qHash(const QMakeBaseKey &key); + friend bool operator==(const QMakeBaseKey &one, const QMakeBaseKey &two); + QString root; QString stash; bool hostBuild; }; -Utils::QHashValueType qHash(const QMakeBaseKey &key); -bool operator==(const QMakeBaseKey &one, const QMakeBaseKey &two); - class QMakeBaseEnv { public: diff --git a/src/tools/clangbackend/source/clangdocument.h b/src/tools/clangbackend/source/clangdocument.h index bb2eb42ab4..a637731a6e 100644 --- a/src/tools/clangbackend/source/clangdocument.h +++ b/src/tools/clangbackend/source/clangdocument.h @@ -115,6 +115,9 @@ public: = PreferredTranslationUnit::RecentlyParsed) const; TranslationUnits &translationUnits() const; + friend bool operator==(const Document &first, const Document &second); + friend std::ostream &operator<<(std::ostream &os, const Document &document); + public: // for tests void parse() const; void reparse() const; @@ -136,6 +139,4 @@ private: mutable std::shared_ptr d; }; -bool operator==(const Document &first, const Document &second); -std::ostream &operator<<(std::ostream &os, const Document &document); } // namespace ClangBackEnd diff --git a/src/tools/clangbackend/source/clangjobrequest.h b/src/tools/clangbackend/source/clangjobrequest.h index 1580e327be..fde2eca4db 100644 --- a/src/tools/clangbackend/source/clangjobrequest.h +++ b/src/tools/clangbackend/source/clangjobrequest.h @@ -96,6 +96,7 @@ public: bool isTakeOverable() const; bool operator==(const JobRequest &other) const; + friend QDebug operator<<(QDebug debug, const JobRequest &jobRequest); public: quint64 id = 0; @@ -121,9 +122,7 @@ public: using JobRequests = QVector; -QDebug operator<<(QDebug debug, const JobRequest &jobRequest); std::ostream &operator<<(std::ostream &os, JobRequest::Type type); std::ostream &operator<<(std::ostream &os, PreferredTranslationUnit preferredTranslationUnit); - } // namespace ClangBackEnd diff --git a/src/tools/clangbackend/source/clangtype.h b/src/tools/clangbackend/source/clangtype.h index 53953392e3..c8dca274d9 100644 --- a/src/tools/clangbackend/source/clangtype.h +++ b/src/tools/clangbackend/source/clangtype.h @@ -40,6 +40,7 @@ class Type { friend class Cursor; friend bool operator==(Type first, Type second); + friend bool operator!=(Type first, Type second); public: bool isValid() const; @@ -80,9 +81,6 @@ private: CXType m_cxType; }; -bool operator==(Type first, Type second); -bool operator!=(Type first, Type second); - std::ostream &operator<<(std::ostream &os, CXTypeKind typeKind); std::ostream &operator<<(std::ostream &os, const Type &type); } // namespace ClangBackEnd diff --git a/src/tools/clangbackend/source/sourcerange.h b/src/tools/clangbackend/source/sourcerange.h index e21f32e9a6..9cef453b92 100644 --- a/src/tools/clangbackend/source/sourcerange.h +++ b/src/tools/clangbackend/source/sourcerange.h @@ -37,6 +37,7 @@ class SourceRange friend class FixIt; friend class Cursor; friend bool operator==(const SourceRange &first, const SourceRange &second); + friend std::ostream &operator<<(std::ostream &os, const SourceRange &sourceRange); public: SourceRange(); @@ -63,6 +64,4 @@ private: CXTranslationUnit cxTranslationUnit = nullptr; }; -bool operator==(const SourceRange &first, const SourceRange &second); -std::ostream &operator<<(std::ostream &os, const SourceRange &sourceRange); } // namespace ClangBackEnd diff --git a/tests/auto/qml/qmldesigner/testview.h b/tests/auto/qml/qmldesigner/testview.h index 6fb835e038..30881e5494 100644 --- a/tests/auto/qml/qmldesigner/testview.h +++ b/tests/auto/qml/qmldesigner/testview.h @@ -37,12 +37,16 @@ class TestView : public QmlDesigner::AbstractView { Q_OBJECT public: - struct MethodCall { + struct MethodCall + { MethodCall(const QString &n, const QStringList &args) : name(n), arguments(args) { } + friend bool operator==(TestView::MethodCall call1, TestView::MethodCall call2); + friend QDebug operator<<(QDebug debug, TestView::MethodCall call); + QString name; QStringList arguments; }; @@ -114,6 +118,3 @@ private: QList m_methodCalls; static QString serialize(AbstractView::PropertyChangeFlags change); }; - -bool operator==(TestView::MethodCall call1, TestView::MethodCall call2); -QDebug operator<<(QDebug debug, TestView::MethodCall call); -- cgit v1.2.3