Log In
New Account
  
Home My Page Project Cloud Code Snippets Project Openings Jenirok
Summary Tracker SCM Files
authoreshe <jessehakanen@gmail.com>
Tue, 17 Aug 2010 10:07:45 +0000 (11:07 +0100)
committereshe <jessehakanen@gmail.com>
Tue, 17 Aug 2010 10:07:45 +0000 (11:07 +0100)
12 files changed:
src/common/dastelefonbuch.cpp
src/common/mobil1881.cpp
src/common/settings.cpp
src/common/settings.h
src/daemon/calllistener.cpp
src/daemon/calllistener.h
src/gui/logwindow.cpp
src/gui/logwindow.h
src/gui/mainwindow.cpp
src/gui/mainwindow.h
src/gui/searchdialog.cpp
src/gui/searchdialog.h

index 7ab3ed4..7cb36ad 100644 (file)
@@ -113,10 +113,10 @@ void DasTelefonbuch::addNumbers(SearchData* searchData,
     }
 
     int pos = 0;
-    QRegExp rx("<table.*class=\"bg-01 entry(.*)</table>");
-    QRegExp name("<div class=\"long hide\">(.*)</a>");
-    QRegExp number("<td class=\"col4\">(.*)</td>");
-    QRegExp address("<td class=\"col2\">(.*)</td>.*<td class=\"col3\">(.*)</td>");
+    static QRegExp rx("<table.*class=\"bg-01 entry(.*)</table>");
+    static QRegExp name("<div class=\"long hide\">(.*)</a>");
+    static QRegExp number("<td class=\"col4\">(.*)</td>");
+    static QRegExp address("<td class=\"col2\">(.*)</td>.*<td class=\"col3\">(.*)</td>");
 
     rx.setMinimal(true);
     name.setMinimal(true);
@@ -197,9 +197,9 @@ void DasTelefonbuch::addOnlyNumber(SearchData* searchData,
                               QString const& data,
                               int index)
 {
-    QRegExp name("<div class=\"long hide\">(.*) (.*)</a>");
-    QRegExp number("<td class=\"col4\">(.*)</td>");
-    QRegExp address("<td class=\"col2\">(.*)</td>.*<td class=\"col3\">(.*)</td>");
+    static QRegExp name("<div class=\"long hide\">(.*) (.*)</a>");
+    static QRegExp number("<td class=\"col4\">(.*)</td>");
+    static QRegExp address("<td class=\"col2\">(.*)</td>.*<td class=\"col3\">(.*)</td>");
     name.setMinimal(true);
     number.setMinimal(true);
     address.setMinimal(true);
index 6bc9deb..6ded070 100644 (file)
@@ -114,10 +114,10 @@ void Mobil1881::addNumbers(SearchData* searchData,
     }
 
     int pos = 0;
-    QRegExp rx("<td valign=\"top\" width=\"99%\">(.*)</td>");
-    QRegExp name("<div class=\"srln\">(.*)</div>");
-    QRegExp address("<div class=\"srla\">(.*),<br/>(.*)</div>");
-    QRegExp number("<div class=\"srlp\">(.*)</div>");
+    static QRegExp rx("<td valign=\"top\" width=\"99%\">(.*)</td>");
+    static QRegExp name("<div class=\"srln\">(.*)</div>");
+    static QRegExp address("<div class=\"srla\">(.*),<br/>(.*)</div>");
+    static QRegExp number("<div class=\"srlp\">(.*)</div>");
     rx.setMinimal(true);
     name.setMinimal(true);
     address.setMinimal(true);
@@ -171,6 +171,11 @@ void Mobil1881::addNumbers(SearchData* searchData,
     if(searchData->results.size() >= maxResults)
     {
         emitRequestFinished(searchData, false, index);
+
+        if(searchData->totalSearches > 1)
+        {
+            abort();
+        }
     }
     else
     {
@@ -192,9 +197,9 @@ void Mobil1881::addOnlyNumber(SearchData* searchData,
                               QString const& data,
                               int index)
 {
-    QRegExp name("<div class=\"srsln\">(.*)</div>");
-    QRegExp number("class=\"srlttxt\"><b>(.*)</b>");
-    QRegExp address("class=\"srlttxt\"><span>(.*),<br/>(.*)</span>");
+    static QRegExp name("<div class=\"srsln\">(.*)</div>");
+    static QRegExp number("class=\"srlttxt\"><b>(.*)</b>");
+    static QRegExp address("class=\"srlttxt\"><span>(.*),<br/>(.*)</span>");
     name.setMinimal(true);
     number.setMinimal(true);
     address.setMinimal(true);
index 21962d9..6453bb3 100644 (file)
@@ -129,11 +129,20 @@ bool Settings::set(QString const& name, QString const& value)
         endEdit();
     }
 
+    settings_[name] = value;
+
     return returnValue;
 }
 
 QString Settings::get(QString const& name)
 {
+    QMap<QString, QString>::iterator it;
+
+    if((it = settings_.find(name)) != settings_.end())
+    {
+        return it.value();
+    }
+
     QString result = "";
 
     bool close = !editing_;
@@ -159,6 +168,8 @@ QString Settings::get(QString const& name)
         endEdit();
     }
 
+    settings_[name] = result;
+
     return result;
 
 }
index c732299..c0d0a5f 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <QtCore/QString>
 #include <QtCore/QList>
+#include <QtCore/QMap>
 #include <QtGui/QApplication>
 
 class Settings;
@@ -55,6 +56,7 @@ public:
 private:
     Settings();
     static Settings* instance_;
+    QMap<QString, QString> settings_;
     bool editing_;
 
 };
