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;
}
};
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const AliveMessage &message);
friend CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const AliveMessage &message);
};
DECLARE_MESSAGE(AliveMessage)
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -79,6 +79,15 @@ public:
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:
bool m_valid = true;
};
@@ -93,15 +102,6 @@ struct ResponseHandler
using ResponseHandlers = std::function<void(const MessageId &, const QByteArray &, QTextCodec *)>;
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>
inline QDebug operator<<(QDebug stream, const LanguageServerProtocol::MessageId &id)
{

View File

@@ -30,7 +30,7 @@
#include <limits>
using namespace LanguageUtils;
namespace LanguageUtils {
const int ComponentVersion::NoVersion = -1;
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));
}
namespace LanguageUtils {
bool operator<(const ComponentVersion &lhs, const ComponentVersion &rhs)
{
return lhs.majorVersion() < rhs.majorVersion()
@@ -121,4 +119,4 @@ bool operator!=(const ComponentVersion &lhs, const ComponentVersion &rhs)
return !(lhs == rhs);
}
}
} // namespace LanguageUtils

View File

@@ -47,21 +47,19 @@ public:
explicit ComponentVersion(const QString &versionString);
~ComponentVersion();
int majorVersion() const
{ return _major; }
int minorVersion() const
{ return _minor; }
int majorVersion() const { return _major; }
int minorVersion() const { return _minor; }
friend bool LANGUAGEUTILS_EXPORT operator<(const ComponentVersion &lhs, const ComponentVersion &rhs);
friend bool LANGUAGEUTILS_EXPORT operator<=(const ComponentVersion &lhs, const ComponentVersion &rhs);
friend bool LANGUAGEUTILS_EXPORT operator>(const ComponentVersion &lhs, const ComponentVersion &rhs);
friend bool LANGUAGEUTILS_EXPORT operator>=(const ComponentVersion &lhs, const ComponentVersion &rhs);
friend bool LANGUAGEUTILS_EXPORT operator==(const ComponentVersion &lhs, const ComponentVersion &rhs);
friend bool LANGUAGEUTILS_EXPORT operator!=(const ComponentVersion &lhs, const ComponentVersion &rhs);
bool isValid() const;
QString toString() const;
void addToHash(QCryptographicHash &hash) const;
};
bool LANGUAGEUTILS_EXPORT operator<(const ComponentVersion &lhs, const ComponentVersion &rhs);
bool LANGUAGEUTILS_EXPORT operator<=(const ComponentVersion &lhs, const ComponentVersion &rhs);
bool LANGUAGEUTILS_EXPORT operator>(const ComponentVersion &lhs, const ComponentVersion &rhs);
bool LANGUAGEUTILS_EXPORT operator>=(const ComponentVersion &lhs, const ComponentVersion &rhs);
bool LANGUAGEUTILS_EXPORT operator==(const ComponentVersion &lhs, const ComponentVersion &rhs);
bool LANGUAGEUTILS_EXPORT operator!=(const ComponentVersion &lhs, const ComponentVersion &rhs);
} // namespace LanguageUtils

View File

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

View File

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

View File

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

View File

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

View File

@@ -58,16 +58,7 @@ struct IconKey {
{
}
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;
};
bool operator==(const IconKey &lhs, const IconKey &rhs) {
friend bool operator==(const IconKey &lhs, const IconKey &rhs) {
return lhs.m_element == rhs.m_element
&& lhs.m_stereotypes == rhs.m_stereotypes
&& lhs.m_defaultIconPath == rhs.m_defaultIconPath
@@ -77,11 +68,20 @@ bool operator==(const IconKey &lhs, const IconKey &rhs) {
&& 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)
+ 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

View File

@@ -72,22 +72,22 @@ public:
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.
return sh1.h == sh2.h && sh1.str && sh2.str && strcmp(sh1.str, sh2.str) == 0;
}
static auto qHash(const StringHolder &sh)
{
return QT_PREPEND_NAMESPACE(qHash)(sh.h, 0);
}
int n = 0;
const char *str = nullptr;
quintptr h;
};
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();
}
} // namespace Utils
QT_BEGIN_NAMESPACE
QDataStream &operator<<(QDataStream &ds, Utils::Id id)
{
return ds << id.name();
@@ -360,4 +356,4 @@ QDebug operator<<(QDebug dbg, const Utils::Id &id)
return dbg << id.name();
}
QT_END_NAMESPACE
} // namespace Utils

View File

