Make some qHash and comparison operators overloads hidden friends

Restricts lookup scope more to necessary bits.

Change-Id: Ia42c95aaa70534843b7f6a90bfc56d2a1202c612
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2021-12-06 05:11:04 +01:00
parent 8cb5c3cfdd
commit 104ea4accc
75 changed files with 461 additions and 518 deletions

View File

@@ -48,9 +48,9 @@ public:
{ {
return true; return true;
} }
};
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const AliveMessage &message); friend CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const AliveMessage &message);
};
DECLARE_MESSAGE(AliveMessage) DECLARE_MESSAGE(AliveMessage)
} }

View File

@@ -97,6 +97,8 @@ public:
&& first.skippedPreprocessorRanges == second.skippedPreprocessorRanges; && first.skippedPreprocessorRanges == second.skippedPreprocessorRanges;
} }
friend CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const AnnotationsMessage &message);
public: public:
FileContainer fileContainer; FileContainer fileContainer;
QVector<TokenInfoContainer> tokenInfos; QVector<TokenInfoContainer> tokenInfos;
@@ -106,7 +108,5 @@ public:
bool onlyTokenInfos = false; bool onlyTokenInfos = false;
}; };
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const AnnotationsMessage &message);
DECLARE_MESSAGE(AnnotationsMessage) DECLARE_MESSAGE(AnnotationsMessage)
} // namespace ClangBackEnd } // namespace ClangBackEnd

View File

@@ -109,6 +109,8 @@ public:
return first.filePath == second.filePath; return first.filePath == second.filePath;
} }
friend CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const FileContainer &container);
public: public:
Utf8String filePath; Utf8String filePath;
Utf8StringVector compilationArguments; Utf8StringVector compilationArguments;
@@ -119,6 +121,4 @@ public:
bool hasUnsavedFileContent = false; bool hasUnsavedFileContent = false;
}; };
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const FileContainer &container);
} // namespace ClangBackEnd } // namespace ClangBackEnd

View File

@@ -46,6 +46,10 @@
#include <QJsonValue> #include <QJsonValue>
#include <QPluginLoader> #include <QPluginLoader>
using namespace ExtensionSystem::Internal;
namespace ExtensionSystem {
/*! /*!
\class ExtensionSystem::PluginDependency \class ExtensionSystem::PluginDependency
\inheaderfile extensionsystem/pluginspec.h \inheaderfile extensionsystem/pluginspec.h
@@ -148,14 +152,11 @@
\sa PluginSpec::argumentDescriptions() \sa PluginSpec::argumentDescriptions()
*/ */
using namespace ExtensionSystem;
using namespace ExtensionSystem::Internal;
/*! /*!
\fn uint ExtensionSystem::qHash(const ExtensionSystem::PluginDependency &value) \fn uint ExtensionSystem::qHash(const ExtensionSystem::PluginDependency &value)
\internal \internal
*/ */
Utils::QHashValueType ExtensionSystem::qHash(const PluginDependency &value) Utils::QHashValueType qHash(const PluginDependency &value)
{ {
return qHash(value.name); return qHash(value.name);
} }
@@ -1125,3 +1126,5 @@ void PluginSpecPrivate::kill()
plugin = nullptr; plugin = nullptr;
state = PluginSpec::Deleted; state = PluginSpec::Deleted;
} }
} // ExtensionSystem

View File

@@ -60,6 +60,8 @@ struct EXTENSIONSYSTEM_EXPORT PluginDependency
PluginDependency() : type(Required) {} PluginDependency() : type(Required) {}
friend Utils::QHashValueType qHash(const PluginDependency &value);
QString name; QString name;
QString version; QString version;
Type type; Type type;
@@ -67,8 +69,6 @@ struct EXTENSIONSYSTEM_EXPORT PluginDependency
QString toString() const; QString toString() const;
}; };
Utils::QHashValueType qHash(const ExtensionSystem::PluginDependency &value);
struct EXTENSIONSYSTEM_EXPORT PluginArgumentDescription struct EXTENSIONSYSTEM_EXPORT PluginArgumentDescription
{ {
QString name; QString name;

View File

@@ -79,6 +79,15 @@ public:
return {}; return {};
} }
friend auto qHash(const MessageId &id)
{
if (Utils::holds_alternative<int>(id))
return QT_PREPEND_NAMESPACE(qHash(Utils::get<int>(id)));
if (Utils::holds_alternative<QString>(id))
return QT_PREPEND_NAMESPACE(qHash(Utils::get<QString>(id)));
return QT_PREPEND_NAMESPACE(qHash(0));
}
private: private:
bool m_valid = true; bool m_valid = true;
}; };
@@ -93,15 +102,6 @@ struct ResponseHandler
using ResponseHandlers = std::function<void(const MessageId &, const QByteArray &, QTextCodec *)>; using ResponseHandlers = std::function<void(const MessageId &, const QByteArray &, QTextCodec *)>;
using MethodHandler = std::function<void(const QString &, const MessageId &, const IContent *)>; using MethodHandler = std::function<void(const QString &, const MessageId &, const IContent *)>;
inline auto qHash(const LanguageServerProtocol::MessageId &id)
{
if (Utils::holds_alternative<int>(id))
return QT_PREPEND_NAMESPACE(qHash(Utils::get<int>(id)));
if (Utils::holds_alternative<QString>(id))
return QT_PREPEND_NAMESPACE(qHash(Utils::get<QString>(id)));
return QT_PREPEND_NAMESPACE(qHash(0));
}
template <typename Error> template <typename Error>
inline QDebug operator<<(QDebug stream, const LanguageServerProtocol::MessageId &id) inline QDebug operator<<(QDebug stream, const LanguageServerProtocol::MessageId &id)
{ {

View File

@@ -30,7 +30,7 @@
#include <limits> #include <limits>
using namespace LanguageUtils; namespace LanguageUtils {
const int ComponentVersion::NoVersion = -1; const int ComponentVersion::NoVersion = -1;
const int ComponentVersion::MaxVersion = std::numeric_limits<int>::max(); const int ComponentVersion::MaxVersion = std::numeric_limits<int>::max();
@@ -87,8 +87,6 @@ void ComponentVersion::addToHash(QCryptographicHash &hash) const
hash.addData(reinterpret_cast<const char *>(&_minor), sizeof(_minor)); hash.addData(reinterpret_cast<const char *>(&_minor), sizeof(_minor));
} }
namespace LanguageUtils {
bool operator<(const ComponentVersion &lhs, const ComponentVersion &rhs) bool operator<(const ComponentVersion &lhs, const ComponentVersion &rhs)
{ {
return lhs.majorVersion() < rhs.majorVersion() return lhs.majorVersion() < rhs.majorVersion()
@@ -121,4 +119,4 @@ bool operator!=(const ComponentVersion &lhs, const ComponentVersion &rhs)
return !(lhs == rhs); return !(lhs == rhs);
} }
} } // namespace LanguageUtils

View File

@@ -47,21 +47,19 @@ public:
explicit ComponentVersion(const QString &versionString); explicit ComponentVersion(const QString &versionString);
~ComponentVersion(); ~ComponentVersion();
int majorVersion() const int majorVersion() const { return _major; }
{ return _major; } int minorVersion() const { return _minor; }
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; bool isValid() const;
QString toString() const; QString toString() const;
void addToHash(QCryptographicHash &hash) 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 } // namespace LanguageUtils

View File

