Added minor changes to userinfo
authorKatri Kaikkonen <katri.kaikkonen@ixonos.com>
Wed, 26 May 2010 11:26:41 +0000 (14:26 +0300)
committerKatri Kaikkonen <katri.kaikkonen@ixonos.com>
Wed, 26 May 2010 11:26:41 +0000 (14:26 +0300)
Reviewed by: Marko Niemelä

src/engine/engine.cpp
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/userinfo.cpp
src/ui/userinfo.h
src/ui/userinfopanel.cpp
src/ui/userinfopanel.h

index 759a3f0..60a2e77 100644 (file)
@@ -335,6 +335,9 @@ void SituareEngine::signalsFromMainWindow()
     connect(m_ui, SIGNAL(refreshUserData()),
             this, SLOT(refreshUserData()));
 
+    connect(m_ui, SIGNAL(findUser(QPointF)),
+            m_mapEngine, SLOT(setViewLocation(QPointF)));
+
     // signals from friend list tab
     connect(m_ui, SIGNAL(findFriend(QPointF)),
             m_mapEngine, SLOT(setViewLocation(QPointF)));
index a70fbc0..cfb0edc 100644 (file)
@@ -197,6 +197,9 @@ void MainWindow::buildUserInfoPanel()
     m_userPanelSidebar->stackUnder(m_friendsListPanel);
     m_userPanel->stackUnder(m_userPanelSidebar);
 
+    connect(m_userPanel, SIGNAL(findUser(QPointF)),
+            this, SIGNAL(findUser(QPointF)));
+
     connect(this, SIGNAL(userLocationReady(User*)),
             m_userPanel, SLOT(userDataReceived(User*)));
 