@@ -74,21 +74,18 @@ public:
static QSet<Id> fromStringList(const QStringList &list);
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:
explicit Id(quintptr uid) : m_id(uid) {}
quintptr m_id = 0;
};
inline QHashValueType qHash(Id id) { return static_cast<QHashValueType>(id.uniqueIdentifier()); }
} // namespace Utils
Q_DECLARE_METATYPE(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;
void setPreferredSuffix(const QString &suffix);
friend auto qHash(const MimeType &mime) { return qHash(mime.name()); }
protected:
friend class Internal::MimeTypeParserBase;
friend class Internal::MimeTypeMapEntry;
@@ -120,8 +122,6 @@ protected:
QExplicitlySharedDataPointer<Internal::MimeTypePrivate> d;
};
inline auto qHash(const MimeType &mime) { return qHash(mime.name()); }
} // Utils
//Q_DECLARE_SHARED(Utils::MimeType)

View File

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

View File

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

View File

@@ -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<FileInfo>;
inline bool operator==(const FileInfo &lhs, const FileInfo &rhs) {
return lhs.file == rhs.file;
}
class FileInfoSelection {
public:
QSet<Utils::FilePath> dirs;

View File

@@ -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<Diagnostic>;
Utils::QHashValueType qHash(const Diagnostic &diagnostic);
} // namespace Internal
} // namespace ClangTools

View File

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

View File

@@ -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

View File

@@ -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

View File

@@ -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<CMakeConfigItem>
{
public:

View File

@@ -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:

View File

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

View File

@@ -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<SearchResultColor::Style, SearchResultColor>;
} // namespace Core

View File

@@ -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<QWidget> m_widget;
@@ -89,4 +91,3 @@ protected:
};
} // namespace Core
CORE_EXPORT QDebug operator<<(QDebug debug, const Core::Context &context);

View File

@@ -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:

View File

@@ -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<ProjectFile>;
const char *projectFileKindToText(ProjectFile::Kind kind);
QDebug operator<<(QDebug stream, const CppEditor::ProjectFile &projectFile);
} // namespace CppEditor

View File

@@ -33,8 +33,13 @@
#include <QtTest>
// 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<Selection> 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)

View File

@@ -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<OverrideItem> 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)

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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<void(TextEditor::TextDocument *,
const QList<ExpandedSemanticToken> &, int, bool)>;

View File

@@ -60,22 +60,22 @@ protected:
struct Section
{
QString name;
int priority;
};
inline bool operator<(const Section &lhs, const Section &rhs)
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;
}
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;
}
QString name;
int priority;
};
class SectionedProducts : public QStackedWidget
{
Q_OBJECT

View File

@@ -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

View File

@@ -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);

View File

@@ -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

View File

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

View File

@@ -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

View File

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

View File

@@ -70,6 +70,19 @@ public:
static Macro fromKeyValue(const QByteArray &text);
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:
QByteArray key;
QByteArray value;
@@ -84,19 +97,4 @@ private:
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

View File

@@ -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<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 bool containsType(const Tasks &issues, Task::TaskType);

View File

@@ -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

View File

@@ -36,7 +36,8 @@ QT_END_NAMESPACE
namespace QmlJSEditor {
class QmlJsEditingSettings {
class QmlJsEditingSettings
{
public:
QmlJsEditingSettings();
@@ -63,6 +64,11 @@ namespace QmlJSEditor {
bool foldAuxData() const;
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:
bool m_enableContextPane;
bool m_pinContextPane;
@@ -71,12 +77,6 @@ namespace QmlJSEditor {
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 {
class QmlJsEditingSettingsPage : public Core::IOptionsPage

View File

@@ -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

View File

@@ -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)

View File

@@ -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 &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, const QmlNote &note);
private:
int m_typeIndex;
int m_collapsedRow;
qint64 m_startTime;
@@ -60,12 +63,6 @@ private:
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
Q_DECLARE_METATYPE(QmlProfiler::QmlNote)

View File

@@ -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 "<QtGui/[Class]>" or just "<[Class]>"
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

View File

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

View File

@@ -52,6 +52,9 @@ public:
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_mouseNavigation;
bool m_scrollWheelZooming;
@@ -61,7 +64,4 @@ public:
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

View File

@@ -81,6 +81,9 @@ public:
QString toString() const;
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:
QColor m_foreground;
QColor m_background;
@@ -94,10 +97,6 @@ private:
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
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 load(const QString &fileName);
inline bool equals(const ColorScheme &cs) const
bool equals(const ColorScheme &cs) const
{
return m_formats == cs.m_formats
&& m_displayName == cs.m_displayName;
return m_formats == cs.m_formats && m_displayName == cs.m_displayName;
}
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:
QMap<TextStyle, Format> 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

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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<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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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<Parenthesis>;
TEXTEDITOR_EXPORT void insertSorted(Parentheses &list, const Parenthesis &elem);
TEXTEDITOR_EXPORT QDebug operator<<(QDebug debug, const Parenthesis &parenthesis);
class TEXTEDITOR_EXPORT CodeFormatterData
{
public:

View File

@@ -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)

View File

@@ -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

View File

@@ -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<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
// 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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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