@@ -68,17 +68,13 @@ public:
void clearTarget() { m_target = nullptr; } void clearTarget() { m_target = nullptr; }
friend auto qHash(const Handle<T> &handle) { return qHash(handle.uid()); }
private: private:
Uid m_uid; Uid m_uid;
T *m_target = nullptr; T *m_target = nullptr;
}; };
template<class T>
inline auto qHash(const Handle<T> &handle)
{
return qHash(handle.uid());
}
template<class T, class U> template<class T, class U>
bool operator==(const Handle<T> &lhs, const Handle<U> &rhs) bool operator==(const Handle<T> &lhs, const Handle<U> &rhs)
{ {

View File

@@ -224,18 +224,16 @@ public:
return take(indexOf(t)); return take(indexOf(t));
} }
friend bool operator==(const Handles<T> &lhs, const Handles<T> &rhs)
{
return lhs.get() == rhs.get();
}
friend bool operator!=(const Handles &lhs, const Handles &rhs) { return !(lhs == rhs); }
private: private:
value_type m_handleList; value_type m_handleList;
bool m_takesOwnership = false; bool m_takesOwnership = false;
}; };
template<typename T>
bool operator==(const Handles<T> &lhs, const Handles<T> &rhs)
{
return lhs.get() == rhs.get();
}
template<typename T>
bool operator!=(const Handles<T> &lhs, const Handles<T> &rhs) { return !(lhs == rhs); }
} // namespace qmt } // namespace qmt

View File

@@ -51,31 +51,17 @@ public:
QString toString() const { return m_uuid.toString(); } QString toString() const { return m_uuid.toString(); }
void fromString(const QString &s) { m_uuid = QUuid(s); } void fromString(const QString &s) { m_uuid = QUuid(s); }
private: friend auto qHash(const Uid &uid) { return qHash(uid.get()); }
QUuid m_uuid;
};
inline auto qHash(const Uid &uid) 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); }
return qHash(uid.get());
}
inline bool operator==(const Uid &lhs, const Uid &rhs) friend QDataStream &operator<<(QDataStream &stream, const Uid &uid)
{
return lhs.get() == rhs.get();
}
inline bool operator!=(const Uid &lhs, const Uid &rhs)
{
return !operator==(lhs, rhs);
}
inline QDataStream &operator<<(QDataStream &stream, const Uid &uid)
{ {
return stream << uid.get(); return stream << uid.get();
} }
inline QDataStream &operator>>(QDataStream &stream, Uid &uid) friend QDataStream &operator>>(QDataStream &stream, Uid &uid)
{ {
QUuid uuid; QUuid uuid;
stream >> uuid; stream >> uuid;
@@ -83,6 +69,10 @@ inline QDataStream &operator>>(QDataStream &stream, Uid &uid)
return stream; return stream;
} }
private:
QUuid m_uuid;
};
} // namespace qmt } // namespace qmt
Q_DECLARE_METATYPE(qmt::Uid) Q_DECLARE_METATYPE(qmt::Uid)

View File

@@ -136,6 +136,18 @@ public:
QColor color() const { return m_color; } QColor color() const { return m_color; }
void setColor(const QColor &color); void setColor(const QColor &color);
friend auto qHash(CustomRelation::Relationship relationship) {
return ::qHash(static_cast<int>(relationship));
}
friend auto qHash(CustomRelation::ShaftPattern pattern) {
return ::qHash(static_cast<int>(pattern));
}
friend auto qHash(CustomRelation::Head head) {
return ::qHash(static_cast<int>(head));
}
private: private:
Element m_element = Element::Relation; Element m_element = Element::Relation;
QString m_id; QString m_id;
@@ -151,16 +163,4 @@ private:
QColor m_color; QColor m_color;
}; };
inline auto qHash(CustomRelation::Relationship relationship) {
return ::qHash(static_cast<int>(relationship));
}
inline auto qHash(CustomRelation::ShaftPattern pattern) {
return ::qHash(static_cast<int>(pattern));
}
inline auto qHash(CustomRelation::Head head) {
return ::qHash(static_cast<int>(head));
}
} // namespace qmt } // namespace qmt

View File

@@ -58,16 +58,7 @@ struct IconKey {
{ {
} }
const StereotypeIcon::Element m_element; friend bool operator==(const IconKey &lhs, const IconKey &rhs) {
const QList<QString> m_stereotypes;
const QString m_defaultIconPath;
const Uid m_styleUid;
const QSize m_size;
const QMarginsF m_margins;
const qreal m_lineWidth;
};
bool operator==(const IconKey &lhs, const IconKey &rhs) {
return lhs.m_element == rhs.m_element return lhs.m_element == rhs.m_element
&& lhs.m_stereotypes == rhs.m_stereotypes && lhs.m_stereotypes == rhs.m_stereotypes
&& lhs.m_defaultIconPath == rhs.m_defaultIconPath && lhs.m_defaultIconPath == rhs.m_defaultIconPath
@@ -77,11 +68,20 @@ bool operator==(const IconKey &lhs, const IconKey &rhs) {
&& lhs.m_lineWidth == rhs.m_lineWidth; && lhs.m_lineWidth == rhs.m_lineWidth;
} }
auto qHash(const IconKey &key) { friend auto qHash(const IconKey &key) {
return ::qHash(key.m_element) + qHash(key.m_stereotypes) + qHash(key.m_defaultIconPath) 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()); + qHash(key.m_styleUid) + ::qHash(key.m_size.width()) + ::qHash(key.m_size.height());
} }
const StereotypeIcon::Element m_element;
const QList<QString> m_stereotypes;
const QString m_defaultIconPath;
const Uid m_styleUid;
const QSize m_size;
const QMarginsF m_margins;
const qreal m_lineWidth;
};
} }
class StereotypeController::StereotypeControllerPrivate class StereotypeController::StereotypeControllerPrivate

View File

@@ -72,22 +72,22 @@ public:
h &= 0x0fffffff; h &= 0x0fffffff;
} }
} }
int n = 0;
const char *str = nullptr;
quintptr h;
};
static bool operator==(const StringHolder &sh1, const StringHolder &sh2) 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. // 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; return sh1.h == sh2.h && sh1.str && sh2.str && strcmp(sh1.str, sh2.str) == 0;
} }
int n = 0;
static auto qHash(const StringHolder &sh) const char *str = nullptr;
{ quintptr h;
return QT_PREPEND_NAMESPACE(qHash)(sh.h, 0); };
}
struct IdCache : public QHash<StringHolder, quintptr> struct IdCache : public QHash<StringHolder, quintptr>
{ {
@@ -338,10 +338,6 @@ QString Id::suffixAfter(Id baseId) const
return n.startsWith(b) ? QString::fromUtf8(n.mid(b.size())) : QString(); return n.startsWith(b) ? QString::fromUtf8(n.mid(b.size())) : QString();
} }
} // namespace Utils
QT_BEGIN_NAMESPACE
QDataStream &operator<<(QDataStream &ds, Utils::Id id) QDataStream &operator<<(QDataStream &ds, Utils::Id id)
{ {
return ds << id.name(); return ds << id.name();
@@ -360,4 +356,4 @@ QDebug operator<<(QDebug dbg, const Utils::Id &id)
return dbg << id.name(); return dbg << id.name();
} }
QT_END_NAMESPACE } // namespace Utils

View File

@@ -74,21 +74,18 @@ public:
static QSet<Id> fromStringList(const QStringList &list); static QSet<Id> fromStringList(const QStringList &list);
static QStringList toStringList(const QSet<Id> &ids); static QStringList toStringList(const QSet<Id> &ids);
friend QHashValueType qHash(Id id) { return static_cast<QHashValueType>(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: private:
explicit Id(quintptr uid) : m_id(uid) {} explicit Id(quintptr uid) : m_id(uid) {}
quintptr m_id = 0; quintptr m_id = 0;
}; };
inline QHashValueType qHash(Id id) { return static_cast<QHashValueType>(id.uniqueIdentifier()); }
} // namespace Utils } // namespace Utils
Q_DECLARE_METATYPE(Utils::Id) Q_DECLARE_METATYPE(Utils::Id)
Q_DECLARE_METATYPE(QList<Utils::Id>) Q_DECLARE_METATYPE(QList<Utils::Id>)
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

View File

@@ -109,6 +109,8 @@ public:
bool matchesName(const QString &nameOrAlias) const; bool matchesName(const QString &nameOrAlias) const;
void setPreferredSuffix(const QString &suffix); void setPreferredSuffix(const QString &suffix);
friend auto qHash(const MimeType &mime) { return qHash(mime.name()); }
protected: protected:
friend class Internal::MimeTypeParserBase; friend class Internal::MimeTypeParserBase;
friend class Internal::MimeTypeMapEntry; friend class Internal::MimeTypeMapEntry;
@@ -120,8 +122,6 @@ protected:
QExplicitlySharedDataPointer<Internal::MimeTypePrivate> d; QExplicitlySharedDataPointer<Internal::MimeTypePrivate> d;
}; };
inline auto qHash(const MimeType &mime) { return qHash(mime.name()); }
} // Utils } // Utils
//Q_DECLARE_SHARED(Utils::MimeType) //Q_DECLARE_SHARED(Utils::MimeType)

View File

@@ -60,12 +60,13 @@ public:
return first.operation == second.operation && first.name == second.name return first.operation == second.operation && first.name == second.name
&& first.value == second.value; && first.value == second.value;
} }
friend bool operator!=(const NameValueItem &first, const NameValueItem &second) friend bool operator!=(const NameValueItem &first, const NameValueItem &second)
{ {
return !(first == second); return !(first == second);
} }
friend QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug debug, const NameValueItem &i);
public: public:
QString name; QString name;
QString value; QString value;
@@ -75,6 +76,4 @@ private:
void apply(NameValueDictionary *dictionary, Operation op) const; void apply(NameValueDictionary *dictionary, Operation op) const;
}; };
QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug debug, const NameValueItem &i);
} // namespace Utils } // namespace Utils

View File

@@ -218,6 +218,4 @@ private:
using ExitCodeInterpreter = std::function<QtcProcess::Result(int /*exitCode*/)>; using ExitCodeInterpreter = std::function<QtcProcess::Result(int /*exitCode*/)>;
QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug str, const QtcProcess &);
} // namespace Utils } // namespace Utils

View File

@@ -46,16 +46,17 @@ public:
, kind(kind) , kind(kind)
, projectPart(projectPart) , projectPart(projectPart)
{} {}
friend bool operator==(const FileInfo &lhs, const FileInfo &rhs) {
return lhs.file == rhs.file;
}
Utils::FilePath file; Utils::FilePath file;
CppEditor::ProjectFile::Kind kind; CppEditor::ProjectFile::Kind kind;
CppEditor::ProjectPart::ConstPtr projectPart; CppEditor::ProjectPart::ConstPtr projectPart;
}; };
using FileInfos = std::vector<FileInfo>; using FileInfos = std::vector<FileInfo>;
inline bool operator==(const FileInfo &lhs, const FileInfo &rhs) {
return lhs.file == rhs.file;
}
class FileInfoSelection { class FileInfoSelection {
public: public:
QSet<Utils::FilePath> dirs; QSet<Utils::FilePath> dirs;

View File

@@ -57,6 +57,9 @@ public:
bool isValid() const; bool isValid() const;
QIcon icon() const; QIcon icon() const;
friend bool operator==(const Diagnostic &lhs, const Diagnostic &rhs);
friend Utils::QHashValueType qHash(const Diagnostic &diagnostic);
QString name; QString name;
QString description; QString description;
QString category; QString category;
@@ -66,12 +69,8 @@ public:
bool hasFixits = false; bool hasFixits = false;
}; };
bool operator==(const Diagnostic &lhs, const Diagnostic &rhs);
using Diagnostics = QList<Diagnostic>; using Diagnostics = QList<Diagnostic>;
Utils::QHashValueType qHash(const Diagnostic &diagnostic);
} // namespace Internal } // namespace Internal
} // namespace ClangTools } // namespace ClangTools

View File

@@ -47,18 +47,18 @@ public:
SuppressedDiagnostic(const Diagnostic &diag); SuppressedDiagnostic(const Diagnostic &diag);
Utils::FilePath filePath; // Relative for files in project, absolute otherwise. friend bool operator==(const SuppressedDiagnostic &d1, const SuppressedDiagnostic &d2)
QString description;
int uniquifier;
};
inline bool operator==(const SuppressedDiagnostic &d1, const SuppressedDiagnostic &d2)
{ {
return d1.filePath == d2.filePath return d1.filePath == d2.filePath
&& d1.description == d2.description && d1.description == d2.description
&& d1.uniquifier == d2.uniquifier; && d1.uniquifier == d2.uniquifier;
} }
Utils::FilePath filePath; // Relative for files in project, absolute otherwise.
QString description;
int uniquifier;
};
using SuppressedDiagnosticsList = QList<SuppressedDiagnostic>; using SuppressedDiagnosticsList = QList<SuppressedDiagnostic>;
class ClangToolsProjectSettings : public QObject class ClangToolsProjectSettings : public QObject

View File

@@ -55,21 +55,15 @@ public:
int iconTypeSortOrder() const; int iconTypeSortOrder() const;
friend auto qHash(const SymbolInformation &information) { return information.hash(); }
private: private:
const int m_iconType; const int m_iconType;
const Utils::QHashValueType m_hash; // precalculated hash value - to speed up qHash const Utils::QHashValueType m_hash; // precalculated hash value - to speed up qHash
const QString m_name; // symbol name (e.g. SymbolInformation) const QString m_name; // symbol name (e.g. SymbolInformation)
const QString m_type; // symbol type (e.g. (int char)) 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 Internal
} // namespace ClassView } // namespace ClassView

View File

@@ -54,6 +54,11 @@ public:
bool equals(const ClearCaseSettings &s) const; 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 ccCommand;
QString ccBinaryPath; QString ccBinaryPath;
DiffType diffType = GraphicalDiff; DiffType diffType = GraphicalDiff;
@@ -71,10 +76,5 @@ public:
int timeOutS; 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 Internal
} // namespace ClearCase } // namespace ClearCase

View File

