Fixed a bug that caused Eniro search results to sometimes have phone number in street...
authoreshe <jessehakanen@gmail.com>
Thu, 17 Jun 2010 21:14:07 +0000 (22:14 +0100)
committereshe <jessehakanen@gmail.com>
Thu, 17 Jun 2010 21:14:07 +0000 (22:14 +0100)
src/common/eniro.cpp
src/common/source.cpp
src/common/source.h

index 49763e7..9a9f1a2 100644 (file)
@@ -317,9 +317,18 @@ void Eniro::loadResults(int id, QString const& httpData)
             break;
 
         case 3:
-            result.name = rows[0];
-            result.street = rows[1];
-            result.city = rows[2];
+            if(isPhoneNumber(rows[1]))
+            {
+                result.name = rows[0];
+                result.number = cleanUpNumber(rows[1]);
+                result.city = rows[2];
+            }
+            else
+            {
+                result.name = rows[0];
+                result.street = rows[1];
+                result.city = rows[2];
+            }
             break;
 
         case 4:
index a978b45..460f98e 100644 (file)
@@ -395,6 +395,12 @@ void Source::fixUrl(QUrl& url)
     url.setEncodedQuery(path);
 }
 
+bool Source::isPhoneNumber(QString const& string)
+{
+    static QRegExp check("^([0-9 -]{7,25})$");
+    return check.exactMatch(string);
+}
+
 Source::SearchDetails::SearchDetails(QString const& q,
                                      QString const& loc,
                                      SearchType t)
index 573563f..3477380 100644 (file)
@@ -96,6 +96,7 @@ protected:
     static QString& cleanUpNumber(QString& number);
     static QString& stripTags(QString& string);
     static QString& htmlEntityDecode(QString& string);
+    static bool isPhoneNumber(QString const& string);
     void fixUrl(QUrl& url);
     QHttp http_;