index d34d0ad..67bb598 100644 (file)
@@ -296,6 +296,13 @@ signals:
     void fetchUsernameFromSettings();
 
     /**
+    * @brief Signal for finding user.
+    *
+    * @param coordinates user geo coordinates
+    */
+    void findUser(const QPointF &coordinates);
+
+    /**
     * @brief GPS setting changed
     *
     * @param enabled True if GPS is enabled, otherwise false
index b8ed9a1..05ea5fb 100644 (file)
@@ -56,7 +56,7 @@ UserInfo::UserInfo(QWidget *parent)
     QVBoxLayout *verticalLayout = new QVBoxLayout(this);
     verticalLayout->setContentsMargins(MARGIN * 2, 0, MARGIN * 2, MARGIN * 2);
     verticalLayout->setSpacing(0);
-    this->setLayout(verticalLayout);
+    setLayout(verticalLayout);
 
     QFormLayout *infoLayout = new QFormLayout();
     infoLayout->setMargin(0);
@@ -66,30 +66,29 @@ UserInfo::UserInfo(QWidget *parent)
     buttonLayout->setMargin(0);
     buttonLayout->setSpacing(0);
 
-    QLabel *envelopeLabel = new QLabel(this);
+    QLabel *envelopeLabel = new QLabel();
     envelopeLabel->setPixmap(QPixmap(":/res/images/envelope.png"));
     envelopeLabel->setContentsMargins(0, 0, MARGIN, 0);
     envelopeLabel->setFixedSize(ICON_WIDTH + MARGIN, ICON_HEIGHT);
-    QLabel *compassLabel = new QLabel(this);
+    QLabel *compassLabel = new QLabel();
     compassLabel->setPixmap(QPixmap(":/res/images/compass.png"));
     compassLabel->setContentsMargins(0, 0, MARGIN, 0);
     compassLabel->setFixedSize(ICON_WIDTH + MARGIN, ICON_HEIGHT);
-    QLabel *clockLabel = new QLabel(this);
+    QLabel *clockLabel = new QLabel();
     clockLabel->setPixmap(QPixmap(":/res/images/clock.png"));
     clockLabel->setContentsMargins(0, 0, MARGIN, 0);
     clockLabel->setFixedSize(ICON_WIDTH + MARGIN, ICON_HEIGHT);
 
-    m_imageLabel = new QLabel(this);
-    m_imageLabel->setFixedSize(IMAGE_WIDTH, IMAGE_HEIGHT);
+    m_findButton = new ImageButton();
 
-    m_nameLabel = new QLabel(this);
+    m_nameLabel = new QLabel();
     m_nameLabel->setWordWrap(true);
 
-    m_statusTextLabel = new QLabel(this);
+    m_statusTextLabel = new QLabel();
     m_statusTextLabel->setWordWrap(true);
-    m_locationLabel = new QLabel(this);
+    m_locationLabel = new QLabel();
     m_locationLabel->setWordWrap(true);
-    m_updatedLabel = new QLabel(this);
+    m_updatedLabel = new QLabel();
     m_updatedLabel->setWordWrap(true);
 
     ImageButton *updateFriendsButton = new ImageButton(this, ":/res/images/refresh.png",
@@ -104,7 +103,7 @@ UserInfo::UserInfo(QWidget *parent)
     infoLayout->addRow(compassLabel, m_locationLabel);
     infoLayout->addRow(clockLabel, m_updatedLabel);
 
-    verticalLayout->addWidget(m_imageLabel, 0, Qt::AlignHCenter);
+    verticalLayout->addWidget(m_findButton, 0, Qt::AlignHCenter);
     verticalLayout->addWidget(m_nameLabel, 0, Qt::AlignHCenter);
     verticalLayout->addLayout(infoLayout);
     verticalLayout->addLayout(buttonLayout);
@@ -113,8 +112,10 @@ UserInfo::UserInfo(QWidget *parent)
             this,SLOT(messageUpdate()));
     connect(updateFriendsButton,SIGNAL(clicked()),
             this, SIGNAL(refreshUserData()));
+    connect(m_findButton, SIGNAL(clicked()),
+        this, SLOT(findButtonClicked()));
 
-    this->setFixedWidth(BACKGROUND_WIDTH);
+    setFixedWidth(BACKGROUND_WIDTH);
 
     this->setFont(NOKIA_FONT_SMALL);
     m_nameLabel->setFont(NOKIA_FONT_NORMAL);
@@ -125,24 +126,23 @@ UserInfo::UserInfo(QWidget *parent)
     namePalette.setColor(QPalette::Foreground, Qt::white);
     m_nameLabel->setPalette(namePalette);
 
-    this->m_backgroundTopImage.load(":/res/images/user_info_item_top.png");
-    this->m_backgroundMiddleImage.load(":/res/images/user_info_item_middle.png");
-    this->m_backgroundBottomImage.load(":/res/images/user_info_item_bottom.png");
+    m_backgroundTopImage.load(":/res/images/user_info_item_top.png");
+    m_backgroundMiddleImage.load(":/res/images/user_info_item_middle.png");
+    m_backgroundBottomImage.load(":/res/images/user_info_item_bottom.png");
 }
 
-void UserInfo::setUserName(const QString &name)
+void UserInfo::setAddress(const QString &address)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_userName = name;
-    setText(false);
+    m_locationLabel->setText(address);
 }
 
-void UserInfo::setProfileImage(const QPixmap &image)
+void UserInfo::setCoordinates(const QPointF &coordinates)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_imageLabel->setPixmap(image);
+    m_coordinates = coordinates;
 }
 
 void UserInfo::setMessageText(const QString &text)
@@ -153,11 +153,11 @@ void UserInfo::setMessageText(const QString &text)
     setText(false);
 }
 
-void UserInfo::setAddress(const QString &address)
+void UserInfo::setProfileImage(const QPixmap &image)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_locationLabel->setText(address);
+    m_findButton->setIcon(image);
 }
 
 void UserInfo::setTime(const QString &time)
@@ -167,6 +167,14 @@ void UserInfo::setTime(const QString &time)
     m_updatedLabel->setText(time);
 }
 
+void UserInfo::setUserName(const QString &name)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_userName = name;
+    setText(false);
+}
+
 QString UserInfo::shortenText(const QLabel *label, const QString &text, int textMaxWidth)
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -239,6 +247,13 @@ void UserInfo::mousePressEvent(QMouseEvent *event)
     m_mousePosition = event->pos();
 }
 
+void UserInfo::findButtonClicked()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    emit findUser(m_coordinates);
+}
+
 void UserInfo::messageUpdate()
 {
     qDebug() << __PRETTY_FUNCTION__;
index bfaf044..7e3684f 100644 (file)
@@ -28,6 +28,8 @@
 #include <QWidget>
 #include "updatelocation/updatelocationdialog.h"
 
+class ImageButton;
+
 /**
 * @brief UserInfo shows user's data in expandable item.
 *
@@ -82,11 +84,11 @@ public:
     void setAddress(const QString &address);
 
     /**
-    * @brief Sets the user picture
+    * @brief Sets the users current coordinates
     *
-    * @param image Reference to user picture
+    * @param coordinates Reference to users current coordinates
     */
