forked from qt-creator/qt-creator
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:
@@ -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 ®exp) 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user