Fix delay parsing
authorLuciano Montanaro <mikelima@cirulla.net>
Thu, 14 Nov 2013 22:33:42 +0000 (23:33 +0100)
committerLuciano Montanaro <mikelima@cirulla.net>
Thu, 14 Nov 2013 22:33:42 +0000 (23:33 +0100)
application/stationschedulemodel.cpp

index 7dd4cf2..986d015 100644 (file)
@@ -176,19 +176,19 @@ static void parseTrain(const QString &text, StationScheduleItem &item)
             item.setArrivalStation(filter.cap(2));
             item.setArrivalTime(filter.cap(3));
         }
-       QString delayDescription = filter.cap(6);
-       if (delayDescription == "in orario") {
-        item.setDelay(QObject::tr("On time"));
-       } else {
-           QRegExp delayRegExp("ritardo (.*)(| minuti)");
-           int pos = delayRegExp.indexIn(delayDescription);
-           if (pos >= 0) {
-        item.setDelay(QString(QObject::tr("Delay: %1 minutes")).arg(delayRegExp.cap(1)));
-           } else {
-               // Does not match, let the user parse it
-               item.setDelay(delayDescription);
-           }
-       }
+        QString delayDescription = filter.cap(6);
+        if (delayDescription == "in orario") {
+            item.setDelay(QObject::tr("On time"));
+        } else {
+            QRegExp delayRegExp("ritardo ([0-9]+)(| minuti)");
+            int pos = delayRegExp.indexIn(delayDescription);
+            if (pos >= 0) {
+                item.setDelay(QString(QObject::tr("Delay: %1 minutes")).arg(delayRegExp.cap(1)));
+            } else {
+                // Does not match, let the user parse it
+                item.setDelay(delayDescription);
+            }
+        }
         item.setExpectedPlatform(filter.cap(4));
         item.setActualPlatform(filter.cap(5));
     } else {