Migrate QStandardPaths to use QRegularExpression
This patch updates the code from the unix implementation of QStandardPaths to use QRegularExpression in place of the deprecated QRegExp. Change-Id: I51fa231dcd70ca55d1bfffb31d8f28f964ac44fe Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
parent
82fbf97903
commit
b03706d35f
@ -42,6 +42,7 @@
|
|||||||
#include <qfile.h>
|
#include <qfile.h>
|
||||||
#include <qhash.h>
|
#include <qhash.h>
|
||||||
#include <qtextstream.h>
|
#include <qtextstream.h>
|
||||||
|
#include <qregularexpression.h>
|
||||||
#include <private/qfilesystemengine_p.h>
|
#include <private/qfilesystemengine_p.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -179,11 +180,12 @@ QString QStandardPaths::writableLocation(StandardLocation type)
|
|||||||
QHash<QString, QString> lines;
|
QHash<QString, QString> lines;
|
||||||
QTextStream stream(&file);
|
QTextStream stream(&file);
|
||||||
// Only look for lines like: XDG_DESKTOP_DIR="$HOME/Desktop"
|
// Only look for lines like: XDG_DESKTOP_DIR="$HOME/Desktop"
|
||||||
QRegExp exp(QLatin1String("^XDG_(.*)_DIR=(.*)$"));
|
QRegularExpression exp(QLatin1String("^XDG_(.*)_DIR=(.*)$"));
|
||||||
while (!stream.atEnd()) {
|
while (!stream.atEnd()) {
|
||||||
const QString &line = stream.readLine();
|
const QString &line = stream.readLine();
|
||||||
if (exp.indexIn(line) != -1) {
|
QRegularExpressionMatch match = exp.match(line);
|
||||||
const QStringList lst = exp.capturedTexts();
|
if (match.hasMatch()) {
|
||||||
|
const QStringList lst = match.capturedTexts();
|
||||||
const QString key = lst.at(1);
|
const QString key = lst.at(1);
|
||||||
QString value = lst.at(2);
|
QString value = lst.at(2);
|
||||||
if (value.length() > 2
|
if (value.length() > 2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user