-    void setProfileImage(const QPixmap &image);
+    void setCoordinates(const QPointF &coordinates);
 
     /**
     * @brief Sets the message text
@@ -96,6 +98,13 @@ public:
     void setMessageText(const QString &text);
 
     /**
+    * @brief Sets the user picture
+    *
+    * @param image Reference to user picture
+    */
+    void setProfileImage(const QPixmap &image);
+
+    /**
     * @brief Sets the time of updated message
     *
     * @param time Reference to time when message was sent.
@@ -126,6 +135,11 @@ private:
 
 private slots:
     /**
+    * @brief Slot for find button click
+    */
+    void findButtonClicked();
+
+    /**
     * @brief Slot function to forward messageUpdate launch signal
     *
     */
@@ -136,6 +150,13 @@ private slots:
 ******************************************************************************/
 signals:
     /**
+    * @brief Signal for finding user.
+    *
+    * @param coordinates user geo coordinates
+    */
+    void findUser(const QPointF &coordinates);
+
+    /**
     * @brief Signal for refreshing user data.
     *
     */
@@ -167,7 +188,6 @@ signals:
 ******************************************************************************/
 private:
     bool m_expanded;                    ///< Item expanded state
-    QLabel *m_imageLabel;               ///< Image label
     QLabel *m_locationLabel;            ///< Location label
     QLabel *m_nameLabel;                ///< Name label
     QLabel *m_statusTextLabel;          ///< Status text label
@@ -176,10 +196,12 @@ private:
     QPixmap m_backgroundMiddleImage;    ///< Middle background image
     QPixmap m_backgroundTopImage;       ///< Top background image
     QPoint m_mousePosition;             ///< Current mouse press position
+    QPointF m_coordinates;              ///< User current coordinates
     QString m_address;                  ///< Address from where the new message was sent.
     QString m_messageText;              ///< User's message
     QString m_time;                     ///< Time when the new message was sent
     QString m_userName;                 ///< User's name
+    ImageButton *m_findButton;          ///< User find button
 };
 
 #endif // USERINFO_H
index 9d45f66..33afd5e 100644 (file)
@@ -31,22 +31,26 @@ UserInfoPanel::UserInfoPanel(QWidget *parent)
 
     m_userInfo = new UserInfo(this);
 
-    m_userInfoView = new QWidget(this);
-    m_userViewLayout = new QVBoxLayout(m_userInfoView);
-    m_userViewLayout->setMargin(0);
-    m_userViewLayout->setSpacing(0);
-    m_userViewLayout->setStretch(0, 0);
-    m_userViewLayout->setSizeConstraint(QLayout::SetFixedSize);
-    m_userViewLayout->addWidget(m_userInfo);
+    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);
     userInfoScroll->setWidgetResizable(true);
-    userInfoScroll->setWidget(m_userInfoView);
+    userInfoScroll->setWidget(userInfoView);
     userInfoScroll->setAlignment(Qt::AlignVCenter);
     userInfoScroll->viewport()->setAutoFillBackground(false);
     userInfoScroll->widget()->setAutoFillBackground(false);
+
     m_panelVBox->addWidget(userInfoScroll);
 
+    connect(m_userInfo, SIGNAL(findUser(QPointF)),
+            this, SIGNAL(findUser(QPointF)));
+
     connect(m_userInfo,SIGNAL(requestReverseGeo()),
             this, SIGNAL(requestReverseGeo()));
 
@@ -62,11 +66,14 @@ UserInfoPanel::UserInfoPanel(QWidget *parent)
 
 void UserInfoPanel::userDataReceived(User *user)
 {
+    qDebug() << __PRETTY_FUNCTION__;
+
     if(user) {
         m_userInfo->setUserName(user->name());
         m_userInfo->setProfileImage(user->profileImage());
         m_userInfo->setMessageText(user->note());
         m_userInfo->setAddress(user->address());
         m_userInfo->setTime(user->timestamp());
+        m_userInfo->setCoordinates(user->coordinates());
     }
 }
index 2c8121b..7aabce7 100644 (file)
@@ -58,8 +58,18 @@ public slots:
     */
     void userDataReceived(User *user);
 
+/*******************************************************************************
+ * SIGNALS
+ ******************************************************************************/
 signals:
     /**
+    * @brief Signal for finding user.
+    *
+    * @param coordinates user geo coordinates
+    */
+    void findUser(const QPointF &coordinates);
+
+    /**
     * @brief Signal for refreshing user data.
     *
     */
@@ -90,8 +100,6 @@ signals:
  * DATA MEMBERS
  ******************************************************************************/
 private:
-    QVBoxLayout *m_userViewLayout; ///< Layout for userInfo
-    QWidget *m_userInfoView; ///< Widget for userInfoLayout
     UserInfo *m_userInfo; ///< Instance of the user info view
 
 };