Commit e97707b4 authored by Ahmad Samir's avatar Ahmad Samir Committed by Ingo Klöcker
Browse files

ListWidget: port to QRegularExpression

parent 0b7faa91
Pipeline #174806 passed with stage
in 1 minute and 50 seconds
......@@ -17,8 +17,7 @@
#include <QItemSelectionModel>
#include <QStringListModel>
#include <QRegExp>
#include <QRegExpValidator>
#include <QRegularExpressionValidator>
#include <QItemDelegate>
#include <QLineEdit>
......@@ -33,14 +32,14 @@ class ItemDelegate : public QItemDelegate
public:
explicit ItemDelegate(QObject *p = nullptr)
: QItemDelegate(p), m_rx() {}
explicit ItemDelegate(const QRegExp &rx, QObject *p = nullptr)
explicit ItemDelegate(const QRegularExpression &rx, QObject *p = nullptr)
: QItemDelegate(p), m_rx(rx) {}
void setRegExpFilter(const QRegExp &rx)
void setRegExpFilter(const QRegularExpression &rx)
{
m_rx = rx;
}
const QRegExp &regExpFilter() const
const QRegularExpression &regExpFilter() const
{
return m_rx;
}
......@@ -48,14 +47,14 @@ public:
QWidget *createEditor(QWidget *p, const QStyleOptionViewItem &o, const QModelIndex &i) const override
{
QWidget *w = QItemDelegate::createEditor(p, o, i);
if (!m_rx.isEmpty())
if (m_rx.isValid())
if (auto const le = qobject_cast<QLineEdit *>(w)) {
le->setValidator(new QRegExpValidator(m_rx, le));
le->setValidator(new QRegularExpressionValidator(m_rx, le));
}
return w;
}
private:
QRegExp m_rx;
QRegularExpression m_rx;
};
}
......@@ -201,12 +200,12 @@ void ListWidget::setItems(const QStringList &items)
d->stringListModel.setStringList(items);
}
QRegExp ListWidget::regExpFilter() const
QRegularExpression ListWidget::regExpFilter() const
{
return d->delegate.regExpFilter();
}
void ListWidget::setRegExpFilter(const QRegExp &rx)
void ListWidget::setRegExpFilter(const QRegularExpression &rx)
{
d->delegate.setRegExpFilter(rx);
}
......
......@@ -13,7 +13,6 @@
#include <utils/pimpl_ptr.h>
class QRegExp;
class QString;
#include <QStringList>
......@@ -26,7 +25,7 @@ class ListWidget : public QWidget
{
Q_OBJECT
Q_PROPERTY(QStringList items READ items WRITE setItems USER true NOTIFY itemsChanged)
Q_PROPERTY(QRegExp regExpFilter READ regExpFilter WRITE setRegExpFilter)
Q_PROPERTY(QRegularExpression regExpFilter READ regExpFilter WRITE setRegExpFilter)
Q_PROPERTY(QString defaultValue READ defaultValue WRITE setDefaultValue)
public:
explicit ListWidget(QWidget *parent = nullptr);
......@@ -35,8 +34,8 @@ public:
void setDefaultValue(const QString &defaultValue);
QString defaultValue() const;
void setRegExpFilter(const QRegExp &rx);
QRegExp regExpFilter() const;
void setRegExpFilter(const QRegularExpression &rx);
QRegularExpression regExpFilter() const;
QStringList items() const;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment