Prevent user from entering incorrect characters in Live Notifications channels list (#3715)

Co-authored-by: Sidd <iProdigy@users.noreply.github.com>
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
kornes
2022-05-08 10:27:25 +00:00
committed by GitHub
parent fd44f30c7d
commit 07dd8c560b
11 changed files with 199 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
#include "widgets/helper/RegExpItemDelegate.hpp"
#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);
editor->setValidator(
new QRegularExpressionValidator(this->regexp_, editor));
return editor;
}
} // namespace chatterino