Merge branch 'master' of https://vcs.maemo.org/git/situare
authorVille Tiensuu <ville.tiensuu@ixonos.com>
Wed, 26 May 2010 12:36:11 +0000 (15:36 +0300)
committerVille Tiensuu <ville.tiensuu@ixonos.com>
Wed, 26 May 2010 12:36:11 +0000 (15:36 +0300)
Conflicts:
doc/test_cases/functionality-tests.doc

12 files changed:
doc/test_cases/functionality-tests.doc
images.qrc
res/images/user_info_item_bottom.png [new file with mode: 0755]
res/images/user_info_item_middle.png [new file with mode: 0755]
res/images/user_info_item_top.png [new file with mode: 0755]
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 e409111..c471008 100644 (file)
Binary files a/doc/test_cases/functionality-tests.doc and b/doc/test_cases/functionality-tests.doc differ
index 5a835e7..5d39858 100644 (file)
@@ -23,6 +23,9 @@
         <file>res/images/list_item_bottom.png</file>
         <file>res/images/list_item_middle.png</file>
         <file>res/images/list_item_top.png</file>
+           <file>res/images/user_info_item_bottom.png</file>
+        <file>res/images/user_info_item_middle.png</file>
+        <file>res/images/user_info_item_top.png</file>
         <file>res/images/sliding_bar_left_test.png</file>
         <file>res/images/userpanel_mask.png</file>
         <file>res/images/sliding_bar_right_test.png</file>
diff --git a/res/images/user_info_item_bottom.png b/res/images/user_info_item_bottom.png
new file mode 100755 (executable)
index 0000000..7a935bc
Binary files /dev/null and b/res/images/user_info_item_bottom.png differ
diff --git a/res/images/user_info_item_middle.png b/res/images/user_info_item_middle.png
new file mode 100755 (executable)
index 0000000..10098a3
Binary files /dev/null and b/res/images/user_info_item_middle.png differ
diff --git a/res/images/user_info_item_top.png b/res/images/user_info_item_top.png
new file mode 100755 (executable)
index 0000000..96e6b70
Binary files /dev/null and b/res/images/user_info_item_top.png differ
index c737508..690a668 100644 (file)
@@ -368,6 +368,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 c4e54d9..63d3a1d 100644 (file)
@@ -200,6 +200,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 d457e46..05ea5fb 100644 (file)
 #include "../user/user.h"
 #include "userinfo.h"
 
-const int BACKGROUND_TOP_HEIGHT = 20;
-const int BACKGROUND_BOTTOM_HEIGHT = 15;
-const QColor COLOR_GRAY = QColor(152, 152, 152);    ///< Gray color
-const QFont NOKIA_FONT_NORMAL = QFont("Nokia Sans", 18, QFont::Normal);    ///< Normal font
-const QFont NOKIA_FONT_SMALL = QFont("Nokia Sans", 13, QFont::Normal);     ///< Small font
-const int ICON_HEIGHT = 24;     ///< Icon height
-const int ICON_WIDTH = 24;       ///< Icon width
-const int IMAGE_HEIGHT = 60; ///< Friend image height
-const int IMAGE_WIDTH = 60;  ///< Friend image width
-const int ITEM_MIN_WIDTH = 250;  ///< Minimum width for item
-const int MARGIN = 5;   ///< Icon margin
+const int BACKGROUND_WIDTH = 240; ///< Width for item
+const int BACKGROUND_TOP_HEIGHT = 16; ///< Height for item top
+const int BACKGROUND_BOTTOM_HEIGHT = 15; ///< Height for item bottom
+const QColor COLOR_GRAY = QColor(152, 152, 152); ///< Gray color
+const QFont NOKIA_FONT_NORMAL = QFont("Nokia Sans", 18, QFont::Normal); ///< Normal font
+const QFont NOKIA_FONT_SMALL = QFont("Nokia Sans", 13, QFont::Normal);  ///< Small font
+const int ICON_HEIGHT = 24; ///< Icon height
+const int ICON_WIDTH = 24;  ///< Icon width
+const int IMAGE_HEIGHT = 60;    ///< Profile image height
+const int IMAGE_WIDTH = 60;     ///< Profile image width
+const int MARGIN = 5; ///< Icon margin
 const int MOUSE_PRESS_AREA_WIDTH = 20;  ///< Area width for item height toggling
 const int MOUSE_PRESS_AREA_HEIGHT = 20; ///< Area height for item height toggling
 
@@ -45,21 +45,16 @@ const int MOUSE_PRESS_AREA_HEIGHT = 20; ///< Area height for item height togglin
 *
 * @brief All label's maximum width
 */
-const int LABEL_MAX_WIDTH = ITEM_MIN_WIDTH - 3*MARGIN - ICON_WIDTH;
-
-/**
-* @brief Name label's maximum width
-*
-* @var NAME_LABEL_MAX_WIDTH
-*/
-const int NAME_LABEL_MAX_WIDTH = LABEL_MAX_WIDTH + 30;
+const int LABEL_MAX_WIDTH = BACKGROUND_WIDTH - 3 * MARGIN - ICON_WIDTH + 130;
 
 UserInfo::UserInfo(QWidget *parent)
