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/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 ++--- 50 files changed, 332 insertions(+), 360 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/clangtools/clangfileinfo.h b/src/plugins/clangtools/clangfileinfo.h index 5052af23adf..7f2e94a82f0 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 10534ff0b22..58961d0ca9c 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 686aafedfb3..be68e5d80b5 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 c6189c0b39e..3e719bf89bf 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 e3700239f3d..03391af6ae9 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 19bbbfd7d66..f94674f6233 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 1bc99bf1a8b..6a5b905a6ed 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 4376553bee4..57b6a5649ec 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 ec1b4c1bd42..9a68f1c35ab 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 792217edb93..9ba7f5c219c 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 afebead5525..3508233575c 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 1bd80fdf65c..52b3f5b4c34 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 ecf27e406af..2bf5e6271c3 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 59bd65c092a..8cfff10c658 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 76459d7661e..fe52fe9248c 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 5053a6de7e1..ab39ebc612a 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 96e03fd5591..5c0d89a3e45 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 724e85f837e..d6a9fc314dd 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 df2070f213b..6581bc344a7 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 4b1429a2049..7dc7d9260fb 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 39c67199299..e9ca91b205f 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 56272baced3..a1f71429915 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 34d5f196244..7b5ef1984bb 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 e3760e4a02b..cc3273623e2 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 37492fe9f1e..ef7d7b3d7db 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 b5cbd7db3f7..818651e7da4 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 76125b53af4..0cdef8fee3e 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 b95d51d34ef..52cebcfc04a 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 17e1fe2f13c..c028dbce189 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 e3536a44ef6..296bc64b416 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 5faf9071019..0c6fb2007da 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 ee87dc94d2e..9eb9954075d 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 1178ccaca67..919d215fafd 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 a5973683a28..22187df9deb 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 23a7545122b..c1a20a650fe 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 fd274a42c0c..fb153f85f5e 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 73114e6538d..ae87f76dfbd 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 ee45b58ace7..ce16ae46fcd 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 9447141434c..e476951eac1 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 e7f6d3bac6a..d9c5eeed7fe 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 88df3ad0e8d..f8e27ee11ed 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 70dc5b784be..6755dffa67f 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 731dd75cafb..274dd445763 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 ce86ad42961..5b8a0447c2d 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 39254b14a87..2a023d39fa3 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 fdcafb0f493..975e2c6060a 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 461b902c122..03f70603df1 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 -- cgit v1.2.3