Applied project style to multiple files
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -19,8 +19,8 @@ public:
|
||||
bool operator<(const Account &other) const;
|
||||
|
||||
private:
|
||||
ProviderId providerId;
|
||||
QString category;
|
||||
ProviderId providerId_;
|
||||
QString category_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace chatterino {
|
||||
AccountController::AccountController()
|
||||
{
|
||||
this->twitch.accounts.itemInserted.connect([this](const auto &args) {
|
||||
this->accounts.insertItem(std::dynamic_pointer_cast<Account>(args.item));
|
||||
this->accounts_.insertItem(std::dynamic_pointer_cast<Account>(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;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
TwitchAccountManager twitch;
|
||||
|
||||
private:
|
||||
SortedSignalVector<std::shared_ptr<Account>, SharedPtrElementLess<Account>> accounts;
|
||||
SortedSignalVector<std::shared_ptr<Account>, SharedPtrElementLess<Account>> accounts_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -27,7 +27,7 @@ void AccountModel::getRowFromItem(const std::shared_ptr<Account> &item,
|
||||
int AccountModel::beforeInsert(const std::shared_ptr<Account> &item,
|
||||
std::vector<QStandardItem *> &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<Account> &item,
|
||||
void AccountModel::afterRemoved(const std::shared_ptr<Account> &item,
|
||||
std::vector<QStandardItem *> &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--;
|
||||
|
||||
@@ -33,7 +33,7 @@ protected:
|
||||
friend class AccountController;
|
||||
|
||||
private:
|
||||
std::unordered_map<QString, int> categoryCount;
|
||||
std::unordered_map<QString, int> categoryCount_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -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<std::mutex> lock(this->mutex);
|
||||
std::lock_guard<std::mutex> 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,10 +28,10 @@ public:
|
||||
UnsortedSignalVector<Command> items;
|
||||
|
||||
private:
|
||||
QMap<QString, Command> commandsMap;
|
||||
QMap<QString, Command> commandsMap_;
|
||||
|
||||
std::mutex mutex;
|
||||
QString filePath;
|
||||
std::mutex mutex_;
|
||||
QString filePath_;
|
||||
|
||||
QString execCustomCommand(const QStringList &words, const Command &command);
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -33,11 +33,11 @@ public:
|
||||
void addHighlight(const MessagePtr &msg);
|
||||
|
||||
private:
|
||||
bool initialized = false;
|
||||
bool initialized_ = false;
|
||||
|
||||
ChatterinoSetting<std::vector<HighlightPhrase>> highlightsSetting = {
|
||||
ChatterinoSetting<std::vector<HighlightPhrase>> highlightsSetting_ = {
|
||||
"/highlighting/highlights"};
|
||||
ChatterinoSetting<std::vector<HighlightPhrase>> blacklistSetting = {"/highlighting/blacklist"};
|
||||
ChatterinoSetting<std::vector<HighlightPhrase>> blacklistSetting_ = {"/highlighting/blacklist"};
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user