@@ -68,6 +68,7 @@ public:
QString toCMakeSetLine(const Utils::MacroExpander *expander = nullptr) const; QString toCMakeSetLine(const Utils::MacroExpander *expander = nullptr) const;
bool operator==(const CMakeConfigItem &o) const; bool operator==(const CMakeConfigItem &o) const;
friend Utils::QHashValueType qHash(const CMakeConfigItem &it); // needed for MSVC
QByteArray key; QByteArray key;
Type type = STRING; Type type = STRING;
@@ -79,8 +80,6 @@ public:
QStringList values; QStringList values;
}; };
Utils::QHashValueType qHash(const CMakeConfigItem &it); // needed for MSVC
class CMAKE_EXPORT CMakeConfig : public QList<CMakeConfigItem> class CMAKE_EXPORT CMakeConfig : public QList<CMakeConfigItem>
{ {
public: public:

View File

@@ -48,6 +48,7 @@ class CMakeFileInfo
{ {
public: public:
bool operator==(const CMakeFileInfo& other) const { return path == other.path; } 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; Utils::FilePath path;
bool isCMake = false; bool isCMake = false;
@@ -56,8 +57,6 @@ public:
bool isGenerated = false; bool isGenerated = false;
}; };
inline auto qHash(const CMakeFileInfo &info, uint seed = 0) { return info.path.hash(seed); }
class FileApiQtcData class FileApiQtcData
{ {
public: public:

View File

@@ -75,11 +75,7 @@ namespace Core {
struct CompletionEntry struct CompletionEntry
{ {
QString text; friend QDebug operator<<(QDebug d, const CompletionEntry &e)
FindFlags findFlags;
};
QDebug operator<<(QDebug d, const CompletionEntry &e)
{ {
QDebugStateSaver saver(d); QDebugStateSaver saver(d);
d.noquote(); d.noquote();
@@ -89,6 +85,10 @@ QDebug operator<<(QDebug d, const CompletionEntry &e)
return d; return d;
} }
QString text;
FindFlags findFlags;
};
class CompletionModel : public QAbstractListModel class CompletionModel : public QAbstractListModel
{ {
public: public:

View File

@@ -32,7 +32,8 @@
namespace Core { namespace Core {
class CORE_EXPORT SearchResultColor { class CORE_EXPORT SearchResultColor
{
public: public:
enum class Style { Default, Alt1, Alt2 }; enum class Style { Default, Alt1, Alt2 };
@@ -48,18 +49,17 @@ public:
highlightForeground = textForeground; highlightForeground = textForeground;
} }
friend auto qHash(SearchResultColor::Style style)
{
return QT_PREPEND_NAMESPACE(qHash(int(style)));
}
QColor textBackground; QColor textBackground;
QColor textForeground; QColor textForeground;
QColor highlightBackground; QColor highlightBackground;
QColor highlightForeground; QColor highlightForeground;
}; };
inline auto qHash(SearchResultColor::Style style)
{
return QT_PREPEND_NAMESPACE(qHash(int(style)));
}
using SearchResultColors = QHash<SearchResultColor::Style, SearchResultColor>; using SearchResultColors = QHash<SearchResultColor::Style, SearchResultColor>;
} // namespace Core } // namespace Core

View File

@@ -82,6 +82,8 @@ public:
virtual void setWidget(QWidget *widget) { m_widget = widget; } virtual void setWidget(QWidget *widget) { m_widget = widget; }
virtual void setContextHelp(const HelpItem &id) { m_contextHelp = id; } virtual void setContextHelp(const HelpItem &id) { m_contextHelp = id; }
friend CORE_EXPORT QDebug operator<<(QDebug debug, const Core::Context &context);
protected: protected:
Context m_context; Context m_context;
QPointer<QWidget> m_widget; QPointer<QWidget> m_widget;
@@ -89,4 +91,3 @@ protected:
}; };
} // namespace Core } // namespace Core
CORE_EXPORT QDebug operator<<(QDebug debug, const Core::Context &context);

View File

@@ -107,6 +107,18 @@ public:
QVariantMap toMap() const; QVariantMap toMap() const;
void fromMap(const QVariantMap &map); 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; Utils::FilePath executableFilePath;
QStringList sessionsWithOneClangd; QStringList sessionsWithOneClangd;
int workerThreadLimit = 0; int workerThreadLimit = 0;
@@ -153,21 +165,6 @@ private:
Data m_data; 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 class CPPEDITOR_EXPORT ClangdProjectSettings
{ {
public: public:

View File

@@ -50,6 +50,9 @@ public:
OpenCLSource, OpenCLSource,
}; };
ProjectFile() = default;
ProjectFile(const QString &filePath, Kind kind, bool active = true);
static Kind classifyByMimeType(const QString &mt); static Kind classifyByMimeType(const QString &mt);
static Kind classify(const QString &filePath); static Kind classify(const QString &filePath);
@@ -69,12 +72,10 @@ public:
bool isC() const; bool isC() const;
bool isCxx() const; bool isCxx() const;
public:
ProjectFile() = default;
ProjectFile(const QString &filePath, Kind kind, bool active = true);
bool operator==(const ProjectFile &other) const; bool operator==(const ProjectFile &other) const;
friend QDebug operator<<(QDebug stream, const CppEditor::ProjectFile &projectFile);
public:
QString path; QString path;
Kind kind = Unclassified; Kind kind = Unclassified;
bool active = true; bool active = true;
@@ -83,6 +84,5 @@ public:
using ProjectFiles = QVector<ProjectFile>; using ProjectFiles = QVector<ProjectFile>;
const char *projectFileKindToText(ProjectFile::Kind kind); const char *projectFileKindToText(ProjectFile::Kind kind);
QDebug operator<<(QDebug stream, const CppEditor::ProjectFile &projectFile);
} // namespace CppEditor } // namespace CppEditor

View File

@@ -33,8 +33,13 @@
#include <QtTest> #include <QtTest>
// Uses 1-based line and 0-based column. // 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) {} 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 line;
int column; int column;
int length; int length;
@@ -42,9 +47,6 @@ struct Selection {
typedef QList<Selection> SelectionList; typedef QList<Selection> SelectionList;
Q_DECLARE_METATYPE(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 QT_BEGIN_NAMESPACE
namespace QTest { namespace QTest {
template<> char *toString(const Selection &selection) template<> char *toString(const Selection &selection)

View File

@@ -82,27 +82,29 @@ using namespace TextEditor;
using namespace Core; using namespace Core;
using namespace ProjectExplorer; using namespace ProjectExplorer;
class OverrideItem { class OverrideItem
{
public: public:
OverrideItem() : line(0) {} OverrideItem() : line(0) {}
OverrideItem(const QString &text, int line = 0) : text(text), line(line) {} OverrideItem(const QString &text, int line = 0) : text(text), line(line) {}
bool isValid() { return line != 0; } bool isValid() { return line != 0; }
QByteArray toByteArray() const QByteArray toByteArray() const
{ {
return "OverrideItem(" + text.toLatin1() + ", " + QByteArray::number(line) + ')'; 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; QString text;
int line; int line;
}; };
typedef QList<OverrideItem> OverrideItemList; typedef QList<OverrideItem> OverrideItemList;
Q_DECLARE_METATYPE(OverrideItem) 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 QT_BEGIN_NAMESPACE
namespace QTest { namespace QTest {
template<> char *toString(const OverrideItem &data) template<> char *toString(const OverrideItem &data)

View File

@@ -43,6 +43,10 @@ public:
bool isValid() const; 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; Utils::FilePath filePath;
// Both values start at 1. // Both values start at 1.
@@ -50,10 +54,6 @@ public:
int column = 0; 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 } // namespace Debugger
Q_DECLARE_METATYPE(Debugger::DiagnosticLocation) Q_DECLARE_METATYPE(Debugger::DiagnosticLocation)

View File

@@ -79,6 +79,8 @@ struct WinException
void fromGdbMI(const GdbMi &); void fromGdbMI(const GdbMi &);
QString toString(bool includeLocation = false) const; QString toString(bool includeLocation = false) const;
friend QDebug operator<<(QDebug s, const WinException &e);
unsigned exceptionCode = 0; unsigned exceptionCode = 0;
unsigned exceptionFlags = 0; unsigned exceptionFlags = 0;
quint64 exceptionAddress = 0; quint64 exceptionAddress = 0;
@@ -90,7 +92,5 @@ struct WinException
QString function; QString function;
}; };
QDebug operator<<(QDebug s, const WinException &e);
} // namespace Internal } // namespace Internal
} // namespace Debugger } // namespace Debugger

View File

@@ -46,6 +46,11 @@ public:
void fromSettings(const QSettings *); void fromSettings(const QSettings *);
void setPortFlagBySshType(); 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; GerritServer server;
Utils::FilePath ssh; Utils::FilePath ssh;
Utils::FilePath curl; Utils::FilePath curl;
@@ -54,10 +59,5 @@ public:
QString portFlag; 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 Internal
} // namespace Gerrit } // namespace Gerrit

View File

@@ -44,17 +44,19 @@ class Client;
class LANGUAGECLIENT_EXPORT ExpandedSemanticToken class LANGUAGECLIENT_EXPORT ExpandedSemanticToken
{ {
public: 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 line = -1;
int column = -1; int column = -1;
int length = -1; int length = -1;
QString type; QString type;
QStringList modifiers; 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<void(TextEditor::TextDocument *, using SemanticTokensHandler = std::function<void(TextEditor::TextDocument *,
const QList<ExpandedSemanticToken> &, int, bool)>; const QList<ExpandedSemanticToken> &, int, bool)>;

View File

@@ -60,22 +60,22 @@ protected:
struct Section struct Section
{ {
QString name; friend bool operator<(const Section &lhs, const Section &rhs)
int priority;
};
inline bool operator<(const Section &lhs, const Section &rhs)
{ {
if (lhs.priority < rhs.priority) if (lhs.priority < rhs.priority)
return true; return true;
return lhs.priority > rhs.priority ? false : lhs.name < rhs.name; return lhs.priority > rhs.priority ? false : lhs.name < rhs.name;
} }
inline bool operator==(const Section &lhs, const Section &rhs) friend bool operator==(const Section &lhs, const Section &rhs)
{ {
return lhs.priority == rhs.priority && lhs.name == rhs.name; return lhs.priority == rhs.priority && lhs.name == rhs.name;
} }
QString name;
int priority;
};
class SectionedProducts : public QStackedWidget class SectionedProducts : public QStackedWidget
{ {
Q_OBJECT Q_OBJECT

View File

@@ -51,14 +51,13 @@ NimSuggestClientRequest::NimSuggestClientRequest(quint64 id)
: m_id(id) : m_id(id)
{} {}
QDebug operator<<(QDebug debug, const Line &c)
} // namespace Suggest
} // namespace Nim
QDebug operator<<(QDebug debug, const Nim::Suggest::Line &c)
{ {
QDebugStateSaver saver(debug); QDebugStateSaver saver(debug);
debug.space() << c.line_type << c.symbol_kind << c.symbol_type << c.data << c.row << c.column << debug.space() << c.line_type << c.symbol_kind << c.symbol_type << c.data << c.row << c.column <<
c.abs_path; c.abs_path;
return debug; return debug;
} }
} // namespace Suggest
} // namespace Nim

View File

@@ -83,6 +83,8 @@ public:
static bool fromString(LineType &type, const std::string &str); static bool fromString(LineType &type, const std::string &str);
static bool fromString(SymbolKind &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; LineType line_type;
SymbolKind symbol_kind; SymbolKind symbol_kind;
QString abs_path; QString abs_path;
@@ -133,5 +135,3 @@ private:
} // namespace Suggest } // namespace Suggest
} // namespace Nim } // namespace Nim
QDebug operator<<(QDebug debug, const Nim::Suggest::Line &c);

View File

@@ -184,6 +184,15 @@ public:
static Abi hostAbi(); static Abi hostAbi();
static Abis abisOfBinary(const Utils::FilePath &path); 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: private:
Architecture m_architecture; Architecture m_architecture;
@@ -194,14 +203,4 @@ private:
QString m_param; 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 } // namespace ProjectExplorer

View File

@@ -52,9 +52,8 @@ public:
Utils::QHashValueType runEnvModifierHash = 0; // Make sure to update this when runEnvModifier changes! Utils::QHashValueType runEnvModifierHash = 0; // Make sure to update this when runEnvModifier changes!
std::function<void(Utils::Environment &, bool)> runEnvModifier; std::function<void(Utils::Environment &, bool)> runEnvModifier;
};
inline bool operator==(const BuildTargetInfo &ti1, const BuildTargetInfo &ti2) friend bool operator==(const BuildTargetInfo &ti1, const BuildTargetInfo &ti2)
{ {
return ti1.buildKey == ti2.buildKey return ti1.buildKey == ti2.buildKey
&& ti1.displayName == ti2.displayName && ti1.displayName == ti2.displayName
@@ -66,14 +65,15 @@ inline bool operator==(const BuildTargetInfo &ti1, const BuildTargetInfo &ti2)
&& ti1.runEnvModifierHash == ti2.runEnvModifierHash; && ti1.runEnvModifierHash == ti2.runEnvModifierHash;
} }
inline bool operator!=(const BuildTargetInfo &ti1, const BuildTargetInfo &ti2) friend bool operator!=(const BuildTargetInfo &ti1, const BuildTargetInfo &ti2)
{ {
return !(ti1 == ti2); return !(ti1 == ti2);
} }
inline auto qHash(const BuildTargetInfo &ti) friend auto qHash(const BuildTargetInfo &ti)
{ {
return qHash(ti.displayName) ^ qHash(ti.buildKey); return qHash(ti.displayName) ^ qHash(ti.buildKey);
} }
};
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -55,23 +55,21 @@ public:
bool isExecutable() const; 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: private:
Utils::FilePath m_localFilePath; Utils::FilePath m_localFilePath;
QString m_remoteDir; QString m_remoteDir;
Type m_type = TypeNormal; 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 } // namespace ProjectExplorer