-    : QWidget(parent)
-        , m_expanded(false)
+    : QWidget(parent),
+      m_expanded(false)
 {
+    qDebug() << __PRETTY_FUNCTION__;
+
     QVBoxLayout *verticalLayout = new QVBoxLayout(this);
-    verticalLayout->setContentsMargins(MARGIN, 0, MARGIN*2, MARGIN*2);
+    verticalLayout->setContentsMargins(MARGIN * 2, 0, MARGIN * 2, MARGIN * 2);
     verticalLayout->setSpacing(0);
     setLayout(verticalLayout);
 
@@ -71,10 +66,6 @@ UserInfo::UserInfo(QWidget *parent)
     buttonLayout->setMargin(0);
     buttonLayout->setSpacing(0);
 
-    QLabel *clockLabel = new QLabel();
-    clockLabel->setPixmap(QPixmap(":/res/images/clock.png"));
-    clockLabel->setContentsMargins(0, 0, MARGIN, 0);
-    clockLabel->setFixedSize(ICON_WIDTH + MARGIN, ICON_HEIGHT);
     QLabel *envelopeLabel = new QLabel();
     envelopeLabel->setPixmap(QPixmap(":/res/images/envelope.png"));
     envelopeLabel->setContentsMargins(0, 0, MARGIN, 0);
@@ -83,21 +74,22 @@ UserInfo::UserInfo(QWidget *parent)
     compassLabel->setPixmap(QPixmap(":/res/images/compass.png"));
     compassLabel->setContentsMargins(0, 0, MARGIN, 0);
     compassLabel->setFixedSize(ICON_WIDTH + MARGIN, ICON_HEIGHT);
+    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();
-    m_imageLabel->setFixedSize(IMAGE_WIDTH, IMAGE_HEIGHT);
-    m_imageLabel->setAlignment(Qt::AlignHCenter);
+    m_findButton = new ImageButton();
 
     m_nameLabel = new QLabel();
-    m_nameLabel->setFixedHeight(IMAGE_HEIGHT);
-    m_nameLabel->setAlignment(Qt::AlignHCenter);
+    m_nameLabel->setWordWrap(true);
 
-    m_updatedLabel = new QLabel();
-    m_updatedLabel->setWordWrap(true);
     m_statusTextLabel = new QLabel();
     m_statusTextLabel->setWordWrap(true);
     m_locationLabel = new QLabel();
     m_locationLabel->setWordWrap(true);
+    m_updatedLabel = new QLabel();
+    m_updatedLabel->setWordWrap(true);
 
     ImageButton *updateFriendsButton = new ImageButton(this, ":/res/images/refresh.png",
                                                              ":/res/images/refresh_s.png");
@@ -107,20 +99,23 @@ UserInfo::UserInfo(QWidget *parent)
     buttonLayout->addWidget(updateFriendsButton);
     buttonLayout->addWidget(updateStatusMessageButton);
 
-    infoLayout->addRow(compassLabel, m_locationLabel);
     infoLayout->addRow(envelopeLabel, m_statusTextLabel);
+    infoLayout->addRow(compassLabel, m_locationLabel);
     infoLayout->addRow(clockLabel, m_updatedLabel);
 
-    verticalLayout->addWidget(m_imageLabel, 0, Qt::AlignHCenter);
-
-    verticalLayout->addWidget(m_nameLabel, 1);
+    verticalLayout->addWidget(m_findButton, 0, Qt::AlignHCenter);
+    verticalLayout->addWidget(m_nameLabel, 0, Qt::AlignHCenter);
     verticalLayout->addLayout(infoLayout);
-    verticalLayout->addLayout(buttonLayout, 2);
+    verticalLayout->addLayout(buttonLayout);
 
     connect(updateStatusMessageButton,SIGNAL(clicked()),
             this,SLOT(messageUpdate()));
     connect(updateFriendsButton,SIGNAL(clicked()),
             this, SIGNAL(refreshUserData()));
+    connect(m_findButton, SIGNAL(clicked()),
+        this, SLOT(findButtonClicked()));
+
+    setFixedWidth(BACKGROUND_WIDTH);
 
     this->setFont(NOKIA_FONT_SMALL);
     m_nameLabel->setFont(NOKIA_FONT_NORMAL);
@@ -131,26 +126,23 @@ UserInfo::UserInfo(QWidget *parent)
     namePalette.setColor(QPalette::Foreground, Qt::white);
     m_nameLabel->setPalette(namePalette);
 
-    m_backgroundTopImage.load(":/res/images/list_item_top.png");
-    m_backgroundMiddleImage.load(":/res/images/list_item_middle.png");
-    m_backgroundBottomImage.load(":/res/images/list_item_bottom.png");
-
-    this->setMinimumWidth(ITEM_MIN_WIDTH);
+    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::setAvatar(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)
@@ -161,18 +153,26 @@ void UserInfo::setMessageText(const QString &text)
     setText(false);
 }
 
