Review and fixes
authorKatri Kaikkonen <katri.kaikkonen@ixonos.com>
Fri, 27 Aug 2010 12:24:25 +0000 (15:24 +0300)
committerKatri Kaikkonen <katri.kaikkonen@ixonos.com>
Fri, 27 Aug 2010 12:24:25 +0000 (15:24 +0300)
Reviewed by Sami Rämö

src/ui/updatelocation/updatelocationdialog.h
src/ui/userinfo.cpp
src/ui/userinfo.h

index 8416c50..2731061 100644 (file)
 #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
@@ -42,8 +44,6 @@ class QTextEdit;
 * @brief Update Location UI\r
 *\r
 * UI for update location functionality.\r
-*\r
-* @class UpdateLocationDialog\r
 */\r
 class UpdateLocationDialog : public QDialog\r
 {\r
@@ -67,7 +67,7 @@ public:
  ******************************************************************************/\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
@@ -75,19 +75,19 @@ public slots:
 \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
@@ -97,7 +97,7 @@ private slots:
  ******************************************************************************/\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
@@ -108,10 +108,10 @@ signals:
  * 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
index d5e59af..0465bf7 100644 (file)
@@ -184,11 +184,11 @@ void UserInfo::messageUpdate()
     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)));
@@ -209,12 +209,11 @@ void UserInfo::mouseReleaseEvent(QMouseEvent *event)
 {
     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;
@@ -226,9 +225,9 @@ void UserInfo::mouseReleaseEvent(QMouseEvent *event)
     }
 }
 
-void UserInfo::paintEvent(QPaintEvent *aPaintEvent)
+void UserInfo::paintEvent(QPaintEvent *event)
 {
-    qDebug() << __PRETTY_FUNCTION__ << " " << aPaintEvent->rect();
+    qDebug() << __PRETTY_FUNCTION__ << " " << event->rect();
 
     QPainter painter(this);
 
@@ -281,7 +280,6 @@ void UserInfo::setMessageText(const QString &text)
     }
 
     m_messageText = list.join(" ");
-    m_statusTextLabel->setText(m_messageText);
     setText(false);
 }
 
@@ -297,14 +295,10 @@ void UserInfo::setText(bool expanded)
 {
     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)
@@ -319,7 +313,7 @@ void UserInfo::setUserName(const QString &name)
     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)
@@ -327,15 +321,15 @@ QString UserInfo::shortenText(const QLabel *label, const QString &text, int text
     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
@@ -346,11 +340,10 @@ 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);
         }
     }
 
index 0e51cd7..9e582aa 100644 (file)
@@ -77,9 +77,9 @@ protected:
     /**
      * @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
@@ -143,7 +143,6 @@ public slots:
     void setMessageText(const QString &text);
 
 private:
-
     /**
      * @brief reads Unsend message from settings at startup
      */
@@ -157,16 +156,22 @@ private:
     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;