View File

@@ -76,15 +76,15 @@ public:
return {fp, HeaderPathType::Framework}; return {fp, HeaderPathType::Framework};
} }
QString path; friend auto qHash(const HeaderPath &key, uint seed = 0)
HeaderPathType type = HeaderPathType::User;
};
inline auto qHash(const HeaderPath &key, uint seed = 0)
{ {
return ((qHash(key.path) << 2) | uint(key.type)) ^ seed; return ((qHash(key.path) << 2) | uint(key.type)) ^ seed;
} }
QString path;
HeaderPathType type = HeaderPathType::User;
};
using HeaderPaths = QVector<HeaderPath>; using HeaderPaths = QVector<HeaderPath>;
template<typename C> HeaderPaths toHeaderPaths(const C &list, HeaderPathType type) template<typename C> HeaderPaths toHeaderPaths(const C &list, HeaderPathType type)
{ {

View File

@@ -43,6 +43,25 @@ enum class StopBeforeBuild { None, SameProject, All, SameBuildDir, SameApp };
class ProjectExplorerSettings class ProjectExplorerSettings
{ {
public: 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; BuildBeforeRunMode buildBeforeDeploy = BuildBeforeRunMode::WholeProject;
bool deployBeforeRun = true; bool deployBeforeRun = true;
bool saveBeforeBuild = false; bool saveBeforeBuild = false;
@@ -66,25 +85,6 @@ public:
QUuid environmentId; 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 class AppOutputSettings
{ {
public: public:

View File

@@ -70,6 +70,19 @@ public:
static Macro fromKeyValue(const QByteArray &text); static Macro fromKeyValue(const QByteArray &text);
QByteArray toKeyValue(const QByteArray &prefix) const; QByteArray toKeyValue(const QByteArray &prefix) const;
friend auto qHash(const Macro &macro)
{
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: public:
QByteArray key; QByteArray key;
QByteArray value; QByteArray value;
@@ -84,19 +97,4 @@ private:
static Macros tokensLinesToMacros(const QList<QList<QByteArray>> &tokensLines); static Macros tokensLinesToMacros(const QList<QList<QByteArray>> &tokensLines);
}; };
inline
auto qHash(const Macro &macro)
{
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 } // namespace ProjectExplorer

View File

@@ -77,6 +77,10 @@ public:
QString description() const; QString description() const;
QIcon icon() 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; unsigned int taskId = 0;
TaskType type = Unknown; TaskType type = Unknown;
Options options = AddTextMark | FlashWorthy; Options options = AddTextMark | FlashWorthy;
@@ -136,11 +140,6 @@ public:
using Tasks = QVector<Task>; using Tasks = QVector<Task>;
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 QString toHtml(const Tasks &issues);
PROJECTEXPLORER_EXPORT bool containsType(const Tasks &issues, Task::TaskType); PROJECTEXPLORER_EXPORT bool containsType(const Tasks &issues, Task::TaskType);

View File

@@ -78,6 +78,25 @@ public:
QStringList toArguments() const; 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 // Actual data
QString sysRoot; QString sysRoot;
QString targetTriple; QString targetTriple;
@@ -89,27 +108,6 @@ public:
Utils::TriState useQtQuickCompiler; 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 class QMAKEPROJECTMANAGER_EXPORT QMakeStep : public ProjectExplorer::AbstractProcessStep
{ {
Q_OBJECT Q_OBJECT

View File

@@ -36,7 +36,8 @@ QT_END_NAMESPACE
namespace QmlJSEditor { namespace QmlJSEditor {
class QmlJsEditingSettings { class QmlJsEditingSettings
{
public: public:
QmlJsEditingSettings(); QmlJsEditingSettings();
@@ -63,6 +64,11 @@ namespace QmlJSEditor {
bool foldAuxData() const; bool foldAuxData() const;
void setFoldAuxData(const bool foldAuxData); void setFoldAuxData(const bool foldAuxData);
friend bool operator==(const QmlJsEditingSettings &s1, const QmlJsEditingSettings &s2)
{ return s1.equals(s2); }
friend bool operator!=(const QmlJsEditingSettings &s1, const QmlJsEditingSettings &s2)
{ return !s1.equals(s2); }
private: private:
bool m_enableContextPane; bool m_enableContextPane;
bool m_pinContextPane; bool m_pinContextPane;
@@ -71,12 +77,6 @@ namespace QmlJSEditor {
bool m_foldAuxData; bool m_foldAuxData;
}; };
inline bool operator==(const QmlJsEditingSettings &s1, const QmlJsEditingSettings &s2)
{ return s1.equals(s2); }
inline bool operator!=(const QmlJsEditingSettings &s1, const QmlJsEditingSettings &s2)
{ return !s1.equals(s2); }
namespace Internal { namespace Internal {
class QmlJsEditingSettingsPage : public Core::IOptionsPage class QmlJsEditingSettingsPage : public Core::IOptionsPage

View File

@@ -55,6 +55,26 @@ public:
int line() const { return m_line; } int line() const { return m_line; }
int column() const { return m_column; } 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: private:
friend QDataStream &operator>>(QDataStream &stream, QmlEventLocation &location); friend QDataStream &operator>>(QDataStream &stream, QmlEventLocation &location);
friend QDataStream &operator<<(QDataStream &stream, const QmlEventLocation &location); friend QDataStream &operator<<(QDataStream &stream, const QmlEventLocation &location);
@@ -64,29 +84,6 @@ private:
int m_column = -1; 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 } // namespace QmlProfiler
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE

View File

@@ -63,9 +63,6 @@ private:
int m_detailType; // can be EventType, BindingType, PixmapEventType or SceneGraphFrameType 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 } // namespace QmlProfiler
Q_DECLARE_METATYPE(QmlProfiler::QmlEventType) Q_DECLARE_METATYPE(QmlProfiler::QmlEventType)

View File

@@ -48,10 +48,13 @@ public:
void setText(const QString &text) { m_text = text; } void setText(const QString &text) { m_text = text; }
void setLoaded(bool loaded) { m_loaded = loaded; } void setLoaded(bool loaded) { m_loaded = loaded; }
private: friend bool operator==(const QmlNote &note1, const QmlNote &note2);
friend bool operator!=(const QmlNote &note1, const QmlNote &note2);
friend QDataStream &operator>>(QDataStream &stream, QmlNote &note); friend QDataStream &operator>>(QDataStream &stream, QmlNote &note);
friend QDataStream &operator<<(QDataStream &stream, const QmlNote &note); friend QDataStream &operator<<(QDataStream &stream, const QmlNote &note);
private:
int m_typeIndex; int m_typeIndex;
int m_collapsedRow; int m_collapsedRow;
qint64 m_startTime; qint64 m_startTime;
@@ -60,12 +63,6 @@ private:
bool m_loaded; bool m_loaded;
}; };
bool operator==(const QmlNote &note1, const QmlNote &note2);
bool operator!=(const QmlNote &note1, const QmlNote &note2);
QDataStream &operator>>(QDataStream &stream, QmlNote &note);
QDataStream &operator<<(QDataStream &stream, const QmlNote &note);
} // namespace QmlProfiler } // namespace QmlProfiler
Q_DECLARE_METATYPE(QmlProfiler::QmlNote) Q_DECLARE_METATYPE(QmlProfiler::QmlNote)

View File

@@ -48,13 +48,13 @@ public:
void fromSettings(const QSettings *settings); void fromSettings(const QSettings *settings);
void toSettings(QSettings *settings) const; 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; UiClassEmbedding embedding;
bool retranslationSupport; // Add handling for language change events bool retranslationSupport; // Add handling for language change events
bool includeQtModule; // Include "<QtGui/[Class]>" or just "<[Class]>" bool includeQtModule; // Include "<QtGui/[Class]>" or just "<[Class]>"
bool addQtVersionCheck; // Include #ifdef when using "#include <QtGui/..." bool addQtVersionCheck; // Include #ifdef when using "#include <QtGui/..."
}; };
inline bool operator==(const CodeGenSettings &p1, const CodeGenSettings &p2) { return p1.equals(p2); }
inline bool operator!=(const CodeGenSettings &p1, const CodeGenSettings &p2) { return !p1.equals(p2); }
} // namespace QtSupport } // namespace QtSupport

View File

@@ -55,16 +55,15 @@ public:
bool operator==(const DeployParameters &other) const { bool operator==(const DeployParameters &other) const {
return file == other.file && host == other.host && sysroot == other.sysroot; return file == other.file && host == other.host && sysroot == other.sysroot;
} }
friend auto qHash(const DeployParameters &p) {
return qHash(qMakePair(qMakePair(p.file, p.host), p.sysroot));
}
DeployableFile file; DeployableFile file;
QString host; QString host;
QString sysroot; QString sysroot;
}; };
auto qHash(const DeployParameters &p) {
return qHash(qMakePair(qMakePair(p.file, p.host), p.sysroot));
}
} // anonymous namespace } // anonymous namespace
class DeploymentTimeInfoPrivate class DeploymentTimeInfoPrivate

View File

@@ -52,6 +52,9 @@ public:
bool equals(const BehaviorSettings &bs) const; bool equals(const BehaviorSettings &bs) const;
friend bool operator==(const BehaviorSettings &t1, const BehaviorSettings &t2) { return t1.equals(t2); }
friend bool operator!=(const BehaviorSettings &t1, const BehaviorSettings &t2) { return !t1.equals(t2); }
bool m_mouseHiding; bool m_mouseHiding;
bool m_mouseNavigation; bool m_mouseNavigation;
bool m_scrollWheelZooming; bool m_scrollWheelZooming;
@@ -61,7 +64,4 @@ public:
bool m_smartSelectionChanging; bool m_smartSelectionChanging;
}; };
inline bool operator==(const BehaviorSettings &t1, const BehaviorSettings &t2) { return t1.equals(t2); }
inline bool operator!=(const BehaviorSettings &t1, const BehaviorSettings &t2) { return !t1.equals(t2); }
} // namespace TextEditor } // namespace TextEditor

