Log In
New Account
  
Home My Page Project Cloud Code Snippets Project Openings Jenirok
Summary Tracker SCM Files
authoreshe <jessehakanen@gmail.com>
Fri, 16 Apr 2010 10:51:05 +0000 (11:51 +0100)
committereshe <jessehakanen@gmail.com>
Fri, 16 Apr 2010 10:51:05 +0000 (11:51 +0100)
28 files changed:
Makefile
src/common/connectionmanager.cpp
src/common/connectionmanager.h
src/common/contactmanager.cpp
src/common/contactmanager.h
src/common/db.cpp
src/common/db.h
src/common/eniro.cpp
src/common/eniro.h
src/common/settings.cpp
src/common/settings.h
src/daemon/calllistener.cpp
src/daemon/calllistener.h
src/gui/buttonselector.cpp
src/gui/buttonselector.h
src/gui/daemon.cpp
src/gui/daemon.h
src/gui/detailwindow.cpp
src/gui/detailwindow.h
src/gui/main.cpp
src/gui/mainwindow.cpp
src/gui/mainwindow.h
src/gui/resultwindow.cpp
src/gui/resultwindow.h
src/gui/searchdialog.cpp
src/gui/searchdialog.h
src/gui/settingsdialog.cpp
src/gui/settingsdialog.h

index 9281321..8b93f1f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 #############################################################################
 # Makefile for building: jenirok
-# Generated by qmake (2.01a) (Qt 4.6.2) on: Wed Apr 14 21:02:29 2010
+# Generated by qmake (2.01a) (Qt 4.6.2) on: Fri Apr 16 11:46:54 2010
 # Project:  jenirok.pro
 # Template: subdirs
 # Command: /usr/bin/qmake -unix -o Makefile jenirok.pro
index 2793d83..174228e 100644 (file)
@@ -25,98 +25,98 @@ ConnectionManager* ConnectionManager::instance_ = 0;
 
 ConnectionManager::ConnectionManager(): connection_(0), connected_(false)
 {
-       DBusError err;
-       DBusConnection* conn;
-       dbus_error_init(&err);
-       conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
+    DBusError err;
+    DBusConnection* conn;
+    dbus_error_init(&err);
+    conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
 
-       if(conn)
-       {
-               dbus_connection_setup_with_g_main(conn, NULL);
-       }
-       else
-       {
-               qDebug() << "Unable to connect to DBUS: " << err.message;
-               dbus_error_free(&err);
-       }
+    if(conn)
+    {
+        dbus_connection_setup_with_g_main(conn, NULL);
+    }
+    else
+    {
+        qDebug() << "Unable to connect to DBUS: " << err.message;
+        dbus_error_free(&err);
+    }
 
-       connection_ = con_ic_connection_new();
+    connection_ = con_ic_connection_new();
 
-       g_signal_connect(G_OBJECT(connection_), "connection-event", G_CALLBACK(connectionHandler), NULL);
+    g_signal_connect(G_OBJECT(connection_), "connection-event", G_CALLBACK(connectionHandler), NULL);
 
 
 }
 
 ConnectionManager& ConnectionManager::instance()
 {
-       if(!instance_)
-       {
-               instance_ = new ConnectionManager;
-       }
+    if(!instance_)
+    {
+        instance_ = new ConnectionManager;
+    }
 
-       return *instance_;
+    return *instance_;
 }
 
 bool ConnectionManager::connect()
 {
-       return con_ic_connection_connect(connection_, CON_IC_CONNECT_FLAG_NONE);
+    return con_ic_connection_connect(connection_, CON_IC_CONNECT_FLAG_NONE);
 }
 
 bool ConnectionManager::disconnect()
 {
-       return con_ic_connection_disconnect(connection_);
+    return con_ic_connection_disconnect(connection_);
 }
 
 bool ConnectionManager::isConnected()
 {
-       return connected_;
+    return connected_;
 }
 void ConnectionManager::connectionHandler(ConIcConnection *connection,
-        ConIcConnectionEvent *event,
-        gpointer user_data)
+                                          ConIcConnectionEvent *event,
+                                          gpointer user_data)
 {
-       Q_UNUSED(connection);
-       Q_UNUSED(user_data);
-
-       ConIcConnectionStatus status = con_ic_connection_event_get_status(event);
-
-       switch(status)
-       {
-
-         case CON_IC_STATUS_CONNECTED:
-               qDebug() << "Connected";
-               instance_->emit connected();
-               instance_->connected_ = true;
-               break;
-
-         case CON_IC_STATUS_DISCONNECTING:
-         case CON_IC_STATUS_NETWORK_UP:
-               break;
-
-         case CON_IC_STATUS_DISCONNECTED:
-               ConIcConnectionError err = con_ic_connection_event_get_error(event);
-               switch(err)
-               {
-                 case CON_IC_CONNECTION_ERROR_NONE:
-                 case CON_IC_CONNECTION_ERROR_USER_CANCELED:
-                       qDebug() << "Disconnected";
-                       instance_->emit disconnected();
-                       instance_->connected_ = false;
-                       break;
-
-                 case CON_IC_CONNECTION_ERROR_INVALID_IAP:
-                       qDebug() << "Invalid IAP";
-                       instance_->emit error("Invalid IAP");
-                       break;
-
-                 case CON_IC_CONNECTION_ERROR_CONNECTION_FAILED:
-                       qDebug() << "Connection failed";
-                       instance_->emit error("Connection failed");
-                       break;
-
-                 default:
-                         break;
-               }
-               break;
-       }
+    Q_UNUSED(connection);
+    Q_UNUSED(user_data);
+
+    ConIcConnectionStatus status = con_ic_connection_event_get_status(event);
+
+    switch(status)
+    {
+
+    case CON_IC_STATUS_CONNECTED:
+        qDebug() << "Connected";
+        instance_->emit connected();
+        instance_->connected_ = true;
+        break;
+
+    case CON_IC_STATUS_DISCONNECTING:
+    case CON_IC_STATUS_NETWORK_UP:
+        break;
+
+    case CON_IC_STATUS_DISCONNECTED:
+        ConIcConnectionError err = con_ic_connection_event_get_error(event);
+        switch(err)
+        {
+        case CON_IC_CONNECTION_ERROR_NONE:
+        case CON_IC_CONNECTION_ERROR_USER_CANCELED:
+            qDebug() << "Disconnected";
+            instance_->emit disconnected();
+            instance_->connected_ = false;
+            break;
+
+        case CON_IC_CONNECTION_ERROR_INVALID_IAP:
+            qDebug() << "Invalid IAP";
+            instance_->emit error("Invalid IAP");
+            break;
+
+        case CON_IC_CONNECTION_ERROR_CONNECTION_FAILED:
+            qDebug() << "Connection failed";
+            instance_->emit error("Connection failed");
+            break;
+
+        default:
+            break;
+        }
+        break;
+    }
 }
index fd31ab6..ea44605 100644 (file)
 
 class ConnectionManager : public QObject
 {
-       Q_OBJECT
+    Q_OBJECT
 
 public:
-       static ConnectionManager& instance();
-       bool connect();
-       bool disconnect();
-       bool isConnected();
+    static ConnectionManager& instance();
+    bool connect();
+    bool disconnect();
+    bool isConnected();
 
 signals:
-       void connected();
-       void disconnected();
-       void error(QString const& error);
+    void connected();
+    void disconnected();
+    void error(QString const& error);
 
 
 private:
-       ConnectionManager();
-       static void connectionHandler(ConIcConnection *connection,
-                   ConIcConnectionEvent *event,
-                   gpointer user_data);
-       static ConnectionManager* instance_;
-       ConIcConnection* connection_;
-       bool connected_;
+    ConnectionManager();
+    static void connectionHandler(ConIcConnection *connection,
+                                  ConIcConnectionEvent *event,
+                                  gpointer user_data);
+    static ConnectionManager* instance_;
+    ConIcConnection* connection_;
+    bool connected_;
 };
 
 #endif
index 3f8affe..1289f1a 100644 (file)
@@ -21,8 +21,8 @@
 
 namespace
 {
-       const int COUNTRY_CODES[] = {358, 45, 46, 47};
-       const int NUM_OF_CODES = 4;
+    const int COUNTRY_CODES[] = {358, 45, 46, 47};
+    const int NUM_OF_CODES = 4;
 }
 
 ContactManager::ContactManager(): book_(0)
@@ -35,142 +35,142 @@ ContactManager::~ContactManager()
 
 bool ContactManager::numberExists(QString const& number)
 {
-       if(!load())
-       {
-               return false;
-       }
+    if(!load())
+    {
+        return false;
+    }
 
-       EBookQuery* query;
-       GList *g_contacts;
+    EBookQuery* query;
+    GList *g_contacts;
 
-       QString copy(number);
-       QString clean = removeCountryCode(copy);
+    QString copy(number);
+    QString clean = removeCountryCode(copy);
 
-       query = e_book_query_any_field_contains(clean.toLatin1());
+    query = e_book_query_any_field_contains(clean.toLatin1());
 
-       if (!e_book_get_contacts (book_, query, &g_contacts, NULL))
-       {
-               qDebug() << "Couldn't get query results.\n";
-               return false;
-       }
+    if (!e_book_get_contacts (book_, query, &g_contacts, NULL))
+    {
+        qDebug() << "Couldn't get query results.\n";
+        return false;
+    }
 
-       if (g_contacts == 0)
-       {
-               qDebug() << "no contacts";
-               return false;
-       }
+    if (g_contacts == 0)
+    {
+        qDebug() << "no contacts";
+        return false;
+    }
 
-       return true;
+    return true;
 
 }
 
 bool ContactManager::addContact(Contact const& contact)
 {
-       if(!load())
-       {
-               return false;
-       }
-
-       EContact* newContact = e_contact_new();
-       GError* error = NULL;
-       //EContactAddress* addr = new EContactAddress;
-
-       if(!contact.name.isEmpty())
-       {
-               char* name = contact.name.toLatin1().data();
-               e_contact_set(newContact, E_CONTACT_FULL_NAME, (gpointer)name);
-       }
-
-       // Doesn't work for some reason
-       /*if(!contact.city.isEmpty() || !contact.street.isEmpty())
+    if(!load())
+    {
+        return false;
+    }
+
+    EContact* newContact = e_contact_new();
+    GError* error = NULL;
+    //EContactAddress* addr = new EContactAddress;
+
+    if(!contact.name.isEmpty())
+    {
+        char* name = contact.name.toLatin1().data();
+        e_contact_set(newContact, E_CONTACT_FULL_NAME, (gpointer)name);
+    }
+
+    // Doesn't work for some reason
+    /*if(!contact.city.isEmpty() || !contact.street.isEmpty())
        {
                addr->street = contact.street.toLatin1().data();
                addr->locality = contact.city.toLatin1().data();
                e_contact_set(newContact, E_CONTACT_ADDRESS_HOME, (gpointer)addr);
        }*/
 
-       if(!contact.number.isEmpty())
-       {
-               char* number = contact.number.toLatin1().data();
-               e_contact_set(newContact, E_CONTACT_PHONE_HOME, (gpointer)number);
-       }
+    if(!contact.number.isEmpty())
+    {
+        char* number = contact.number.toLatin1().data();
+        e_contact_set(newContact, E_CONTACT_PHONE_HOME, (gpointer)number);
+    }
 
-       if(!e_book_add_contact(book_, newContact, &error))
-       {
-               qDebug() << "Couldn't add contact: %s" <<  error->message;
-               g_error_free(error);
-               return false;
-       }
+    if(!e_book_add_contact(book_, newContact, &error))
+    {
+        qDebug() << "Couldn't add contact: %s" <<  error->message;
+        g_error_free(error);
+        return false;
+    }
 
-       return true;
+    return true;
 }
 
 bool ContactManager::load()
 {
-       if(book_)
-       {
-               return true;
-       }
-
-       GError* error = NULL;
-       book_ = e_book_new_system_addressbook(&error);
-
-       if (!book_)
-       {
-               qDebug() << "Couldn't open addressbook: %s" <<  error->message;
-               g_error_free(error);
-               return false;
-       }
-
-       /* Open connection to the address book */
-       if (!e_book_open(book_, FALSE, &error))
-       {
-               qDebug() << "Couldn't open addressbook: %s" << error->message;
-               g_error_free(error);
-               return false;
-       }
-
-       return true;
+    if(book_)
+    {
+        return true;
+    }
+
+    GError* error = NULL;
+    book_ = e_book_new_system_addressbook(&error);
+
+    if (!book_)
+    {
+        qDebug() << "Couldn't open addressbook: %s" <<  error->message;
+        g_error_free(error);
+        return false;
+    }
+
+    /* Open connection to the address book */
+    if (!e_book_open(book_, FALSE, &error))
+    {
+        qDebug() << "Couldn't open addressbook: %s" << error->message;
+        g_error_free(error);
+        return false;
+    }
+
+    return true;
 
 }
 
 QString& ContactManager::removeCountryCode(QString& number)
 {
-       if(number.isEmpty())
-       {
-               return number;
-       }
-
-       if(number.at(0) == '0')
-       {
-               return number.remove(0, 1);
-       }
-       else if(number.at(0) != '+')
-       {
-               return number;
-       }
-
-       static QRegExp countryCodeCleaner;
-       static bool countryCodeCleanerLoaded = false;
-
-       if(!countryCodeCleanerLoaded)
-       {
-               QString match = "";
-
-               for(int i = 0; i < NUM_OF_CODES; i++)
-               {
-                       if(i > 0)
-                       {
-                               match += "|";
-                       }
-
-                       match += "\\+" + QString::number(COUNTRY_CODES[i]);
-               }
-
-               countryCodeCleaner = QRegExp("^(" + match + ")");
-               countryCodeCleanerLoaded = true;
-       }
-
-       return number.replace(countryCodeCleaner, "");
+    if(number.isEmpty())
+    {
+        return number;
+    }
+
+    if(number.at(0) == '0')
+    {
+        return number.remove(0, 1);
+    }
+    else if(number.at(0) != '+')
+    {
+        return number;
+    }
+
+    static QRegExp countryCodeCleaner;
+    static bool countryCodeCleanerLoaded = false;
+
+    if(!countryCodeCleanerLoaded)
+    {
+        QString match = "";
+
+        for(int i = 0; i < NUM_OF_CODES; i++)
+        {
+            if(i > 0)
+            {
+                match += "|";
+            }
+
+            match += "\\+" + QString::number(COUNTRY_CODES[i]);
+        }
+
+        countryCodeCleaner = QRegExp("^(" + match + ")");
+        countryCodeCleanerLoaded = true;
+    }
+
+    return number.replace(countryCodeCleaner, "");
 }
 
