Migrate Cocoa QPA backend to use QRegularExpression

This patch updates the Cocoa QPA backend code to use QRegularExpression
in place of the deprecated QRegExp.

Change-Id: I6de2774975e63f8dbff6dad0a842f35c3c4b4f83
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Samuel Gaist 2017-02-12 21:40:27 +01:00
parent f3f4f95536
commit 83aca24bc4
2 changed files with 9 additions and 5 deletions

View File

@ -63,7 +63,8 @@
#include <qsysinfo.h>
#include <qoperatingsystemversion.h>
#include <qglobal.h>
#include <QDir>
#include <qdir.h>
#include <qregularexpression.h>
#include <qpa/qplatformnativeinterface.h>
@ -509,9 +510,10 @@ static QString strippedText(QString s)
- (QString)removeExtensions:(const QString &)filter
{
QRegExp regExp(QString::fromLatin1(QPlatformFileDialogHelper::filterRegExp));
if (regExp.indexIn(filter) != -1)
return regExp.cap(1).trimmed();
QRegularExpression regExp(QString::fromLatin1(QPlatformFileDialogHelper::filterRegExp));
QRegularExpressionMatch match = regExp.match(filter);
if (match.hasMatch())
return match.captured(1).trimmed();
return filter;
}

View File

@ -49,6 +49,7 @@
#include "qcocoaapplication.h" // for custom application category
#include "qcocoamenuloader.h"
#include <QtGui/private/qcoregraphics_p.h>
#include <QtCore/qregularexpression.h>
#include <QtCore/QDebug>
@ -261,7 +262,8 @@ NSMenuItem *QCocoaMenuItem::sync()
m_detectedRole = detectMenuRole(m_text);
switch (m_detectedRole) {
case QPlatformMenuItem::AboutRole:
if (m_text.indexOf(QRegExp(QString::fromLatin1("qt$"), Qt::CaseInsensitive)) == -1)
if (m_text.indexOf(QRegularExpression(QString::fromLatin1("qt$"),
QRegularExpression::CaseInsensitiveOption)) == -1)
mergeItem = [loader aboutMenuItem];
else
mergeItem = [loader aboutQtMenuItem];