/***************************************************************************
- * Copyright (C) 2005-2018 by the Quassel Project *
+ * Copyright (C) 2005-2020 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
{
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!
/**
* Construct an empty NicknameMatcher
*/
- NickHighlightMatcher() {}
+ NickHighlightMatcher() = default;
/**
* Construct a configured NicknameMatcher
* @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
*
* @param highlightMode Nickname highlighting mode
*/
- void setHighlightMode(HighlightNickType highlightMode) {
+ void setHighlightMode(HighlightNickType highlightMode)
+ {
if (_highlightMode != highlightMode) {
_highlightMode = highlightMode;
invalidateNickCache();
*
* @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();
* @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:
/**
*
* @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;
}
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
* @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();
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<NetworkId, NickMatchCache> _nickMatchCache; ///< Per-network nick matching cache
-
+ mutable QHash<NetworkId, NickMatchCache> _nickMatchCache; ///< Per-network nick matching cache
};