#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
*
* @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);
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);
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");
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);
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)
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)
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));
}
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);
m_mousePosition = event->pos();
}
+void UserInfo::findButtonClicked()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ emit findUser(m_coordinates);
+}
+
void UserInfo::messageUpdate()
{
qDebug() << __PRETTY_FUNCTION__;
#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
* @param event QMouseEvent mouse press event
*/
void mousePressEvent(QMouseEvent *event);
+
/**
* @brief Call toggleHeight if mouse position is unchanged.
*
* @param event QMouseEvent mouse release event
*/
void mouseReleaseEvent(QMouseEvent *event);
+
/**
* @brief This function is called when the widget is drawn
*
/**
* @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
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);
private slots:
/**
+ * @brief Slot for find button click
+ */
+ void findButtonClicked();
+
+ /**
* @brief Slot function to forward messageUpdate launch signal
*
*/
******************************************************************************/
signals:
/**
+ * @brief Signal for finding user.
+ *
+ * @param coordinates user geo coordinates
+ */
+ void findUser(const QPointF &coordinates);
+
+ /**
* @brief Signal for refreshing user data.
*
*/
******************************************************************************/
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
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