View File

@@ -81,6 +81,9 @@ public:
QString toString() const; QString toString() const;
bool fromString(const QString &str); bool fromString(const QString &str);
friend bool operator==(const Format &f1, const Format &f2) { return f1.equals(f2); }
friend bool operator!=(const Format &f1, const Format &f2) { return !f1.equals(f2); }
private: private:
QColor m_foreground; QColor m_foreground;
QColor m_background; QColor m_background;
@@ -94,10 +97,6 @@ private:
bool m_italic = false; bool m_italic = false;
}; };
inline bool operator==(const Format &f1, const Format &f2) { return f1.equals(f2); }
inline bool operator!=(const Format &f1, const Format &f2) { return !f1.equals(f2); }
/*! A color scheme combines a set of formats for different highlighting /*! A color scheme combines a set of formats for different highlighting
categories. It also provides saving and loading of the scheme to a file. categories. It also provides saving and loading of the scheme to a file.
*/ */
@@ -125,20 +124,19 @@ public:
bool save(const QString &fileName, QWidget *parent) const; bool save(const QString &fileName, QWidget *parent) const;
bool load(const QString &fileName); bool load(const QString &fileName);
inline bool equals(const ColorScheme &cs) const bool equals(const ColorScheme &cs) const
{ {
return m_formats == cs.m_formats return m_formats == cs.m_formats && m_displayName == cs.m_displayName;
&& m_displayName == cs.m_displayName;
} }
static QString readNameOfScheme(const QString &fileName); static QString readNameOfScheme(const QString &fileName);
friend bool operator==(const ColorScheme &cs1, const ColorScheme &cs2) { return cs1.equals(cs2); }
friend bool operator!=(const ColorScheme &cs1, const ColorScheme &cs2) { return !cs1.equals(cs2); }
private: private:
QMap<TextStyle, Format> m_formats; QMap<TextStyle, Format> m_formats;
QString m_displayName; 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 } // namespace TextEditor

