Replace use of QRegExp

This commit is contained in:
Jonas Kvinge
2020-07-20 00:57:42 +02:00
parent eb270df835
commit 0b7b7656b2
15 changed files with 105 additions and 85 deletions

View File

@@ -28,7 +28,7 @@
#include <QString>
#include <QStringList>
#include <QRegularExpression>
#include <QRegExp>
#include <QRegularExpressionMatch>
#include <QTextCodec>
#include <QTextStream>
#include <QtDebug>
@@ -272,13 +272,14 @@ SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const
// line into logical parts and getting rid of all the unnecessary whitespaces and quoting.
QStringList CueParser::SplitCueLine(const QString &line) const {
QRegExp line_regexp(kFileLineRegExp);
if (!line_regexp.exactMatch(line.trimmed())) {
QRegularExpression line_regexp(kFileLineRegExp);
QRegularExpressionMatch re_match = line_regexp.match(line.trimmed());
if (!re_match.hasMatch()) {
return QStringList();
}
// Let's remove the empty entries while we're at it
return line_regexp.capturedTexts().filter(QRegularExpression(".+")).mid(1, -1);
return re_match.capturedTexts().filter(QRegularExpression(".+")).mid(1, -1);
}
@@ -336,12 +337,13 @@ bool CueParser::UpdateLastSong(const CueEntry &entry, Song *song) const {
qint64 CueParser::IndexToMarker(const QString &index) const {
QRegExp index_regexp(kIndexRegExp);
if (!index_regexp.exactMatch(index)) {
QRegularExpression index_regexp(kIndexRegExp);
QRegularExpressionMatch re_match = index_regexp.match(index);
if (!re_match.hasMatch()) {
return -1;
}
QStringList splitted = index_regexp.capturedTexts().mid(1, -1);
QStringList splitted = re_match.capturedTexts().mid(1, -1);
qlonglong frames = splitted.at(0).toLongLong() * 60 * 75 + splitted.at(1).toLongLong() * 75 + splitted.at(2).toLongLong();
return (frames * kNsecPerSec) / 75;