Merge branch 'master' into new_panels_with_context_buttons
[situare] / src / ui / userinfopanel.cpp
index 7e6ccce..2c48092 100644 (file)
@@ -1,8 +1,10 @@
- /*
+/*
     Situare - A location system for Facebook
     Copyright (C) 2010  Ixonos Plc. Authors:
 
         Kaj Wallin - kaj.wallin@ixonos.com
+        Katri Kaikkonen - katri.kaikkonen@ixonos.com
+        Pekka Nissinen - pekka.nissinen@ixonos.com
 
     Situare is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License
     along with Situare; if not, write to the Free Software
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
     USA.
- */
+*/
 
 #include <QScrollArea>
 #include <QVBoxLayout>
 
+#include "imagebutton.h"
 #include "panelcommon.h"
 #include "userinfo.h"
 
 #include "userinfopanel.h"
 
 UserInfoPanel::UserInfoPanel(QWidget *parent)
-    : SidePanel(parent)
+    : PanelBase(parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    setType(SidePanel::UserPanel);
+    QVBoxLayout *userInfoPanelLayout = new QVBoxLayout;
+    userInfoPanelLayout->setMargin(0);
+    userInfoPanelLayout->setSpacing(0);
+    userInfoPanelLayout->setContentsMargins(PANEL_MARGIN_LEFT, PANEL_MARGIN_TOP,
+                                            PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
+    setLayout(userInfoPanelLayout);
 
     m_userInfo = new UserInfo(this);
 
     QWidget *userInfoView = new QWidget(this);
-    QVBoxLayout *userViewLayout = new QVBoxLayout(userInfoView);
-    userViewLayout->setMargin(0);
-    userViewLayout->setSpacing(0);
-    userViewLayout->setStretch(0, 0);
-    userViewLayout->setSizeConstraint(QLayout::SetFixedSize);
-    userViewLayout->addWidget(m_userInfo);
-
-    QScrollArea *userInfoScroll = new QScrollArea(this);
+    QVBoxLayout *userInfoViewLayout = new QVBoxLayout(userInfoView);
+    userInfoViewLayout->setMargin(0);
+    userInfoViewLayout->setSpacing(0);
+    userInfoViewLayout->setStretch(0, 0);
+    userInfoViewLayout->setSizeConstraint(QLayout::SetFixedSize);
+    userInfoViewLayout->addWidget(m_userInfo);
+
+    QScrollArea *userInfoScroll = new QScrollArea();
     userInfoScroll->setWidgetResizable(true);
     userInfoScroll->setWidget(userInfoView);
     userInfoScroll->setAlignment(Qt::AlignVCenter);
     userInfoScroll->viewport()->setAutoFillBackground(false);
     userInfoScroll->widget()->setAutoFillBackground(false);
 
-    m_panelVBox->addWidget(userInfoScroll);
-    m_panelVBox->setContentsMargins(USERPANEL_MARGIN_LEFT, 0, USERPANEL_MARGIN_RIGHT, 0);
+    userInfoPanelLayout->addWidget(userInfoScroll);
 
     connect(m_userInfo, SIGNAL(findUser(GeoCoordinate)),
             this, SIGNAL(findUser(GeoCoordinate)));
@@ -60,20 +67,36 @@ UserInfoPanel::UserInfoPanel(QWidget *parent)
     connect(m_userInfo,SIGNAL(requestReverseGeo()),
             this, SIGNAL(requestReverseGeo()));
 
-    connect(this, SIGNAL(reverseGeoReady(QString)),
-            m_userInfo, SIGNAL(reverseGeoReady(QString)));
+    connect(m_userInfo, SIGNAL(statusUpdate(QString, bool)),
+            this, SIGNAL(statusUpdate(QString, bool)));
 
-    connect(m_userInfo, SIGNAL(statusUpdate(QString,bool)),
-            this, SIGNAL(statusUpdate(QString,bool)));
+    connect(m_userInfo, SIGNAL(notificateUpdateFailing(QString, bool)),
+             this, SIGNAL(notificateUpdateFailing(QString, bool)));
 
-    connect(m_userInfo, SIGNAL(refreshUserData()),
-            this, SIGNAL(refreshUserData()));
+    connect(this, SIGNAL(reverseGeoReady(QString)),
+            m_userInfo, SIGNAL(reverseGeoReady(QString)));
 
     connect(this, SIGNAL(clearUpdateLocationDialogData()),
             m_userInfo, SLOT(clearUpdateLocationDialogData()));
 
-    connect(m_userInfo, SIGNAL(notificateUpdateFailing(QString, bool)),
-             this, SIGNAL(notificateUpdateFailing(QString, bool)));
+    connect(this, SIGNAL(collapse()),
+            m_userInfo, SLOT(collapse()));
+
+    ImageButton *updateFriendsButton = new ImageButton(":/res/images/refresh.png",
+                                                       ":/res/images/refresh_s.png",
+                                                       "", this);
+    ImageButton *updateStatusMessageButton = new ImageButton(":/res/images/send_position.png",
+                                                             ":/res/images/send_position_s.png",
+                                                             "", this);
+
+    m_contextButtonLayout->addWidget(updateFriendsButton);
+    m_contextButtonLayout->addWidget(updateStatusMessageButton);
+
+    connect(updateFriendsButton, SIGNAL(clicked()),
+            this, SIGNAL(refreshUserData()));
+
+    connect(updateStatusMessageButton, SIGNAL(clicked()),
+            m_userInfo, SLOT(messageUpdate()));
 }
 
 void UserInfoPanel::userDataReceived(User *user)