- inline HighlightRuleManager(QObject *parent = nullptr) : SyncableObject(parent) { setAllowClientUpdates(true); }
- HighlightRuleManager &operator=(const HighlightRuleManager &other);
-
- struct HighlightRule {
- QString name;
- bool isRegEx = false;
- bool isCaseSensitive = false;
- bool isEnabled = true;
- bool isInverse = false;
- QString sender;
- QString chanName;
- HighlightRule() {}
- HighlightRule(QString name_, bool isRegEx_, bool isCaseSensitive_, bool isEnabled_, bool isInverse_,
- QString sender_, QString chanName_)
- : name(std::move(name_)), isRegEx(isRegEx_), isCaseSensitive(isCaseSensitive_), isEnabled(isEnabled_),
- isInverse(isInverse_), sender(std::move(sender_)), chanName(std::move(chanName_)) {
+ inline HighlightRuleManager(QObject* parent = nullptr)
+ : SyncableObject(parent)
+ {
+ setAllowClientUpdates(true);
+ }
+ HighlightRuleManager& operator=(const HighlightRuleManager& other);
+
+ /**
+ * Individual highlight rule
+ */
+ class COMMON_EXPORT HighlightRule
+ {
+ public:
+ /**
+ * Construct an empty highlight rule
+ */
+ HighlightRule() = default;
+
+ /**
+ * Construct a highlight rule with the given parameters
+ *
+ * @param id Integer ID of the rule
+ * @param contents String representing a message contents expression to match
+ * @param isRegEx True if regular expression, otherwise false
+ * @param isCaseSensitive True if case sensitive, otherwise false
+ * @param isEnabled True if enabled, otherwise false
+ * @param isInverse True if rule is treated as highlight ignore, otherwise false
+ * @param sender String representing a message sender expression to match
+ * @param chanName String representing a channel name expression to match
+ */
+ HighlightRule(
+ int id, QString contents, bool isRegEx, bool isCaseSensitive, bool isEnabled, bool isInverse, QString sender, QString chanName)
+ : _id(id)
+ , _contents(std::move(contents))
+ , _isRegEx(isRegEx)
+ , _isCaseSensitive(isCaseSensitive)
+ , _isEnabled(isEnabled)
+ , _isInverse(isInverse)
+ , _sender(std::move(sender))
+ , _chanName(std::move(chanName))
+ {
+ _cacheInvalid = true;
+ // Cache expression matches on construction
+ //
+ // This provides immediate feedback on errors when loading the rule. If profiling shows
+ // this as a performance bottleneck, this can be removed in deference to caching on
+ // first use.
+ //
+ // Inversely, if needed for validity checks, caching can be done on every update below
+ // instead of on first use.
+ determineExpressions();
+ }
+
+ /**
+ * Gets the unique ID of this rule
+ *
+ * @return Integer ID of the rule
+ */
+ inline int id() const { return _id; }
+ /**
+ * Sets the ID of this rule
+ *
+ * CAUTION: IDs should be kept unique!
+ *
+ * @param id Integer ID of the rule
+ */
+ inline void setId(int id) { _id = id; }
+
+ /**
+ * Gets the message contents this rule matches
+ *
+ * NOTE: Use HighlightRule::contentsMatcher() for performing matches
+ *
+ * @return String representing a phrase or expression to match
+ */
+ inline QString contents() const { return _contents; }
+ /**
+ * Sets the message contents this rule matches
+ *
+ * @param contents String representing a phrase or expression to match
+ */
+ inline void setContents(const QString& contents)
+ {
+ _contents = contents;
+ _cacheInvalid = true;
+ }
+
+ /**
+ * Gets if this is a regular expression rule
+ *
+ * @return True if regular expression, otherwise false
+ */
+ inline bool isRegEx() const { return _isRegEx; }
+ /**
+ * Sets if this rule is a regular expression rule
+ *
+ * @param isRegEx True if regular expression, otherwise false
+ */
+ inline void setIsRegEx(bool isRegEx)
+ {
+ _isRegEx = isRegEx;
+ _cacheInvalid = true;