View File

@@ -43,15 +43,15 @@ public:
bool equals(const CommentsSettings &other) const; 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_enableDoxygen;
bool m_generateBrief; bool m_generateBrief;
bool m_leadingAsterisks; 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 } // namespace TextEditor

View File

@@ -56,6 +56,9 @@ public:
bool equals(const CompletionSettings &bs) const; 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; CaseSensitivity m_caseSensitivity = CaseInsensitive;
CompletionTrigger m_completionTrigger = AutomaticCompletion; CompletionTrigger m_completionTrigger = AutomaticCompletion;
int m_automaticProposalTimeoutInMs = 400; int m_automaticProposalTimeoutInMs = 400;
@@ -74,7 +77,4 @@ public:
bool m_overwriteClosingChars = false; 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 } // namespace TextEditor

View File

@@ -52,6 +52,9 @@ public:
void toSettings(const QString &category, QSettings *s) const; void toSettings(const QString &category, QSettings *s) const;
void fromSettings(const QString &category, const QSettings *s); 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_displayLineNumbers = true;
bool m_textWrapping = false; bool m_textWrapping = false;
bool m_visualizeWhitespace = false; bool m_visualizeWhitespace = false;
@@ -78,9 +81,6 @@ public:
static QLabel *createAnnotationSettingsLink(); 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 } // namespace TextEditor
Q_DECLARE_METATYPE(TextEditor::AnnotationAlignment) Q_DECLARE_METATYPE(TextEditor::AnnotationAlignment)

View File

@@ -49,6 +49,12 @@ public:
bool equals(const ExtraEncodingSettings &s) const; 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(); static QStringList lineTerminationModeNames();
enum Utf8BomSetting { enum Utf8BomSetting {
@@ -59,10 +65,4 @@ public:
Utf8BomSetting m_utf8BomSetting; 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 } // TextEditor

View File

@@ -98,6 +98,9 @@ public:
static QString defaultSchemeFileName(const QString &fileName = QString()); 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: private:
void addMixinStyle(QTextCharFormat &textCharFormat, const MixinTextStyles &mixinStyles) const; void addMixinStyle(QTextCharFormat &textCharFormat, const MixinTextStyles &mixinStyles) const;
@@ -112,7 +115,4 @@ private:
mutable QHash<TextStyles, QTextCharFormat> m_textCharFormatCache; mutable QHash<TextStyles, QTextCharFormat> 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 } // namespace TextEditor

View File

@@ -48,14 +48,14 @@ public:
bool equals(const MarginSettings &other) const; 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_showMargin;
bool m_useIndenter; bool m_useIndenter;
int m_marginColumn; 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 } // namespace TextEditor

View File

@@ -46,14 +46,13 @@ public:
bool equals(const SnippetsSettings &snippetsSettings) const; 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: private:
QString m_lastUsedSnippetGroup; 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 } // TextEditor

View File

@@ -50,6 +50,10 @@ public:
bool removeTrailingWhitespace(const QString &filePattern) const; bool removeTrailingWhitespace(const QString &filePattern) const;
bool equals(const StorageSettings &ts) 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; QString m_ignoreFileTypes;
bool m_cleanWhitespace; bool m_cleanWhitespace;
@@ -59,7 +63,4 @@ public:
bool m_skipTrailingWhitespace; 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 } // namespace TextEditor

View File

@@ -81,6 +81,9 @@ public:
bool isIndentationClean(const QTextBlock &block, const int indent) const; bool isIndentationClean(const QTextBlock &block, const int indent) const;
bool guessSpacesForTabs(const QTextBlock &block) 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 int firstNonSpace(const QString &text);
static inline bool onlySpace(const QString &text) { return firstNonSpace(text) == text.length(); } static inline bool onlySpace(const QString &text) { return firstNonSpace(text) == text.length(); }
static int spacesLeftFromPosition(const QString &text, int position); static int spacesLeftFromPosition(const QString &text, int position);
@@ -96,9 +99,6 @@ public:
bool equals(const TabSettings &ts) const; 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 } // namespace TextEditor
Q_DECLARE_METATYPE(TextEditor::TabSettings) Q_DECLARE_METATYPE(TextEditor::TabSettings)

View File

