Commit dd7ca23d authored by Volker Krause's avatar Volker Krause
Browse files

Port from QRegExp to QRegularExpression

parent 66a830a6
Pipeline #168305 passed with stage
in 1 minute and 16 seconds
......@@ -129,7 +129,7 @@ int main(int argc, char *argv[])
return -1;
}
const QStringList args = parser.value(QStringLiteral("args")).split(QRegExp(QStringLiteral(" +")), Qt::SkipEmptyParts);
const QStringList args = parser.value(QStringLiteral("args")).split(QRegularExpression(QStringLiteral(" +")), Qt::SkipEmptyParts);
QString startupModule;
if (parser.positionalArguments().count() == 1) {
......@@ -158,7 +158,7 @@ int main(int argc, char *argv[])
parser.parse(arguments);
const QStringList args = parser.value(QStringLiteral("args")).split(QRegExp(QStringLiteral(" +")), Qt::SkipEmptyParts);
const QStringList args = parser.value(QStringLiteral("args")).split(QRegularExpression(QStringLiteral(" +")), Qt::SkipEmptyParts);
QString startupModule;
if (parser.positionalArguments().count() == 1) {
......
......@@ -111,7 +111,11 @@ Qt::ItemFlags MenuProxyModel::flags(const QModelIndex &index) const
}
QString matchText = index.data(MenuModel::UserFilterRole).toString();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QRegExp pattern = KCategorizedSortFilterProxyModel::filterRegExp();
#else
QRegularExpression pattern = KCategorizedSortFilterProxyModel::filterRegularExpression();
#endif
if (!matchText.contains(pattern)) {
return Qt::NoItemFlags;
......@@ -120,6 +124,7 @@ Qt::ItemFlags MenuProxyModel::flags(const QModelIndex &index) const
}
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void MenuProxyModel::setFilterRegExp(const QString &pattern)
{
if (pattern == filterRegExp()) {
......@@ -142,3 +147,27 @@ void MenuProxyModel::setFilterRegExp(const QRegExp &regExp)
KCategorizedSortFilterProxyModel::setFilterRegExp(regExp);
Q_EMIT layoutChanged();
}
#else
void MenuProxyModel::setFilterRegularExpression(const QString &pattern)
{
if (pattern == filterRegularExpression()) {
return;
}
Q_EMIT layoutAboutToBeChanged();
KCategorizedSortFilterProxyModel::setFilterRegularExpression(pattern);
Q_EMIT layoutChanged();
Q_EMIT filterRegularExpressionChanged();
}
QString MenuProxyModel::filterRegularExpression() const
{
return KCategorizedSortFilterProxyModel::filterRegularExpression().pattern();
}
void MenuProxyModel::setFilterRegularExpression(const QRegularExpression &regExp)
{
Q_EMIT layoutAboutToBeChanged();
KCategorizedSortFilterProxyModel::setFilterRegularExpression(regExp);
Q_EMIT layoutChanged();
}
#endif
......@@ -28,7 +28,11 @@ class SYSTEMSETTINGSVIEW_EXPORT MenuProxyModel : public KCategorizedSortFilterPr
{
Q_OBJECT
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Q_PROPERTY(QString filterRegExp READ filterRegExp WRITE setFilterRegExp NOTIFY filterRegExpChanged)
#else
Q_PROPERTY(QString filterRegExp READ filterRegularExpression WRITE setFilterRegularExpression NOTIFY filterRegularExpressionChanged)
#endif
public:
/**
......@@ -79,6 +83,7 @@ public:
*/
Qt::ItemFlags flags(const QModelIndex &index) const override;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
/**
* Please see Qt QAbstractItemModel documentation for more details.\n
* Reimplemented for internal reasons.
......@@ -92,6 +97,21 @@ public:
void setFilterRegExp(const QString &pattern);
QString filterRegExp() const;
#else
/**
* Please see Qt QAbstractItemModel documentation for more details.\n
* Reimplemented for internal reasons.
*/
void setFilterRegularExpression(const QRegularExpression &regExp);
/**
* Please see Qt QAbstractItemModel documentation for more details.\n
* Reimplemented for internal reasons.
*/
void setFilterRegularExpression(const QString &pattern);
QString filterRegularExpression() const;
#endif
/**
* makes the filter highlight matching entries instead of hiding them
......@@ -104,7 +124,11 @@ public:
bool filterHighlightsEntries() const;
Q_SIGNALS:
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void filterRegExpChanged();
#else
void filterRegularExpressionChanged();
#endif
private:
bool m_filterHighlightsEntries : 1;
......
......@@ -116,7 +116,11 @@ void IconMode::initEvent()
void IconMode::searchChanged(const QString &text)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
d->proxyModel->setFilterRegExp(text);
#else
d->proxyModel->setFilterRegularExpression(text);
#endif
if (d->categoryView) {
QAbstractItemModel *model = d->categoryView->model();
const int column = d->categoryView->modelColumn();
......
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