From: Katri Kaikkonen Date: Fri, 14 May 2010 12:42:11 +0000 (+0300) Subject: Merge branch 'master' into userinfo X-Git-Tag: v0.4~7^2~5 X-Git-Url: http://git.maemo.org/git/?a=commitdiff_plain;h=3c52f797538a08df8a7a8a9d58fd525d3625dac9;hp=66210d9650938f7d6254b4e58b801d3c52e4e53e;p=situare Merge branch 'master' into userinfo Conflicts: src/src.pro src/ui/mapviewscreen.cpp src/ui/mapviewscreen.h --- diff --git a/src/src.pro b/src/src.pro index eb321ae..9e80663 100644 --- a/src/src.pro +++ b/src/src.pro @@ -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 # ----------------------------------------------------------------- diff --git a/src/ui/mapviewscreen.cpp b/src/ui/mapviewscreen.cpp index c9dff1c..7aeb178 100644 --- a/src/ui/mapviewscreen.cpp +++ b/src/ui/mapviewscreen.cpp @@ -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&)), m_mapEngine, SIGNAL(friendsLocationsReady(QList&))); 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); diff --git a/src/ui/userinfo.cpp b/src/ui/userinfo.cpp index afb28fb..fa6c507 100644 --- a/src/ui/userinfo.cpp +++ b/src/ui/userinfo.cpp @@ -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); diff --git a/src/ui/userinfo.h b/src/ui/userinfo.h index e9507ce..ef5b8cf 100644 --- a/src/ui/userinfo.h +++ b/src/ui/userinfo.h @@ -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 diff --git a/src/ui/userpanel.cpp b/src/ui/userpanel.cpp index a88a890..99eeaa8 100644 --- a/src/ui/userpanel.cpp +++ b/src/ui/userpanel.cpp @@ -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)