2021-07-31 16:15:43 +02:00
|
|
|
#include "NicknamesModel.hpp"
|
|
|
|
|
|
|
|
#include "Application.hpp"
|
|
|
|
#include "providers/twitch/api/Helix.hpp"
|
|
|
|
#include "singletons/Settings.hpp"
|
|
|
|
#include "util/StandardItemHelper.hpp"
|
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
|
|
|
|
NicknamesModel::NicknamesModel(QObject *parent)
|
2021-08-22 13:30:17 +02:00
|
|
|
: SignalVectorModel<Nickname>(4, parent)
|
2021-07-31 16:15:43 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// turn a vector item into a model row
|
|
|
|
Nickname NicknamesModel::getItemFromRow(std::vector<QStandardItem *> &row,
|
|
|
|
const Nickname &original)
|
|
|
|
{
|
2022-09-04 18:58:44 +02:00
|
|
|
return Nickname{row[0]->data(Qt::DisplayRole).toString().trimmed(),
|
2021-08-22 13:30:17 +02:00
|
|
|
row[1]->data(Qt::DisplayRole).toString(),
|
|
|
|
row[2]->data(Qt::CheckStateRole).toBool(),
|
|
|
|
row[3]->data(Qt::CheckStateRole).toBool()};
|
2021-07-31 16:15:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// turns a row in the model into a vector item
|
|
|
|
void NicknamesModel::getRowFromItem(const Nickname &item,
|
|
|
|
std::vector<QStandardItem *> &row)
|
|
|
|
{
|
|
|
|
setStringItem(row[0], item.name());
|
|
|
|
setStringItem(row[1], item.replace());
|
2021-08-22 13:30:17 +02:00
|
|
|
setBoolItem(row[2], item.isRegex());
|
|
|
|
setBoolItem(row[3], item.isCaseSensitive());
|
2021-07-31 16:15:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace chatterino
|