From 9752cf7d130a0ab1a7ece6e3fe698379d8835039 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 13 Jan 2014 14:14:17 +0100 Subject: linuxfb: Migrate to QRegularExpression Change-Id: Ieeef375a5f613c09b2c85f632a093dd575290ba2 Reviewed-by: Giuseppe D'Angelo --- src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp | 32 +++++++++++++----------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp index 735a43daf7..c0691a38fc 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp @@ -41,6 +41,7 @@ #include "qlinuxfbscreen.h" #include +#include #include #include // overrides QT_OPEN @@ -318,11 +319,11 @@ QLinuxFbScreen::~QLinuxFbScreen() bool QLinuxFbScreen::initialize() { - QRegExp ttyRx(QLatin1String("tty=(.*)")); - QRegExp fbRx(QLatin1String("fb=(.*)")); - QRegExp mmSizeRx(QLatin1String("mmsize=(\\d+)x(\\d+)")); - QRegExp sizeRx(QLatin1String("size=(\\d+)x(\\d+)")); - QRegExp offsetRx(QLatin1String("offset=(\\d+)x(\\d+)")); + QRegularExpression ttyRx(QLatin1String("tty=(.*)")); + QRegularExpression fbRx(QLatin1String("fb=(.*)")); + QRegularExpression mmSizeRx(QLatin1String("mmsize=(\\d+)x(\\d+)")); + QRegularExpression sizeRx(QLatin1String("size=(\\d+)x(\\d+)")); + QRegularExpression offsetRx(QLatin1String("offset=(\\d+)x(\\d+)")); QString fbDevice, ttyDevice; QSize userMmSize; @@ -331,18 +332,19 @@ bool QLinuxFbScreen::initialize() // Parse arguments foreach (const QString &arg, mArgs) { + QRegularExpressionMatch match; if (arg == QLatin1String("nographicsmodeswitch")) doSwitchToGraphicsMode = false; - else if (sizeRx.indexIn(arg) != -1) - userGeometry.setSize(QSize(sizeRx.cap(1).toInt(), sizeRx.cap(2).toInt())); - else if (offsetRx.indexIn(arg) != -1) - userGeometry.setTopLeft(QPoint(offsetRx.cap(1).toInt(), offsetRx.cap(2).toInt())); - else if (ttyRx.indexIn(arg) != -1) - ttyDevice = ttyRx.cap(1); - else if (fbRx.indexIn(arg) != -1) - fbDevice = fbRx.cap(1); - else if (mmSizeRx.indexIn(arg) != -1) - userMmSize = QSize(mmSizeRx.cap(1).toInt(), mmSizeRx.cap(2).toInt()); + else if (arg.contains(sizeRx, &match)) + userGeometry.setSize(QSize(match.captured(1).toInt(), match.captured(2).toInt())); + else if (arg.contains(offsetRx, &match)) + userGeometry.setTopLeft(QPoint(match.captured(1).toInt(), match.captured(2).toInt())); + else if (arg.contains(ttyRx, &match)) + ttyDevice = match.captured(1); + else if (arg.contains(fbRx, &match)) + fbDevice = match.captured(1); + else if (arg.contains(mmSizeRx, &match)) + userMmSize = QSize(match.captured(1).toInt(), match.captured(2).toInt()); } if (fbDevice.isEmpty()) { -- cgit v1.2.3