USA.
*/
+#include <QFormLayout>
+#include <QLabel>
+#include <QMouseEvent>
+#include <QPainter>
+#include <QSettings>
+#include <QVBoxLayout>
+
#include "common.h"
#include "imagebutton.h"
-#include "../user/user.h"
+#include "user/user.h"
+
#include "userinfo.h"
-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 int ICON_HEIGHT = 24; ///< Icon height
-const int ICON_WIDTH = 24; ///< Icon 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
+const int BACKGROUND_WIDTH = 368; ///< Width for item
+const int BACKGROUND_TOP_HEIGHT = 20; ///< Height for item top
+const int BACKGROUND_BOTTOM_HEIGHT = 15; ///< Height for item bottom
+const int ICON_HEIGHT = 24; ///< Icon height
+const int ICON_WIDTH = 24; ///< Icon width
+const int MARGIN = 5; ///< Icon margin
+const int LINE_LENGTH = 27; ///< Line length
+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
/**
* @var LABEL_MAX_WIDTH
UserInfo::UserInfo(QWidget *parent)
: QWidget(parent),
m_expanded(false),
- m_messageUpdateVerified(false),
m_updateLocation(0)
{
qDebug() << __PRETTY_FUNCTION__;
infoLayout->setMargin(0);
infoLayout->setSpacing(0);
- QHBoxLayout *buttonLayout = new QHBoxLayout();
- buttonLayout->setMargin(0);
- buttonLayout->setSpacing(0);
-
QLabel *envelopeLabel = new QLabel();
envelopeLabel->setPixmap(QPixmap(":/res/images/envelope.png"));
envelopeLabel->setContentsMargins(0, 0, MARGIN, 0);
m_updatedLabel = new QLabel();
m_updatedLabel->setWordWrap(true);
- ImageButton *updateFriendsButton = new ImageButton(this, ":/res/images/refresh.png",
- ":/res/images/refresh_s.png");
- ImageButton *updateStatusMessageButton = new ImageButton(this, ":/res/images/send_position.png",
- ":/res/images/send_position_s.png");
-
- buttonLayout->addWidget(updateFriendsButton);
- buttonLayout->addWidget(updateStatusMessageButton);
-
infoLayout->addRow(envelopeLabel, m_statusTextLabel);
infoLayout->addRow(compassLabel, m_locationLabel);
infoLayout->addRow(clockLabel, m_updatedLabel);
verticalLayout->addWidget(m_findButton, 0, Qt::AlignHCenter);
verticalLayout->addWidget(m_nameLabel, 0, Qt::AlignHCenter);
verticalLayout->addLayout(infoLayout);
- 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()));
namePalette.setColor(QPalette::Foreground, Qt::white);
m_nameLabel->setPalette(namePalette);
- 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");
+ 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");
restoreUnsendMessage();
}
QSettings settings(DIRECTORY_NAME, FILE_NAME);
- if (!m_backupMessage.isEmpty()) {
+ if (!m_backupMessage.isEmpty()) {
settings.setValue(USER_UNSEND_MESSAGE, m_backupMessage.toAscii());
settings.setValue(USER_UNSEND_MESSAGE_PUBLISH, m_backupFacebookPublishPolicity);
} else {
m_locationLabel->setText(address);
}
-void UserInfo::setCoordinates(const QPointF &coordinates)
+void UserInfo::setCoordinates(const GeoCoordinate &coordinates)
{
qDebug() << __PRETTY_FUNCTION__;
qDebug() << __PRETTY_FUNCTION__;
m_messageText = text;
+ m_expandedMessageText.clear();
+ QString temp = "";
+ for(int i=0;i < text.length();i++) {
+ if(fontMetrics().width(temp.append(text.at(i))) > 170) {
+ temp.append("\n");
+ if(temp.startsWith(QString(" ")))
+ temp.remove(0, 1);
+
+ m_expandedMessageText.append(temp);
+ temp.clear();
+ }
+ }
+ m_expandedMessageText.append(temp);
setText(false);
}
{
qDebug() << __PRETTY_FUNCTION__;
- m_findButton->setButtonIcon(image);
+ if(!image.isNull())
+ m_findButton->setButtonIcon(image);
}
void UserInfo::setTime(const QString &time)
qDebug() << __PRETTY_FUNCTION__;
if (expanded) {
- m_nameLabel->setText(m_userName);
- m_statusTextLabel->setText(m_messageText);
+ m_statusTextLabel->setText(m_expandedMessageText);
}
else {
m_nameLabel->setText(shortenText(m_nameLabel, m_userName, LABEL_MAX_WIDTH));
m_backupMessage = status;
m_backupFacebookPublishPolicity = publish;
-
- m_messageUpdateVerified = false;
}
void UserInfo::clearUpdateLocationDialogData()
{
qDebug() << __PRETTY_FUNCTION__;
- emit requestReverseGeo();
-
delete m_updateLocation;
m_updateLocation = new UpdateLocationDialog(m_backupMessage, m_backupFacebookPublishPolicity,
this);
this, SLOT(updateLocationDialogFinished(int)));
m_updateLocation->show();
+
+ emit requestReverseGeo();
}
void UserInfo::paintEvent(QPaintEvent *aPaintEvent)
QPainter painter(this);
QRect topRect = QRect(0, MARGIN, BACKGROUND_WIDTH, BACKGROUND_TOP_HEIGHT);
+///< @todo Overlaps with topRect?
QRect middleRect = QRect(0, topRect.bottom(), BACKGROUND_WIDTH,
- height() - BACKGROUND_TOP_HEIGHT - BACKGROUND_BOTTOM_HEIGHT);
+ this->height() - BACKGROUND_TOP_HEIGHT - BACKGROUND_BOTTOM_HEIGHT);
+///< @todo Overlaps with middleRect
QRect bottomRect = QRect(topRect.left(), middleRect.bottom(), BACKGROUND_WIDTH,
BACKGROUND_BOTTOM_HEIGHT);
qDebug() << __PRETTY_FUNCTION__;
QFontMetrics labelMetrics = label->fontMetrics();
-
QString textParam = text;
int index = textParam.indexOf('\n');
+ int textWidth = fontMetrics().width(textParam);
- if (index > 0) {
- textParam.truncate(index);
- textParam.append("...");
- }
+ if (index > 0) {
+ textParam.truncate(index);
+ textParam.append("...");
+ }
+ if (textWidth > 250) ///< @todo magic number
+ textParam.insert(LINE_LENGTH, QString("\n"));
return labelMetrics.elidedText(textParam, Qt::ElideRight, textMaxWidth);
}
-void UserInfo::verifyMessageUpdateFailure(const int error)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- Q_UNUSED(error);
-
- if (!m_messageUpdateVerified) {
-
- if (m_messageText != m_backupMessage && !m_backupMessage.isEmpty())
- emit notificateUpdateFailing(tr("Location update failed, please try again"), false);
- }
-
- m_messageUpdateVerified = true;
-}
-
void UserInfo::updateLocationDialogFinished(int reason)
{
qDebug() << __PRETTY_FUNCTION__;
m_updateLocation->deleteLater();
m_updateLocation = 0;
}
-
}