Port QtCreator over to use filterRegularExpression

QSortFilterProxyModel::filterRegExp is going to go away in Qt6,
so port over to use QRegularExpression instead.

This required some changes where setFilterWildcard/FixedString()
was being used, as those would instantiate QRegExp based filters
in Qt 5, and will use QRegularExpression in Qt 6. Use the generic
setFilterRegularExpression here, to keep things portable between
5 and 6.

Change-Id: I6379be781aa3821b10ba783c088f82c1a0970911
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Lars Knoll
2020-03-27 11:56:25 +01:00
parent 553c3c2c74
commit 47e576528e
18 changed files with 48 additions and 67 deletions

View File

@@ -36,6 +36,7 @@
#include <QIcon>
#include <QLabel>
#include <QPushButton>
#include <QRegularExpression>
using namespace Utils;
@@ -227,11 +228,11 @@ const QList<Core::IOptionsPage *> Core::IOptionsPage::allOptionsPages()
}
/*!
Is used by the \uicontrol Options dialog search filter to match \a searchKeyWord to this options
Is used by the \uicontrol Options dialog search filter to match \a regexp to this options
page. This defaults to take the widget and then looks for all child labels, check boxes, push
buttons, and group boxes. Should return \c true when a match is found.
*/
bool Core::IOptionsPage::matches(const QString &searchKeyWord) const
bool Core::IOptionsPage::matches(const QRegularExpression &regexp) const
{
if (!m_keywordsInitialized) {
auto that = const_cast<IOptionsPage *>(this);
@@ -251,7 +252,7 @@ bool Core::IOptionsPage::matches(const QString &searchKeyWord) const
m_keywordsInitialized = true;
}
foreach (const QString &keyword, m_keywords)
if (keyword.contains(searchKeyWord, Qt::CaseInsensitive))
if (keyword.contains(regexp))
return true;
return false;
}