@@ -43,9 +43,11 @@ struct TEXTEDITOR_EXPORT Parenthesis
{ {
enum Type : char { Opened, Closed }; enum Type : char { Opened, Closed };
inline Parenthesis() = default; Parenthesis() = default;
inline Parenthesis(Type t, QChar c, int position) Parenthesis(Type t, QChar c, int position) : pos(position), chr(c), type(t) {}
: pos(position), chr(c), type(t) {}
friend TEXTEDITOR_EXPORT QDebug operator<<(QDebug debug, const Parenthesis &parenthesis);
int pos = -1; int pos = -1;
QChar chr; QChar chr;
Utils::Id source; Utils::Id source;
@@ -56,8 +58,6 @@ struct TEXTEDITOR_EXPORT Parenthesis
using Parentheses = QVector<Parenthesis>; using Parentheses = QVector<Parenthesis>;
TEXTEDITOR_EXPORT void insertSorted(Parentheses &list, const Parenthesis &elem); TEXTEDITOR_EXPORT void insertSorted(Parentheses &list, const Parenthesis &elem);
TEXTEDITOR_EXPORT QDebug operator<<(QDebug debug, const Parenthesis &parenthesis);
class TEXTEDITOR_EXPORT CodeFormatterData class TEXTEDITOR_EXPORT CodeFormatterData
{ {
public: public:

View File

@@ -66,6 +66,9 @@ public:
bool equals(const TypingSettings &ts) const; 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; bool m_autoIndent;
TabKeyBehavior m_tabKeyBehavior; TabKeyBehavior m_tabKeyBehavior;
SmartBackspaceBehavior m_smartBackspaceBehavior; SmartBackspaceBehavior m_smartBackspaceBehavior;
@@ -73,9 +76,6 @@ public:
bool m_preferSingleLineComments; 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 } // namespace TextEditor
Q_DECLARE_METATYPE(TextEditor::TypingSettings) Q_DECLARE_METATYPE(TextEditor::TypingSettings)

View File

@@ -40,6 +40,8 @@ class CommonVcsSettings : public Utils::AspectContainer
public: public:
CommonVcsSettings(); CommonVcsSettings();
friend QDebug operator<<(QDebug, const CommonVcsSettings &);
Utils::StringAspect nickNameMailMap; Utils::StringAspect nickNameMailMap;
Utils::StringAspect nickNameFieldListFile; Utils::StringAspect nickNameFieldListFile;
@@ -52,9 +54,6 @@ public:
Utils::IntegerAspect lineWrapWidth; Utils::IntegerAspect lineWrapWidth;
}; };
QDebug operator<<(QDebug, const CommonVcsSettings &);
class CommonOptionsPage final : public Core::IOptionsPage class CommonOptionsPage final : public Core::IOptionsPage
{ {
Q_OBJECT Q_OBJECT

View File

@@ -106,6 +106,11 @@ public:
friend VCSBASE_EXPORT QDebug operator<<(QDebug in, const VcsBasePluginState &state); 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: private:
friend class VcsBasePluginPrivate; friend class VcsBasePluginPrivate;
bool equals(const Internal::State &s) const; bool equals(const Internal::State &s) const;
@@ -114,13 +119,6 @@ private:
QSharedDataPointer<VcsBasePluginStateData> data; QSharedDataPointer<VcsBasePluginStateData> 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 // Convenience that searches for the repository specifically for version control
// systems that do not have directories like "CVS" in each managed subdirectory // 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 // but have a directory at the top of the repository like ".git" containing

View File

@@ -164,6 +164,8 @@ public:
QByteArray toLatin1() const { return toStringView().toLatin1(); } QByteArray toLatin1() const { return toStringView().toLatin1(); }
friend QDebug operator<<(QDebug debug, const ProString &str);
private: private:
ProString(const ProKey &other); ProString(const ProKey &other);
ProString &operator=(const ProKey &other); ProString &operator=(const ProKey &other);
@@ -512,6 +514,4 @@ struct ProFunctionDefs {
QHash<ProKey, ProFunctionDef> replaceFunctions; QHash<ProKey, ProFunctionDef> replaceFunctions;
}; };
QDebug operator<<(QDebug debug, const ProString &str);
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@@ -54,14 +54,14 @@ class QMakeBaseKey
public: public:
QMakeBaseKey(const QString &_root, const QString &_stash, bool _hostBuild); 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 root;
QString stash; QString stash;
bool hostBuild; bool hostBuild;
}; };
Utils::QHashValueType qHash(const QMakeBaseKey &key);
bool operator==(const QMakeBaseKey &one, const QMakeBaseKey &two);
class QMakeBaseEnv class QMakeBaseEnv
{ {
public: public:

View File

@@ -115,6 +115,9 @@ public:
= PreferredTranslationUnit::RecentlyParsed) const; = PreferredTranslationUnit::RecentlyParsed) const;
TranslationUnits &translationUnits() 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 public: // for tests
void parse() const; void parse() const;
void reparse() const; void reparse() const;
@@ -136,6 +139,4 @@ private:
mutable std::shared_ptr<DocumentData> d; mutable std::shared_ptr<DocumentData> d;
}; };
bool operator==(const Document &first, const Document &second);
std::ostream &operator<<(std::ostream &os, const Document &document);
} // namespace ClangBackEnd } // namespace ClangBackEnd

View File

@@ -96,6 +96,7 @@ public:
bool isTakeOverable() const; bool isTakeOverable() const;
bool operator==(const JobRequest &other) const; bool operator==(const JobRequest &other) const;
friend QDebug operator<<(QDebug debug, const JobRequest &jobRequest);
public: public:
quint64 id = 0; quint64 id = 0;
@@ -121,9 +122,7 @@ public:
using JobRequests = QVector<JobRequest>; using JobRequests = QVector<JobRequest>;
QDebug operator<<(QDebug debug, const JobRequest &jobRequest);
std::ostream &operator<<(std::ostream &os, JobRequest::Type type); std::ostream &operator<<(std::ostream &os, JobRequest::Type type);
std::ostream &operator<<(std::ostream &os, PreferredTranslationUnit preferredTranslationUnit); std::ostream &operator<<(std::ostream &os, PreferredTranslationUnit preferredTranslationUnit);
} // namespace ClangBackEnd } // namespace ClangBackEnd

View File

@@ -40,6 +40,7 @@ class Type
{ {
friend class Cursor; friend class Cursor;
friend bool operator==(Type first, Type second); friend bool operator==(Type first, Type second);
friend bool operator!=(Type first, Type second);
public: public:
bool isValid() const; bool isValid() const;
@@ -80,9 +81,6 @@ private:
CXType m_cxType; 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, CXTypeKind typeKind);
std::ostream &operator<<(std::ostream &os, const Type &type); std::ostream &operator<<(std::ostream &os, const Type &type);
} // namespace ClangBackEnd } // namespace ClangBackEnd

View File

@@ -37,6 +37,7 @@ class SourceRange
friend class FixIt; friend class FixIt;
friend class Cursor; friend class Cursor;
friend bool operator==(const SourceRange &first, const SourceRange &second); friend bool operator==(const SourceRange &first, const SourceRange &second);
friend std::ostream &operator<<(std::ostream &os, const SourceRange &sourceRange);
public: public:
SourceRange(); SourceRange();
@@ -63,6 +64,4 @@ private:
CXTranslationUnit cxTranslationUnit = nullptr; CXTranslationUnit cxTranslationUnit = nullptr;
}; };
bool operator==(const SourceRange &first, const SourceRange &second);
std::ostream &operator<<(std::ostream &os, const SourceRange &sourceRange);
} // namespace ClangBackEnd } // namespace ClangBackEnd

View File

@@ -37,12 +37,16 @@ class TestView : public QmlDesigner::AbstractView
{ {
Q_OBJECT Q_OBJECT
public: public:
struct MethodCall { struct MethodCall
{
MethodCall(const QString &n, const QStringList &args) : MethodCall(const QString &n, const QStringList &args) :
name(n), arguments(args) name(n), arguments(args)
{ {
} }
friend bool operator==(TestView::MethodCall call1, TestView::MethodCall call2);
friend QDebug operator<<(QDebug debug, TestView::MethodCall call);
QString name; QString name;
QStringList arguments; QStringList arguments;
}; };
@@ -114,6 +118,3 @@ private:
QList<MethodCall> m_methodCalls; QList<MethodCall> m_methodCalls;
static QString serialize(AbstractView::PropertyChangeFlags change); static QString serialize(AbstractView::PropertyChangeFlags change);
}; };
bool operator==(TestView::MethodCall call1, TestView::MethodCall call2);
QDebug operator<<(QDebug debug, TestView::MethodCall call);