mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
53 lines
2 KiB
C++
53 lines
2 KiB
C++
#include "UserHighlightModel.hpp"
|
|
|
|
#include "Application.hpp"
|
|
#include "controllers/highlights/HighlightModel.hpp"
|
|
#include "singletons/Settings.hpp"
|
|
#include "util/StandardItemHelper.hpp"
|
|
|
|
namespace chatterino {
|
|
|
|
using Column = HighlightModel::Column;
|
|
|
|
// commandmodel
|
|
UserHighlightModel::UserHighlightModel(QObject *parent)
|
|
: SignalVectorModel<HighlightPhrase>(Column::COUNT, parent)
|
|
{
|
|
}
|
|
|
|
// turn vector item into model row
|
|
HighlightPhrase UserHighlightModel::getItemFromRow(
|
|
std::vector<QStandardItem *> &row, const HighlightPhrase &original)
|
|
{
|
|
// In order for old messages to update their highlight color, we need to
|
|
// update the highlight color here.
|
|
auto highlightColor = original.getColor();
|
|
*highlightColor =
|
|
row[Column::Color]->data(Qt::DecorationRole).value<QColor>();
|
|
|
|
return HighlightPhrase{
|
|
row[Column::Pattern]->data(Qt::DisplayRole).toString(),
|
|
row[Column::ShowInMentions]->data(Qt::CheckStateRole).toBool(),
|
|
row[Column::FlashTaskbar]->data(Qt::CheckStateRole).toBool(),
|
|
row[Column::PlaySound]->data(Qt::CheckStateRole).toBool(),
|
|
row[Column::UseRegex]->data(Qt::CheckStateRole).toBool(),
|
|
row[Column::CaseSensitive]->data(Qt::CheckStateRole).toBool(),
|
|
row[Column::SoundPath]->data(Qt::UserRole).toString(),
|
|
highlightColor};
|
|
}
|
|
|
|
// row into vector item
|
|
void UserHighlightModel::getRowFromItem(const HighlightPhrase &item,
|
|
std::vector<QStandardItem *> &row)
|
|
{
|
|
setStringItem(row[Column::Pattern], item.getPattern());
|
|
setBoolItem(row[Column::ShowInMentions], item.showInMentions());
|
|
setBoolItem(row[Column::FlashTaskbar], item.hasAlert());
|
|
setBoolItem(row[Column::PlaySound], item.hasSound());
|
|
setBoolItem(row[Column::UseRegex], item.isRegex());
|
|
setBoolItem(row[Column::CaseSensitive], item.isCaseSensitive());
|
|
setFilePathItem(row[Column::SoundPath], item.getSoundUrl());
|
|
setColorItem(row[Column::Color], *item.getColor());
|
|
}
|
|
|
|
} // namespace chatterino
|