2022-05-08 12:27:25 +02:00
|
|
|
#include "widgets/helper/RegExpItemDelegate.hpp"
|
|
|
|
|
2022-05-16 11:42:17 +02:00
|
|
|
#include "widgets/helper/TrimRegExpValidator.hpp"
|
|
|
|
|
2022-05-08 12:27:25 +02:00
|
|
|
#include <QLineEdit>
|
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
|
|
|
|
RegExpItemDelegate::RegExpItemDelegate(QObject *parent,
|
|
|
|
QRegularExpression regexp)
|
|
|
|
: QStyledItemDelegate(parent)
|
|
|
|
, regexp_(regexp)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidget *RegExpItemDelegate::createEditor(QWidget *parent,
|
|
|
|
const QStyleOptionViewItem &option,
|
|
|
|
const QModelIndex &index) const
|
|
|
|
{
|
|
|
|
auto *editor = new QLineEdit(parent);
|
2022-05-16 11:42:17 +02:00
|
|
|
editor->setValidator(new TrimRegExpValidator(this->regexp_, editor));
|
2022-05-08 12:27:25 +02:00
|
|
|
return editor;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace chatterino
|