Merge branch 'master' into userinfo
authorKatri Kaikkonen <katri.kaikkonen@ixonos.com>
Fri, 14 May 2010 12:42:11 +0000 (15:42 +0300)
committerKatri Kaikkonen <katri.kaikkonen@ixonos.com>
Fri, 14 May 2010 12:42:11 +0000 (15:42 +0300)
Conflicts:
src/src.pro
src/ui/mapviewscreen.cpp
src/ui/mapviewscreen.h

src/src.pro
src/ui/mapviewscreen.cpp
src/ui/userinfo.cpp
src/ui/userinfo.h
src/ui/userpanel.cpp

index eb321ae..9e80663 100644 (file)
@@ -82,7 +82,8 @@ HEADERS += ui/mainwindow.h \
     ui/userinfo.h
 QT += network \
     webkit
-DEFINES += QT_NO_DEBUG_OUTPUT
+
+#DEFINES += QT_NO_DEBUG_OUTPUT
 
 !maemo5 {
     SOURCES += gps/gpspositionmockup.cpp
@@ -108,6 +109,7 @@ maemo5 {
     message(install headers with: apt-get install libqtm-dev)
 }
 
+
 # -----------------------------------------------------------------
 # Debian packetizing additions
 # -----------------------------------------------------------------
index c9dff1c..7aeb178 100644 (file)
@@ -79,12 +79,17 @@ MapViewScreen::MapViewScreen(QWidget *parent)
 
     connect(this, SIGNAL(userLocationReady(User*)),
             m_mapEngine, SLOT(receiveOwnLocation(User*)));
+    connect(this, SIGNAL(userLocationReady(User*)),
+            m_mapEngine, SLOT(receiveOwnLocation(User*)));
     connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
             m_mapEngine, SIGNAL(friendsLocationsReady(QList<User*>&)));
 
     connect(m_mapEngine, SIGNAL(mapScrolled()),
             this, SLOT(locationChanged()));
 
+    connect(this, SIGNAL(userLocationReady(User*)),
+            m_userPanel, SLOT(receiveUserData(User*)));
+
     QHBoxLayout *mapViewLayout = new QHBoxLayout;
 
     m_osmLicense = new QLabel(this);
index afb28fb..fa6c507 100644 (file)
@@ -83,8 +83,6 @@ UserInfo::UserInfo(QWidget *parent)
     m_nameLabel = new QLabel();
     m_nameLabel->setFixedHeight(IMAGE_HEIGHT);
 
-
-
     m_updatedLabel = new QLabel();
     m_updatedLabel->setWordWrap(true);
     m_statusTextLabel = new QLabel();
@@ -151,10 +149,10 @@ void UserInfo::setUserName(const QString &name)
 
 void UserInfo::setAvatar(const QPixmap &image)
 {
-//    m_avatar = image;
-//   // m_imageLabel->setPixmap(AvatarImage::create(m_avatar.profileImage()));
-//    //m_imageLabel->setPixmap(AvatarImage::create(m_avatar.profileImage()));
-//    m_imageLabel->setPixmap(m_avatar);
+    m_avatar = image;
+   // m_imageLabel->setPixmap(AvatarImage::create(m_avatar.profileImage()));
+    //m_imageLabel->setPixmap(AvatarImage::create(m_avatar.profileImage()));
+    m_imageLabel->setPixmap(m_avatar);
 }
 
 
@@ -169,10 +167,9 @@ void UserInfo::setMessageText(const QString &text)
 
 void UserInfo::setAddress(const QString &addr)
 {
-    if(m_address == addr)
-      return;
-    m_address = addr;
-    m_locationLabel->setText(m_address);
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_locationLabel->setText(addr);
 //    shortenTexts();
 }
 
@@ -182,84 +179,84 @@ void UserInfo::setTime(const QString &tim)
       return;
     m_time = tim;
     m_updatedLabel->setText(m_time);
-//    shortenTexts();
+    shortenTexts();
 }
 
-//void UserInfo::shortenTexts()
-//{
-//    qDebug() << __PRETTY_FUNCTION__;
-//
-//    QFontMetrics nameLabelMetrics = m_nameLabel->fontMetrics();
-//    QFontMetrics otherLabelsMetrics = m_locationLabel->fontMetrics();
-//
-//    QString name = m_userName;
-//    QString updated = m_time;
-//    QString statusText = m_messageText;
-//    QString location = m_address;
-//
-//    int nameIndex = name.indexOf('\n');
-//    int updatedIndex = updated.indexOf('\n');
-//    int statusTextIndex = statusText.indexOf('\n');
-//    int locationIndex = location.indexOf('\n');
-//
-//    if (nameIndex > 0) {
-//        name.truncate(nameIndex);
-//        name.append("...");
-//    }
-//    if (updatedIndex > 0) {
-//        updated.truncate(updatedIndex);
-//        updated.append("...");
-//    }
-//    if (statusTextIndex > 0) {
-//        statusText.truncate(statusTextIndex);
-//        statusText.append("...");
-//    }
-//    if (locationIndex > 0) {
-//        location.truncate(locationIndex);
-//        location.append("...");
-//    }
-//
-//    m_shortenedName = nameLabelMetrics.elidedText(name, Qt::ElideRight, LABEL_MAX_WIDTH + 30);
-//    m_shortenedUpdated = otherLabelsMetrics.elidedText(updated, Qt::ElideRight, LABEL_MAX_WIDTH);
-//    m_shortenedStatusText = otherLabelsMetrics.elidedText(statusText, Qt::ElideRight,
-//                                                          LABEL_MAX_WIDTH);
-//    m_shortenedLocation = otherLabelsMetrics.elidedText(location, Qt::ElideRight, LABEL_MAX_WIDTH);
-//}
-//
-//void UserInfo::setText(bool expanded)
-//{
-//    qDebug() << __PRETTY_FUNCTION__;
-//
-//    if (expanded) {
-//        m_nameLabel->setText(m_userName);
-//        m_updatedLabel->setText(m_time);
-//        m_statusTextLabel->setText(m_messageText);
-//        m_locationLabel->setText(m_address);
-//    }
-//    else {
-//        m_nameLabel->setText(m_shortenedName);
-//        m_updatedLabel->setText(m_shortenedUpdated);
-//        m_statusTextLabel->setText(m_shortenedStatusText);
-//        m_locationLabel->setText(m_shortenedLocation);
-//    }
-//}
-
-//void UserInfo::mouseReleaseEvent(QMouseEvent *event)
-//{
-//    qDebug() << __PRETTY_FUNCTION__ << " " << event->pos();
-//
-//    if ((abs(m_mousePosition.y() - event->pos().y()) <= MOUSE_PRESS_AREA_WIDTH) &&
-//        (abs(m_mousePosition.x() - event->pos().x()) <= MOUSE_PRESS_AREA_HEIGHT)) {
-//        if (m_expanded) {
-//            setText(false);
-//            m_expanded = false;
-//        }
-//        else {
-//            setText(true);
-//            m_expanded = true;
-//        }
-//    }
-//}
+void UserInfo::shortenTexts()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    QFontMetrics nameLabelMetrics = m_nameLabel->fontMetrics();
+    QFontMetrics otherLabelsMetrics = m_locationLabel->fontMetrics();
+
+    QString name = m_userName;
+    QString updated = m_time;
+    QString statusText = m_messageText;
+    QString location = m_address;
+
+    int nameIndex = name.indexOf('\n');
+    int updatedIndex = updated.indexOf('\n');
+    int statusTextIndex = statusText.indexOf('\n');
+    int locationIndex = location.indexOf('\n');
+
+    if (nameIndex > 0) {
+        name.truncate(nameIndex);
+        name.append("...");
+    }
+    if (updatedIndex > 0) {
+        updated.truncate(updatedIndex);
+        updated.append("...");
+    }
+    if (statusTextIndex > 0) {
+        statusText.truncate(statusTextIndex);
+        statusText.append("...");
+    }
+    if (locationIndex > 0) {
+        location.truncate(locationIndex);
+        location.append("...");
+    }
+
+    m_shortenedName = nameLabelMetrics.elidedText(name, Qt::ElideRight, LABEL_MAX_WIDTH + 30);
+    m_shortenedUpdated = otherLabelsMetrics.elidedText(updated, Qt::ElideRight, LABEL_MAX_WIDTH);
+    m_shortenedStatusText = otherLabelsMetrics.elidedText(statusText, Qt::ElideRight,
+                                                          LABEL_MAX_WIDTH);
+    m_shortenedLocation = otherLabelsMetrics.elidedText(location, Qt::ElideRight, LABEL_MAX_WIDTH);
+}
+
+void UserInfo::setText(bool expanded)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    if (expanded) {
+        m_nameLabel->setText(m_userName);
+        m_updatedLabel->setText(m_time);
+        m_statusTextLabel->setText(m_messageText);
+        m_locationLabel->setText(m_address);
+    }
+    else {
+        m_nameLabel->setText(m_shortenedName);
+        m_updatedLabel->setText(m_shortenedUpdated);
+        m_statusTextLabel->setText(m_shortenedStatusText);
+        m_locationLabel->setText(m_shortenedLocation);
+    }
+}
+
+void UserInfo::mouseReleaseEvent(QMouseEvent *event)
+{
+    qDebug() << __PRETTY_FUNCTION__ << " " << event->pos();
+
+    if ((abs(m_mousePosition.y() - event->pos().y()) <= MOUSE_PRESS_AREA_WIDTH) &&
+        (abs(m_mousePosition.x() - event->pos().x()) <= MOUSE_PRESS_AREA_HEIGHT)) {
+        if (m_expanded) {
+            setText(false);
+            m_expanded = false;
+        }
+        else {
+            setText(true);
+            m_expanded = true;
+        }
+    }
+}
 void UserInfo::paintEvent(QPaintEvent *aPaintEvent)
 {
 //    Q_UNUSED(aPaintEvent);
@@ -277,6 +274,7 @@ void UserInfo::paintEvent(QPaintEvent *aPaintEvent)
     qDebug() << __PRETTY_FUNCTION__ << " " << aPaintEvent->rect();
 
     QPainter painter(this);
+
     QRect topRect = QRect(0, 0, ITEM_MIN_WIDTH, BACKGROUND_TOP_HEIGHT);
     QRect middleRect = QRect(0, topRect.bottom(), ITEM_MIN_WIDTH,
                              height() - BACKGROUND_TOP_HEIGHT - BACKGROUND_BOTTOM_HEIGHT);
index e9507ce..ef5b8cf 100644 (file)
@@ -58,13 +58,13 @@ protected:
     * @param event QMouseEvent mouse press event
     */
     void mousePressEvent(QMouseEvent *event);
-//    /**
-//    * @brief Call toggleHeight if mouse position is unchanged.
-//    *
-//    * Check if current mouse position is same as mouse release position.
-//    * @param event QMouseEvent mouse release event
-//    */
-//    void mouseReleaseEvent(QMouseEvent *event);
+    /**
+    * @brief Call toggleHeight if mouse position is unchanged.
+    *
+    * Check if current mouse position is same as mouse release position.
+    * @param event QMouseEvent mouse release event
+    */
+    void mouseReleaseEvent(QMouseEvent *event);
 
 /******************************************************************************
 * MEMBER FUNCTIONS AND SLOTS
@@ -96,7 +96,7 @@ public slots:
     * @param tim Reference to time when message was sent.
     */
     void setTime(const QString &tim);
-    /**
+   /**
     * @brief Sets the user name
     *
     * @param usernam Reference to user name
@@ -108,18 +108,18 @@ private slots:
     *
     */
     void messageUpdate();
-//    /**
-//    * @brief Set shortened or full-length text to labels.
-//    *
-//    * @param expanded true if full-length text is set, false otherwise
-//    */
-//    void setText(bool expanded);
-//    /**
-//    * @brief Set shortened texts from User data.
-//    *
-//    * Text length is defined by MAXIMUM_CHARS.
-//    */
-//    void shortenTexts();
+    /**
+    * @brief Set shortened or full-length text to labels.
+    *
+    * @param expanded true if full-length text is set, false otherwise
+    */
+    void setText(bool expanded);
+    /**
+    * @brief Set shortened texts from User data.
+    *
+    * Text length is defined by MAXIMUM_CHARS.
+    */
+    void shortenTexts();
     /**
     * @brief Slot function to forward friends status update signal
     *
@@ -154,7 +154,7 @@ private:
     QString m_address;
     QString m_time;
     QString m_messageText;
-    QString m_avatar;
+    QPixmap m_avatar;
     QString m_shortenedLocation;    ///< Shortened location text
     QString m_shortenedName;        ///< Shortened name text
     QString m_shortenedStatusText;  ///< Shortened status text
index a88a890..99eeaa8 100644 (file)
@@ -71,11 +71,11 @@ void UserInfoPanel::userDataReceived(User *user)
 {
     qDebug() << __PRETTY_FUNCTION__ << " " << user->name();
 
-    //m_userInfo->setUserName(user->name());
-//    m_userInfo->setAvatar(user->profileImage());
-//    m_userInfo->setMessageText(user->note());
-//    m_userInfo->setAddress(user->address());
-//    m_userInfo->setTime(user->timestamp());
+    m_userInfo->setUserName(user->name());
+    m_userInfo->setAvatar(user->profileImage());
+    m_userInfo->setMessageText(user->note());
+    m_userInfo->setAddress(user->address());
+    m_userInfo->setTime(user->timestamp());
 }
 
 void UserInfoPanel::reDrawUserPanel(int width, int height)