2018-04-30 23:30:05 +02:00
|
|
|
#include "commandmodel.hpp"
|
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
namespace controllers {
|
|
|
|
namespace commands {
|
|
|
|
|
|
|
|
// commandmodel
|
|
|
|
CommandModel::CommandModel(QObject *parent)
|
|
|
|
: util::SignalVectorModel<Command>(2, parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// turn a vector item into a model row
|
2018-05-26 20:25:00 +02:00
|
|
|
Command CommandModel::getItemFromRow(std::vector<QStandardItem *> &row, const Command &original)
|
2018-04-30 23:30:05 +02:00
|
|
|
{
|
|
|
|
return Command(row[0]->data(Qt::EditRole).toString(), row[1]->data(Qt::EditRole).toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
// turns a row in the model into a vector item
|
|
|
|
void CommandModel::getRowFromItem(const Command &item, std::vector<QStandardItem *> &row)
|
|
|
|
{
|
|
|
|
row[0]->setData(item.name, Qt::DisplayRole);
|
|
|
|
row[0]->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable);
|
|
|
|
row[1]->setData(item.func, Qt::DisplayRole);
|
|
|
|
row[1]->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace commands
|
|
|
|
} // namespace controllers
|
|
|
|
} // namespace chatterino
|