index 904e103..0807519 100644 (file)
 class ContactManager
 {
 public:
-       struct Contact
-       {
-               QString name;
-               QString number;
-               QString street;
-               QString city;
-       };
+    struct Contact
+    {
+        QString name;
+        QString number;
+        QString street;
+        QString city;
+    };
 
-       ContactManager();
-       ~ContactManager();
-       bool addContact(Contact const& contact);
-       bool numberExists(QString const& number);
-       static QString& removeCountryCode(QString& number);
+    ContactManager();
+    ~ContactManager();
+    bool addContact(Contact const& contact);
+    bool numberExists(QString const& number);
+    static QString& removeCountryCode(QString& number);
 
 private:
-       bool load();
-       EBook* book_;
+    bool load();
+    EBook* book_;
 };
 
 #endif
index e5ce316..d7b7dfa 100644 (file)
@@ -24,8 +24,8 @@
 
 namespace
 {
-       const QString SQL_DRIVER = "QSQLITE";
-       const QString SQL_DATABASE = ".jenirok.db";
+    const QString SQL_DRIVER = "QSQLITE";
+    const QString SQL_DATABASE = ".jenirok.db";
 }
 
 bool DB::initialized_ = false;
@@ -33,71 +33,71 @@ QSqlDatabase DB::db_;
 
 bool DB::connect()
 {
-       if(!initialized_)
-       {
-               db_ = QSqlDatabase::addDatabase(SQL_DRIVER);
-               QString path = QDir::home().path() + QDir::separator() + SQL_DATABASE;
-               db_.setDatabaseName(QDir::toNativeSeparators(path));
-       }
-
-       bool ret = db_.open();
-
-       if(!ret)
-       {
-               QSqlError error = db_.lastError();
-               qDebug() << error.text();
-       }
-
-       if(ret && !initialized_)
-       {
-               QSqlQuery query("SELECT value FROM settings WHERE name = 'initialized'");
-
-               if(!query.next())
-               {
-                       ret = createTables();
-               }
-       }
-
-       if(!initialized_)
-       {
-               initialized_ = true;
-       }
-
-       return ret;
+    if(!initialized_)
+    {
+        db_ = QSqlDatabase::addDatabase(SQL_DRIVER);
+        QString path = QDir::home().path() + QDir::separator() + SQL_DATABASE;
+        db_.setDatabaseName(QDir::toNativeSeparators(path));
+    }
+
+    bool ret = db_.open();
+
+    if(!ret)
+    {
+        QSqlError error = db_.lastError();
+        qDebug() << error.text();
+    }
+
+    if(ret && !initialized_)
+    {
+        QSqlQuery query("SELECT value FROM settings WHERE name = 'initialized'");
+
+        if(!query.next())
+        {
+            ret = createTables();
+        }
+    }
+
+    if(!initialized_)
+    {
+        initialized_ = true;
+    }
+
+    return ret;
 }
 
 void DB::disconnect()
 {
-       db_.close();
+    db_.close();
 }
 
 void DB::removeDatabase()
 {
-       db_.close();
-       db_ = QSqlDatabase();
-       QSqlDatabase::removeDatabase(QSqlDatabase::defaultConnection);
-       initialized_ = false;
+    db_.close();
+    db_ = QSqlDatabase();
+    QSqlDatabase::removeDatabase(QSqlDatabase::defaultConnection);
+    initialized_ = false;
 }
 
 bool DB::connected()
 {
-       return db_.isOpen();
+    return db_.isOpen();
 }
 
 QSqlDatabase& DB::instance()
 {
-       return db_;
+    return db_;
 }
 
 bool DB::createTables()
 {
-       QSqlQuery query;
+    QSqlQuery query;
 
-       bool ret = true;
+    bool ret = true;
 
-       ret = ret && query.exec("CREATE TABLE cache (id INTEGER PRIMARY KEY, number VARCHAR(32) NOT NULL UNIQUE, name VARCHAR(255) NOT NULL, street VARCHAR(255) NOT NULL, city VARCHAR(255) NOT NULL)");
-       ret = ret && query.exec("CREATE TABLE settings (name VARCHAR(255) NOT NULL PRIMARY KEY, value VARCHAR(255) NOT NULL)");
-       ret = ret && query.exec("INSERT INTO settings(name, value) VALUES('initialized', '1')");
+    ret = ret && query.exec("CREATE TABLE cache (id INTEGER PRIMARY KEY, number VARCHAR(32) NOT NULL UNIQUE, name VARCHAR(255) NOT NULL, street VARCHAR(255) NOT NULL, city VARCHAR(255) NOT NULL)");
+    ret = ret && query.exec("CREATE TABLE settings (name VARCHAR(255) NOT NULL PRIMARY KEY, value VARCHAR(255) NOT NULL)");
+    ret = ret && query.exec("INSERT INTO settings(name, value) VALUES('initialized', '1')");
 
-       return ret;
+    return ret;
 }
index 20eeae2..0aa2490 100644 (file)
@@ -26,17 +26,17 @@ class DB
 {
 
 public:
-       static bool connect();
-       static bool connected();
-       static void disconnect();
-       static void removeDatabase();
-       QSqlDatabase& instance();
+    static bool connect();
+    static bool connected();
+    static void disconnect();
+    static void removeDatabase();
+    QSqlDatabase& instance();
 
 private:
-       DB();
-       static bool createTables();
-       static QSqlDatabase db_;
-       static bool initialized_;
+    DB();
+    static bool createTables();
+    static QSqlDatabase db_;
+    static bool initialized_;
 };
 
 #endif // DB_H
