X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fqtuimessageprocessor.h;h=bf437660c319998b75f71fddc697a1573abe0f13;hp=d8559d362f8de405a0bf8d1ea8420bd1a684125c;hb=3a3e844f9fcfd12235a0086af75ecd503b621ef4;hpb=54ebc1bf00f4f9a8376629925329f0e72be04662 diff --git a/src/qtui/qtuimessageprocessor.h b/src/qtui/qtuimessageprocessor.h index d8559d36..bf437660 100644 --- a/src/qtui/qtuimessageprocessor.h +++ b/src/qtui/qtuimessageprocessor.h @@ -22,9 +22,11 @@ #define QTUIMESSAGEPROCESSOR_H_ #include +#include #include "abstractmessageprocessor.h" #include "expressionmatch.h" +#include "nickhighlightmatcher.h" class QtUiMessageProcessor : public AbstractMessageProcessor { @@ -41,11 +43,23 @@ public: inline bool isProcessing() const { return _processing; } inline Mode processMode() const { return _processMode; } - void reset(); + void reset() override; public slots: - void process(Message &msg); - void process(QList &msgs); + void process(Message &msg) override; + void process(QList &msgs) override; + + /** + * Network removed from system + * + * Handles cleaning up cache from stale networks. + * + * @param id Network ID of removed network + */ + inline void networkRemoved(NetworkId id) { + // Clean up nickname matching cache + _nickMatcher.removeNetwork(id); + } private slots: void processNextMessage(); @@ -76,8 +90,8 @@ private: */ LegacyHighlightRule(QString contents, bool isRegEx, bool isCaseSensitive, bool isEnabled, QString chanName) - : _contents(contents), _isRegEx(isRegEx), _isCaseSensitive(isCaseSensitive), - _isEnabled(isEnabled), _chanName(chanName) + : _contents(std::move(contents)), _isRegEx(isRegEx), _isCaseSensitive(isCaseSensitive), + _isEnabled(isEnabled), _chanName(std::move(chanName)) { _cacheInvalid = true; // Cache expression matches on construction @@ -239,33 +253,12 @@ private: using HighlightNickType = NotificationSettings::HighlightNickType; - /** - * Update internal cache of expression matching if needed - */ - void determineNickExpressions(const QString ¤tNick, - const QStringList identityNicks) const; + LegacyHighlightRuleList _highlightRuleList; ///< Custom highlight rule list + NickHighlightMatcher _nickMatcher = {}; ///< Nickname highlight matcher - /** - * Check if nickname matching cache is invalid - * @param currentNick - * @param identityNicks - * @return - */ - bool cacheNickInvalid(const QString ¤tNick, const QStringList identityNicks) const { - if (_cacheNickConfigInvalid) return true; - if (_cachedNickCurrent != currentNick) return true; - if (_cachedIdentityNicks != identityNicks) return true; - } - - LegacyHighlightRuleList _highlightRuleList; + /// Nickname highlighting mode HighlightNickType _highlightNick = HighlightNickType::CurrentNick; - bool _nicksCaseSensitive = false; - - // These represent internal cache and should be safe to mutate in 'const' functions - mutable bool _cacheNickConfigInvalid = true; ///< If true, nick match cache needs redone - mutable QString _cachedNickCurrent = {}; ///< Last cached current nick - mutable QStringList _cachedIdentityNicks = {}; ///< Last cached identity nicks - mutable ExpressionMatch _cachedNickMatcher = {}; ///< Expression match cache for nicks + bool _nicksCaseSensitive = false; ///< If true, match nicknames with exact case QList > _processQueue; QList _currentBatch;