-void UserInfo::setAddress(const QString &addr)
+void UserInfo::setProfileImage(const QPixmap &image)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_locationLabel->setText(addr);
+    m_findButton->setIcon(image);
 }
 
-void UserInfo::setTime(const QString &tim)
+void UserInfo::setTime(const QString &time)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_updatedLabel->setText(tim);
+    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)
@@ -201,7 +201,7 @@ void UserInfo::setText(bool expanded)
         m_statusTextLabel->setText(m_messageText);
     }
     else {
-        m_nameLabel->setText(shortenText(m_nameLabel, m_userName, NAME_LABEL_MAX_WIDTH));
+        m_nameLabel->setText(shortenText(m_nameLabel, m_userName, LABEL_MAX_WIDTH));
         m_statusTextLabel->setText(shortenText(m_statusTextLabel, m_messageText,
                                                LABEL_MAX_WIDTH));
     }
@@ -229,10 +229,10 @@ void UserInfo::paintEvent(QPaintEvent *aPaintEvent)
 
     QPainter painter(this);
 
-    QRect topRect = QRect(0, 0, ITEM_MIN_WIDTH, BACKGROUND_TOP_HEIGHT);
-    QRect middleRect = QRect(0, topRect.bottom(), ITEM_MIN_WIDTH,
+    QRect topRect = QRect(0, MARGIN, BACKGROUND_WIDTH, BACKGROUND_TOP_HEIGHT);
+    QRect middleRect = QRect(0, topRect.bottom(), BACKGROUND_WIDTH,
                              height() - BACKGROUND_TOP_HEIGHT - BACKGROUND_BOTTOM_HEIGHT);
-    QRect bottomRect = QRect(topRect.left(), middleRect.bottom(), ITEM_MIN_WIDTH,
+    QRect bottomRect = QRect(topRect.left(), middleRect.bottom(), BACKGROUND_WIDTH,
                              BACKGROUND_BOTTOM_HEIGHT);
 
     painter.drawPixmap(topRect, m_backgroundTopImage);
@@ -247,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 06c2494..7e3684f 100644 (file)
 #include <QWidget>
 #include "updatelocation/updatelocationdialog.h"
 
+class ImageButton;
+
+/**
+* @brief UserInfo shows user's data in expandable item.
+*
+* @class UserInfo userinfo.h "ui/userinfo.h"
+*/
 class UserInfo : public QWidget
 {
     Q_OBJECT
@@ -49,6 +56,7 @@ protected:
     * @param event QMouseEvent mouse press event
     */
     void mousePressEvent(QMouseEvent *event);
+
     /**
     * @brief Call toggleHeight if mouse position is unchanged.
     *
@@ -56,6 +64,7 @@ protected:
     * @param event QMouseEvent mouse release event
     */
     void mouseReleaseEvent(QMouseEvent *event);
+
     /**
     * @brief This function is called when the widget is drawn
     *
@@ -70,16 +79,16 @@ public:
     /**
     * @brief Sets the users current address
     *
-    * @param addr Reference to users current address
+    * @param address Reference to users current address
     */
-    void setAddress(const QString &addr);
+    void setAddress(const QString &address);
 
     /**
-    * @brief Sets the user picture
+    * @brief Sets the users current coordinates
     *
-    * @param avat Reference to user picture
+    * @param coordinates Reference to users current coordinates
     */
-    void setAvatar(const QPixmap &image);
+    void setCoordinates(const QPointF &coordinates);
 
     /**
     * @brief Sets the message text
@@ -89,16 +98,23 @@ 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 tim Reference to time when message was sent.
+    * @param time Reference to time when message was sent.
     */
-    void setTime(const QString &tim);
+    void setTime(const QString &time);
 
    /**
     * @brief Sets the user name
     *
-    * @param usernam Reference to user name
+    * @param name Reference to user name
     */
     void setUserName(const QString &name);
 
@@ -119,6 +135,11 @@ private:
 
 private slots:
     /**
+    * @brief Slot for find button click
+    */
+    void findButtonClicked();
+
+    /**
     * @brief Slot function to forward messageUpdate launch signal
     *
     */
@@ -129,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.
     *
     */
@@ -160,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
@@ -169,11 +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 7d76313..33afd5e 100644 (file)
@@ -26,10 +26,30 @@ UserInfoPanel::UserInfoPanel(QWidget *parent)
     : SidePanel(parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
+
     setType(SidePanel::UserPanel);
 
     m_userInfo = new UserInfo(this);
-    m_panelVBox->addWidget(m_userInfo, 0, Qt::AlignCenter);
+
+    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(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()));
@@ -50,9 +70,10 @@ void UserInfoPanel::userDataReceived(User *user)
 
     if(user) {
         m_userInfo->setUserName(user->name());
-        m_userInfo->setAvatar(user->profileImage());
+        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 21d1e2c..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.
     *
     */
@@ -91,5 +101,6 @@ signals:
  ******************************************************************************/
 private:
     UserInfo *m_userInfo; ///< Instance of the user info view
+
 };
 #endif // USERPANEL_H