Log In
New Account
  
Home My Page Project Cloud Code Snippets Project Openings Jenirok
Summary Tracker SCM Files
authoreshe <jessehakanen@gmail.com>
Sun, 18 Jul 2010 20:27:58 +0000 (21:27 +0100)
committereshe <jessehakanen@gmail.com>
Sun, 18 Jul 2010 20:27:58 +0000 (21:27 +0100)
12 files changed:
debian/postinst
src/common/source.cpp
src/common/source.h
src/common/sourcecoreconfig.cpp
src/daemon/daemon.pro
src/gui/gui.pro
src/gui/mainwindow.cpp
src/gui/searchdialog.cpp
src/gui/searchdialog.h
src/gui/settingsdialog.cpp
src/gui/settingsdialog.h
src/gui/sourceguiconfig.cpp

index 9dbc6dc..1d89f14 100644 (file)
@@ -1,6 +1,5 @@
 #!/bin/sh -e
 
-gtk-update-icon-cache -f /usr/share/icons/hicolor
 /etc/init.d/jenirokd start -boot
 
 exit 0
index 460f98e..21245b9 100644 (file)
 #include "source.h"
 #include "eniro.h"
 #include "mobil1881.h"
+#include "dastelefonbuch.h"
 
 namespace
 {
     static const QString SOURCE_NAMES[Source::SOURCE_COUNT] =
     {
          "Eniro (FI, SE, DK)",
-         "1881 Mobil (NO)"
+         "1881 Mobil (NO)",
+         "Das Telefonbuch (DE)"
     };
 
     static const QString SOURCE_IDS[Source::SOURCE_COUNT] =
     {
          "eniro",
-         "1881mobil"
+         "1881mobil",
+         "dastelefonbuch"
     };
 
 }
@@ -53,6 +56,9 @@ Source* Source::getSource(Source::SourceId id, QObject* parent)
     case MOBIL1881:
         return new Mobil1881(parent);
         break;
+    case DASTELEFONBUCH:
+        return new DasTelefonbuch(parent);
+        break;
     default:
         qDebug() << "Unknown source:" << id;
     }
@@ -112,6 +118,13 @@ unsigned int Source::getMaxResults() const
     return maxResults_;
 }
 
+void Source::getSearchTypes(QList<SearchType>& types) const
+{
+    types.clear();
+    types.push_back(PERSONS);
+    types.push_back(YELLOW_PAGES);
+}
+
 void Source::setTimeout(unsigned int timeout)
 {
     timeout_ = timeout;
index 3477380..6af26b2 100644 (file)
@@ -55,8 +55,8 @@ public:
 
 
     enum Error {NO_ERROR, CONNECTION_FAILURE, INVALID_LOGIN, TIMEOUT};
-    enum SourceId {ENIRO, MOBIL1881};
-    static int const SOURCE_COUNT = 2;
+    enum SourceId {ENIRO, MOBIL1881, DASTELEFONBUCH};
+    static int const SOURCE_COUNT = 3;
 
     struct SourceDetails
     {
@@ -75,6 +75,7 @@ public:
     static Source* getSource();
     virtual void abort();
     virtual void search(SearchDetails const& details) = 0;
+    virtual void getSearchTypes(QList<SearchType>& types) const;
     void setMaxResults(unsigned int results);
     unsigned int getMaxResults() const;
     void setTimeout(unsigned int ms);
index 79c88c6..09a66d5 100644 (file)
@@ -37,6 +37,7 @@ SourceCoreConfig* SourceCoreConfig::getCoreConfig(Source::SourceId id)
         return new EniroCoreConfig();
         break;
     case Source::MOBIL1881:
+    case Source::DASTELEFONBUCH:
         return new EmptyCoreConfig(); // No configuration
         break;
     default:
index 26485e3..d9e3ccd 100644 (file)
@@ -15,7 +15,8 @@ SOURCES += main.cpp \
     ../common/db.cpp \
     ../common/settings.cpp \
     ../common/connectionmanager.cpp \
-    ../common/cache.cpp
+    ../common/cache.cpp \
+    ../common/dastelefonbuch.cpp
 HEADERS += calllistener.h \
     informationbox.h \
     ../common/source.h \
@@ -28,7 +29,8 @@ HEADERS += calllistener.h \
     ../common/db.h \
     ../common/settings.h \
     ../common/connectionmanager.h \
-    ../common/cache.h
+    ../common/cache.h \
+    ../common/dastelefonbuch.h
 TRANSLATIONS = ../common/translations/fi_FI.ts
 RESOURCES = ../common/translations.grc
 INCLUDEPATH += ../common
index d93bd09..3492c0a 100644 (file)
@@ -24,7 +24,8 @@ SOURCES += main.cpp \
     ../common/db.cpp \
     ../common/settings.cpp \
     ../common/connectionmanager.cpp \ 
-    ../common/cache.cpp
+    ../common/cache.cpp \
+    ../common/dastelefonbuch.cpp
 HEADERS += mainwindow.h \
     searchdialog.h \
     resultwindow.h \
@@ -47,7 +48,8 @@ HEADERS += mainwindow.h \
     ../common/db.h \
     ../common/settings.h \
     ../common/connectionmanager.h \
-    ../common/cache.h
+    ../common/cache.h \
+    ../common/dastelefonbuch.h
 TRANSLATIONS = ../common/translations/fi_FI.ts
 RESOURCES = icons.grc ../common/translations.grc
 INCLUDEPATH += ../common
index 8a5c71d..2d4800d 100644 (file)
@@ -98,6 +98,11 @@ void MainWindow::showSettings()
     if(!settingsDialog_)
     {
         settingsDialog_ = new SettingsDialog(this);
+
+        if(searchDialog_)
+        {
+            connect(settingsDialog_, SIGNAL(saved()), searchDialog_, SLOT(loadSearchTypes()));
+        }
     }
 
     settingsDialog_->show();
@@ -187,6 +192,11 @@ void MainWindow::openSearch()
         searchDialog_ = new SearchDialog(this);
         connect(searchDialog_, SIGNAL(search(SearchDialog::SearchDetails&)),
                 this, SLOT(handleSearch(SearchDialog::SearchDetails&)));
+
+        if(settingsDialog_)
+        {
+            connect(settingsDialog_, SIGNAL(saved()), searchDialog_, SLOT(loadSearchTypes()));
+        }
     }
 
     searchDialog_->show();
index 58dd94f..5ee806c 100644 (file)
@@ -23,6 +23,8 @@
 #include <QtGui/QDialogButtonBox>
 #include <QMaemo5ValueButton>
 #include "searchdialog.h"
+#include "source.h"
+#include "settings.h"
 
 SearchDialog::SearchDialog(QWidget* parent): QDialog(parent),
 numberInput_(0), locationInput_(0), selector_(0)
@@ -42,8 +44,7 @@ numberInput_(0), locationInput_(0), selector_(0)
     locationLayout->addWidget(locationInput_);
 
     selector_ = new ButtonSelector(tr("Type"), this);
-    selector_->addItem(tr("Persons"));
-    selector_->addItem(tr("Companies"));
+    loadSearchTypes();
 
     QVBoxLayout* leftLayout = new QVBoxLayout;
     leftLayout->addLayout(numberLayout);
@@ -75,7 +76,7 @@ void SearchDialog::searchPressed()
     }
 
     details.location = locationInput_->text();