index b4d80d4..79a6485 100644 (file)
@@ -111,8 +111,6 @@ void CallListener::end()
 
 void CallListener::search(Source::SearchDetails const& details)
 {
-    qDebug() << "Search called";
-
     if(currentCall_)
     {
         delete currentCall_;
@@ -150,8 +148,6 @@ void CallListener::search(Source::SearchDetails const& details)
 
         showDelayedResult(tr("Searching..."), BANNER_DELAY);
 
-        qDebug() << "Starting to search...";
-
         source_->search(details);
     }
 
index 5e1d18b..23b97eb 100644 (file)
@@ -40,7 +40,7 @@ public:
     static const int BANNER_DELAY = 350;
     static const int SEARCH_RETRIES = 2;
     static const int CONNECT_RETRIES = 2;
-    static const int CONNECTION_LOOKUP_RETRIES = 10;
+    static const int CONNECTION_LOOKUP_RETRIES = 8;
     static const int GPRS_SCANS = 2;
     static const int WLAN_SCANS = 5;
     static const int WAIT_BETWEEN_RETRIES = 500;
index 4197111..bd57ce5 100644 (file)
@@ -90,20 +90,22 @@ void LogWindow::itemClicked(int index)
     }
 
     QMap <QString, QVariant> data = list_->getData(index).toMap();
-    Source::Result details;
-    details.name = data["name"].toString();
 
-    if(details.name.isEmpty())
+    if(data["name"].toString().isEmpty())
     {
-        return;
+        emit openSearch(data["number"].toString());
+    }
+    else
+    {
+        Source::Result details;
+        details.name = data["name"].toString();
+        details.street = data["street"].toString();
+        details.city = data["city"].toString();
+        details.number = data["number"].toString();
+        details.country = data["country"].toString();
+
+        emit logItemSelected(details);
     }
-
-    details.street = data["street"].toString();
-    details.city = data["city"].toString();
-    details.number = data["number"].toString();
-    details.country = data["country"].toString();
-
-    emit logItemSelected(details);
 }
 
 QWidget* LogWindow::createWidget(Cache::LogDetails const& details)
index 2afe7e7..a242a4f 100644 (file)
@@ -35,6 +35,7 @@ public:
 
 signals:
     void logItemSelected(Source::Result const& result);
+    void openSearch(QString const& number);
 
 protected:
     void setVisible(bool visible);
index 3e62491..4388860 100644 (file)
@@ -186,7 +186,7 @@ void MainWindow::toggleDaemon()
 
 }
 
-void MainWindow::openSearch()
+void MainWindow::openSearch(QString const& str)
 {
     Source::SourceId sourceId = Source::stringToId(Settings::instance()->get("source"));
     SourceCoreConfig* config = SourceCoreConfig::getCoreConfig(sourceId);
@@ -206,7 +206,7 @@ void MainWindow::openSearch()
     {
         searchDialog_ = new SearchDialog(this);
         connect(searchDialog_, SIGNAL(search(SearchDialog::SearchDetails&)),
-                this, SLOT(handleSearch(SearchDialog::SearchDetails&)));
+                this, SIGNAL(search(SearchDialog::SearchDetails&)));
 
         if(settingsDialog_)
         {
@@ -214,6 +214,11 @@ void MainWindow::openSearch()
         }
     }
 
+    if(!str.isEmpty())
+    {
+        searchDialog_->setSearchString(str);
+    }
+
     searchDialog_->show();
 }
 
@@ -223,6 +228,7 @@ void MainWindow::openLog()
     {
         logWindow_ = new LogWindow(this);
         connect(logWindow_, SIGNAL(logItemSelected(Source::Result const&)), this, SIGNAL(logItemSelected(Source::Result const&)));
+        connect(logWindow_, SIGNAL(openSearch(QString const&)), this, SLOT(openSearch(QString const&)));
     }
 
     logWindow_->show();
@@ -236,11 +242,6 @@ QToolButton* MainWindow::createButton(QString const& text)
     return button;
 }
 
-void MainWindow::handleSearch(SearchDialog::SearchDetails& details)
-{
-    emit search(details);
-}
-
 void MainWindow::showAbout()
 {
     if(!aboutDialog_)
index 98ff0c6..b859be0 100644 (file)
@@ -45,9 +45,8 @@ public slots:
     void showSettings();
     void showAbout();
     void toggleDaemon();
-    void openSearch();
+    void openSearch(QString const& str = QString());
     void openLog();
-    void handleSearch(SearchDialog::SearchDetails& details);
 
 private:
     QToolButton* createButton(QString const& text);
index a6224cb..ea412a9 100644 (file)
@@ -99,6 +99,11 @@ void SearchDialog::setVisible(bool visible)
     }
 }
 
+void SearchDialog::setSearchString(QString const& string)
+{
+    numberInput_->setText(string);
+}
+
 void SearchDialog::loadSearchTypes()
 {
     selector_->clear();
index 2f57a9b..0a143e0 100644 (file)
@@ -48,6 +48,7 @@ signals:
 
 public slots:
     void loadSearchTypes();
+    void setSearchString(QString const& string);
 
 private slots:
     void searchPressed();

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment