#define UPDATELOCATIONDIALOG_H\r
\r
#include <QDialog>\r
+\r
#ifdef Q_WS_MAEMO_5\r
#include <QAbstractKineticScroller>\r
#endif // Q_WS_MAEMO_5\r
+\r
#include "texteditautoresizer.h"\r
\r
class QCheckBox;\r
* @brief Update Location UI\r
*\r
* UI for update location functionality.\r
-*\r
-* @class UpdateLocationDialog\r
*/\r
class UpdateLocationDialog : public QDialog\r
{\r
******************************************************************************/\r
public slots:\r
/**\r
- * @brief Public slot, which is used to set the street address to location label\r
+ * @brief Used to set the street address to location label\r
*\r
* @param address Street address, result from SituareService's reverseGeo\r
*/\r
\r
private slots:\r
/**\r
- * @brief Private slot, which is used to connect send button\r
+ * @brief Used to connect send button\r
*\r
*/\r
void sendUpdate();\r
\r
/**\r
- * @brief Private slot, which is used to get changes in messagetext\r
+ * @brief Used to get changes in messagetext\r
*\r
*/\r
void textChanged();\r
\r
/**\r
- * @brief Private slot, which is used to clear default messagetext\r
+ * @brief Used to clear default messagetext\r
*\r
*/\r
void textSelectionChanged();\r
******************************************************************************/\r
signals:\r
/**\r
- * @brief Signal Signal for requestLocationUpdate from SituareEngine via MainWindow class\r
+ * @brief Routing signal for requestLocationUpdate to SituareEngine via MainWindow class\r
*\r
* @param status Status message\r
* @param publish Publish on Facebook\r
* DATA MEMBERS\r
******************************************************************************/\r
private:\r
- QCheckBox *m_checkBox; ///< Pointer to CheckBox\r
- QLabel *m_locationLabel; ///< Pointer to locationLabel\r
- QLabel *m_charCountLabel; ///< Pointer to locationLabel\r
- QTextEdit *m_textEdit; ///< Pointer to TextEdit\r
+ QCheckBox *m_checkBox; ///< Pointer to CheckBox\r
+ QLabel *m_charCountLabel; ///< Pointer to character counter label\r
+ QLabel *m_locationLabel; ///< Pointer to locationLabel\r
+ QTextEdit *m_textEdit; ///< Pointer to TextEdit\r
};\r
\r
#endif // UPDATELOCATIONDIALOG_H\r
connect(this, SIGNAL(reverseGeoReady(QString)),
m_updateLocation, SLOT(setAddress(QString)));
- connect(m_updateLocation, SIGNAL(statusUpdate(QString,bool)),
- this, SIGNAL(statusUpdate(QString,bool)));
+ connect(m_updateLocation, SIGNAL(statusUpdate(QString, bool)),
+ this, SIGNAL(statusUpdate(QString, bool)));
- connect(m_updateLocation, SIGNAL(statusUpdate(QString,bool)),
- this, SLOT(backupUpdateLocationDialogData(QString,bool)));
+ connect(m_updateLocation, SIGNAL(statusUpdate(QString, bool)),
+ this, SLOT(backupUpdateLocationDialogData(QString, bool)));
connect(m_updateLocation, SIGNAL(finished(int)),
this, SLOT(updateLocationDialogFinished(int)));
{
qDebug() << __PRETTY_FUNCTION__ << " " << event->pos();
-
- const int MOUSE_PRESS_AREA_WIDTH = 20;
const int MOUSE_PRESS_AREA_HEIGHT = 20;
+ const int MOUSE_PRESS_AREA_WIDTH = 20;
- if ((abs(m_mousePosition.y() - event->pos().y()) <= MOUSE_PRESS_AREA_WIDTH) &&
- (abs(m_mousePosition.x() - event->pos().x()) <= MOUSE_PRESS_AREA_HEIGHT)) {
+ 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;
}
}
-void UserInfo::paintEvent(QPaintEvent *aPaintEvent)
+void UserInfo::paintEvent(QPaintEvent *event)
{
- qDebug() << __PRETTY_FUNCTION__ << " " << aPaintEvent->rect();
+ qDebug() << __PRETTY_FUNCTION__ << " " << event->rect();
QPainter painter(this);
}
m_messageText = list.join(" ");
- m_statusTextLabel->setText(m_messageText);
setText(false);
}
{
qDebug() << __PRETTY_FUNCTION__;
- if (expanded) {
+ if (expanded)
m_statusTextLabel->setText(m_messageText);
- }
- else {
- m_nameLabel->setText(shortenText(m_nameLabel, m_userName, LABEL_MAX_WIDTH));
- m_statusTextLabel->setText(shortenText(m_statusTextLabel, m_messageText,
- LABEL_MAX_WIDTH));
- }
+ else
+ m_statusTextLabel->setText(shortenText(m_statusTextLabel, m_messageText, LABEL_MAX_WIDTH));
}
void UserInfo::setTime(const QString &time)
qDebug() << __PRETTY_FUNCTION__;
m_userName = name;
- setText(false);
+ m_nameLabel->setText(shortenText(m_nameLabel, m_userName, LABEL_MAX_WIDTH));
}
QString UserInfo::shortenText(const QLabel *label, const QString &text, int textMaxWidth)
qDebug() << __PRETTY_FUNCTION__;
QFontMetrics labelMetrics = label->fontMetrics();
- QString textParam = text;
- int index = textParam.indexOf('\n');
+ QString copiedText = text;
+ int index = copiedText.indexOf('\n');
- if (index > 0) {
- textParam.truncate(index);
- textParam.append("...");
- }
+ if (index >= 0) {
+ copiedText.truncate(index);
+ copiedText.append("...");
+ }
- return labelMetrics.elidedText(textParam, Qt::ElideRight, textMaxWidth);
+ return labelMetrics.elidedText(copiedText, Qt::ElideRight, textMaxWidth);
}
QString UserInfo::splitWord(const QString &word) const
QString temp;
for (int i = 0; i < word.length(); i++) {
- if (fontMetrics().width(temp.append(word.at(i))) > LABEL_MAX_WIDTH)
- {
- temp.append(" ");
- result.append(temp);
- temp.clear();
+ if (fontMetrics().width(temp.append(word.at(i))) > LABEL_MAX_WIDTH) {
+ result.append(temp.left(temp.length() - 1));
+ result.append(" ");
+ temp.remove(0, temp.length() - 1);
}
}
/**
* @brief This function is called when the widget is drawn
*
- * @param aPaintEvent Pointer to paint event
+ * @param event Pointer to paint event
*/
- void paintEvent(QPaintEvent *aPaintEvent);
+ void paintEvent(QPaintEvent *event);
/******************************************************************************
* MEMBER FUNCTIONS AND SLOTS
void setMessageText(const QString &text);
private:
-
/**
* @brief reads Unsend message from settings at startup
*/
void setText(bool expanded);
/**
- * @brief Set shortened texts from User data.
+ * @brief Elides long text
*
- * Text length is defined by MAXIMUM_CHARS.
+ * @param label get the fontmetrics from the label
+ * @param text long text to be shortened
+ * @param textMaxWidth label width
+ * @returns shortened text
*/
QString shortenText(const QLabel *label, const QString &text, int textMaxWidth);
/**
* @brief Split too long words.
*
- * Word Reference to long word
+ * Splits long word to several by adding extra spaces
+ *
+ * @param word long word to be splitted
+ * @returns splitted word
*/
QString splitWord(const QString &word) const;