changed to 80 max column
This commit is contained in:
@@ -15,8 +15,9 @@ class HighlightBlacklistModel : public SignalVectorModel<HighlightBlacklistUser>
|
||||
|
||||
protected:
|
||||
// turn a vector item into a model row
|
||||
virtual HighlightBlacklistUser getItemFromRow(std::vector<QStandardItem *> &row,
|
||||
const HighlightBlacklistUser &original) override;
|
||||
virtual HighlightBlacklistUser getItemFromRow(
|
||||
std::vector<QStandardItem *> &row,
|
||||
const HighlightBlacklistUser &original) override;
|
||||
|
||||
// turns a row in the model into a vector item
|
||||
virtual void getRowFromItem(const HighlightBlacklistUser &item,
|
||||
|
||||
@@ -16,14 +16,16 @@ class HighlightBlacklistUser
|
||||
public:
|
||||
bool operator==(const HighlightBlacklistUser &other) const
|
||||
{
|
||||
return std::tie(this->pattern_, this->isRegex_) == std::tie(other.pattern_, other.isRegex_);
|
||||
return std::tie(this->pattern_, this->isRegex_) ==
|
||||
std::tie(other.pattern_, other.isRegex_);
|
||||
}
|
||||
|
||||
HighlightBlacklistUser(const QString &pattern, bool isRegex = false)
|
||||
: pattern_(pattern)
|
||||
, isRegex_(isRegex)
|
||||
, regex_(isRegex ? pattern : "", QRegularExpression::CaseInsensitiveOption |
|
||||
QRegularExpression::UseUnicodePropertiesOption)
|
||||
, regex_(isRegex ? pattern : "",
|
||||
QRegularExpression::CaseInsensitiveOption |
|
||||
QRegularExpression::UseUnicodePropertiesOption)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -25,12 +25,14 @@ void HighlightController::initialize(Settings &settings, Paths &paths)
|
||||
this->highlightsSetting_.setValue(this->phrases.getVector());
|
||||
});
|
||||
|
||||
for (const HighlightBlacklistUser &blacklistedUser : this->blacklistSetting_.getValue()) {
|
||||
for (const HighlightBlacklistUser &blacklistedUser :
|
||||
this->blacklistSetting_.getValue()) {
|
||||
this->blacklistedUsers.appendItem(blacklistedUser);
|
||||
}
|
||||
|
||||
this->blacklistedUsers.delayedItemsChanged.connect(
|
||||
[this] { this->blacklistSetting_.setValue(this->blacklistedUsers.getVector()); });
|
||||
this->blacklistedUsers.delayedItemsChanged.connect([this] {
|
||||
this->blacklistSetting_.setValue(this->blacklistedUsers.getVector());
|
||||
});
|
||||
}
|
||||
|
||||
HighlightModel *HighlightController::createModel(QObject *parent)
|
||||
@@ -61,7 +63,8 @@ bool HighlightController::isHighlightedUser(const QString &username)
|
||||
return false;
|
||||
}
|
||||
|
||||
HighlightBlacklistModel *HighlightController::createBlacklistModel(QObject *parent)
|
||||
HighlightBlacklistModel *HighlightController::createBlacklistModel(
|
||||
QObject *parent)
|
||||
{
|
||||
auto *model = new HighlightBlacklistModel(parent);
|
||||
model->init(&this->blacklistedUsers);
|
||||
@@ -71,7 +74,8 @@ HighlightBlacklistModel *HighlightController::createBlacklistModel(QObject *pare
|
||||
|
||||
bool HighlightController::blacklistContains(const QString &username)
|
||||
{
|
||||
std::vector<HighlightBlacklistUser> blacklistItems = this->blacklistedUsers.getVector();
|
||||
std::vector<HighlightBlacklistUser> blacklistItems =
|
||||
this->blacklistedUsers.getVector();
|
||||
for (const auto &blacklistedUser : blacklistItems) {
|
||||
if (blacklistedUser.isMatch(username)) {
|
||||
return true;
|
||||
|
||||
@@ -13,18 +13,20 @@ HighlightModel::HighlightModel(QObject *parent)
|
||||
}
|
||||
|
||||
// turn a vector item into a model row
|
||||
HighlightPhrase HighlightModel::getItemFromRow(std::vector<QStandardItem *> &row,
|
||||
const HighlightPhrase &original)
|
||||
HighlightPhrase HighlightModel::getItemFromRow(
|
||||
std::vector<QStandardItem *> &row, const HighlightPhrase &original)
|
||||
{
|
||||
// key, alert, sound, regex
|
||||
|
||||
return HighlightPhrase{
|
||||
row[0]->data(Qt::DisplayRole).toString(), row[1]->data(Qt::CheckStateRole).toBool(),
|
||||
row[2]->data(Qt::CheckStateRole).toBool(), row[3]->data(Qt::CheckStateRole).toBool()};
|
||||
return HighlightPhrase{row[0]->data(Qt::DisplayRole).toString(),
|
||||
row[1]->data(Qt::CheckStateRole).toBool(),
|
||||
row[2]->data(Qt::CheckStateRole).toBool(),
|
||||
row[3]->data(Qt::CheckStateRole).toBool()};
|
||||
}
|
||||
|
||||
// turns a row in the model into a vector item
|
||||
void HighlightModel::getRowFromItem(const HighlightPhrase &item, std::vector<QStandardItem *> &row)
|
||||
void HighlightModel::getRowFromItem(const HighlightPhrase &item,
|
||||
std::vector<QStandardItem *> &row)
|
||||
{
|
||||
setStringItem(row[0], item.getPattern());
|
||||
setBoolItem(row[1], item.getAlert());
|
||||
@@ -35,31 +37,38 @@ void HighlightModel::getRowFromItem(const HighlightPhrase &item, std::vector<QSt
|
||||
void HighlightModel::afterInit()
|
||||
{
|
||||
std::vector<QStandardItem *> row = this->createRow();
|
||||
setBoolItem(row[0], getApp()->settings->enableHighlightsSelf.getValue(), true, false);
|
||||
setBoolItem(row[0], getApp()->settings->enableHighlightsSelf.getValue(),
|
||||
true, false);
|
||||
row[0]->setData("Your username (automatic)", Qt::DisplayRole);
|
||||
setBoolItem(row[1], getApp()->settings->enableHighlightTaskbar.getValue(), true, false);
|
||||
setBoolItem(row[2], getApp()->settings->enableHighlightSound.getValue(), true, false);
|
||||
setBoolItem(row[1], getApp()->settings->enableHighlightTaskbar.getValue(),
|
||||
true, false);
|
||||
setBoolItem(row[2], getApp()->settings->enableHighlightSound.getValue(),
|
||||
true, false);
|
||||
row[3]->setFlags(0);
|
||||
this->insertCustomRow(row, 0);
|
||||
}
|
||||
|
||||
void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row, int column,
|
||||
const QVariant &value, int role)
|
||||
void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row,
|
||||
int column, const QVariant &value,
|
||||
int role)
|
||||
{
|
||||
switch (column) {
|
||||
case 0: {
|
||||
if (role == Qt::CheckStateRole) {
|
||||
getApp()->settings->enableHighlightsSelf.setValue(value.toBool());
|
||||
getApp()->settings->enableHighlightsSelf.setValue(
|
||||
value.toBool());
|
||||
}
|
||||
} break;
|
||||
case 1: {
|
||||
if (role == Qt::CheckStateRole) {
|
||||
getApp()->settings->enableHighlightTaskbar.setValue(value.toBool());
|
||||
getApp()->settings->enableHighlightTaskbar.setValue(
|
||||
value.toBool());
|
||||
}
|
||||
} break;
|
||||
case 2: {
|
||||
if (role == Qt::CheckStateRole) {
|
||||
getApp()->settings->enableHighlightSound.setValue(value.toBool());
|
||||
getApp()->settings->enableHighlightSound.setValue(
|
||||
value.toBool());
|
||||
}
|
||||
} break;
|
||||
case 3: {
|
||||
|
||||
@@ -15,8 +15,9 @@ class HighlightModel : public SignalVectorModel<HighlightPhrase>
|
||||
|
||||
protected:
|
||||
// turn a vector item into a model row
|
||||
virtual HighlightPhrase getItemFromRow(std::vector<QStandardItem *> &row,
|
||||
const HighlightPhrase &original) override;
|
||||
virtual HighlightPhrase getItemFromRow(
|
||||
std::vector<QStandardItem *> &row,
|
||||
const HighlightPhrase &original) override;
|
||||
|
||||
// turns a row in the model into a vector item
|
||||
virtual void getRowFromItem(const HighlightPhrase &item,
|
||||
@@ -24,8 +25,9 @@ protected:
|
||||
|
||||
virtual void afterInit() override;
|
||||
|
||||
virtual void customRowSetData(const std::vector<QStandardItem *> &row, int column,
|
||||
const QVariant &value, int role) override;
|
||||
virtual void customRowSetData(const std::vector<QStandardItem *> &row,
|
||||
int column, const QVariant &value,
|
||||
int role) override;
|
||||
|
||||
friend class HighlightController;
|
||||
};
|
||||
|
||||
@@ -14,16 +14,20 @@ class HighlightPhrase
|
||||
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)
|
||||
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",
|
||||
, regex_(isRegex_ ? pattern
|
||||
: "\\b" + QRegularExpression::escape(pattern) + "\\b",
|
||||
QRegularExpression::CaseInsensitiveOption |
|
||||
QRegularExpression::UseUnicodePropertiesOption)
|
||||
{
|
||||
|
||||
@@ -13,14 +13,15 @@ UserHighlightModel::UserHighlightModel(QObject *parent)
|
||||
}
|
||||
|
||||
// turn vector item into model row
|
||||
HighlightPhrase UserHighlightModel::getItemFromRow(std::vector<QStandardItem *> &row,
|
||||
const HighlightPhrase &original)
|
||||
HighlightPhrase UserHighlightModel::getItemFromRow(
|
||||
std::vector<QStandardItem *> &row, const HighlightPhrase &original)
|
||||
{
|
||||
// key, regex
|
||||
|
||||
return HighlightPhrase{
|
||||
row[0]->data(Qt::DisplayRole).toString(), row[1]->data(Qt::CheckStateRole).toBool(),
|
||||
row[2]->data(Qt::CheckStateRole).toBool(), row[3]->data(Qt::CheckStateRole).toBool()};
|
||||
return HighlightPhrase{row[0]->data(Qt::DisplayRole).toString(),
|
||||
row[1]->data(Qt::CheckStateRole).toBool(),
|
||||
row[2]->data(Qt::CheckStateRole).toBool(),
|
||||
row[3]->data(Qt::CheckStateRole).toBool()};
|
||||
}
|
||||
|
||||
// row into vector item
|
||||
|
||||
@@ -15,8 +15,9 @@ class UserHighlightModel : public SignalVectorModel<HighlightPhrase>
|
||||
|
||||
protected:
|
||||
// vector into model row
|
||||
virtual HighlightPhrase getItemFromRow(std::vector<QStandardItem *> &row,
|
||||
const HighlightPhrase &original) override;
|
||||
virtual HighlightPhrase getItemFromRow(
|
||||
std::vector<QStandardItem *> &row,
|
||||
const HighlightPhrase &original) override;
|
||||
|
||||
virtual void getRowFromItem(const HighlightPhrase &item,
|
||||
std::vector<QStandardItem *> &row) override;
|
||||
|
||||
Reference in New Issue
Block a user