2018-04-26 23:07:02 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QStandardItem>
|
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
namespace util {
|
|
|
|
|
2018-05-06 00:32:45 +02:00
|
|
|
static void setBoolItem(QStandardItem *item, bool value, bool userCheckable = true,
|
|
|
|
bool selectable = true)
|
2018-04-26 23:07:02 +02:00
|
|
|
{
|
|
|
|
item->setFlags((Qt::ItemFlags)(Qt::ItemIsEnabled | (selectable ? Qt::ItemIsSelectable : 0) |
|
|
|
|
(userCheckable ? Qt::ItemIsUserCheckable : 0)));
|
|
|
|
item->setCheckState(value ? Qt::Checked : Qt::Unchecked);
|
|
|
|
}
|
|
|
|
|
2018-05-06 00:32:45 +02:00
|
|
|
static void setStringItem(QStandardItem *item, const QString &value, bool editable = true,
|
|
|
|
bool selectable = true)
|
2018-04-26 23:07:02 +02:00
|
|
|
{
|
2018-05-06 00:32:45 +02:00
|
|
|
item->setData(value, Qt::EditRole);
|
2018-04-26 23:07:02 +02:00
|
|
|
item->setFlags((Qt::ItemFlags)(Qt::ItemIsEnabled | (selectable ? Qt::ItemIsSelectable : 0) |
|
|
|
|
(editable ? (Qt::ItemIsEditable) : 0)));
|
|
|
|
}
|
|
|
|
|
2018-04-27 01:11:09 +02:00
|
|
|
static QStandardItem *emptyItem()
|
2018-04-26 23:07:02 +02:00
|
|
|
{
|
|
|
|
auto *item = new QStandardItem();
|
|
|
|
item->setFlags((Qt::ItemFlags)0);
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace util
|
|
|
|
} // namespace chatterino
|