Migrate QPlatformDialogHelper to QRegularExpression
This patch updates the QPlatformDialogHelper class to use QRegularExpression in place of QRegExp which is to be considered deprecated. Change-Id: I8a79c5425217d18a3210c87f7f505b1aa288801d Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
2955afdf31
commit
5ae8fcd17b
@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
#include <QtCore/QVariant>
|
#include <QtCore/QVariant>
|
||||||
|
#include <QtCore/QRegularExpression>
|
||||||
#include <QtCore/QSharedData>
|
#include <QtCore/QSharedData>
|
||||||
#if QT_CONFIG(settings)
|
#if QT_CONFIG(settings)
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
@ -779,18 +780,19 @@ void QPlatformFileDialogHelper::setOptions(const QSharedPointer<QFileDialogOptio
|
|||||||
m_options = options;
|
m_options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *QPlatformFileDialogHelper::filterRegExp =
|
const char QPlatformFileDialogHelper::filterRegExp[] =
|
||||||
"^(.*)\\(([a-zA-Z0-9_.,*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$";
|
"^(.*)\\(([a-zA-Z0-9_.,*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$";
|
||||||
|
|
||||||
// Makes a list of filters from a normal filter string "Image Files (*.png *.jpg)"
|
// Makes a list of filters from a normal filter string "Image Files (*.png *.jpg)"
|
||||||
QStringList QPlatformFileDialogHelper::cleanFilterList(const QString &filter)
|
QStringList QPlatformFileDialogHelper::cleanFilterList(const QString &filter)
|
||||||
{
|
{
|
||||||
QRegExp regexp(QString::fromLatin1(filterRegExp));
|
QRegularExpression regexp(QString::fromLatin1(filterRegExp));
|
||||||
Q_ASSERT(regexp.isValid());
|
Q_ASSERT(regexp.isValid());
|
||||||
QString f = filter;
|
QString f = filter;
|
||||||
int i = regexp.indexIn(f);
|
QRegularExpressionMatch match;
|
||||||
if (i >= 0)
|
filter.indexOf(regexp, 0, &match);
|
||||||
f = regexp.cap(2);
|
if (match.hasMatch())
|
||||||
|
f = match.captured(2);
|
||||||
return f.split(QLatin1Char(' '), QString::SkipEmptyParts);
|
return f.split(QLatin1Char(' '), QString::SkipEmptyParts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,7 +414,7 @@ public:
|
|||||||
void setOptions(const QSharedPointer<QFileDialogOptions> &options);
|
void setOptions(const QSharedPointer<QFileDialogOptions> &options);
|
||||||
|
|
||||||
static QStringList cleanFilterList(const QString &filter);
|
static QStringList cleanFilterList(const QString &filter);
|
||||||
static const char *filterRegExp;
|
static const char filterRegExp[];
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void fileSelected(const QUrl &file);
|
void fileSelected(const QUrl &file);
|
||||||
|
Loading…
Reference in New Issue
Block a user