-    details.type = selector_->currentIndex();
+    details.type = selector_->value().toInt();
     emit search(details);
     hide();
 }
@@ -89,3 +90,40 @@ void SearchDialog::setVisible(bool visible)
         numberInput_->setFocus();
     }
 }
+
+void SearchDialog::loadSearchTypes()
+{
+    selector_->clear();
+
+    Source* source = Source::getSource(Source::stringToId(Settings::instance()->get("source")));
+
+    QList<Source::SearchType> types;
+    source->getSearchTypes(types);
+
+    if(types.size() > 1)
+    {
+        for(int i = 0; i < types.size(); i++)
+        {
+            switch(types.at(i))
+            {
+            case Source::PERSONS:
+                selector_->addItem(tr("Persons"), static_cast<int>(Source::PERSONS));
+                break;
+            case Source::YELLOW_PAGES:
+                selector_->addItem(tr("Companies"), static_cast<int>(Source::YELLOW_PAGES));
+                break;
+            case Source::BOTH:
+                break;
+            }
+        }
+
+        if(!selector_->isVisible())
+        {
+            selector_->show();
+        }
+    }
+    else
+    {
+        selector_->hide();
+    }
+}
index 193ee83..05c54c5 100644 (file)
@@ -45,6 +45,9 @@ public:
 signals:
     void search(SearchDialog::SearchDetails& details);
 
+public slots:
+    void loadSearchTypes();
+
 private slots:
     void searchPressed();
 
index 44207c6..2c3ee77 100644 (file)
@@ -188,6 +188,8 @@ void SettingsDialog::saveSettings()
         Daemon::restart();
     }
 
+    emit saved();
+
 }
 
 void SettingsDialog::resetCache()
index 9686e37..b93b028 100644 (file)
@@ -42,6 +42,9 @@ class SettingsDialog : public QDialog
 public:
     SettingsDialog(QWidget* parent = 0);
 
+signals:
+    void saved();
+
 public slots:
     void saveSettings();
     void resetCache();
index 70f214a..5d918bb 100644 (file)
@@ -39,6 +39,7 @@ SourceGuiConfig* SourceGuiConfig::getGuiConfig(Source::SourceId id, QWidget* par
         return new EniroGuiConfig(parent);
         break;
     case Source::MOBIL1881:
+    case Source::DASTELEFONBUCH:
         return new EmptyGuiConfig(parent); // No configuration
         break;
     default:

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment