Merge branch 'master' into contact_dialog
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Fri, 3 Sep 2010 08:26:34 +0000 (11:26 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Fri, 3 Sep 2010 08:26:34 +0000 (11:26 +0300)
Conflicts:
src/engine/engine.cpp
src/engine/engine.h
src/src.pro
src/ui/friendlistpanel.cpp
src/ui/friendlistpanel.h
src/ui/listview.h
src/ui/mainwindow.h

21 files changed:
1  2 
images.qrc
res/images/contact_btn.png
res/images/contact_btn_d.png
res/images/contact_btn_s.png
src/engine/contactmanager.h
src/engine/contactmanagerprivate.cpp
src/engine/contactmanagerprivate.h
src/engine/contactmanagerprivatestub.cpp
src/engine/contactmanagerprivatestub.h
src/engine/engine.cpp
src/engine/engine.h
src/src.pro
src/ui/friendlistitem.cpp
src/ui/friendlistpanel.cpp
src/ui/friendlistpanel.h
src/ui/listview.cpp
src/ui/listview.h
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/ossoabookdialog.cpp
src/ui/ossoabookdialog.h

diff --cc images.qrc
          <file>res/images/walk_icon_gray.png</file>
          <file>res/images/zoom_in.png</file>
          <file>res/images/zoom_out.png</file>
+         <file>res/images/location_search.png</file>
+         <file>res/images/search_history.png</file>
+         <file>res/images/clear_btn_d.png</file>
+         <file>res/images/clear_btn_s.png</file>
+         <file>res/images/clear_btn.png</file>
++        <file>res/images/contact_btn.png</file>
++        <file>res/images/contact_btn_d.png</file>
++        <file>res/images/contact_btn_s.png</file>
      </qresource>
  </RCC>
index 0000000,0000000..026212c
new file mode 100644 (file)
Binary files differ
index 0000000,0000000..1ee74b2
new file mode 100644 (file)
Binary files differ
index 0000000,0000000..5738d33
new file mode 100644 (file)
Binary files differ
index f6f5a6f,0000000..cdca367
mode 100644,000000..100644
--- /dev/null
@@@ -1,50 -1,0 +1,59 @@@
 +#ifndef CONTACTMANAGER_H
 +#define CONTACTMANAGER_H
 +
 +#include <QObject>
 +#include <QHash>
 +
 +class ContactManagerPrivate;
 +
 +class ContactManager : public QObject
 +{
 +    Q_OBJECT
 +public:
 +    /**
 +    * @brief Friend class for ContactManagerPrivate.
 +    */
 +    friend class ContactManagerPrivate;
 +
 +    ContactManager(QObject *parent = 0);
 +
++/*******************************************************************************
++* MEMBER FUNCTIONS AND SLOTS
++******************************************************************************/
 +    /**
 +    * @brief Returns contact's guid from contact's facebook ID.
 +    *
 +    * @param facebookId contact's facebook ID
 +    * @return contact guid
 +    */
 +    QString contactGuid(const QString &facebookId) const;
 +
 +    /**
 +    * @brief Requests contact guids.
 +    *
 +    * Guid is a globally unique ID of a contact, which can be used with
 +    * other datastores.
 +    */
 +    void requestContactGuids();
 +
++/*******************************************************************************
++* SIGNALS
++******************************************************************************/
 +signals:
 +    /**
 +    * @brief Signal for contacts guids added.
 +    *
 +    * Contact guids has Facebook ID as key and Guid as value.. Guid is a globally
 +    * unique ID of a contact, which can be used with other datastores.
 +    * @param contactGuids list of contact guids
 +    */
 +    void contactsGuidsAdded(const QHash<QString, QString> &contactGuids);
 +
++/******************************************************************************
++* DATA MEMBERS
++******************************************************************************/
 +private:
 +    ContactManagerPrivate *m_contactManagerPrivate; ///< ContactManagerPrivate
 +};
 +
 +#endif // CONTACTMANAGER_H
index c28325e,0000000..656e6d8
mode 100644,000000..100644
--- /dev/null
@@@ -1,84 -1,0 +1,84 @@@
 +#include <QContact>
 +#include <QContactGuid>
 +#include <QContactManager>
 +#include <QContactOnlineAccount>
 +#include <QDebug>
 +#include <QHash>
 +#include <QList>
 +#include <QStringList>
 +
 +#include "contactmanager.h"
 +
 +#include "contactmanagerprivate.h"
 +
 +QTM_USE_NAMESPACE
 +
 +ContactManagerPrivate::ContactManagerPrivate(QObject *parent)
 +    : QObject(parent),
 +      m_manager(0)
 +{
 +    qDebug() << __PRETTY_FUNCTION__;
 +
 +    m_parent = static_cast<ContactManager *>(parent);
 +
 +    const QString MAEMO5_MANAGER_NAME = "maemo5";
 +
 +    QStringList availableManagers = QContactManager::availableManagers();
 +
 +    if (availableManagers.contains(MAEMO5_MANAGER_NAME)) {
 +        QMap<QString, QString> params;
 +        QString managerUri = QContactManager::buildUri(MAEMO5_MANAGER_NAME, params);
 +        m_manager = QContactManager::fromUri(managerUri);
 +    }
 +}
 +
 +QString ContactManagerPrivate::parseFacebookId(const QString &accountUri) const
 +{
 +    qDebug() << __PRETTY_FUNCTION__;
 +
 +    const QString FACEBOOK_CHAT_URL = "@chat.facebook.com";
 +    int facebookChatUrlIndex = accountUri.indexOf(FACEBOOK_CHAT_URL);
 +    QString facebookId;
 +
 +    if (facebookChatUrlIndex != -1) {
 +        facebookId = accountUri.left(facebookChatUrlIndex);
 +        facebookId.remove("-");
 +    }
 +
 +    return facebookId;
 +}
 +
 +QString ContactManagerPrivate::contactGuid(const QString &facebookId) const
 +{
 +    qDebug() << __PRETTY_FUNCTION__;
 +
 +    if (!m_manager) {
 +        qWarning() << "Manager is uninitialized";
-         return;
++        return QString();
 +    }
 +
 +    return m_contactGuids.value(facebookId);
 +}
 +
 +void ContactManagerPrivate::requestContactGuids()
 +{
 +    qDebug() << __PRETTY_FUNCTION__;
 +
 +    if (!m_manager) {
 +        qWarning() << "Manager is uninitialized";
 +        return;
 +    }
 +
 +    QHash<QString, QString> contactGuids;
 +
 +    foreach (QContact contact, m_manager->contacts()) {
 +        QContactOnlineAccount account = contact.detail(QContactOnlineAccount::DefinitionName);
 +        QString facebookId = parseFacebookId(account.accountUri());
 +        QContactGuid contactGuid = contact.detail(QContactGuid::DefinitionName);
 +
 +        if (!facebookId.isEmpty())
 +            contactGuids.insert(facebookId, contactGuid.guid());
 +    }
 +
 +    m_contactGuids = contactGuids;
 +}
index ef1a6b0,0000000..9a59127
mode 100644,000000..100644
--- /dev/null
@@@ -1,49 -1,0 +1,56 @@@
 +#ifndef CONTACTMANAGERPRIVATE_H
 +#define CONTACTMANAGERPRIVATE_H
 +
 +#include <QObject>
 +
 +#include <QContactManager>
 +
 +class ContactManager;
 +
 +QTM_USE_NAMESPACE
 +
 +class ContactManagerPrivate : public QObject
 +{
 +    Q_OBJECT
++
 +public:
 +    ContactManagerPrivate(QObject *parent = 0);
 +
++/*******************************************************************************
++* MEMBER FUNCTIONS AND SLOTS
++******************************************************************************/
 +    /**
 +    * @brief Returns contact's guid from contact's facebook ID.
 +    *
 +    * @param facebookId contact's facebook ID
 +    * @return contact guid
 +    */
 +    QString contactGuid(const QString &facebookId) const;
 +
 +    /**
 +    * @brief Requests contact guids.
 +    *
 +    * Guid is a globally unique ID of a contact, which can be used with
 +    * other datastores.
 +    */
 +    void requestContactGuids();
 +
 +private:
 +    /**
 +    * @brief Parses Facebook id from account URI.
 +    *
 +    * @param accountUri Accounts universal resource identifier.
 +    * @return Facebook ID or empty if cannot parse the ID.
 +    */
 +    QString parseFacebookId(const QString &accountUri) const;
 +
++/******************************************************************************
++* DATA MEMBERS
++******************************************************************************/
 +private:
 +    ContactManager *m_parent;   ///< Parent
 +    QContactManager *m_manager; ///< Contact manager
 +    QHash<QString, QString> m_contactGuids;
 +};
 +
 +#endif // CONTACTMANAGERPRIVATE_H
index 178cbc9,0000000..df142d2
mode 100644,000000..100644
--- /dev/null
@@@ -1,14 -1,0 +1,23 @@@
 +#include <QDebug>
 +
 +#include "contactmanagerprivatestub.h"
 +
 +ContactManagerPrivate::ContactManagerPrivate(QObject *parent) :
 +    QObject(parent)
 +{
 +    qDebug() << __PRETTY_FUNCTION__;
 +}
 +
 +void ContactManagerPrivate::requestContactGuids()
 +{
 +    qDebug() << __PRETTY_FUNCTION__;
 +}
++
++QString ContactManagerPrivate::contactGuid(const QString &facebookId) const
++{
++    qDebug() << __PRETTY_FUNCTION__;
++
++    Q_UNUSED(facebookId);
++
++    return QString();
++}
index 04815cf,0000000..b8abb1c
mode 100644,000000..100644
--- /dev/null
@@@ -1,32 -1,0 +1,36 @@@
 +#ifndef CONTACTMANAGERPRIVATESTUB_H
 +#define CONTACTMANAGERPRIVATESTUB_H
 +
 +#include <QObject>
 +
 +class ContactManagerPrivate : public QObject
 +{
 +    Q_OBJECT
 +public:
 +    ContactManagerPrivate(QObject *parent = 0);
 +
++/*******************************************************************************
++* MEMBER FUNCTIONS AND SLOTS
++******************************************************************************/
 +    /**
 +    * @brief Returns contact's guid from contact's facebook ID.
 +    *
++    * RETURNS empty QString.
++    *
 +    * @param facebookId contact's facebook ID
 +    * @return contact guid
 +    */
 +    QString contactGuid(const QString &facebookId) const;
 +
 +    /**
 +    * @brief Requests contact guids.
 +    *
 +    * Guid is a globally unique ID of a contact, which can be used with
 +    * other datastores.
 +    *
 +    * DOES NOTHING.
 +    */
 +    void requestContactGuids();
 +};
 +
 +#endif // CONTACTMANAGERPRIVATESTUB_H
@@@ -29,8 -29,7 +29,8 @@@
  
  #include "application.h"
  #include "common.h"
 +#include "contactmanager.h"
- #include "error.h"
+ #include "../error.h"
  #include "facebookservice/facebookauthentication.h"
  #include "gps/gpsposition.h"
  #include "map/mapengine.h"
@@@ -133,9 -132,6 +133,9 @@@ SituareEngine::SituareEngine(
  
      m_mce = new MCE(this);
      connect(m_mce, SIGNAL(displayOff(bool)), this, SLOT(setPowerSaving(bool)));
++    
 +    m_contactManager = new ContactManager(this);
 +    m_contactManager->requestContactGuids();
  }
  
  SituareEngine::~SituareEngine()
@@@ -564,16 -567,6 +571,19 @@@ void SituareEngine::setPowerSaving(boo
          m_mapEngine->setAutoCentering(!enabled);
  }
  
 +void SituareEngine::showContactDialog(const QString &facebookId)
 +{
 +    qDebug() << __PRETTY_FUNCTION__;
 +
 +    QString guid = m_contactManager->contactGuid(facebookId);
 +
 +    if (!guid.isEmpty())
 +        m_ui->showContactDialog(guid);
++    else
++        m_ui->buildInformationBox(tr("Unable to find contact.\nYou must have Facebook "
++                                     "chat account to be able to open contact dialog."), true);
 +}
 +
  void SituareEngine::signalsFromFacebookAuthenticator()
  {
      qDebug() << __PRETTY_FUNCTION__;
@@@ -692,14 -702,9 +719,13 @@@ void SituareEngine::signalsFromMainWind
      connect(m_ui, SIGNAL(draggingModeTriggered()),
              this, SLOT(draggingModeTriggered()));
  
-     connect(m_ui, SIGNAL(routeTo(const GeoCoordinate&)),
-             this, SLOT(routeTo(const GeoCoordinate&)));
+     // signal from search location dialog
+     connect(m_ui, SIGNAL(searchForLocation(QString)),
+             this, SLOT(locationSearch(QString)));
 +
++    // signal from friend list panel
 +    connect(m_ui, SIGNAL(requestContactDialog(const QString &)),
 +            this, SLOT(showContactDialog(const QString &)));
  }
  
  void SituareEngine::signalsFromMapEngine()
@@@ -295,6 -291,6 +292,14 @@@ private slots
      void setPowerSaving(bool enabled);
  
      /**
++    * @brief Shows contact dialog.
++    *
++    * Calls MainWindow showContactDialog with contact guid defined by contact's Facebook ID.
++    * @param facebookId contact's facebookId
++    */
++    void showContactDialog(const QString &facebookId);
++
++    /**
      * @brief Automatic update interval timer timeout.
      *
      * Requests update location if user has moved.
diff --cc src/src.pro
@@@ -12,6 -12,6 +12,7 @@@ SOURCES += main.cpp 
      application.cpp \
      coordinates/geocoordinate.cpp \
      coordinates/scenecoordinate.cpp \
++    engine/contactmanager.cpp \
      engine/engine.cpp \
      engine/mce.cpp \
      facebookservice/facebookauthentication.cpp \
      ui/locationlistitem.cpp \
      ui/locationlistview.cpp \
      ui/indicatorbuttonpanel.cpp \
++    ui/locationsearchpanel.cpp \
      ui/logindialog.cpp \
      ui/mainwindow.cpp \
      ui/mapscale.cpp \
--    ui/settingsdialog.cpp \
--    ui/userinfo.cpp \
--    ui/userinfopanel.cpp \
--    ui/zoombutton.cpp \
--    ui/zoombuttonpanel.cpp \
--    ui/searchdialog.cpp \
      ui/panelbar.cpp \
+     ui/panelbase.cpp \
      ui/panelcontentstack.cpp \
+     ui/panelcontextbuttonbar.cpp \
      ui/paneltab.cpp \
      ui/paneltabbar.cpp \
--    ui/tabbedpanel.cpp \
      ui/routingpanel.cpp \
      ui/routewaypointlistitem.cpp \
--    ui/routewaypointlistview.cpp \
--    user/user.cpp \
-     engine/contactmanager.cpp
 -    ui/locationsearchpanel.cpp \
 -    ui/textmodifier.cpp \
++    ui/routewaypointlistview.cpp \    
++    ui/searchdialog.cpp \
++    ui/searchhistorylistitem.cpp \
+     ui/searchhistorylistview.cpp \
 -    ui/searchhistorylistitem.cpp
++    ui/settingsdialog.cpp \
++    ui/tabbedpanel.cpp \
++    ui/textmodifier.cpp \
++    ui/userinfo.cpp \
++    ui/userinfopanel.cpp \
++    ui/zoombutton.cpp \
++    ui/zoombuttonpanel.cpp \
++    user/user.cpp
  HEADERS += application.h \
      common.h \
      coordinates/geocoordinate.h \
      coordinates/scenecoordinate.h \
++    engine/contactmanager.h \
      engine/engine.h \
      engine/mce.h \
      error.h \
      ui/imagebutton.h \
      ui/indicatorbutton.h \
      ui/indicatorbuttonpanel.h \
-     ui/logindialog.h \
-     ui/locationlistview.h \
-     ui/mainwindow.h \
-     ui/mapscale.h \
-     ui/settingsdialog.h \
-     ui/userinfo.h \
-     ui/userinfopanel.h \
-     ui/zoombutton.h \
-     ui/zoombuttonpanel.h \
 +    ui/listcommon.h \    
 +    ui/listview.h \
 +    ui/listitem.h \
 +    ui/listitemdelegate.h \
-     ui/searchdialog.h \
+     ui/logindialog.h \
+     ui/locationlistitem.h \
+     ui/locationlistview.h \
++    ui/locationsearchpanel.h \
+     ui/mainwindow.h \
+     ui/mapscale.h \
 -    ui/settingsdialog.h \
 -    ui/userinfo.h \
 -    ui/userinfopanel.h \
 -    ui/zoombutton.h \
 -    ui/zoombuttonpanel.h \
 -    ui/listcommon.h \    
 -    ui/listview.h \
 -    ui/listitem.h \
 -    ui/listitemdelegate.h \
 -    ui/searchdialog.h \
      ui/panelbar.h \
+     ui/panelbase.h \
      ui/panelcommon.h \
      ui/panelcontentstack.h \
+     ui/panelcontextbuttonbar.h \
      ui/paneltab.h \
      ui/paneltabbar.h \
      ui/routingpanel.h \
      ui/routewaypointlistitem.h \
      ui/routewaypointlistview.h \
--    user/user.h \
-     engine/contactmanager.h
 -    ui/locationsearchpanel.h \
 -    ui/textmodifier.h \
++    ui/searchdialog.h \
++    ui/searchhistorylistitem.h \
+     ui/searchhistorylistview.h \
 -    ui/searchhistorylistitem.h
++    ui/settingsdialog.h \
++    ui/tabbedpanel.h \
++    ui/textmodifier.h \
++    ui/userinfo.h \
++    ui/userinfopanel.h \
++    ui/zoombutton.h \
++    ui/zoombuttonpanel.h \
++    user/user.h
  QT += network \
      webkit
  DEFINES += QT_NO_DEBUG_OUTPUT
  
  simulator {
Simple merge
@@@ -6,6 -6,6 +6,7 @@@
          Henri Lampela - henri.lampela@ixonos.com
          Pekka Nissinen - pekka.nissinen@ixonos.com
          Sami Rämö - sami.ramo@ixonos.com
++        Jussi Laitinen - jussi.laitinen@ixonos.com
  
      Situare is free software; you can redistribute it and/or
      modify it under the terms of the GNU General Public License
@@@ -135,8 -107,34 +108,41 @@@ FriendListPanel::FriendListPanel(QWidge
      connect(qApp, SIGNAL(topmostWindowChanged(bool)),
              this, SLOT(topmostWindowChanged(bool)));
  
+     // --- MAIN LAYOUT ---
+     QVBoxLayout *friendListPanelLayout = new QVBoxLayout();
+     friendListPanelLayout->setMargin(0);
+     friendListPanelLayout->setSpacing(0);
+     setLayout(friendListPanelLayout);
+     friendListPanelLayout->addWidget(m_headerWidget);
+     friendListPanelLayout->addLayout(listViewLayout);
+     friendListPanelLayout->addLayout(footerLayout);
+     // --- CONTEXT BUTTONS ---
+     m_routeButton = new ImageButton(":res/images/route_to_friend.png",
+                                     ":res/images/route_to_friend_s.png",
+                                     ":res/images/route_to_friend_d.png", this);
+     m_routeButton->setDisabled(true);
+     connect(m_routeButton, SIGNAL(clicked()),
+             this, SLOT(routeToSelectedFriend()));
++    m_showContactButton = new ImageButton(":res/images/contact_btn.png",
++                                          ":res/images/contact_btn_s.png",
++                                          ":res/images/contact_btn_d.png", this);
 +    connect(m_showContactButton, SIGNAL(clicked()),
 +            this, SLOT(requestSelectedFriendContactDialog()));
++
+     m_clearGroupFilteringButton = new ImageButton(":res/images/filtered.png",
+                                                   ":res/images/filtered_s.png",
+                                                   ":res/images/filtered_d.png", this);
+     m_clearGroupFilteringButton->setCheckable(true);
+     m_clearGroupFilteringButton->setDisabled(true);
+     connect(m_clearGroupFilteringButton, SIGNAL(clicked()),
+             this, SLOT(clearFiltering()));
+     m_contextButtonLayout->addWidget(m_routeButton);
++    m_contextButtonLayout->addWidget(m_showContactButton);
+     m_contextButtonLayout->addWidget(m_clearGroupFilteringButton);
  }
  
  void FriendListPanel::anyPanelClosed()
@@@ -236,22 -236,9 +244,22 @@@ void FriendListPanel::hideEvent(QHideEv
      clearFiltering();
  
      m_friendListView->clearItemSelection();
-     setSelectionButtonsDisabled();
+     setRouteButtonDisabled();
  }
  
 +void FriendListPanel::requestSelectedFriendContactDialog()
 +{
-     qDebug() << __PRETTY_FUNCTION__;
++     qDebug() << __PRETTY_FUNCTION__;
 +
-     FriendListItem *item = dynamic_cast<FriendListItem *>(m_friendListView->selectedItem());
++     FriendListItem *item = dynamic_cast<FriendListItem *>(m_friendListView->selectedItem());
 +
-     if (item) {
-         QString facebookId = item->facebookId();
-         if (!facebookId.isEmpty())
-             emit requestContactDialog(facebookId);
-     }
++     if (item) {
++         QString facebookId = item->facebookId();
++         if (!facebookId.isEmpty())
++             emit requestContactDialog(facebookId);
++     }
 +}
 +
  void FriendListPanel::routeToSelectedFriend()
  {
      qDebug() << __PRETTY_FUNCTION__;
@@@ -162,6 -162,6 +162,11 @@@ private slots
      void filterTextChanged(const QString &text);
  
      /**
++    * @brief Requests selected friend's contact dialog.
++    */
++    void requestSelectedFriendContactDialog();
++
++    /**
      * @brief Routes to selected friend.
      *
      * Emits routeToFriend if friend is selected from list.
@@@ -209,45 -204,30 +209,38 @@@ signals
      void findFriend(const GeoCoordinate &coordinates);
  
      /**
-     * @brief Signal for routing to friend.
-     *
-     * @param coordinates friend's geo coordinates
-     */
-     void routeToFriend(const GeoCoordinate &coordinates);
-     /**
 +    * @brief Requests contact dialog.
 +    *
 +    * @param facebookId contact's facebookId
 +    */
 +    void requestContactDialog(const QString &facebookId);
 +
 +    /**
-      * @brief Signal for requesting a panel to be opened
-      *
-      * @param widget Pointer to the widget that emitted the signal
-      */
-     void showPanelRequested(QWidget *widget);
+     * @brief Signal for routing to friend.
+     *
+     * @param coordinates friend's geo coordinates
+     */
+     void routeToFriend(const GeoCoordinate &coordinates);
  
  /*******************************************************************************
   * DATA MEMBERS
   ******************************************************************************/
  private:
-     bool m_mainWindowIsTopmost;         ///< Is the MainWindow the topmost one
-     bool m_somePanelIsOpen;             ///< Is any panel tab open
+     bool m_mainWindowIsTopmost;                 ///< Is the MainWindow the topmost one
+     bool m_somePanelIsOpen;                     ///< Is any panel tab open
  
-     QLabel *m_friendListLabel;          ///< Friend list label
+     QLabel *m_headerLabel;                      ///< Show how many friends are selected
  
-     QLineEdit *m_filterField;           ///< Text field for the filter text
+     QLineEdit *m_filterField;                   ///< Text field for the filter text
  
-     QPushButton *m_clearFilterButton;   ///< Button to clear list filtering
-     QPushButton *m_filterClearButton;   ///< Button for clearing the filtering
-     QPushButton *m_routeButton;         ///< Button to route to friend
-     QPushButton *m_showContactButton;   ///< Button to show contact dialog
+     QPushButton *m_clearTextFilteringButton;    ///< Button for clearing the text filtering
  
-     QWidget *m_friendListHeaderWidget;  ///< Friend list header widget
+     QWidget *m_headerWidget;                    ///< Friend list header widget
  
-     FriendListView *m_friendListView;   ///< Friend list view
+     FriendListView *m_friendListView;           ///< Friend list view
+     ImageButton *m_clearGroupFilteringButton;   ///< Button for clearing friend group filtering
++    ImageButton *m_showContactButton;           ///< Button for showing contact dialog    
+     ImageButton *m_routeButton;                 ///< Button for routing to selected friend
  };
  
  #endif // FRIENDLISTPANEL_H
@@@ -206,29 -208,43 +208,50 @@@ ListItem *ListView::listItemAt(int inde
  {
      qDebug() << __PRETTY_FUNCTION__;
  
-     QHashIterator<QString, ListItem*> itemIterator(m_listItems);
-     ListItem *item = 0;
-     int counter = 0;
+     ListItem *listItem = 0;
  
-     while (itemIterator.hasNext()) {
-         itemIterator.next();
-         if (index == counter) {
-             item = itemIterator.value();
-             break;
-         }
-         counter++;
+     if (index < count())
+         listItem = dynamic_cast<ListItem*>(item(index));
+     return listItem;
+ }
+ void ListView::prependListItem(const QString &key, ListItem *item)
+ {
+     qDebug() << __PRETTY_FUNCTION__;
+     if (!m_listItems.contains(key)) {
+         insertItem(0, item);
+         m_listItems.insert(key, item);
      }
+ }
  
-     return item;
+ void ListView::removeLastItem()
+ {
+     qDebug() << __PRETTY_FUNCTION__;
+     ListItem *item = listItemAt(count() - 1);
+     if (item) {
+         if (item) {
+             QString key = m_listItems.key(item);
+             m_listItems.remove(key);
+             takeItem(row(item));
+             if (m_currentItem == item)
+                 m_currentItem = 0;
+             delete item;
+             item = 0;
+         }
+     }
  }
  
 +QHash<QString, ListItem *> ListView::listItems() const
 +{
 +    qDebug() << __PRETTY_FUNCTION__;
 +
 +    return m_listItems;
 +}
 +
  ListItem *ListView::selectedItem()
  {
      qDebug() << __PRETTY_FUNCTION__;
@@@ -154,14 -155,19 +155,27 @@@ public
      ListItem *listItemAt(int index);
  
      /**
 +    * @brief Returns all list items.
 +    *
 +    * Item ID is key.
 +    * @return list of ListItems
 +    */
 +    QHash<QString, ListItem *> listItems() const;
 +
 +    /**
+     * @brief Prepends item to view and item list.
+     *
+     * @param key user ID
+     * @param item item to prepend to view and list
+     */
+     void prependListItem(const QString &key, ListItem *item);
+     /**
+     * @brief Removes last ListItem in list.
+     */
+     void removeLastItem();
+     /**
      * @brief Returns selected ListItem.
      *
      * @return ListItem if there is selected, 0 otherwise
  #include <QtGui/QX11Info>
  #include <X11/Xatom.h>
  #include <X11/Xlib.h>
- #include "ossoabookdialog.h"
  #endif // Q_WS_MAEMO_5
  
++#if defined(Q_WS_MAEMO_5) & defined(ARMEL)
++#include "ossoabookdialog.h"
++#endif
++
  MainWindow::MainWindow(QWidget *parent)
      : QMainWindow(parent),
        m_errorShown(false),
@@@ -909,15 -937,6 +945,18 @@@ void MainWindow::setUsername(const QStr
      m_email = username;
  }
  
 +void MainWindow::showContactDialog(const QString &guid)
 +{
-     qDebug() << __PRETTY_FUNCTION__ << guid;
++    qDebug() << __PRETTY_FUNCTION__;
 +
 +#if defined(Q_WS_MAEMO_5) & defined(ARMEL)
 +    OssoABookDialog::showContactDialog(guid);
++#else
++    Q_UNUSED(guid);
++    buildInformationBox(tr("Contact dialog works only on phone!"), true);
 +#endif
 +}
 +
  void MainWindow::showEnableAutomaticUpdateLocationDialog(const QString &text)
  {
      qDebug() << __PRETTY_FUNCTION__;
@@@ -198,19 -193,6 +193,14 @@@ public slots
      void setUsername(const QString &username);
  
      /**
 +    * @brief Shows contact dialog.
 +    *
 +    * Shows contact dialog with contact's information.
 +    * @param guid globally unique ID of a contact
 +    */
 +    void showContactDialog(const QString &guid);
 +
 +    /**
-      * @brief Method to show panels
-      */
-     void showPanels();
-     /**
       * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
       *        doesn't exist yet
       */
index f7d6846,0000000..3c35c39
mode 100644,000000..100644
--- /dev/null
@@@ -1,70 -1,0 +1,44 @@@
 +#include "ossoabookdialog.h"
 +#include <QDebug>
 +
 +OssoABookDialog::OssoABookDialog(QObject *parent) :
 +    QObject(parent)
 +{
- }
- QStringList OssoABookDialog::contactChooser(const QString& windowTitle, OssoABookCapsFlags caps, OssoABookContactOrder order)
- {
-     QStringList rtn;
-     GtkWidget* contactChooser = osso_abook_contact_chooser_new_with_capabilities (NULL, qPrintable(windowTitle), caps, order);
-     //Shows a modal dialog.
-     GList* contacts; // Do not free
-     if (gtk_dialog_run(GTK_DIALOG(contactChooser)) == GTK_RESPONSE_OK){
-       contacts = osso_abook_contact_chooser_get_selection(OSSO_ABOOK_CONTACT_CHOOSER(contactChooser));
-       while (contacts){
-           EContact* eContact = E_CONTACT(contacts->data);
-           const char* id = (const char*)e_contact_get_const(eContact, E_CONTACT_UID);
-           rtn << QString::fromLatin1(id);
-           contacts = contacts->next;
-       }
-     }
-     gtk_widget_destroy(contactChooser);
-     return rtn;
- }
- void OssoABookDialog::contactEditor(const QString& id){
-     OssoABookContact* contact = OssoABookDialog::lookup(id);
-     OssoABookContactEditorMode mode = (contact) ?  OSSO_ABOOK_CONTACT_EDITOR_EDIT : OSSO_ABOOK_CONTACT_EDITOR_CREATE;
-     GtkWidget* contactEditor = osso_abook_contact_editor_new_with_contact(NULL, contact, mode);
-     gtk_dialog_run(GTK_DIALOG(contactEditor));
-     gtk_widget_destroy(contactEditor);
++    qDebug() << __PRETTY_FUNCTION__;
 +}
 +
 +void OssoABookDialog::showContactDialog(const QString &id)
 +{
++    qDebug() << __PRETTY_FUNCTION__;
++
 +    OssoABookContact *contact = OssoABookDialog::lookup(id);
 +    if (contact) {
-     //GtkWidget *contactDialog = osso_abook_touch_contact_starter_new_with_contact(NULL, contact);
-     GtkWidget *contactDialog = osso_abook_touch_contact_starter_dialog_new(NULL,
++        GtkWidget *contactDialog = osso_abook_touch_contact_starter_dialog_new(NULL,
 +        (OssoABookTouchContactStarter*)osso_abook_touch_contact_starter_new_with_contact(NULL,
 +        contact));
 +
 +    gtk_widget_show_all(contactDialog);
 +    gtk_dialog_run(GTK_DIALOG(contactDialog));
 +    gtk_widget_destroy(contactDialog);
 +    }
 +}
 +
- OssoABookContact* OssoABookDialog::lookup(const QString& id){
-   GList* l = NULL; // Do not free
-   GError *error = NULL;
-   OssoABookAggregator* aggregator = NULL; // Do not free
++OssoABookContact* OssoABookDialog::lookup(const QString& id)
++{
++    qDebug() << __PRETTY_FUNCTION__;
++
++    GList* l = NULL; // Do not free
++    GError *error = NULL;
++    OssoABookAggregator* aggregator = NULL; // Do not free
 +
-   aggregator = (OssoABookAggregator*) osso_abook_aggregator_get_default(&error);
-   if (error){
-     qWarning() << "error opening addressbook" << error->message;
-     g_error_free (error);
-     return NULL;
-   }
++    aggregator = (OssoABookAggregator*) osso_abook_aggregator_get_default(&error);
++    if (error) {
++        qWarning() << "error opening addressbook" << error->message;
++        g_error_free (error);
++        return NULL;
++    }
 +
-   l = osso_abook_aggregator_lookup(aggregator,qPrintable(id));
++    l = osso_abook_aggregator_lookup(aggregator,qPrintable(id));
 +
-   return (OssoABookContact*) l->data;
++    return (OssoABookContact*) l->data;
 +}
index 1c9a728,0000000..21dc94c
mode 100644,000000..100644
--- /dev/null
@@@ -1,26 -1,0 +1,36 @@@
 +#ifndef OSSOABOOKDIALOG_H
 +#define OSSOABOOKDIALOG_H
 +
 +#include <QObject>
 +#include <QStringList>
 +
 +#undef signals // Collides with GTK symbols
 +#include <libosso-abook/osso-abook.h>
 +
 +class OssoABookDialog : public QObject
 +{
 +    Q_OBJECT
 +public:
-     explicit OssoABookDialog(QObject *parent = 0);
++    OssoABookDialog(QObject *parent = 0);
 +
-     static QStringList contactChooser(const QString& windowTitle,
-                                       OssoABookCapsFlags caps = OSSO_ABOOK_CAPS_ALL,
-                                       OssoABookContactOrder order = OSSO_ABOOK_CONTACT_ORDER_NAME);
-     static void contactEditor(const QString& id);
++/*******************************************************************************
++* MEMBER FUNCTIONS AND SLOTS
++******************************************************************************/
++    /**
++    * @brief Shows contact dialog.
++    *
++    * @param id contact ID
++    */
 +    static void showContactDialog(const QString &id);
 +
 +private:
++    /**
++    * @brief Returns address book contact.
++    *
++    * @param id contact ID
++    * @return OssoABookContact
++    */
 +    static OssoABookContact *lookup(const QString& id);
 +};
 +
 +#endif // OSSOABOOKDIALOG_H