X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fnickhighlightmatcher.h;h=e5d5dcd5c91045032bc99f712e74590de7dfae50;hp=78a8e8fa913799c061d596ef0090f95cf1d3cca3;hb=e38846f054ad1766f2e91992a57bbaffd33c7c06;hpb=92fc8c5b119111a35ab8423c3cbde5b2a022badf diff --git a/src/common/nickhighlightmatcher.h b/src/common/nickhighlightmatcher.h index 78a8e8fa..e5d5dcd5 100644 --- a/src/common/nickhighlightmatcher.h +++ b/src/common/nickhighlightmatcher.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2018 by the Quassel Project * + * Copyright (C) 2005-2019 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -36,10 +36,11 @@ class COMMON_EXPORT NickHighlightMatcher { public: /// Nickname highlighting mode - enum class HighlightNickType { - NoNick = 0x00, ///< Don't match any nickname - CurrentNick = 0x01, ///< Match the current nickname - AllNicks = 0x02 ///< Match all configured nicknames in the chosen identity + enum class HighlightNickType + { + NoNick = 0x00, ///< Don't match any nickname + CurrentNick = 0x01, ///< Match the current nickname + AllNicks = 0x02 ///< Match all configured nicknames in the chosen identity }; // NOTE: Keep this in sync with HighlightRuleManager::HighlightNickType and // NotificationSettings::HighlightNickType! @@ -47,7 +48,7 @@ public: /** * Construct an empty NicknameMatcher */ - NickHighlightMatcher() {} + NickHighlightMatcher() = default; /** * Construct a configured NicknameMatcher @@ -56,8 +57,9 @@ public: * @param isCaseSensitive If true, nick matching is case-sensitive, otherwise case-insensitive */ NickHighlightMatcher(HighlightNickType highlightMode, bool isCaseSensitive) - : _highlightMode(highlightMode), - _isCaseSensitive(isCaseSensitive) {} + : _highlightMode(highlightMode) + , _isCaseSensitive(isCaseSensitive) + {} /** * Gets the nickname highlighting policy @@ -71,7 +73,8 @@ public: * * @param highlightMode Nickname highlighting mode */ - void setHighlightMode(HighlightNickType highlightMode) { + void setHighlightMode(HighlightNickType highlightMode) + { if (_highlightMode != highlightMode) { _highlightMode = highlightMode; invalidateNickCache(); @@ -90,7 +93,8 @@ public: * * @param isCaseSensitive If true, nick matching is case-sensitive, otherwise case-insensitive */ - void setCaseSensitive(bool isCaseSensitive) { + void setCaseSensitive(bool isCaseSensitive) + { if (_isCaseSensitive != isCaseSensitive) { _isCaseSensitive = isCaseSensitive; invalidateNickCache(); @@ -108,8 +112,7 @@ public: * @param identityNicks All nicknames configured for the current identity * @return True if match found, otherwise false */ - bool match(const QString &string, const NetworkId &netId, const QString ¤tNick, - const QStringList &identityNicks) const; + bool match(const QString& string, const NetworkId& netId, const QString& currentNick, const QStringList& identityNicks) const; public slots: /** @@ -117,7 +120,8 @@ public slots: * * @param netId Network ID of source network */ - void removeNetwork(const NetworkId &netId) { + void removeNetwork(const NetworkId& netId) + { // Remove the network from the cache list if (_nickMatchCache.remove(netId) > 0) { qDebug() << "Cleared nickname matching cache for removed network ID" << netId; @@ -125,7 +129,8 @@ public slots: } private: - struct NickMatchCache { + struct NickMatchCache + { // These represent internal cache and should be safe to mutate in 'const' functions QString nickCurrent = {}; ///< Last cached current nick QStringList identityNicks = {}; ///< Last cached identity nicks @@ -139,15 +144,15 @@ private: * @param currentNick Current nickname * @param identityNicks All nicknames configured for the current identity */ - void determineExpressions(const NetworkId &netId, const QString ¤tNick, - const QStringList &identityNicks) const; + void determineExpressions(const NetworkId& netId, const QString& currentNick, const QStringList& identityNicks) const; /** * Invalidate all nickname match caches * * Use this after changing global configuration. */ - inline void invalidateNickCache() { + inline void invalidateNickCache() + { // Mark all as invalid if (_nickMatchCache.size() > 0) { _nickMatchCache.clear(); @@ -161,6 +166,5 @@ private: bool _isCaseSensitive = false; ///< If true, match nicknames with exact case // These represent internal cache and should be safe to mutate in 'const' functions - mutable QHash _nickMatchCache; ///< Per-network nick matching cache - + mutable QHash _nickMatchCache; ///< Per-network nick matching cache };