diff options
author | hjk <hjk@qt.io> | 2021-12-06 05:11:04 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2021-12-06 17:10:49 +0000 |
commit | 104ea4accc8bf7d2e317c10638a299c3af267ede (patch) | |
tree | 8ab53d49a45cb72372a5294d272a7e43c815d661 /src/plugins/texteditor/colorscheme.h | |
parent | 8cb5c3cfdd07f98449d3df0a676c5026c33f6b7a (diff) |
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>
Diffstat (limited to 'src/plugins/texteditor/colorscheme.h')
-rw-r--r-- | src/plugins/texteditor/colorscheme.h | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/plugins/texteditor/colorscheme.h b/src/plugins/texteditor/colorscheme.h index 22b625ec24..6548742dae 100644 --- a/src/plugins/texteditor/colorscheme.h +++ b/src/plugins/texteditor/colorscheme.h @@ -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 |