m_nameLabel = new QLabel();
m_nameLabel->setFixedHeight(IMAGE_HEIGHT);
-
-
+ m_nameLabel->setAlignment(Qt::AlignHCenter);
m_updatedLabel = new QLabel();
m_updatedLabel->setWordWrap(true);
connect(updateStatusMessageButton,SIGNAL(clicked()),
this,SLOT(messageUpdate()));
connect(updateFriendsButton,SIGNAL(clicked()),
- this,SLOT(updateFriendsStatus()));
+ this, SIGNAL(refreshUserData()));
- setFont(NOKIA_FONT_SMALL);
+ this->setFont(NOKIA_FONT_SMALL);
m_nameLabel->setFont(NOKIA_FONT_NORMAL);
QPalette itemPalette = palette();
itemPalette.setColor(QPalette::Foreground, COLOR_GRAY);
namePalette.setColor(QPalette::Foreground, Qt::white);
m_nameLabel->setPalette(namePalette);
- m_nameLabel->setText("");
-
- this->setMaximumHeight(300);
+ this->setMinimumHeight(300);
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");
}
-
-
void UserInfo::setUserName(const QString &name)
{
qDebug() << __PRETTY_FUNCTION__;
qDebug() << name;
- m_nameLabel->setText(name);
+// m_nameLabel->setText(name);
// shortenTexts();
}
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);
}
if(m_messageText == text)
return;
m_messageText = text;
- m_statusTextLabel->setText(m_messageText);
+// m_statusTextLabel->setText(m_messageText);
// shortenTexts();
}
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();
}
if(m_time == tim)
return;
m_time = tim;
- m_updatedLabel->setText(m_time);
-// shortenTexts();
+// m_updatedLabel->setText(m_time);
+ shortenTexts();
+ setText(false);
}
-//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::shortenTexts()
+{
+ qDebug() << __PRETTY_FUNCTION__;
-//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)) {
+ 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;
// setText(true);
// m_expanded = true;
// }
-// }
-//}
+ }
+}
void UserInfo::paintEvent(QPaintEvent *aPaintEvent)
{
// Q_UNUSED(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);
void UserInfo::messageUpdate()
{
qDebug() << __PRETTY_FUNCTION__;
+
m_locationDialog = new UpdateLocationDialog(this);
+ emit requestReverseGeo();
+
+ connect(this, SIGNAL(reverseGeoReady(QString)),
+ m_locationDialog, SLOT(setAddress(QString)));
+ connect(m_locationDialog, SIGNAL(statusUpdate(QString, bool)),
+ this, SIGNAL(statusUpdate(QString, bool)));
+
m_locationDialog->show();
}
-void UserInfo::updateFriendsStatus()
-{
- qDebug() << __PRETTY_FUNCTION__;
- //emit launchUpdateFriendsStatus();
-}
+//void UserInfo::updateFriendsStatus()
+//{
+// qDebug() << __PRETTY_FUNCTION__;
+// //emit launchUpdateFriendsStatus();
+//}