index 56f27fe..0b8579b 100644 (file)
@@ -23,9 +23,9 @@ namespace
 {
     static const QString SITE_URLS[] =
     {
-        "http://wap.eniro.fi/",
-        "http://wap.eniro.se/",
-        "http://wap.eniro.dk/"
+            "http://wap.eniro.fi/",
+            "http://wap.eniro.se/",
+            "http://wap.eniro.dk/"
     };
 
     const QString INVALID_LOGIN_STRING = "Invalid login details";
@@ -59,7 +59,7 @@ void Eniro::abort()
     http_.abort();
 
     for(searchMap::iterator sit = pendingSearches_.begin();
-        sit != pendingSearches_.end(); sit++)
+    sit != pendingSearches_.end(); sit++)
     {
         if(sit.value() != 0)
         {
@@ -71,7 +71,7 @@ void Eniro::abort()
     pendingSearches_.clear();
 
     for(numberMap::iterator nit = pendingNumberRequests_.begin();
-        nit != pendingNumberRequests_.end(); nit++)
+    nit != pendingNumberRequests_.end(); nit++)
     {
         if(nit.value() != 0)
         {
@@ -91,7 +91,7 @@ void Eniro::setMaxResults(unsigned int value)
 
 void Eniro::setFindNumber(bool value)
 {
-       findNumber_ = value;
+    findNumber_ = value;
 }
 
 void Eniro::setSite(Eniro::Site site)
@@ -202,7 +202,7 @@ void Eniro::httpReady(int id, bool error)
 
     // Check if request is pending search request
     if((searchIt = pendingSearches_.find(id)) !=
-       pendingSearches_.end())
+        pendingSearches_.end())
     {
         if(error)
         {
@@ -220,7 +220,7 @@ void Eniro::httpReady(int id, bool error)
 
     // Check if request is pending number requests
     else if((numberIt = pendingNumberRequests_.find(id)) !=
-            pendingNumberRequests_.end())
+        pendingNumberRequests_.end())
     {
         if(error)
         {
@@ -239,24 +239,24 @@ void Eniro::httpReady(int id, bool error)
 
     // Check for login request
     else if(pendingLoginRequests_.find(id) !=
-            pendingLoginRequests_.end())
+        pendingLoginRequests_.end())
     {
-       bool success = true;
-
-       if(!error)
-       {
-               QString result(http_.readAll());
-
-               // If html source contains LOGIN_CHECK, login failed
-               if(result.indexOf(LOGIN_CHECK) != -1)
-               {
-                       success = false;
-               }
-       }
-       else
-       {
-               success = false;
-       }
+        bool success = true;
+
+        if(!error)
+        {
+            QString result(http_.readAll());
+
+            // If html source contains LOGIN_CHECK, login failed
+            if(result.indexOf(LOGIN_CHECK) != -1)
+            {
+                success = false;
+            }
+        }
+        else
+        {
+            success = false;
+        }
 
         emit loginStatus(success);
     }
@@ -271,13 +271,13 @@ void Eniro::loadResults(int id, QString const& httpData)
 
     switch(it.value()->details.type)
     {
-      case YELLOW_PAGES:
+    case YELLOW_PAGES:
         expr = YELLOW_REGEXP;
         break;
-      case PERSONS:
+    case PERSONS:
         expr = PERSON_REGEXP;
         break;
-      default:
+    default:
         return;
     }
 
@@ -291,15 +291,15 @@ void Eniro::loadResults(int id, QString const& httpData)
     // Find all matches
     while((pos = rx.indexIn(httpData, pos)) != -1)
     {
-       pos += rx.matchedLength();
+        pos += rx.matchedLength();
 
-       data = rx.cap(2);
-       data = stripTags(data);
-       QStringList rows = data.split('\n');
+        data = rx.cap(2);
+        data = stripTags(data);
+        QStringList rows = data.split('\n');
 
-       for(int i = 0; i < rows.size(); i++)
-       {
-           // Remove white spaces
+        for(int i = 0; i < rows.size(); i++)
+        {
+            // Remove white spaces
             QString trimmed = rows.at(i).trimmed().toLower();
 
             // Remove empty strings
@@ -310,68 +310,68 @@ void Eniro::loadResults(int id, QString const& httpData)
             }
             else
             {
-               // Convert words to uppercase
+                // Convert words to uppercase
                 rows[i] = ucFirst(trimmed);
             }
-       }
+        }
 
-       Result result;
+        Result result;
 
-       int size = rows.size();
+        int size = rows.size();
 
-       switch(size)
-       {
-         case 1:
-           result.name = rows[0];
-           break;
+        switch(size)
+        {
+        case 1:
+            result.name = rows[0];
+            break;
 
-         case 2:
-           result.name = rows[0];
-           result.city = rows[1];
-           break;
+        case 2:
+            result.name = rows[0];
+            result.city = rows[1];
+            break;
 
-         case 3:
-           result.name = rows[0];
-           result.street = rows[1];
-           result.city = rows[2];
-           break;
+        case 3:
+            result.name = rows[0];
+            result.street = rows[1];
+            result.city = rows[2];
+            break;
 
-         case 4:
-           result.name = rows[0];
-           // Remove slashes and spaces from number
-           result.number = cleanUpNumber(rows[1]);
-           result.street = rows[2];
-           result.city = rows[3];
-           break;
+        case 4:
+            result.name = rows[0];
+            // Remove slashes and spaces from number
+            result.number = cleanUpNumber(rows[1]);
+            result.street = rows[2];
+            result.city = rows[3];
+            break;
 
-         default:
-           continue;
+        default:
+            continue;
 
-       }
+        }
 
-       it.value()->results.push_back(result);
+        it.value()->results.push_back(result);
 
-       unsigned int foundResults = ++(it.value()->numbersTotal);
+        unsigned int foundResults = ++(it.value()->numbersTotal);
 
-       // If phone number searh is enabled, we have to make another
-       // request to find it out
-       if(findNumber_ && size < 4 && loggedIn_ &&
-          it.value()->details.type != YELLOW_PAGES)
-       {
+        // If phone number searh is enabled, we have to make another
+        // request to find it out
+        if(findNumber_ && size < 4 && loggedIn_ &&
+                it.value()->details.type != YELLOW_PAGES)
+        {
             requestsPending = true;
             getNumberForResult(id, it.value()->results.size() - 1, it.value()->details);
-       }
-       // Otherwise result is ready
-       else
-       {
+        }
+        // Otherwise result is ready
+        else
+        {
             emit resultAvailable(result, it.value()->details);
-       }
+        }
 
-       // Stop searching if max results is reached
-       if(maxResults_ && (foundResults >= maxResults_))
-       {
-           break;
-       }
+        // Stop searching if max results is reached
+        if(maxResults_ && (foundResults >= maxResults_))
+        {
+            break;
+        }
     }
 
     // If number there were no results or no phone numbers needed to
@@ -424,7 +424,7 @@ void Eniro::loadNumber(int id, QString const& result)
 
         if(!trimmed.isEmpty())
         {
-               // Remove whitespaces from number
+            // Remove whitespaces from number
             searchIt.value()->results[numberIt.value()->index].number = cleanUpNumber(trimmed);
 
             emit resultAvailable(searchIt.value()->results[numberIt.value()->index], searchIt.value()->details);
@@ -434,7 +434,7 @@ void Eniro::loadNumber(int id, QString const& result)
             // Check if all numbers have been found
             if(found >= searchIt.value()->numbersTotal)
             {
-               emitRequestFinished(searchIt.key(), searchIt.value(), false);
+                emitRequestFinished(searchIt.key(), searchIt.value(), false);
             }
 
             // If number was found, there was no error
@@ -507,11 +507,11 @@ void Eniro::getNumberForResult(int id, int index, SearchDetails const& details)
 void Eniro::emitRequestFinished(int key, SearchData* data, bool error)
 {
 
-       // Do not emit "Request aborted" error
-       if(!(error && (http_.error() == QHttp::Aborted)))
-       {
-               emit requestFinished(data->results, data->details, error);
-       }
+    // Do not emit "Request aborted" error
+    if(!(error && (http_.error() == QHttp::Aborted)))
+    {
+        emit requestFinished(data->results, data->details, error);
+    }
 
     delete pendingSearches_[key];
     pendingSearches_[key] = 0;
@@ -520,19 +520,19 @@ void Eniro::emitRequestFinished(int key, SearchData* data, bool error)
 
 QString Eniro::ucFirst(QString& str)
 {
-       if (str.size() < 1) {
-               return "";
-       }
+    if (str.size() < 1) {
+        return "";
+    }
 
-       QStringList tokens = str.split(" ");
-       QList<QString>::iterator tokItr;
+    QStringList tokens = str.split(" ");
+    QList<QString>::iterator tokItr;
 
-       for (tokItr = tokens.begin(); tokItr != tokens.end(); ++tokItr)
-       {
-               (*tokItr) = (*tokItr).at(0).toUpper() + (*tokItr).mid(1);
-       }
+    for (tokItr = tokens.begin(); tokItr != tokens.end(); ++tokItr)
+    {
+        (*tokItr) = (*tokItr).at(0).toUpper() + (*tokItr).mid(1);
+    }
 
-       return tokens.join(" ");
+    return tokens.join(" ");
 }
 
 QString& Eniro::cleanUpNumber(QString& number)
@@ -547,39 +547,39 @@ QString& Eniro::stripTags(QString& string)
 
 QMap <Eniro::Site, Eniro::SiteDetails> Eniro::getSites()
 {
-       QMap <Site, SiteDetails> sites;
-       SiteDetails details;
-       details.name = tr("Finnish");
-       details.id = "fi";
-       sites[FI] = details;
+    QMap <Site, SiteDetails> sites;
+    SiteDetails details;
+    details.name = tr("Finnish");
+    details.id = "fi";
+    sites[FI] = details;
 
-       details.name = tr("Swedish");
-       details.id = "se";
-       sites[SE] = details;
+    details.name = tr("Swedish");
+    details.id = "se";
+    sites[SE] = details;
 
-       details.name = tr("Danish");
-       details.id = "dk";
-       sites[DK] = details;
+    details.name = tr("Danish");
+    details.id = "dk";
+    sites[DK] = details;
 
-       return sites;
+    return sites;
 }
 
 Eniro::Site Eniro::stringToSite(QString const& str)
 {
-       Site site = FI;
+    Site site = FI;
 
-       QString lower = str.toLower();
+    QString lower = str.toLower();
 
-       if(lower == "se" || lower == "swedish")
-       {
-               site = SE;
-       }
-       else if(lower == "dk" || lower == "danish")
-       {
-               site = DK;
-       }
+    if(lower == "se" || lower == "swedish")
+    {
+        site = SE;
+    }
+    else if(lower == "dk" || lower == "danish")
+    {
+        site = DK;
+    }
 
-       return site;
+    return site;
 }
 
 Eniro::SearchDetails::SearchDetails(QString const& q,
index af3d3b1..44165ee 100644 (file)
@@ -59,8 +59,8 @@ public:
 
     struct SiteDetails
     {
-       QString name;
-       QString id;
+        QString name;
+        QString id;
     };
 
     Eniro(Site site, QObject *parent = 0);
@@ -90,7 +90,7 @@ private slots:
 
 private:
 
-       Q_DISABLE_COPY(Eniro);
+    Q_DISABLE_COPY(Eniro);
 
     struct NumberData
     {
index 25fc13b..91b289d 100644 (file)
@@ -25,129 +25,129 @@ Settings* Settings::instance_ = 0;
 
 Settings* Settings::instance()
 {
-       if(!instance_)
-       {
-               instance_ = new Settings;
-       }
+    if(!instance_)
+    {
+        instance_ = new Settings;
+    }
 
-       return instance_;
+    return instance_;
 }
 
 bool Settings::set(QString const& name, QString const& value)
 {
-       bool connected = DB::connected();
-
-       if(!connected)
-       {
-               if(!DB::connect())
-               {
-                       return false;
-               }
-       }
-
-       QSqlQuery deleteQuery;
-       deleteQuery.prepare("DELETE FROM settings WHERE name = :name");
-       deleteQuery.bindValue(":name", QVariant(name));
-       deleteQuery.exec();
-
-       QSqlQuery query;
-       query.prepare("INSERT INTO settings(name, value) VALUES(:name, :value)");
-       query.bindValue(":name", QVariant(name));
-       query.bindValue(":value", QVariant(value));
-
-       bool returnValue = query.exec();
-
-       if(!connected)
-       {
-               DB::disconnect();
-       }
-
-       return returnValue;
+    bool connected = DB::connected();
+
+    if(!connected)
+    {
+        if(!DB::connect())
+        {
+            return false;
+        }
+    }
+
+    QSqlQuery deleteQuery;
+    deleteQuery.prepare("DELETE FROM settings WHERE name = :name");
+    deleteQuery.bindValue(":name", QVariant(name));
+    deleteQuery.exec();
+
+    QSqlQuery query;
+    query.prepare("INSERT INTO settings(name, value) VALUES(:name, :value)");
+    query.bindValue(":name", QVariant(name));
+    query.bindValue(":value", QVariant(value));
+
+    bool returnValue = query.exec();
+
+    if(!connected)
+    {
+        DB::disconnect();
+    }
+
+    return returnValue;
 }
 
 QString Settings::get(QString const& name)
 {
-       QString result = "";
+    QString result = "";
 
-       bool connected = DB::connected();
+    bool connected = DB::connected();
 
-       if(!connected)
-       {
-               if(!DB::connect())
-               {
-                       return result;
-               }
-       }
+    if(!connected)
+    {
+        if(!DB::connect())
+        {
+            return result;
+        }
+    }
 
-       QSqlQuery query;
+    QSqlQuery query;
 
-       query.prepare("SELECT value FROM settings WHERE name = :name");
-       query.bindValue(":name", name);
+    query.prepare("SELECT value FROM settings WHERE name = :name");
+    query.bindValue(":name", name);
 
-       if(query.exec() && query.next())
-       {
-               result = query.value(0).toString();
-       }
-       else
-       {
-               result = getDefaultValue(name);
-       }
+    if(query.exec() && query.next())
+    {
+        result = query.value(0).toString();
+    }
+    else
+    {
+        result = getDefaultValue(name);
+    }
 
-       if(!connected)
-       {
-               DB::disconnect();
-       }
+    if(!connected)
+    {
+        DB::disconnect();
+    }
 
-       return result;
+    return result;
 
 }
 
 QString Settings::getDefaultValue(QString const& name)
 {
-       static bool defaultValuesLoaded = false;
-       static QMap <QString, QString> defaultValues;
+    static bool defaultValuesLoaded = false;
+    static QMap <QString, QString> defaultValues;
 
-       if(!defaultValuesLoaded)
-       {
-               defaultValues["autostart"] = "1";
-               defaultValues["eniro_site"] = tr("fi");
-               defaultValues["cache_size"] = "200";
-               defaultValuesLoaded = true;
-       }
+    if(!defaultValuesLoaded)
+    {
+        defaultValues["autostart"] = "1";
+        defaultValues["eniro_site"] = tr("fi");
+        defaultValues["cache_size"] = "200";
+        defaultValuesLoaded = true;
+    }
 
-       QMap<QString, QString>::const_iterator it = defaultValues.find(name);
+    QMap<QString, QString>::const_iterator it = defaultValues.find(name);
 
-       if(it != defaultValues.end())
-       {
-               return it.value();
-       }
+    if(it != defaultValues.end())
+    {
+        return it.value();
+    }
 
-       return "";
+    return "";
 
 }
 
 bool Settings::reset()
 {
-       bool connected = DB::connected();
+    bool connected = DB::connected();
 
-       if(!connected)
-       {
-               if(!DB::connect())
-               {
-                       return false;
-               }
-       }
+    if(!connected)
+    {
+        if(!DB::connect())
+        {
+            return false;
+        }
+    }
 
-       QSqlQuery query;
+    QSqlQuery query;
 
-       bool ret = query.exec("DELETE FROM settings");
+    bool ret = query.exec("DELETE FROM settings");
 
-       if(!connected)
-       {
-               DB::disconnect();
-       }
+    if(!connected)
+    {
+        DB::disconnect();
+    }
 
-       return ret;
+    return ret;
 }
 
 Settings::Settings()
index 51bdf6c..2263beb 100644 (file)
@@ -26,18 +26,18 @@ class Settings;
 
 class Settings
 {
-       Q_DECLARE_TR_FUNCTIONS(Settings)
+    Q_DECLARE_TR_FUNCTIONS(Settings)
 
 public:
-       static Settings* instance();
-       bool set(QString const& name, QString const& value);
-       QString get(QString const& name);
-       QString getDefaultValue(QString const& name);
-       bool reset();
+    static Settings* instance();
+    bool set(QString const& name, QString const& value);
+    QString get(QString const& name);
+    QString getDefaultValue(QString const& name);
+    bool reset();
 
 private:
-       Settings();
-       static Settings* instance_;
+    Settings();
+    static Settings* instance_;
 
 };
 
index 93fb100..9071713 100644 (file)
 
 namespace
 {
-       const QString CALL_SERVICE_NAME = "com.nokia.csd";
-       const QString CALL_SERVICE_PATH = "/com/nokia/csd/call";
-       const QString CALL_SERVICE_INTERFACE = "com.nokia.csd.Call";
-       const QString CALL_SERVICE_INSTANCE_NAME = "com.nokia.csd.Call.Instance";
-       const QString CALL_SIGNAL_INCOMING = "Coming";
-       const QString CALL_SIGNAL_RELEASE = "Release";
-       const QString CALL_SIGNAL_TERMINATED = "Terminated";
+    const QString CALL_SERVICE_NAME = "com.nokia.csd";
+    const QString CALL_SERVICE_PATH = "/com/nokia/csd/call";
+    const QString CALL_SERVICE_INTERFACE = "com.nokia.csd.Call";
+    const QString CALL_SERVICE_INSTANCE_NAME = "com.nokia.csd.Call.Instance";
+    const QString CALL_SIGNAL_INCOMING = "Coming";
+    const QString CALL_SIGNAL_RELEASE = "Release";
+    const QString CALL_SIGNAL_TERMINATED = "Terminated";
 }
 
 QDBusConnection CallListener::systemBus_ = QDBusConnection::systemBus();
@@ -41,105 +41,105 @@ CallListener::CallListener(): eniro_(0), contactManager_(0), box_(0), label_(0)
 
 CallListener::~CallListener()
 {
-       end();
+    end();
 }
 
 void CallListener::begin()
 {
-       systemBus_.connect(CALL_SERVICE_NAME,
-                                  CALL_SERVICE_PATH,
-                                  CALL_SERVICE_INTERFACE,
-                                  CALL_SIGNAL_INCOMING,
-                                  this,
-                                  SLOT(incomingCall(QDBusObjectPath, QString)));
+    systemBus_.connect(CALL_SERVICE_NAME,
+                       CALL_SERVICE_PATH,
+                       CALL_SERVICE_INTERFACE,
+                       CALL_SIGNAL_INCOMING,
+                       this,
+                       SLOT(incomingCall(QDBusObjectPath, QString)));
 
-       systemBus_.connect(CALL_SERVICE_NAME,
-                                      CALL_SERVICE_PATH,
-                                      CALL_SERVICE_INTERFACE,
-                                      CALL_SIGNAL_RELEASE,
-                                      this,
-                                      SLOT(callTerminate()));
+    systemBus_.connect(CALL_SERVICE_NAME,
+                       CALL_SERVICE_PATH,
+                       CALL_SERVICE_INTERFACE,
+                       CALL_SIGNAL_RELEASE,
+                       this,
+                       SLOT(callTerminate()));
 
-       contactManager_ = new ContactManager;
+    contactManager_ = new ContactManager;
 
-       eniro_ = new Eniro(Eniro::stringToSite(Settings::instance()->get("site")));
+    eniro_ = new Eniro(Eniro::stringToSite(Settings::instance()->get("site")));
 
-       eniro_->setMaxResults(1);
-       eniro_->setFindNumber(false);
+    eniro_->setMaxResults(1);
+    eniro_->setFindNumber(false);
 
-       connect(eniro_, SIGNAL(requestFinished(QVector <Eniro::Result> const&,
-                       Eniro::SearchDetails const&, bool)),
-                       this, SLOT(requestFinished(QVector <Eniro::Result> const&,
-                       Eniro::SearchDetails const&, bool)));
+    connect(eniro_, SIGNAL(requestFinished(QVector <Eniro::Result> const&,
+                                           Eniro::SearchDetails const&, bool)),
+                                           this, SLOT(requestFinished(QVector <Eniro::Result> const&,
+                                                                      Eniro::SearchDetails const&, bool)));
 
-       box_ = new InformationBox();
-       label_ = new QLabel("", box_);
-       label_->setMargin(10);
-       box_->setWidget(label_);
+    box_ = new InformationBox();
+    label_ = new QLabel("", box_);
+    label_->setMargin(10);
+    box_->setWidget(label_);
 
 }
 
 void CallListener::end()
 {
-       systemBus_.disconnect(CALL_SERVICE_NAME,
-                                          CALL_SERVICE_PATH,
-                                          CALL_SERVICE_INTERFACE,
-                                          CALL_SIGNAL_INCOMING,
-                                          this,
-                                          SLOT(incomingCall(QDBusObjectPath, QString)));
-
-       systemBus_.disconnect(CALL_SERVICE_NAME,
-                                              CALL_SERVICE_PATH,
-                                              CALL_SERVICE_INTERFACE,
-                                              CALL_SIGNAL_RELEASE,
-                                              this,
-                                              SLOT(callTerminate()));
-
-       delete eniro_;
-       eniro_ = 0;
-       delete box_;
-       box_ = 0;
-       delete label_;
-       label_ = 0;
+    systemBus_.disconnect(CALL_SERVICE_NAME,
+                          CALL_SERVICE_PATH,
+                          CALL_SERVICE_INTERFACE,
+                          CALL_SIGNAL_INCOMING,
+                          this,
+                          SLOT(incomingCall(QDBusObjectPath, QString)));
+
+    systemBus_.disconnect(CALL_SERVICE_NAME,
+                          CALL_SERVICE_PATH,
+                          CALL_SERVICE_INTERFACE,
+                          CALL_SIGNAL_RELEASE,
+                          this,
+                          SLOT(callTerminate()));
+
+    delete eniro_;
+    eniro_ = 0;
+    delete box_;
+    box_ = 0;
+    delete label_;
+    label_ = 0;
 }
 
 void CallListener::search(Eniro::SearchDetails const& details)
 {
-       label_->setText(tr("Searching..."));
-       box_->show();
+    label_->setText(tr("Searching..."));
+    box_->show();
 
-       DB::connect();
+    DB::connect();
 
-       QSqlQuery query;
-       query.prepare("SELECT name, street, city FROM cache WHERE number = :number");
-       query.bindValue(":number", details.query);
+    QSqlQuery query;
+    query.prepare("SELECT name, street, city FROM cache WHERE number = :number");
+    query.bindValue(":number", details.query);
 
-       if(query.exec() && query.next())
-       {
-               showResult(createResult(query.value(0).toString(),
-                               query.value(1).toString(),
-                               query.value(2).toString()));
+    if(query.exec() && query.next())
+    {
+        showResult(createResult(query.value(0).toString(),
+                                query.value(1).toString(),
+                                query.value(2).toString()));
 
-       }
-       else
-       {
-               eniro_->search(details);
-       }
+    }
+    else
+    {
+        eniro_->search(details);
+    }
 
-       DB::disconnect();
+    DB::disconnect();
 
 }
 
 void CallListener::requestFinished(QVector <Eniro::Result> const& results,
-                                          Eniro::SearchDetails const& details,
-                                          bool error)
+                                   Eniro::SearchDetails const& details,
+                                   bool error)
 {
     qDebug() << "Found: " << results.size();
 
     // If box is not visible, the call must have been terminated already
     if(!box_->isVisible())
     {
-       return;
+        return;
     }
 
     QString message;
@@ -151,38 +151,38 @@ void CallListener::requestFinished(QVector <Eniro::Result> const& results,
     }
     else if(results.size() == 0)
     {
-       message = tr("Phone number was not found");
+        message = tr("Phone number was not found");
     }
     else
     {
-       message = createResult(results.at(0).name, results.at(0).street, results.at(0).city);
-       QSqlQuery query;
-
-       DB::connect();
-
-       query.prepare("INSERT INTO cache(number, name, street, city) VALUES(:number, :name, :street, :city)");
-       query.bindValue(":number", details.query);
-       query.bindValue(":name", results.at(0).name);
-       query.bindValue(":street", results.at(0).street);
-       query.bindValue(":city", results.at(0).city);
-
-       if(!query.exec())
-       {
-               qDebug() << "Unable to save cache";
-       }
-
-       QString cacheSize = Settings::instance()->get("cache_size");
-
-       // Delete old entries from cache
-       if(cacheSize.toInt() > 0)
-       {
-               if(!query.exec("DELETE c1 FROM cache AS c1 LEFT JOIN (SELECT id FROM cache ORDER BY id DESC LIMIT " + cacheSize + ") AS c2 ON c1.id = c2.id WHERE c2.id IS NULL"))
-               {
-                       qDebug() << "Unable to delete old cache entries";
-               }
-       }
-
-       DB::disconnect();
+        message = createResult(results.at(0).name, results.at(0).street, results.at(0).city);
+        QSqlQuery query;
+
+        DB::connect();
+
+        query.prepare("INSERT INTO cache(number, name, street, city) VALUES(:number, :name, :street, :city)");
+        query.bindValue(":number", details.query);
+        query.bindValue(":name", results.at(0).name);
+        query.bindValue(":street", results.at(0).street);
+        query.bindValue(":city", results.at(0).city);
+
+        if(!query.exec())
+        {
+            qDebug() << "Unable to save cache";
+        }
+
+        QString cacheSize = Settings::instance()->get("cache_size");
+
+        // Delete old entries from cache
+        if(cacheSize.toInt() > 0)
+        {
+            if(!query.exec("DELETE c1 FROM cache AS c1 LEFT JOIN (SELECT id FROM cache ORDER BY id DESC LIMIT " + cacheSize + ") AS c2 ON c1.id = c2.id WHERE c2.id IS NULL"))
+            {
+                qDebug() << "Unable to delete old cache entries";
+            }
+        }
+
+        DB::disconnect();
     }
 
     showResult(message);
@@ -191,49 +191,49 @@ void CallListener::requestFinished(QVector <Eniro::Result> const& results,
 
 QString CallListener::createResult(QString const& name, QString const& street, QString const& city)
 {
-       QString result = "<b>" + name + "</b>";
+    QString result = "<b>" + name + "</b>";
 
-       if(!street.isEmpty() || !city.isEmpty())
-       {
-               result += "<br>";
+    if(!street.isEmpty() || !city.isEmpty())
+    {
+        result += "<br>";
 
-               if(!street.isEmpty())
-               {
-                       result += street + ", ";
-               }
+        if(!street.isEmpty())
+        {
+            result += street + ", ";
+        }
 
-               result += city;
-       }
+        result += city;
+    }
 
-       return result;
+    return result;
 }
 
 void CallListener::showResult(QString const& text)
 {
-       label_->setText(text);
-       box_->hide();
-       box_->show();
+    label_->setText(text);
+    box_->hide();
+    box_->show();
 }
 
 void CallListener::incomingCall(QDBusObjectPath path, QString number)
 {
-       qDebug() << number;
+    qDebug() << number;
 
-       if(!contactManager_->numberExists(number))
-       {
+    if(!contactManager_->numberExists(number))
+    {
 
-               systemBus_.connect(CALL_SERVICE_NAME,
-                                  path.path(),
-                                  CALL_SERVICE_INSTANCE_NAME,
-                                  CALL_SIGNAL_TERMINATED,
-                                  this,
-                                  SLOT(callTerminate()));
+        systemBus_.connect(CALL_SERVICE_NAME,
+                           path.path(),
+                           CALL_SERVICE_INSTANCE_NAME,
+                           CALL_SIGNAL_TERMINATED,
+                           this,
+                           SLOT(callTerminate()));
 
-               search(Eniro::SearchDetails(number));
-       }
+        search(Eniro::SearchDetails(number));
+    }
 }
 
 void CallListener::callTerminate()
 {
-       box_->hide();
+    box_->hide();
 }
index 7e47306..d066a47 100644 (file)
@@ -45,11 +45,11 @@ private slots:
     void callTerminate();
 
 private:
-       Q_DISABLE_COPY(CallListener);
+    Q_DISABLE_COPY(CallListener);
 
-       void search(Eniro::SearchDetails const& details);
-       void showResult(QString const& text);
-       QString createResult(QString const& name, QString const& street, QString const& city);
+    void search(Eniro::SearchDetails const& details);
+    void showResult(QString const& text);
+    QString createResult(QString const& name, QString const& street, QString const& city);
     Eniro* eniro_;
     ContactManager* contactManager_;
     InformationBox* box_;
index 67ef3db..d41ff9e 100644 (file)
 #include <QtGui/QStandardItem>
 #include "buttonselector.h"
 
-ButtonSelector::ButtonSelector(QString const& text, QWidget* parent): QMaemo5ValueButton(text, parent),
-selector_(0), model_(0)
+ButtonSelector::ButtonSelector(QString const& text, QWidget* parent):
+QMaemo5ValueButton(text, parent), selector_(0), model_(0)
 {
-       setValueLayout(QMaemo5ValueButton::ValueBesideText);
-       selector_ = new QMaemo5ListPickSelector(this);
-       model_ = new QStandardItemModel(0, 1);
-       selector_->setModel(model_);
-       setPickSelector(selector_);
+    setValueLayout(QMaemo5ValueButton::ValueBesideText);
+    selector_ = new QMaemo5ListPickSelector(this);
+    model_ = new QStandardItemModel(0, 1);
+    selector_->setModel(model_);
+    setPickSelector(selector_);
 }
 
 void ButtonSelector::addItem(QString const& text)
 {
-       addItem(text, QVariant(text));
+    addItem(text, QVariant(text));
 }
 
 void ButtonSelector::addItem(QString const& text, QVariant const& value)
 {
-       QStandardItem* item = new QStandardItem(text);
-       item->setData(value, Qt::UserRole);
-       item->setTextAlignment(Qt::AlignCenter);
-       item->setEditable(false);
-       model_->appendRow(item);
+    QStandardItem* item = new QStandardItem(text);
+    item->setData(value, Qt::UserRole);
+    item->setTextAlignment(Qt::AlignCenter);
+    item->setEditable(false);
+    model_->appendRow(item);
 
-       if(selector_->currentIndex() < 0)
-       {
-               selector_->setCurrentIndex(0);
-       }
+    if(selector_->currentIndex() < 0)
+    {
+        selector_->setCurrentIndex(0);
+    }
 }
 
 void ButtonSelector::clear()
 {
-       model_->clear();
+    model_->clear();
 }
 
 void ButtonSelector::setCurrentIndex(int index)
 {
-       selector_->setCurrentIndex(index);
+    selector_->setCurrentIndex(index);
 }
 
 int ButtonSelector::currentIndex() const
 {
-       return selector_->currentIndex();
+    return selector_->currentIndex();
 }
 
 QString ButtonSelector::text() const
 {
-       return selector_->currentValueText();
+    return selector_->currentValueText();
 }
 
 QVariant ButtonSelector::value() const
 {
-       int currentIndex = selector_->currentIndex();
+    int currentIndex = selector_->currentIndex();
 
-       if(currentIndex < 0)
-       {
-               return QVariant("");
-       }
+    if(currentIndex < 0)
+    {
+        return QVariant("");
+    }
 
-       QStandardItem* item = model_->item(currentIndex);
+    QStandardItem* item = model_->item(currentIndex);
 
-       return item->data(Qt::UserRole);
+    return item->data(Qt::UserRole);
 }
index 74f878e..cb05209 100644 (file)
 class ButtonSelector : public QMaemo5ValueButton
 {
 public:
-       ButtonSelector(QString const& text, QWidget* parent = 0);
-       void addItem(QString const& text);
-       void addItem(QString const& text, QVariant const& value);
-       void clear();
-       void setCurrentIndex(int index);
-       int currentIndex() const;
-       QString text() const;
-       QVariant value() const;
+    ButtonSelector(QString const& text, QWidget* parent = 0);
+    void addItem(QString const& text);
+    void addItem(QString const& text, QVariant const& value);
+    void clear();
+    void setCurrentIndex(int index);
+    int currentIndex() const;
+    QString text() const;
+    QVariant value() const;
 
 private:
-       QMaemo5ListPickSelector* selector_;
-       QStandardItemModel* model_;
+    QMaemo5ListPickSelector* selector_;
+    QStandardItemModel* model_;
 
 };
 
index 32a3f1a..6a5a4e8 100644 (file)
 
 namespace
 {
-       const QString DAEMON_NAME = "jenirokd";
-       const QString INIT_DIR = "/etc/init.d";
-       const QString AUTOSTART_ENABLE = "update-rc.d jenirokd defaults 99";
-       const QString AUTOSTART_DISABLE = "update-rc.d -f jenirokd remove";
+    const QString DAEMON_NAME = "jenirokd";
+    const QString INIT_DIR = "/etc/init.d";
+    const QString AUTOSTART_ENABLE = "update-rc.d jenirokd defaults 99";
+    const QString AUTOSTART_DISABLE = "update-rc.d -f jenirokd remove";
 }
 
 bool Daemon::start()
 {
-       QProcess proc;
-       proc.start(INIT_DIR + "/" + DAEMON_NAME, QStringList() << "start");
+    QProcess proc;
+    proc.start(INIT_DIR + "/" + DAEMON_NAME, QStringList() << "start");
 
     proc.waitForStarted();
     proc.waitForFinished();
 
-       if(proc.exitCode() != 0)
-       {
-               return false;
-       }
+    if(proc.exitCode() != 0)
+    {
+        return false;
+    }
 
-       return true;
+    return true;
 }
 
 bool Daemon::stop()
 {
-       QProcess proc;
-       proc.start(INIT_DIR + "/" + DAEMON_NAME, QStringList() << "stop");
+    QProcess proc;
+    proc.start(INIT_DIR + "/" + DAEMON_NAME, QStringList() << "stop");
 
-       proc.waitForStarted();
-       proc.waitForFinished();
+    proc.waitForStarted();
+    proc.waitForFinished();
 
-       if(proc.exitCode() != 0)
-       {
-               return false;
-       }
+    if(proc.exitCode() != 0)
+    {
+        return false;
+    }
 
-       return true;
+    return true;
 }
 
 bool Daemon::restart()
 {
-       stop();
-       return start();
+    stop();
+    return start();
 }
 
 bool Daemon::isRunning()
 {
-       QProcess proc;
+    QProcess proc;
 
-       proc.start("pgrep", QStringList() << "-n" << DAEMON_NAME);
+    proc.start("pgrep", QStringList() << "-n" << DAEMON_NAME);
 
-       if(!proc.waitForStarted())
-       {
-               return false;
-       }
+    if(!proc.waitForStarted())
+    {
+        return false;
+    }
 
-       if(!proc.waitForFinished())
-       {
-               return false;
-       }
+    if(!proc.waitForFinished())
+    {
+        return false;
+    }
 
-       QString result = proc.readAll();
+    QString result = proc.readAll();
 
-       return !result.isEmpty();
+    return !result.isEmpty();
 }
 
 bool Daemon::setAutostart(bool enabled)
 {
-       QProcess proc;
-
-       if(enabled)
-       {
-               proc.start(AUTOSTART_ENABLE);
-       }
-       else
-       {
-               proc.start(AUTOSTART_DISABLE);
-       }
-
-       proc.waitForStarted();
-       proc.waitForFinished();
-
-       if(proc.exitCode() != 0)
-       {
-               return false;
-       }
-
-       return true;
+    QProcess proc;
+
+    if(enabled)
+    {
+        proc.start(AUTOSTART_ENABLE);
+    }
+    else
+    {
+        proc.start(AUTOSTART_DISABLE);
+    }
+
+    proc.waitForStarted();
+    proc.waitForFinished();
+
+    if(proc.exitCode() != 0)
+    {
+        return false;
+    }
+
+    return true;
 
 }
 
index b6c65ab..9fc8bc4 100644 (file)
@@ -23,14 +23,14 @@ class Daemon
 {
 public:
 
-       static bool start();
-       static bool stop();
-       static bool restart();
-       static bool isRunning();
-       static bool setAutostart(bool enabled);
+    static bool start();
+    static bool stop();
+    static bool restart();
+    static bool isRunning();
+    static bool setAutostart(bool enabled);
 
 private:
-       Daemon();
+    Daemon();
 };
 
 
index 09b4380..71cffce 100644 (file)
 
 DetailWindow::DetailWindow(QWidget* parent): QMainWindow(parent), addDialog_(0)
 {
-       setAttribute(Qt::WA_Maemo5StackedWindow);
-       area_ = new QScrollArea(this);
-       layout_ = new QVBoxLayout;
-       QHBoxLayout* top = new QHBoxLayout;
-       QHBoxLayout* bottom = new QHBoxLayout;
-
-       QPushButton* addButton = new QPushButton(QIcon::fromTheme("general_contacts"), tr("Add to contacts"));
-       QPushButton* copyButton = new QPushButton(tr("Copy number to clipboard"));
-
-       connect(addButton, SIGNAL(pressed()), this, SLOT(showAddToContactsDialog()));
-       connect(copyButton, SIGNAL(pressed()), this, SLOT(copyToClipboard()));
-
-       nameButton_ = new QMaemo5ValueButton(QIcon::fromTheme("general_default_avatar"), tr("Name"), this);
-       streetButton_ = new QMaemo5ValueButton(tr("Street"), this);
-       cityButton_ = new QMaemo5ValueButton(tr("City"), this);
-       numberButton_ = new QMaemo5ValueButton(QIcon::fromTheme("general_call"), tr("Phone number"), this);
-
-       connect(numberButton_, SIGNAL(pressed()), this, SLOT(makeCall()));
-
-       top->addWidget(nameButton_);
-       bottom->addWidget(streetButton_);
-       top->addWidget(numberButton_);
-       bottom->addWidget(cityButton_);
-       layout_->addLayout(top);
-       layout_->addLayout(bottom);
-       layout_->addWidget(addButton);
-       layout_->addWidget(copyButton);
-       area_->setLayout(layout_);
-       setCentralWidget(area_);
+    setAttribute(Qt::WA_Maemo5StackedWindow);
+    area_ = new QScrollArea(this);
+    layout_ = new QVBoxLayout;
+    QHBoxLayout* top = new QHBoxLayout;
+    QHBoxLayout* bottom = new QHBoxLayout;
+
+    QPushButton* addButton = new QPushButton(QIcon::fromTheme("general_contacts"), tr("Add to contacts"));
+    QPushButton* copyButton = new QPushButton(tr("Copy number to clipboard"));
+
+    connect(addButton, SIGNAL(pressed()), this, SLOT(showAddToContactsDialog()));
+    connect(copyButton, SIGNAL(pressed()), this, SLOT(copyToClipboard()));
+
+    nameButton_ = new QMaemo5ValueButton(QIcon::fromTheme("general_default_avatar"),
+                                         tr("Name"), this);
+    streetButton_ = new QMaemo5ValueButton(tr("Street"), this);
+    cityButton_ = new QMaemo5ValueButton(tr("City"), this);
+    numberButton_ = new QMaemo5ValueButton(QIcon::fromTheme("general_call"),
+                                           tr("Phone number"), this);
+
+    connect(numberButton_, SIGNAL(pressed()), this, SLOT(makeCall()));
+
+    top->addWidget(nameButton_);
+    bottom->addWidget(streetButton_);
+    top->addWidget(numberButton_);
+    bottom->addWidget(cityButton_);
+    layout_->addLayout(top);
+    layout_->addLayout(bottom);
+    layout_->addWidget(addButton);
+    layout_->addWidget(copyButton);
+    area_->setLayout(layout_);
+    setCentralWidget(area_);
 }
 
 void DetailWindow::loadData(Eniro::Result const& details)
 {
-       setWindowTitle(details.name);
-       nameButton_->setValueText(details.name);
-       streetButton_->setValueText(details.street);
-       cityButton_->setValueText(details.city);
-       numberButton_->setValueText(details.number);
-       layout_->update();
-       show();
+    setWindowTitle(details.name);
+    nameButton_->setValueText(details.name);
+    streetButton_->setValueText(details.street);
+    cityButton_->setValueText(details.city);
+    numberButton_->setValueText(details.number);
+    layout_->update();
+    show();
 }
 
 void DetailWindow::makeCall()
 {
-       QString number = numberButton_->valueText();
+    QString number = numberButton_->valueText();
 
-       qDebug() << number;
+    qDebug() << number;
 
-       if(number.isEmpty())
-       {
-               return;
-       }
+    if(number.isEmpty())
+    {
+        return;
+    }
 
-       QDBusMessage msg = QDBusMessage::createMethodCall("com.nokia.csd",
-                                                                 "/com/nokia/csd/call",
-                                                                 "com.nokia.csd.Call",
-                                                                 "CreateWith");
-       QList<QVariant> arguments;
+    QDBusMessage msg = QDBusMessage::createMethodCall("com.nokia.csd",
+                                                      "/com/nokia/csd/call",
+                                                      "com.nokia.csd.Call",
+                                                      "CreateWith");
+    QList<QVariant> arguments;
 
-       arguments.append(QVariant(number));
-       arguments.append(QVariant(0));
+    arguments.append(QVariant(number));
+    arguments.append(QVariant(0));
 
-       msg.setArguments(arguments);
+    msg.setArguments(arguments);
 
-       QDBusConnection::systemBus().send(msg);
+    QDBusConnection::systemBus().send(msg);
 
 }
 
 void DetailWindow::showAddToContactsDialog()
 {
-       if(!addDialog_)
-       {
-               addDialog_ = new QDialog(this);
-               addDialog_->setWindowTitle(tr("Add to contacts"));
-               addContactInput_ = new QLineEdit();
-               QHBoxLayout* layout = new QHBoxLayout();
-               QLabel* name = new QLabel(tr("Name"));
-               QPushButton* button = new QPushButton(tr("Add"));
-               connect(button, SIGNAL(pressed()), this, SLOT(addToContacts()));
-               layout->addWidget(name);
-               layout->addWidget(addContactInput_);
-               layout->addWidget(button);
-               addDialog_->setLayout(layout);
-       }
-
-       addContactInput_->setText(nameButton_->valueText());
-       addDialog_->show();
+    if(!addDialog_)
+    {
+        addDialog_ = new QDialog(this);
+        addDialog_->setWindowTitle(tr("Add to contacts"));
+        addContactInput_ = new QLineEdit();
+        QHBoxLayout* layout = new QHBoxLayout();
+        QLabel* name = new QLabel(tr("Name"));
+        QPushButton* button = new QPushButton(tr("Add"));
+        connect(button, SIGNAL(pressed()), this, SLOT(addToContacts()));
+        layout->addWidget(name);
+        layout->addWidget(addContactInput_);
+        layout->addWidget(button);
+        addDialog_->setLayout(layout);
+    }
+
+    addContactInput_->setText(nameButton_->valueText());
+    addDialog_->show();
 }
 
 void DetailWindow::addToContacts()
 {
-       ContactManager cm;
-       ContactManager::Contact contact;
-       contact.name = addContactInput_->text();
-       contact.number = numberButton_->valueText();
-
-       addDialog_->hide();
-
-       if(cm.addContact(contact))
-       {
-               QMaemo5InformationBox::information(this, tr("Contact was successfully added to contacts."));
-       }
-       else
-       {
-               QMessageBox::critical(this, tr("Error"), tr("Unable to add contact."));
-       }
+    ContactManager cm;
+    ContactManager::Contact contact;
+    contact.name = addContactInput_->text();
+    contact.number = numberButton_->valueText();
+
+    addDialog_->hide();
+
+    if(cm.addContact(contact))
+    {
+        QMaemo5InformationBox::information(this, tr("Contact was successfully added to contacts."));
+    }
+    else
+    {
+        QMessageBox::critical(this, tr("Error"), tr("Unable to add contact."));
+    }
 
 }
 
 void DetailWindow::copyToClipboard()
 {
-       QApplication::clipboard()->setText(numberButton_->valueText());
-       QMaemo5InformationBox::information(this, tr("Number was successfully copied to clipboard."));
+    QApplication::clipboard()->setText(numberButton_->valueText());
+    QMaemo5InformationBox::information(this, tr("Number was successfully copied to clipboard."));
 }
index 19a6660..eefad76 100644 (file)
@@ -36,23 +36,23 @@ public:
     DetailWindow(QWidget* parent = 0);
 
 public slots:
-       void loadData(Eniro::Result const& details);
+    void loadData(Eniro::Result const& details);
 
 private slots:
-       void makeCall();
-       void showAddToContactsDialog();
-       void addToContacts();
-       void copyToClipboard();
+    void makeCall();
+    void showAddToContactsDialog();
+    void addToContacts();
+    void copyToClipboard();
 
 private:
-       QScrollArea* area_;
-       QVBoxLayout* layout_;
-       QMaemo5ValueButton* nameButton_;
-       QMaemo5ValueButton* streetButton_;
-       QMaemo5ValueButton* cityButton_;
-       QMaemo5ValueButton* numberButton_;
-       QDialog* addDialog_;
-       QLineEdit* addContactInput_;
+    QScrollArea* area_;
+    QVBoxLayout* layout_;
+    QMaemo5ValueButton* nameButton_;
+    QMaemo5ValueButton* streetButton_;
+    QMaemo5ValueButton* cityButton_;
+    QMaemo5ValueButton* numberButton_;
+    QDialog* addDialog_;
+    QLineEdit* addContactInput_;
 
 
 };
index 14ad287..8a3ebf2 100644 (file)
@@ -43,10 +43,10 @@ int main(int argc, char *argv[])
     window.show();\r
 \r
     QObject::connect(&window, SIGNAL(search(SearchDialog::SearchDetails&)),\r
-                        &results, SLOT(search(SearchDialog::SearchDetails&)));\r
+                     &results, SLOT(search(SearchDialog::SearchDetails&)));\r
 \r
     QObject::connect(&results, SIGNAL(itemSelected(Eniro::Result const&)),\r
-                        &details, SLOT(loadData(Eniro::Result const&)));\r
+                     &details, SLOT(loadData(Eniro::Result const&)));\r
 \r
     return app.exec();\r
 }\r
index d340fa1..cec7517 100644 (file)
 
 namespace
 {
-       const QString START_ICON = ":/icons/start.png";
-       const QString CLOSE_ICON = ":/icons/stop.png";
+    const QString START_ICON = ":/icons/start.png";
+    const QString CLOSE_ICON = ":/icons/stop.png";
 }
 
 MainWindow::MainWindow(QWidget* parent): QMainWindow(parent),
 searchResults_(0), settingsDialog_(0), running_(false),
 toggleButton_(0), searchDialog_(0)
 {
-       setWindowTitle(tr("Jenirok"));
-       setAttribute(Qt::WA_Maemo5StackedWindow);
-       QWidget* mainWidget = new QWidget(this);
-
-       if(Daemon::isRunning())
-       {
-               toggleButton_ = createButton(tr("Stop daemon"));
-               toggleButton_->setIcon(QIcon(CLOSE_ICON));
-               running_ = true;
-       }
-       else
-       {
-               toggleButton_ = createButton(tr("Start daemon"));
-               toggleButton_->setIcon(QIcon(START_ICON));
-               running_ = false;
-       }
-
-       QToolButton* searchButton = createButton(tr("Search"));
-       searchButton->setIcon(QIcon::fromTheme("general_search"));
-
-       QSize size(64, 64);
-       searchButton->setIconSize(size);
-       toggleButton_->setIconSize(size);
-
-       QHBoxLayout *buttonLayout = new QHBoxLayout;
-       buttonLayout->addWidget(toggleButton_, Qt::AlignLeft);
-       buttonLayout->addWidget(searchButton, Qt::AlignRight);
-
-       mainWidget->setLayout(buttonLayout);
-
-       connect(toggleButton_, SIGNAL(pressed()), this, SLOT(toggleDaemon()));
-       connect(searchButton, SIGNAL(pressed()), this, SLOT(openSearch()));
-
-       setCentralWidget(mainWidget);
-       menuBar()->addAction(tr("Settings"), this, SLOT(showSettings()));
+    setWindowTitle(tr("Jenirok"));
+    setAttribute(Qt::WA_Maemo5StackedWindow);
+    QWidget* mainWidget = new QWidget(this);
+
+    if(Daemon::isRunning())
+    {
+        toggleButton_ = createButton(tr("Stop daemon"));
+        toggleButton_->setIcon(QIcon(CLOSE_ICON));
+        running_ = true;
+    }
+    else
+    {
+        toggleButton_ = createButton(tr("Start daemon"));
+        toggleButton_->setIcon(QIcon(START_ICON));
+        running_ = false;
+    }
+
+    QToolButton* searchButton = createButton(tr("Search"));
+    searchButton->setIcon(QIcon::fromTheme("general_search"));
+
+    QSize size(64, 64);
+    searchButton->setIconSize(size);
+    toggleButton_->setIconSize(size);
+
+    QHBoxLayout *buttonLayout = new QHBoxLayout;
+    buttonLayout->addWidget(toggleButton_, Qt::AlignLeft);
+    buttonLayout->addWidget(searchButton, Qt::AlignRight);
+
+    mainWidget->setLayout(buttonLayout);
+
+    connect(toggleButton_, SIGNAL(pressed()), this, SLOT(toggleDaemon()));
+    connect(searchButton, SIGNAL(pressed()), this, SLOT(openSearch()));
+
+    setCentralWidget(mainWidget);
+    menuBar()->addAction(tr("Settings"), this, SLOT(showSettings()));
 }
 
 MainWindow::~MainWindow()
 {
-       DB::removeDatabase();
+    DB::removeDatabase();
 }
 
 void MainWindow::showSettings()
 {
-       if(!settingsDialog_)
-       {
-               settingsDialog_ = new SettingsDialog(this);
-       }
+    if(!settingsDialog_)
+    {
+        settingsDialog_ = new SettingsDialog(this);
+    }
 
-       settingsDialog_->show();
+    settingsDialog_->show();
 }
 
 void MainWindow::toggleDaemon()
@@ -102,66 +102,66 @@ void MainWindow::toggleDaemon()
 
     if(running_)
     {
-               readyText = tr("Daemon was successfully stopped.");
-               failText = tr("Unable to stop daemon.");
-               buttonText = tr("Start daemon");
-               ret = Daemon::stop();
+        readyText = tr("Daemon was successfully stopped.");
+        failText = tr("Unable to stop daemon.");
+        buttonText = tr("Start daemon");
+        ret = Daemon::stop();
     }
     else
     {
-       readyText = tr("Daemon was successfully started.");
-       failText = tr("Unable to start daemon.");
-       buttonText = tr("Stop daemon");
-       ret = Daemon::start();
+        readyText = tr("Daemon was successfully started.");
+        failText = tr("Unable to start daemon.");
+        buttonText = tr("Stop daemon");
+        ret = Daemon::start();
     }
 
     if(!ret)
     {
-       QMessageBox::critical(this, tr("Error"), failText);
+        QMessageBox::critical(this, tr("Error"), failText);
     }
     else
     {
-       QMaemo5InformationBox::information(this, readyText);
-       toggleButton_->setText(buttonText);
-       toggleButton_->setIcon(QIcon(running_ ? START_ICON : CLOSE_ICON));
-       running_ = !running_;
+        QMaemo5InformationBox::information(this, readyText);
+        toggleButton_->setText(buttonText);
+        toggleButton_->setIcon(QIcon(running_ ? START_ICON : CLOSE_ICON));
+        running_ = !running_;
     }
 
 }
 
 void MainWindow::openSearch()
 {
-       DB::connect();
+    DB::connect();
 
-       QString username = Settings::instance()->get("eniro_username");
-       QString password = Settings::instance()->get("eniro_password");
+    QString username = Settings::instance()->get("eniro_username");
+    QString password = Settings::instance()->get("eniro_password");
 
-       DB::disconnect();
+    DB::disconnect();
 
-       if(username.isEmpty() || password.isEmpty())
-       {
-               QMessageBox::information(this, tr("Info"), tr("You need to set Eniro login details in settings before using this feature."));
-               return;
-       }
+    if(username.isEmpty() || password.isEmpty())
+    {
+        QMessageBox::information(this, tr("Info"), tr("You need to set Eniro login details in settings before using this feature."));
+        return;
+    }
 
-       if(!searchDialog_)
-       {
-               searchDialog_ = new SearchDialog(this);
-               connect(searchDialog_, SIGNAL(search(SearchDialog::SearchDetails&)), this, SLOT(handleSearch(SearchDialog::SearchDetails&)));
-       }
+    if(!searchDialog_)
+    {
+        searchDialog_ = new SearchDialog(this);
+        connect(searchDialog_, SIGNAL(search(SearchDialog::SearchDetails&)), this, SLOT(handleSearch(SearchDialog::SearchDetails&)));
+    }
 
-       searchDialog_->show();
+    searchDialog_->show();
 }
 
 QToolButton* MainWindow::createButton(QString const& text)
 {
-       QToolButton* button = new QToolButton();
-       button->setText(text);
-       button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
-       return button;
+    QToolButton* button = new QToolButton();
+    button->setText(text);
+    button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
+    return button;
 }
 
 void MainWindow::handleSearch(SearchDialog::SearchDetails& details)
 {
-       emit search(details);
+    emit search(details);
 }
index 429b92d..fc7f12e 100644 (file)
@@ -35,7 +35,7 @@ public:
     ~MainWindow();
 
 signals:
-       void search(SearchDialog::SearchDetails& details);
+    void search(SearchDialog::SearchDetails& details);
 
 public slots:
     void showSettings();
@@ -44,12 +44,12 @@ public slots:
     void handleSearch(SearchDialog::SearchDetails& details);
 
 private:
-       QToolButton* createButton(QString const& text);
-       QListWidget* searchResults_;
-       SettingsDialog* settingsDialog_;
-       bool running_;
-       QToolButton* toggleButton_;
-       SearchDialog* searchDialog_;
+    QToolButton* createButton(QString const& text);
+    QListWidget* searchResults_;
+    SettingsDialog* settingsDialog_;
+    bool running_;
+    QToolButton* toggleButton_;
+    SearchDialog* searchDialog_;
 
 };
 
index 0a5fe23..179eac8 100644 (file)
 #include "settings.h"
 #include "db.h"
 
-ResultWindow::ResultWindow(QWidget* parent): QMainWindow(parent), eniro_(0), list_(0)
+ResultWindow::ResultWindow(QWidget* parent): QMainWindow(parent),
+eniro_(0), list_(0)
 {
-       setAttribute(Qt::WA_Maemo5StackedWindow);
-       setWindowTitle(tr("Search results"));
+    setAttribute(Qt::WA_Maemo5StackedWindow);
+    setWindowTitle(tr("Search results"));
 }
 
 void ResultWindow::search(SearchDialog::SearchDetails& details)
 {
-       if(!list_)
-       {
-               list_ = new QListWidget(this);
-               setCentralWidget(list_);
-               connect(list_, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(itemClicked(QListWidgetItem*)));
-       }
-       else
-       {
-               list_->clear();
-       }
-
-       DB::connect();
-
-       Eniro::Site selectedSite = Eniro::stringToSite(Settings::instance()->get("site"));
-
-       if(!eniro_)
-       {
-               eniro_ = new Eniro(selectedSite, this);
-
-               connect(eniro_, SIGNAL(resultAvailable(Eniro::Result const&,
-                               Eniro::SearchDetails const&)),
-                               this, SLOT(resultAvailable(Eniro::Result const&,
-                               Eniro::SearchDetails const&)));
-
-               connect(eniro_, SIGNAL(requestFinished(QVector <Eniro::Result> const&,
-                               Eniro::SearchDetails const&, bool)),
-                               this, SLOT(requestFinished(QVector <Eniro::Result> const&,
-                               Eniro::SearchDetails const&, bool)));
-       }
-
-       QString username = Settings::instance()->get("eniro_username");
-       QString password = Settings::instance()->get("eniro_password");
-
-       if(!username.isEmpty() && !password.isEmpty())
-       {
-               eniro_->login(username, password);
-       }
-
-       eniro_->setSite(selectedSite);
-
-       DB::disconnect();
-
-       Eniro::SearchType type;
-
-       switch(details.type)
-       {
-       case 0:
-               type = Eniro::PERSONS;
-               break;
-       case 1:
-               type = Eniro::YELLOW_PAGES;
-               break;
-       default:
-               return;
-       }
-
-       show();
-       setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
-
-       eniro_->abort();
-       eniro_->search(Eniro::SearchDetails(details.name, details.location, type));
+    if(!list_)
+    {
+        list_ = new QListWidget(this);
+        setCentralWidget(list_);
+        connect(list_, SIGNAL(itemClicked(QListWidgetItem*)), this,
+                SLOT(itemClicked(QListWidgetItem*)));
+    }
+    else
+    {
+        list_->clear();
+    }
+
+    DB::connect();
+
+    Eniro::Site selectedSite = Eniro::stringToSite(Settings::instance()->get("site"));
+
+    if(!eniro_)
+    {
+        eniro_ = new Eniro(selectedSite, this);
+
+        connect(eniro_, SIGNAL(resultAvailable(Eniro::Result const&,
+                                               Eniro::SearchDetails const&)),
+                                               this, SLOT(resultAvailable(Eniro::Result const&,
+                                                                          Eniro::SearchDetails const&)));
+
+        connect(eniro_, SIGNAL(requestFinished(QVector <Eniro::Result> const&,
+                                               Eniro::SearchDetails const&, bool)),
+                                               this, SLOT(requestFinished(QVector <Eniro::Result> const&,
+                                                                          Eniro::SearchDetails const&, bool)));
+    }
+
+    QString username = Settings::instance()->get("eniro_username");
+    QString password = Settings::instance()->get("eniro_password");
+
+    if(!username.isEmpty() && !password.isEmpty())
+    {
+        eniro_->login(username, password);
+    }
+
+    eniro_->setSite(selectedSite);
+
+    DB::disconnect();
+
+    Eniro::SearchType type;
+
+    switch(details.type)
+    {
+    case 0:
+        type = Eniro::PERSONS;
+        break;
+    case 1:
+        type = Eniro::YELLOW_PAGES;
+        break;
+    default:
+        return;
+    }
+
+    show();
+    setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
+
+    eniro_->abort();
+    eniro_->search(Eniro::SearchDetails(details.name, details.location, type));
 
 }
 
 void ResultWindow::resultAvailable(Eniro::Result const& result,
-                                          Eniro::SearchDetails const& details)
+                                   Eniro::SearchDetails const& details)
 {
-       Q_UNUSED(details);
+    Q_UNUSED(details);
 
-       QString row = result.name;
+    QString row = result.name;
 
-       if(!result.street.isEmpty())
-       {
-               row += ", " + result.street;
-       }
+    if(!result.street.isEmpty())
+    {
+        row += ", " + result.street;
+    }
 
-       if(!result.city.isEmpty())
-       {
-               row += ", " + result.city;
-       }
+    if(!result.city.isEmpty())
+    {
+        row += ", " + result.city;
+    }
 
-       QListWidgetItem* item = new QListWidgetItem(row, list_);
-       QMap <QString, QVariant> data;
-       data["name"] = QVariant(result.name);
-       data["street"] = QVariant(result.street);
-       data["city"] = QVariant(result.city);
-       data["number"] = QVariant(result.number);
+    QListWidgetItem* item = new QListWidgetItem(row, list_);
+    QMap <QString, QVariant> data;
+    data["name"] = QVariant(result.name);
+    data["street"] = QVariant(result.street);
+    data["city"] = QVariant(result.city);
+    data["number"] = QVariant(result.number);
 
-       item->setData(Qt::UserRole, QVariant(data));
+    item->setData(Qt::UserRole, QVariant(data));
 
-       list_->addItem(item);
+    list_->addItem(item);
 }
 
 void ResultWindow::requestFinished(QVector <Eniro::Result> const& results,
-                                          Eniro::SearchDetails const& details,
-                                          bool error)
+                                   Eniro::SearchDetails const& details,
+                                   bool error)
 {
-       Q_UNUSED(details);
+    Q_UNUSED(details);
 
-       if(error)
-       {
-               QMessageBox::critical(this, tr("Error"), eniro_->errorString());
-       }
+    if(error)
+    {
+        QMessageBox::critical(this, tr("Error"), eniro_->errorString());
+    }
 
-       if(results.size() == 0)
-       {
-               QLabel* info = new QLabel(tr("No results found"));
-               info->setAlignment(Qt::AlignCenter);
-               setCentralWidget(info);
-               list_ = 0;
-       }
+    if(results.size() == 0)
+    {
+        QLabel* info = new QLabel(tr("No results found"));
+        info->setAlignment(Qt::AlignCenter);
+        setCentralWidget(info);
+        list_ = 0;
+    }
 
-       setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
+    setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
 
 }
 
 void ResultWindow::itemClicked(QListWidgetItem* item)
 {
-       QMap <QString, QVariant> data = item->data(Qt::UserRole).toMap();
-       Eniro::Result details;
-       details.name = data["name"].toString();
-       details.street = data["street"].toString();
-       details.city = data["city"].toString();
-       details.number = data["number"].toString();
-
-       emit itemSelected(details);
+    QMap <QString, QVariant> data = item->data(Qt::UserRole).toMap();
+    Eniro::Result details;
+    details.name = data["name"].toString();
+    details.street = data["street"].toString();
+    details.city = data["city"].toString();
+    details.number = data["number"].toString();
+
+    emit itemSelected(details);
 }
 
 
index 88dc9ca..f9b884f 100644 (file)
@@ -34,19 +34,19 @@ public:
     ResultWindow(QWidget* parent = 0);
 
 signals:
-       void itemSelected(Eniro::Result const& result);
+    void itemSelected(Eniro::Result const& result);
 
 public slots:
-       void search(SearchDialog::SearchDetails& details);
+    void search(SearchDialog::SearchDetails& details);
 
 private slots:
-       void resultAvailable(Eniro::Result const& result, Eniro::SearchDetails const& details);
-       void requestFinished(QVector <Eniro::Result> const& results, Eniro::SearchDetails const& details, bool error);
-       void itemClicked(QListWidgetItem* item);
+    void resultAvailable(Eniro::Result const& result, Eniro::SearchDetails const& details);
+    void requestFinished(QVector <Eniro::Result> const& results, Eniro::SearchDetails const& details, bool error);
+    void itemClicked(QListWidgetItem* item);
 
 private:
-       Eniro* eniro_;
-       QListWidget* list_;
+    Eniro* eniro_;
+    QListWidget* list_;
 
 };
 
index 17fb292..a56838e 100644 (file)
 SearchDialog::SearchDialog(QWidget* parent): QDialog(parent),
 numberInput_(0), locationInput_(0), selector_(0)
 {
-       setWindowTitle(tr("Search"));
+    setWindowTitle(tr("Search"));
 
-       QHBoxLayout* numberLayout = new QHBoxLayout;
-       QLabel* numberLabel = new QLabel(tr("Name/number"));
-       numberInput_ = new QLineEdit;
-       numberLayout->addWidget(numberLabel);
-       numberLayout->addWidget(numberInput_);
+    QHBoxLayout* numberLayout = new QHBoxLayout;
+    QLabel* numberLabel = new QLabel(tr("Name/number"));
+    numberInput_ = new QLineEdit;
+    numberLayout->addWidget(numberLabel);
+    numberLayout->addWidget(numberInput_);
 
-       QHBoxLayout* locationLayout = new QHBoxLayout;
-       QLabel* locationLabel = new QLabel(tr("Location"));
-       locationInput_ = new QLineEdit;
-       locationLayout->addWidget(locationLabel);
-       locationLayout->addWidget(locationInput_);
+    QHBoxLayout* locationLayout = new QHBoxLayout;
+    QLabel* locationLabel = new QLabel(tr("Location"));
+    locationInput_ = new QLineEdit;
+    locationLayout->addWidget(locationLabel);
+    locationLayout->addWidget(locationInput_);
 
-       selector_ = new ButtonSelector(tr("Type"), this);
-       selector_->addItem(tr("Persons"));
-       selector_->addItem(tr("Yellow pages"));
+    selector_ = new ButtonSelector(tr("Type"), this);
+    selector_->addItem(tr("Persons"));
+    selector_->addItem(tr("Yellow pages"));
 
-       QVBoxLayout* leftLayout = new QVBoxLayout;
-       leftLayout->addLayout(numberLayout);
-       leftLayout->addLayout(locationLayout);
-       leftLayout->addWidget(selector_);
+    QVBoxLayout* leftLayout = new QVBoxLayout;
+    leftLayout->addLayout(numberLayout);
+    leftLayout->addLayout(locationLayout);
+    leftLayout->addWidget(selector_);
 
-       QDialogButtonBox* buttons = new QDialogButtonBox;
-       QPushButton* submitButton = new QPushButton(tr("Search"));
-       buttons->addButton(submitButton, QDialogButtonBox::AcceptRole);
-       connect(submitButton, SIGNAL(pressed()), this, SLOT(searchPressed()));
+    QDialogButtonBox* buttons = new QDialogButtonBox;
+    QPushButton* submitButton = new QPushButton(tr("Search"));
+    buttons->addButton(submitButton, QDialogButtonBox::AcceptRole);
+    connect(submitButton, SIGNAL(pressed()), this, SLOT(searchPressed()));
 
-       QHBoxLayout* mainLayout = new QHBoxLayout;
-       mainLayout->addLayout(leftLayout, Qt::AlignLeft);
-       mainLayout->addWidget(buttons);
+    QHBoxLayout* mainLayout = new QHBoxLayout;
+    mainLayout->addLayout(leftLayout, Qt::AlignLeft);
+    mainLayout->addWidget(buttons);
 
-       setLayout(mainLayout);
+    setLayout(mainLayout);
 }
 
 void SearchDialog::searchPressed()
 {
-       SearchDetails details;
-       details.name = numberInput_->text();
+    SearchDetails details;
+    details.name = numberInput_->text();
 
-       if(details.name.isEmpty())
-       {
-               numberInput_->setFocus();
-               return;
-       }
+    if(details.name.isEmpty())
+    {
+        numberInput_->setFocus();
+        return;
+    }
 
-       details.location = locationInput_->text();
-       details.type = selector_->currentIndex();
-       emit search(details);
-       hide();
+    details.location = locationInput_->text();
+    details.type = selector_->currentIndex();
+    emit search(details);
+    hide();
 }
index 09d13ed..3364c1a 100644 (file)
@@ -32,25 +32,25 @@ class SearchDialog : public QDialog
 
 public:
 
-       struct SearchDetails
-       {
-               QString name;
-               QString location;
-               int type;
-       };
+    struct SearchDetails
+    {
+        QString name;
+        QString location;
+        int type;
+    };
 
     SearchDialog(QWidget* parent = 0);
 
 signals:
-       void search(SearchDialog::SearchDetails& details);
+    void search(SearchDialog::SearchDetails& details);
 
 private slots:
-       void searchPressed();
+    void searchPressed();
 
 private:
-       QLineEdit* numberInput_;
-       QLineEdit* locationInput_;
-       ButtonSelector* selector_;
+    QLineEdit* numberInput_;
+    QLineEdit* locationInput_;
+    ButtonSelector* selector_;
 
 };
 
index 25ba29d..b2f3904 100644 (file)
 QMap <Eniro::Site, Eniro::SiteDetails> SettingsDialog::sites_ = Eniro::getSites();
 
 SettingsDialog::SettingsDialog(QWidget* parent): QDialog(parent),
-usernameInput_(0), passwordInput_(0), cacheInput_(0), siteSelector_(0), autostartSelector_(0)
+usernameInput_(0), passwordInput_(0), cacheInput_(0), siteSelector_(0),
+autostartSelector_(0)
 {
-       setWindowTitle(tr("Settings"));
-
-       DB::connect();
-
-       QVBoxLayout* left = new QVBoxLayout;
-       QHBoxLayout* mainLayout = new QHBoxLayout;
-       QHBoxLayout* username = new QHBoxLayout;
-       QHBoxLayout* password = new QHBoxLayout;
-       QHBoxLayout* cache = new QHBoxLayout;
-
-       QLabel* usernameLabel = new QLabel(tr("Eniro username"));
-       usernameInput_ = new QLineEdit(Settings::instance()->get("eniro_username"));
-
-       QLabel* passwordLabel = new QLabel(tr("Eniro password"));
-       passwordInput_ = new QLineEdit(Settings::instance()->get("eniro_password"));
-
-       QLabel* cacheLabel = new QLabel(tr("Cache size (numbers)"));
-       cacheInput_ = new QLineEdit(Settings::instance()->get("cache_size"));
-       cacheInput_->setValidator(new QIntValidator(0, 10000, this));
-
-       siteSelector_ = new ButtonSelector(tr("Eniro site"), this);
-       QString site = Settings::instance()->get("eniro_site");
-       int i = 0;
-       QMap <Eniro::Site, Eniro::SiteDetails>::const_iterator it;
-       for(it = sites_.begin(); it != sites_.end(); it++)
-       {
-               siteSelector_->addItem(it.value().name, it.value().id);
-
-               if(it.value().id == site)
-               {
-                       siteSelector_->setCurrentIndex(i);
-               }
-
-               i++;
-       }
-
-       autostartSelector_ = new ButtonSelector(tr("Autostart"), this);
-       QString autostart = Settings::instance()->get("autostart");
-       autostartSelector_->addItem(tr("Enabled"), "1");
-       autostartSelector_->addItem(tr("Disabled"), "0");
-       autostartSelector_->setCurrentIndex(autostart == "1" ? 0 : 1);
-
-       QPushButton* submitButton = new QPushButton(tr("Save"));
-       connect(submitButton, SIGNAL(pressed()), this, SLOT(saveSettings()));
-
-       username->addWidget(usernameLabel);
-       username->addWidget(usernameInput_);
-       password->addWidget(passwordLabel);
-       password->addWidget(passwordInput_);
-       cache->addWidget(cacheLabel);
-       cache->addWidget(cacheInput_);
-       left->addLayout(username);
-       left->addLayout(password);
-       left->addLayout(cache);
-       left->addWidget(siteSelector_);
-       left->addWidget(autostartSelector_);
-
-       mainLayout->addLayout(left);
-       mainLayout->addWidget(submitButton);
-
-       setLayout(mainLayout);
-
-       DB::disconnect();
+    setWindowTitle(tr("Settings"));
+
+    DB::connect();
+
+    QVBoxLayout* left = new QVBoxLayout;
+    QHBoxLayout* mainLayout = new QHBoxLayout;
+    QHBoxLayout* username = new QHBoxLayout;
+    QHBoxLayout* password = new QHBoxLayout;
+    QHBoxLayout* cache = new QHBoxLayout;
+
+    QLabel* usernameLabel = new QLabel(tr("Eniro username"));
+    usernameInput_ = new QLineEdit(Settings::instance()->get("eniro_username"));
+
+    QLabel* passwordLabel = new QLabel(tr("Eniro password"));
+    passwordInput_ = new QLineEdit(Settings::instance()->get("eniro_password"));
+
+    QLabel* cacheLabel = new QLabel(tr("Cache size (numbers)"));
+    cacheInput_ = new QLineEdit(Settings::instance()->get("cache_size"));
+    cacheInput_->setValidator(new QIntValidator(0, 10000, this));
+
+    siteSelector_ = new ButtonSelector(tr("Eniro site"), this);
+    QString site = Settings::instance()->get("eniro_site");
+    int i = 0;
+    QMap <Eniro::Site, Eniro::SiteDetails>::const_iterator it;
+    for(it = sites_.begin(); it != sites_.end(); it++)
+    {
+        siteSelector_->addItem(it.value().name, it.value().id);
+
+        if(it.value().id == site)
+        {
+            siteSelector_->setCurrentIndex(i);
+        }
+
+        i++;
+    }
+
+    autostartSelector_ = new ButtonSelector(tr("Autostart"), this);
+    QString autostart = Settings::instance()->get("autostart");
+    autostartSelector_->addItem(tr("Enabled"), "1");
+    autostartSelector_->addItem(tr("Disabled"), "0");
+    autostartSelector_->setCurrentIndex(autostart == "1" ? 0 : 1);
+
+    QPushButton* submitButton = new QPushButton(tr("Save"));
+    connect(submitButton, SIGNAL(pressed()), this, SLOT(saveSettings()));
+
+    username->addWidget(usernameLabel);
+    username->addWidget(usernameInput_);
+    password->addWidget(passwordLabel);
+    password->addWidget(passwordInput_);
+    cache->addWidget(cacheLabel);
+    cache->addWidget(cacheInput_);
+    left->addLayout(username);
+    left->addLayout(password);
+    left->addLayout(cache);
+    left->addWidget(siteSelector_);
+    left->addWidget(autostartSelector_);
+
+    mainLayout->addLayout(left);
+    mainLayout->addWidget(submitButton);
+
+    setLayout(mainLayout);
+
+    DB::disconnect();
 }
 
 void SettingsDialog::saveSettings()
 {
-       DB::connect();
+    DB::connect();
 
-       Settings::instance()->set("eniro_username", usernameInput_->text());
-       Settings::instance()->set("eniro_password", passwordInput_->text());
-       Settings::instance()->set("cache_size", cacheInput_->text());
-       QString site = siteSelector_->value().toString();
-       Settings::instance()->set("site", site);
-       QString autostart = autostartSelector_->value().toString();
-       Settings::instance()->set("autostart", autostart);
+    Settings::instance()->set("eniro_username", usernameInput_->text());
+    Settings::instance()->set("eniro_password", passwordInput_->text());
+    Settings::instance()->set("cache_size", cacheInput_->text());
+    QString site = siteSelector_->value().toString();
+    Settings::instance()->set("site", site);
+    QString autostart = autostartSelector_->value().toString();
+    Settings::instance()->set("autostart", autostart);
 
-       DB::disconnect();
+    DB::disconnect();
 
-       hide();
+    hide();
 
-       if(site != currentSite_ && Daemon::isRunning())
-       {
-               QMaemo5InformationBox::information(this, tr("Restarting daemon..."));
-               Daemon::restart();
-               currentSite_ = site;
-       }
+    if(site != currentSite_ && Daemon::isRunning())
+    {
+        QMaemo5InformationBox::information(this, tr("Restarting daemon..."));
+        Daemon::restart();
+        currentSite_ = site;
+    }
 
-       if(autostart != currentAutostart_)
-       {
-               bool value = false;
+    if(autostart != currentAutostart_)
+    {
+        bool value = false;
 
-               if(autostart == "1")
-               {
-                       value = true;
-               }
+        if(autostart == "1")
+        {
+            value = true;
+        }
 
-               Daemon::setAutostart(value);
-       }
+        Daemon::setAutostart(value);
+    }
 
 }
 
 void SettingsDialog::setVisible(bool visible)
 {
-       QDialog::setVisible(visible);
+    QDialog::setVisible(visible);
 
-       if(visible)
-       {
-               currentSite_ = siteSelector_->value().toString();
-               currentAutostart_ = autostartSelector_->value().toString();
-       }
+    if(visible)
+    {
+        currentSite_ = siteSelector_->value().toString();
+        currentAutostart_ = autostartSelector_->value().toString();
+    }
 
 }
index 52e9774..eebdc92 100644 (file)
 
 class SettingsDialog : public QDialog
 {
-       Q_OBJECT
+    Q_OBJECT
 
 public:
-       SettingsDialog(QWidget* parent = 0);
+    SettingsDialog(QWidget* parent = 0);
 
 public slots:
-       void saveSettings();
-       void setVisible(bool visible);
+    void saveSettings();
+    void setVisible(bool visible);
 
 private:
-       static QMap <Eniro::Site, Eniro::SiteDetails> sites_;
-       QLineEdit* usernameInput_;
-       QLineEdit* passwordInput_;
-       QLineEdit* cacheInput_;
-       ButtonSelector* siteSelector_;
-       ButtonSelector* autostartSelector_;
-       QString currentSite_;
-       QString currentAutostart_;
+    static QMap <Eniro::Site, Eniro::SiteDetails> sites_;
+    QLineEdit* usernameInput_;
+    QLineEdit* passwordInput_;
+    QLineEdit* cacheInput_;
+    ButtonSelector* siteSelector_;
+    ButtonSelector* autostartSelector_;
+    QString currentSite_;
+    QString currentAutostart_;
 };
 
 #endif

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment