From ff83ab580c847f8f8e684f3b1d7bc100ff2f1510 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sun, 25 Oct 2020 21:24:43 +0000 Subject: ported some code to QRegularExpression git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@9529 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/CommandLineOptions/SeekOption/seekoption.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/plugins/CommandLineOptions') diff --git a/src/plugins/CommandLineOptions/SeekOption/seekoption.cpp b/src/plugins/CommandLineOptions/SeekOption/seekoption.cpp index ce4ff6ffe..77786ec0a 100644 --- a/src/plugins/CommandLineOptions/SeekOption/seekoption.cpp +++ b/src/plugins/CommandLineOptions/SeekOption/seekoption.cpp @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include "seekoption.h" @@ -52,13 +52,14 @@ QString SeekOption::executeCommand(int id, const QStringList &args) int seek_pos = -1; int elapsed = core->elapsed() / 1000; - QRegExp seek_regexp1 ("^([0-9]{1,4})$"); - QRegExp seek_regexp2 ("^([0-9]{1,2}):([0-9]{1,2})$"); + static const QRegularExpression seek_regexp1 ("^([0-9]{1,4})$"); + static const QRegularExpression seek_regexp2 ("^([0-9]{1,2}):([0-9]{1,2})$"); - if(seek_regexp1.indexIn(args.first()) != -1) - seek_pos = seek_regexp1.cap(1).toInt(); - else if(seek_regexp2.indexIn(args.first()) != -1) - seek_pos = seek_regexp2.cap(1).toInt()*60 + seek_regexp2.cap(2).toInt(); + QRegularExpressionMatch match; + if((match = seek_regexp1.match(args.first())).hasMatch()) + seek_pos = match.captured(1).toInt(); + else if((match = seek_regexp2.match(args.first())).hasMatch()) + seek_pos = match.captured(1).toInt()*60 + match.captured(2).toInt(); switch (id) { case SEEK: //seek absolute -- cgit v1.2.3-13-gbd6f