diff --git a/src/common/Channel.cpp b/src/common/Channel.cpp index 04e7cc7de..26d9e536e 100644 --- a/src/common/Channel.cpp +++ b/src/common/Channel.cpp @@ -17,10 +17,10 @@ namespace chatterino { -Channel::Channel(const QString &_name, Type _type) +Channel::Channel(const QString &_name, Type type) : name(_name) , completionModel(this->name) - , type_(_type) + , type_(type) { QObject::connect(&this->clearCompletionModelTimer_, &QTimer::timeout, [this]() { this->completionModel.clearExpiredStrings(); // diff --git a/src/common/Channel.hpp b/src/common/Channel.hpp index ef8a53abd..552349419 100644 --- a/src/common/Channel.hpp +++ b/src/common/Channel.hpp @@ -29,7 +29,7 @@ public: Misc }; - explicit Channel(const QString &_name, Type type_); + explicit Channel(const QString &name, Type type); virtual ~Channel(); pajlada::Signals::Signal sendMessageSignal; diff --git a/src/common/ChatterinoSetting.hpp b/src/common/ChatterinoSetting.hpp index 9bd4c0225..226610381 100644 --- a/src/common/ChatterinoSetting.hpp +++ b/src/common/ChatterinoSetting.hpp @@ -11,14 +11,14 @@ template class ChatterinoSetting : public pajlada::Settings::Setting { public: - ChatterinoSetting(const std::string &_path) - : pajlada::Settings::Setting(_path) + ChatterinoSetting(const std::string &path) + : pajlada::Settings::Setting(path) { _registerSetting(this->data); } - ChatterinoSetting(const std::string &_path, const Type &_defaultValue) - : pajlada::Settings::Setting(_path, _defaultValue) + ChatterinoSetting(const std::string &path, const Type &defaultValue) + : pajlada::Settings::Setting(path, defaultValue) { _registerSetting(this->data); } diff --git a/src/common/CompletionModel.cpp b/src/common/CompletionModel.cpp index 9df3dfd2e..de5bafce8 100644 --- a/src/common/CompletionModel.cpp +++ b/src/common/CompletionModel.cpp @@ -73,8 +73,8 @@ bool CompletionModel::TaggedString::operator<(const TaggedString &that) const // -- CompletionModel -CompletionModel::CompletionModel(const QString &_channelName) - : channelName_(_channelName) +CompletionModel::CompletionModel(const QString &channelName) + : channelName_(channelName) { } diff --git a/src/common/CompletionModel.hpp b/src/common/CompletionModel.hpp index 9f0d27979..5bae63be0 100644 --- a/src/common/CompletionModel.hpp +++ b/src/common/CompletionModel.hpp @@ -45,7 +45,7 @@ class CompletionModel : public QAbstractListModel }; public: - CompletionModel(const QString &_channelName); + CompletionModel(const QString &channelName); virtual int columnCount(const QModelIndex &) const override; virtual QVariant data(const QModelIndex &index, int) const override; diff --git a/src/common/Emotemap.cpp b/src/common/Emotemap.cpp index 7b0042e4b..b8903afd9 100644 --- a/src/common/Emotemap.cpp +++ b/src/common/Emotemap.cpp @@ -5,8 +5,8 @@ namespace chatterino { -EmoteData::EmoteData(Image *_image) - : image1x(_image) +EmoteData::EmoteData(Image *image) + : image1x(image) { } diff --git a/src/common/Emotemap.hpp b/src/common/Emotemap.hpp index 3c8b86a08..d4010048d 100644 --- a/src/common/Emotemap.hpp +++ b/src/common/Emotemap.hpp @@ -8,7 +8,7 @@ namespace chatterino { struct EmoteData { EmoteData() = default; - EmoteData(Image *_image); + EmoteData(Image *image); // Emotes must have a 1x image to be valid bool isValid() const; diff --git a/src/common/NetworkRequest.cpp b/src/common/NetworkRequest.cpp index 74698a986..796a54309 100644 --- a/src/common/NetworkRequest.cpp +++ b/src/common/NetworkRequest.cpp @@ -24,9 +24,9 @@ void NetworkRequest::setRequestType(RequestType newRequestType) this->data.requestType = newRequestType; } -void NetworkRequest::setCaller(const QObject *_caller) +void NetworkRequest::setCaller(const QObject *caller) { - this->data.caller = _caller; + this->data.caller = caller; } void NetworkRequest::setOnReplyCreated(std::function f) diff --git a/src/common/NetworkRequest.hpp b/src/common/NetworkRequest.hpp index 6fcc069a6..d9685a5b0 100644 --- a/src/common/NetworkRequest.hpp +++ b/src/common/NetworkRequest.hpp @@ -135,7 +135,7 @@ public: } void setUseQuickLoadCache(bool value); - void setCaller(const QObject *_caller); + void setCaller(const QObject *caller); void setOnReplyCreated(std::function f); void setRawHeader(const char *headerName, const char *value); void setRawHeader(const char *headerName, const QByteArray &value); diff --git a/src/common/Property.hpp b/src/common/Property.hpp index c888aa16f..99d0efa48 100644 --- a/src/common/Property.hpp +++ b/src/common/Property.hpp @@ -12,23 +12,23 @@ public: { } - Property(const T &_value) - : value(_value) + Property(const T &value) + : value_(value) { } T &operator=(const T &f) { - return value = f; + return value_ = f; } operator T const &() const { - return value; + return value_; } protected: - T value; + T value_; }; } // namespace chatterino diff --git a/src/common/SerializeCustom.hpp b/src/common/SerializeCustom.hpp index 7a85f4a23..9aa31bcfb 100644 --- a/src/common/SerializeCustom.hpp +++ b/src/common/SerializeCustom.hpp @@ -10,9 +10,7 @@ template <> struct Serialize { static rapidjson::Value get(const QString &value, rapidjson::Document::AllocatorType &a) { - rapidjson::Value ret(value.toUtf8(), a); - - return ret; + return rapidjson::Value(value.toUtf8(), a); } }; @@ -27,10 +25,7 @@ struct Deserialize { } try { - const char *str = value.GetString(); - auto strLen = value.GetStringLength(); - - return QString::fromUtf8(str, strLen); + return QString::fromUtf8(value.GetString(), value.GetStringLength()); } catch (const std::exception &) { // int x = 5; } catch (...) { diff --git a/src/common/SignalVector.hpp b/src/common/SignalVector.hpp index 98253e451..0594b8847 100644 --- a/src/common/SignalVector.hpp +++ b/src/common/SignalVector.hpp @@ -23,10 +23,10 @@ class ReadOnlySignalVector : boost::noncopyable public: ReadOnlySignalVector() { - QObject::connect(&this->itemsChangedTimer, &QTimer::timeout, + QObject::connect(&this->itemsChangedTimer_, &QTimer::timeout, [this] { this->delayedItemsChanged.invoke(); }); - this->itemsChangedTimer.setInterval(100); - this->itemsChangedTimer.setSingleShot(true); + this->itemsChangedTimer_.setInterval(100); + this->itemsChangedTimer_.setSingleShot(true); } virtual ~ReadOnlySignalVector() = default; @@ -38,23 +38,23 @@ public: { assertInGuiThread(); - return this->vector; + return this->vector_; } void invokeDelayedItemsChanged() { assertInGuiThread(); - if (!this->itemsChangedTimer.isActive()) { - itemsChangedTimer.start(); + if (!this->itemsChangedTimer_.isActive()) { + this->itemsChangedTimer_.start(); } } virtual bool isSorted() const = 0; protected: - std::vector vector; - QTimer itemsChangedTimer; + std::vector vector_; + QTimer itemsChangedTimer_; }; template @@ -68,10 +68,10 @@ public: void removeItem(int index, void *caller = nullptr) { assertInGuiThread(); - assert(index >= 0 && index < this->vector.size()); + assert(index >= 0 && index < this->vector_.size()); - TVectorItem item = this->vector[index]; - this->vector.erase(this->vector.begin() + index); + TVectorItem item = this->vector_[index]; + this->vector_.erase(this->vector_.begin() + index); SignalVectorItemArgs args{item, index, caller}; this->itemRemoved.invoke(args); @@ -92,12 +92,12 @@ public: { assertInGuiThread(); if (index == -1) { - index = this->vector.size(); + index = this->vector_.size(); } else { - assert(index >= 0 && index <= this->vector.size()); + assert(index >= 0 && index <= this->vector_.size()); } - this->vector.insert(this->vector.begin() + index, item); + this->vector_.insert(this->vector_.begin() + index, item); SignalVectorItemArgs args{item, index, caller}; this->itemInserted.invoke(args); @@ -119,9 +119,9 @@ public: { assertInGuiThread(); - auto it = std::lower_bound(this->vector.begin(), this->vector.end(), item, Compare{}); - int index = it - this->vector.begin(); - this->vector.insert(it, item); + auto it = std::lower_bound(this->vector_.begin(), this->vector_.end(), item, Compare{}); + int index = it - this->vector_.begin(); + this->vector_.insert(it, item); SignalVectorItemArgs args{item, index, caller}; this->itemInserted.invoke(args); diff --git a/src/common/SignalVectorModel.hpp b/src/common/SignalVectorModel.hpp index c4fe7485a..cab31c063 100644 --- a/src/common/SignalVectorModel.hpp +++ b/src/common/SignalVectorModel.hpp @@ -16,16 +16,16 @@ class SignalVectorModel : public QAbstractTableModel, pajlada::Signals::SignalHo public: SignalVectorModel(int columnCount, QObject *parent = nullptr) : QAbstractTableModel(parent) - , _columnCount(columnCount) + , columnCount_(columnCount) { for (int i = 0; i < columnCount; i++) { - this->_headerData.emplace_back(); + this->headerData_.emplace_back(); } } void init(BaseSignalVector *vec) { - this->vector = vec; + this->vector_ = vec; auto insert = [this](const SignalVectorItemArgs &args) { if (args.caller == this) { @@ -33,7 +33,7 @@ public: } // get row index int index = this->getModelIndexFromVectorIndex(args.index); - assert(index >= 0 && index <= this->rows.size()); + assert(index >= 0 && index <= this->rows_.size()); // get row items std::vector row = this->createRow(); @@ -43,7 +43,7 @@ public: index = this->beforeInsert(args.item, row, index); this->beginInsertRows(QModelIndex(), index, index); - this->rows.insert(this->rows.begin() + index, Row(row, args.item)); + this->rows_.insert(this->rows_.begin() + index, Row(row, args.item)); this->endInsertRows(); }; @@ -62,13 +62,13 @@ public: } int row = this->getModelIndexFromVectorIndex(args.index); - assert(row >= 0 && row <= this->rows.size()); + assert(row >= 0 && row <= this->rows_.size()); // remove row - std::vector items = std::move(this->rows[row].items); + std::vector items = std::move(this->rows_[row].items); this->beginRemoveRows(QModelIndex(), row, row); - this->rows.erase(this->rows.begin() + row); + this->rows_.erase(this->rows_.begin() + row); this->endRemoveRows(); this->afterRemoved(args.item, items, row); @@ -83,7 +83,7 @@ public: virtual ~SignalVectorModel() { - for (Row &row : this->rows) { + for (Row &row : this->rows_) { for (QStandardItem *item : row.items) { delete item; } @@ -92,28 +92,28 @@ public: int rowCount(const QModelIndex &parent) const override { - return this->rows.size(); + return this->rows_.size(); } int columnCount(const QModelIndex &parent) const override { - return this->_columnCount; + return this->columnCount_; } QVariant data(const QModelIndex &index, int role) const override { int row = index.row(), column = index.column(); - assert(row >= 0 && row < this->rows.size() && column >= 0 && column < this->_columnCount); + assert(row >= 0 && row < this->rows_.size() && column >= 0 && column < this->columnCount_); - return rows[row].items[column]->data(role); + return rows_[row].items[column]->data(role); } bool setData(const QModelIndex &index, const QVariant &value, int role) override { int row = index.row(), column = index.column(); - assert(row >= 0 && row < this->rows.size() && column >= 0 && column < this->_columnCount); + assert(row >= 0 && row < this->rows_.size() && column >= 0 && column < this->columnCount_); - Row &rowItem = this->rows[row]; + Row &rowItem = this->rows_[row]; rowItem.items[column]->setData(value, role); @@ -121,12 +121,12 @@ public: this->customRowSetData(rowItem.items, column, value, role); } else { int vecRow = this->getVectorIndexFromModelIndex(row); - this->vector->removeItem(vecRow, this); + this->vector_->removeItem(vecRow, this); - assert(this->rows[row].original); + assert(this->rows_[row].original); TVectorItem item = - this->getItemFromRow(this->rows[row].items, this->rows[row].original.get()); - this->vector->insertItem(item, vecRow, this); + this->getItemFromRow(this->rows_[row].items, this->rows_[row].original.get()); + this->vector_->insertItem(item, vecRow, this); } return true; @@ -138,8 +138,8 @@ public: return QVariant(); } - auto it = this->_headerData[section].find(role); - if (it == this->_headerData[section].end()) { + auto it = this->headerData_[section].find(role); + if (it == this->headerData_[section].end()) { return QVariant(); } else { return it.value(); @@ -153,7 +153,7 @@ public: return false; } - this->_headerData[section][role] = value; + this->headerData_[section][role] = value; emit this->headerDataChanged(Qt::Horizontal, section, section); return true; @@ -162,22 +162,22 @@ public: Qt::ItemFlags flags(const QModelIndex &index) const override { int row = index.row(), column = index.column(); - assert(row >= 0 && row < this->rows.size() && column >= 0 && column < this->_columnCount); + assert(row >= 0 && row < this->rows_.size() && column >= 0 && column < this->columnCount_); - return this->rows[index.row()].items[index.column()]->flags(); + return this->rows_[index.row()].items[index.column()]->flags(); } QStandardItem *getItem(int row, int column) { - assert(row >= 0 && row < this->rows.size() && column >= 0 && column < this->_columnCount); + assert(row >= 0 && row < this->rows_.size() && column >= 0 && column < this->columnCount_); - return rows[row].items[column]; + return rows_[row].items[column]; } void deleteRow(int row) { int signalVectorRow = this->getVectorIndexFromModelIndex(row); - this->vector->removeItem(signalVectorRow); + this->vector_->removeItem(signalVectorRow); } bool removeRows(int row, int count, const QModelIndex &parent) override @@ -186,10 +186,10 @@ public: return false; } - assert(row >= 0 && row < this->rows.size()); + assert(row >= 0 && row < this->rows_.size()); int signalVectorRow = this->getVectorIndexFromModelIndex(row); - this->vector->removeItem(signalVectorRow); + this->vector_->removeItem(signalVectorRow); return true; } @@ -223,27 +223,27 @@ protected: void insertCustomRow(std::vector row, int index) { - assert(index >= 0 && index <= this->rows.size()); + assert(index >= 0 && index <= this->rows_.size()); this->beginInsertRows(QModelIndex(), index, index); - this->rows.insert(this->rows.begin() + index, Row(std::move(row), true)); + this->rows_.insert(this->rows_.begin() + index, Row(std::move(row), true)); this->endInsertRows(); } void removeCustomRow(int index) { - assert(index >= 0 && index <= this->rows.size()); - assert(this->rows[index].isCustomRow); + assert(index >= 0 && index <= this->rows_.size()); + assert(this->rows_[index].isCustomRow); this->beginRemoveRows(QModelIndex(), index, index); - this->rows.erase(this->rows.begin() + index); + this->rows_.erase(this->rows_.begin() + index); this->endRemoveRows(); } std::vector createRow() { std::vector row; - for (int i = 0; i < this->_columnCount; i++) { + for (int i = 0; i < this->columnCount_; i++) { row.push_back(new QStandardItem()); } return row; @@ -268,20 +268,20 @@ protected: { } }; - std::vector rows; private: - std::vector> _headerData; - BaseSignalVector *vector; + std::vector> headerData_; + BaseSignalVector *vector_; + std::vector rows_; - int _columnCount; + int columnCount_; // returns the related index of the SignalVector int getVectorIndexFromModelIndex(int index) { int i = 0; - for (auto &row : this->rows) { + for (auto &row : this->rows_) { if (row.isCustomRow) { index--; continue; @@ -301,7 +301,7 @@ private: { int i = 0; - for (auto &row : this->rows) { + for (auto &row : this->rows_) { if (row.isCustomRow) { index++; } diff --git a/src/common/SimpleSignalVector.hpp b/src/common/SimpleSignalVector.hpp index 64440fc61..6aca458f5 100644 --- a/src/common/SimpleSignalVector.hpp +++ b/src/common/SimpleSignalVector.hpp @@ -13,7 +13,7 @@ class SimpleSignalVector public: SimpleSignalVector &operator=(std::vector &other) { - this->data = other; + this->data_ = other; this->updated.invoke(); @@ -22,13 +22,13 @@ public: operator std::vector &() { - return this->data; + return this->data_; } pajlada::Signals::NoArgSignal updated; private: - std::vector data; + std::vector data_; }; } // namespace chatterino diff --git a/src/controllers/accounts/Account.cpp b/src/controllers/accounts/Account.cpp index ae3e0e384..234723946 100644 --- a/src/controllers/accounts/Account.cpp +++ b/src/controllers/accounts/Account.cpp @@ -4,13 +4,13 @@ namespace chatterino { -Account::Account(ProviderId _providerId) - : providerId(_providerId) +Account::Account(ProviderId providerId) + : providerId_(providerId) { static QString twitch("Twitch"); - this->category = [&]() { - switch (_providerId) { + this->category_ = [&]() { + switch (providerId) { case ProviderId::Twitch: return twitch; } @@ -20,12 +20,12 @@ Account::Account(ProviderId _providerId) const QString &Account::getCategory() const { - return this->category; + return this->category_; } ProviderId Account::getProviderId() const { - return this->providerId; + return this->providerId_; } bool Account::operator<(const Account &other) const @@ -33,7 +33,7 @@ bool Account::operator<(const Account &other) const QString a = this->toString(); QString b = other.toString(); - return std::tie(this->category, a) < std::tie(other.category, b); + return std::tie(this->category_, a) < std::tie(other.category_, b); } } // namespace chatterino diff --git a/src/controllers/accounts/Account.hpp b/src/controllers/accounts/Account.hpp index 1e9aef5d6..f288aa09b 100644 --- a/src/controllers/accounts/Account.hpp +++ b/src/controllers/accounts/Account.hpp @@ -19,8 +19,8 @@ public: bool operator<(const Account &other) const; private: - ProviderId providerId; - QString category; + ProviderId providerId_; + QString category_; }; } // namespace chatterino diff --git a/src/controllers/accounts/AccountController.cpp b/src/controllers/accounts/AccountController.cpp index 375c972d2..17dca956a 100644 --- a/src/controllers/accounts/AccountController.cpp +++ b/src/controllers/accounts/AccountController.cpp @@ -7,7 +7,7 @@ namespace chatterino { AccountController::AccountController() { this->twitch.accounts.itemInserted.connect([this](const auto &args) { - this->accounts.insertItem(std::dynamic_pointer_cast(args.item)); + this->accounts_.insertItem(std::dynamic_pointer_cast(args.item)); }); this->twitch.accounts.itemRemoved.connect([this](const auto &args) { @@ -16,11 +16,11 @@ AccountController::AccountController() auto it = std::find(accs.begin(), accs.end(), args.item); assert(it != accs.end()); - this->accounts.removeItem(it - accs.begin()); + this->accounts_.removeItem(it - accs.begin()); } }); - this->accounts.itemRemoved.connect([this](const auto &args) { + this->accounts_.itemRemoved.connect([this](const auto &args) { switch (args.item->getProviderId()) { case ProviderId::Twitch: { auto &accs = this->twitch.accounts.getVector(); @@ -42,7 +42,7 @@ AccountModel *AccountController::createModel(QObject *parent) { AccountModel *model = new AccountModel(parent); - model->init(&this->accounts); + model->init(&this->accounts_); return model; } diff --git a/src/controllers/accounts/AccountController.hpp b/src/controllers/accounts/AccountController.hpp index 4e16caaa3..2b273bfcd 100644 --- a/src/controllers/accounts/AccountController.hpp +++ b/src/controllers/accounts/AccountController.hpp @@ -23,7 +23,7 @@ public: TwitchAccountManager twitch; private: - SortedSignalVector, SharedPtrElementLess> accounts; + SortedSignalVector, SharedPtrElementLess> accounts_; }; } // namespace chatterino diff --git a/src/controllers/accounts/AccountModel.cpp b/src/controllers/accounts/AccountModel.cpp index 3302f59b4..d18946468 100644 --- a/src/controllers/accounts/AccountModel.cpp +++ b/src/controllers/accounts/AccountModel.cpp @@ -27,7 +27,7 @@ void AccountModel::getRowFromItem(const std::shared_ptr &item, int AccountModel::beforeInsert(const std::shared_ptr &item, std::vector &row, int proposedIndex) { - if (this->categoryCount[item->getCategory()]++ == 0) { + if (this->categoryCount_[item->getCategory()]++ == 0) { auto row = this->createRow(); setStringItem(row[0], item->getCategory(), false, false); @@ -44,11 +44,11 @@ int AccountModel::beforeInsert(const std::shared_ptr &item, void AccountModel::afterRemoved(const std::shared_ptr &item, std::vector &row, int index) { - auto it = this->categoryCount.find(item->getCategory()); - assert(it != this->categoryCount.end()); + auto it = this->categoryCount_.find(item->getCategory()); + assert(it != this->categoryCount_.end()); if (it->second <= 1) { - this->categoryCount.erase(it); + this->categoryCount_.erase(it); this->removeCustomRow(index - 1); } else { it->second--; diff --git a/src/controllers/accounts/AccountModel.hpp b/src/controllers/accounts/AccountModel.hpp index 714bf51ce..0ac239a2a 100644 --- a/src/controllers/accounts/AccountModel.hpp +++ b/src/controllers/accounts/AccountModel.hpp @@ -33,7 +33,7 @@ protected: friend class AccountController; private: - std::unordered_map categoryCount; + std::unordered_map categoryCount_; }; } // namespace chatterino diff --git a/src/controllers/commands/CommandController.cpp b/src/controllers/commands/CommandController.cpp index 0421d763f..fa8119037 100644 --- a/src/controllers/commands/CommandController.cpp +++ b/src/controllers/commands/CommandController.cpp @@ -28,11 +28,11 @@ namespace chatterino { CommandController::CommandController() { auto addFirstMatchToMap = [this](auto args) { - this->commandsMap.remove(args.item.name); + this->commandsMap_.remove(args.item.name); for (const Command &cmd : this->items.getVector()) { if (cmd.name == args.item.name) { - this->commandsMap[cmd.name] = cmd; + this->commandsMap_[cmd.name] = cmd; break; } } @@ -45,9 +45,9 @@ CommandController::CommandController() void CommandController::load() { auto app = getApp(); - this->filePath = app->paths->settingsDirectory + "/commands.txt"; + this->filePath_ = app->paths->settingsDirectory + "/commands.txt"; - QFile textFile(this->filePath); + QFile textFile(this->filePath_); if (!textFile.open(QIODevice::ReadOnly)) { // No commands file created yet return; @@ -68,9 +68,9 @@ void CommandController::load() void CommandController::save() { - QFile textFile(this->filePath); + QFile textFile(this->filePath_); if (!textFile.open(QIODevice::WriteOnly)) { - Log("[CommandController::saveCommands] Unable to open {} for writing", this->filePath); + Log("[CommandController::saveCommands] Unable to open {} for writing", this->filePath_); return; } @@ -95,7 +95,7 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel, Command command; { - std::lock_guard lock(this->mutex); + std::lock_guard lock(this->mutex_); if (words.length() == 0) { return text; @@ -202,8 +202,8 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel, } // check if custom command exists - auto it = this->commandsMap.find(commandName); - if (it == this->commandsMap.end()) { + auto it = this->commandsMap_.find(commandName); + if (it == this->commandsMap_.end()) { return text; } diff --git a/src/controllers/commands/CommandController.hpp b/src/controllers/commands/CommandController.hpp index 58f0c91e7..4f5005378 100644 --- a/src/controllers/commands/CommandController.hpp +++ b/src/controllers/commands/CommandController.hpp @@ -28,10 +28,10 @@ public: UnsortedSignalVector items; private: - QMap commandsMap; + QMap commandsMap_; - std::mutex mutex; - QString filePath; + std::mutex mutex_; + QString filePath_; QString execCustomCommand(const QStringList &words, const Command &command); }; diff --git a/src/controllers/highlights/HighlightBlacklistUser.hpp b/src/controllers/highlights/HighlightBlacklistUser.hpp index e56ea8d8e..122a53e89 100644 --- a/src/controllers/highlights/HighlightBlacklistUser.hpp +++ b/src/controllers/highlights/HighlightBlacklistUser.hpp @@ -13,10 +13,6 @@ namespace chatterino { class HighlightBlacklistUser { - QString pattern_; - bool isRegex_; - QRegularExpression regex_; - public: bool operator==(const HighlightBlacklistUser &other) const { @@ -58,6 +54,11 @@ public: return subject.toLower() == this->pattern_.toLower(); } + +private: + QString pattern_; + bool isRegex_; + QRegularExpression regex_; }; } // namespace chatterino diff --git a/src/controllers/highlights/HighlightController.cpp b/src/controllers/highlights/HighlightController.cpp index db759deee..32327d8fb 100644 --- a/src/controllers/highlights/HighlightController.cpp +++ b/src/controllers/highlights/HighlightController.cpp @@ -14,15 +14,15 @@ HighlightController::HighlightController() void HighlightController::initialize() { - assert(!this->initialized); - this->initialized = true; + assert(!this->initialized_); + this->initialized_ = true; - for (const HighlightPhrase &phrase : this->highlightsSetting.getValue()) { + for (const HighlightPhrase &phrase : this->highlightsSetting_.getValue()) { this->phrases.appendItem(phrase); } this->phrases.delayedItemsChanged.connect([this] { // - this->highlightsSetting.setValue(this->phrases.getVector()); + this->highlightsSetting_.setValue(this->phrases.getVector()); }); } diff --git a/src/controllers/highlights/HighlightController.hpp b/src/controllers/highlights/HighlightController.hpp index eef884b7e..f9db887b4 100644 --- a/src/controllers/highlights/HighlightController.hpp +++ b/src/controllers/highlights/HighlightController.hpp @@ -33,11 +33,11 @@ public: void addHighlight(const MessagePtr &msg); private: - bool initialized = false; + bool initialized_ = false; - ChatterinoSetting> highlightsSetting = { + ChatterinoSetting> highlightsSetting_ = { "/highlighting/highlights"}; - ChatterinoSetting> blacklistSetting = {"/highlighting/blacklist"}; + ChatterinoSetting> blacklistSetting_ = {"/highlighting/blacklist"}; }; } // namespace chatterino diff --git a/src/controllers/highlights/HighlightPhrase.hpp b/src/controllers/highlights/HighlightPhrase.hpp index b27daaac3..fe4ed5cc2 100644 --- a/src/controllers/highlights/HighlightPhrase.hpp +++ b/src/controllers/highlights/HighlightPhrase.hpp @@ -11,61 +11,57 @@ namespace chatterino { class HighlightPhrase { - QString pattern; - bool alert; - bool sound; - bool _isRegex; - QRegularExpression regex; - public: bool operator==(const HighlightPhrase &other) const { - return std::tie(this->pattern, this->sound, this->alert, this->_isRegex) == - std::tie(other.pattern, other.sound, other.alert, other._isRegex); + return std::tie(this->pattern_, this->sound_, this->alert_, this->isRegex_) == + std::tie(other.pattern_, other.sound_, other.alert_, other.isRegex_); } - HighlightPhrase(const QString &_pattern, bool _alert, bool _sound, bool isRegex) - : pattern(_pattern) - , alert(_alert) - , sound(_sound) - , _isRegex(isRegex) - , regex(_isRegex ? _pattern : "\\b" + QRegularExpression::escape(_pattern) + "\\b", - QRegularExpression::CaseInsensitiveOption | - QRegularExpression::UseUnicodePropertiesOption) + HighlightPhrase(const QString &pattern, bool alert, bool sound, bool isRegex) + : pattern_(pattern) + , alert_(alert) + , sound_(sound) + , isRegex_(isRegex) + , regex_(isRegex_ ? pattern : "\\b" + QRegularExpression::escape(pattern) + "\\b", + QRegularExpression::CaseInsensitiveOption | + QRegularExpression::UseUnicodePropertiesOption) { } const QString &getPattern() const { - return this->pattern; + return this->pattern_; } bool getAlert() const { - return this->alert; + return this->alert_; } bool getSound() const { - return this->sound; + return this->sound_; } bool isRegex() const { - return this->_isRegex; + return this->isRegex_; } bool isValid() const { - return !this->pattern.isEmpty() && this->regex.isValid(); + return !this->pattern_.isEmpty() && this->regex_.isValid(); } bool isMatch(const QString &subject) const { - return this->isValid() && this->regex.match(subject).hasMatch(); + return this->isValid() && this->regex_.match(subject).hasMatch(); } - // const QRegularExpression &getRegex() const - // { - // return this->regex; - // } +private: + QString pattern_; + bool alert_; + bool sound_; + bool isRegex_; + QRegularExpression regex_; }; } // namespace chatterino