Moved location update logic to new class called UpdateLocation.
authorSami Rämö <sami.ramo@ixonos.com>
Fri, 12 Nov 2010 11:24:00 +0000 (13:24 +0200)
committerSami Rämö <sami.ramo@ixonos.com>
Fri, 12 Nov 2010 11:24:00 +0000 (13:24 +0200)
13 files changed:
src/common.h
src/engine/engine.cpp
src/engine/updatelocation.cpp [new file with mode: 0644]
src/engine/updatelocation.h [new file with mode: 0644]
src/facebookservice/facebookauthentication.cpp
src/situareservice/situareservice.cpp
src/situareservice/situareservice.h
src/src.pro
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/updatelocation/updatelocationdialog.cpp
src/ui/updatelocation/updatelocationdialog.h
src/ui/userinfo.cpp

index 9c27d2b..8c0f9e0 100644 (file)
@@ -33,8 +33,6 @@ const QString SETTINGS_APPLICATION_NAME = "Situare";
 // QSettings common values
 const QString SETTINGS_AUTOMATIC_UPDATE_ENABLED = "SETTINGS_AUTOMATIC_UPDATE_ENABLED";
 const QString SETTINGS_AUTOMATIC_UPDATE_INTERVAL = "SETTINGS_AUTOMATIC_UPDATE_INTERVAL";
-const QString USER_UNSEND_MESSAGE = "UNSEND_MESSAGE_CONTENT";
-const QString USER_UNSEND_MESSAGE_PUBLISH = "UNSEND_MESSAGE_PUBLISH_POLICITY";
 
 // Misc values
 const int DEFAULT_SCREEN_WIDTH = 800;           ///< Default N900 screen width
index 7f2f32d..6b68d34 100644 (file)
@@ -376,7 +376,6 @@ void SituareEngine::onLogout()
     qDebug() << __PRETTY_FUNCTION__;
 
     m_ui->loggedIn(false);
-    m_ui->clearUpdateLocationDialogData();
     m_situareService->updateSession(""); // empty session string means logged out
     m_automaticUpdateFirstStart = true;
 }
@@ -626,7 +625,7 @@ void SituareEngine::signalsFromMainWindow()
     connect(m_ui, SIGNAL(requestReverseGeo()),
             this, SLOT(requestAddress()));
 
-    connect(m_ui, SIGNAL(statusUpdate(QString,bool)),
+    connect(m_ui, SIGNAL(locationUpdate(QString,bool)),
             this, SLOT(requestUpdateLocation(QString,bool)));
 
     connect(m_ui, SIGNAL(enableAutomaticLocationUpdate(bool, int)),
@@ -744,7 +743,7 @@ void SituareEngine::signalsFromSituareService()
             this, SLOT(updateWasSuccessful()));
 
     connect(m_situareService, SIGNAL(updateWasSuccessful()),
-            m_ui, SLOT(clearUpdateLocationDialogData()));
+            m_ui, SIGNAL(updateWasSuccessful()));
 }
 
 void SituareEngine::startAutomaticUpdate()
diff --git a/src/engine/updatelocation.cpp b/src/engine/updatelocation.cpp
new file mode 100644 (file)
index 0000000..4997316
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
+
+        Sami Rämö - sami.ramo@ixonos.com
+
+    Situare is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License
+    version 2 as published by the Free Software Foundation.
+
+    Situare is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with Situare; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+    USA.
+*/
+
+#include <QDebug>
+#include <QSettings>
+
+#include "common.h"
+
+#include "updatelocation.h"
+
+const QString UNSENT_MESSAGE_SETTING = "UNSENT_MESSAGE";
+const QString UNSENT_MESSAGE_PUBLISH_SETTING = "UNSENT_MESSAGE_PUBLISH";
+
+UpdateLocation::UpdateLocation(QObject *parent) :
+    QObject(parent),
+    m_publish(false)
+{
+    qWarning() << __PRETTY_FUNCTION__;
+
+    QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
+    m_message = settings.value(UNSENT_MESSAGE_SETTING).toString();
+    m_publish = settings.value(UNSENT_MESSAGE_PUBLISH_SETTING, false).toBool();
+}
+
+UpdateLocation::~UpdateLocation()
+{
+    qWarning() << __PRETTY_FUNCTION__;
+
+    QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
+
+    if (!m_message.isEmpty()) {
+        settings.setValue(UNSENT_MESSAGE_SETTING, m_message);
+        settings.setValue(UNSENT_MESSAGE_PUBLISH_SETTING, m_publish);
+    } else {
+        settings.remove(UNSENT_MESSAGE_SETTING);
+        settings.remove(UNSENT_MESSAGE_PUBLISH_SETTING);
+    }
+}
+
+void UpdateLocation::clear()
+{
+    qWarning() << __PRETTY_FUNCTION__;
+
+    m_message.clear();
+    m_publish = false;
+}
+
+QString UpdateLocation::message() const
+{
+    qWarning() << __PRETTY_FUNCTION__;
+
+    return m_message;
+}
+
+void UpdateLocation::send()
+{
+    qWarning() << __PRETTY_FUNCTION__;
+
+    emit locationUpdate(m_message, m_publish);
+}
+
+void UpdateLocation::setMessage(const QString &message)
+{
+    qWarning() << __PRETTY_FUNCTION__;
+
+    if (message != m_message) {
+        m_message = message;
+        emit messageChanged();
+    }
+}
+
+bool UpdateLocation::publish() const
+{
+    qWarning() << __PRETTY_FUNCTION__;
+
+    return m_publish;
+}
+
+void UpdateLocation::setPublish(bool publish)
+{
+    qWarning() << __PRETTY_FUNCTION__;
+
+    if (publish != m_publish) {
+        m_publish = publish;
+        emit publishChanged();
+    }
+}
diff --git a/src/engine/updatelocation.h b/src/engine/updatelocation.h
new file mode 100644 (file)
index 0000000..8140644
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
+
+        Sami Rämö - sami.ramo@ixonos.com
+
+    Situare is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License
+    version 2 as published by the Free Software Foundation.
+
+    Situare is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with Situare; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+    USA.
+*/
+
+
+#ifndef UPDATELOCATION_H
+#define UPDATELOCATION_H
+
+#include <QObject>
+
+/**
+  * @brief Controller for location update
+  *
+  * @author Sami Rämö (at) ixonos.com
+  */
+class UpdateLocation : public QObject
+{
+    Q_OBJECT
+
+    /**
+    * @brief Message text
+    *
+    * @property message
+    */
+    Q_PROPERTY(QString message READ message WRITE setMessage NOTIFY messageChanged)
+
+    /**
+    * @brief Publish on FB wall setting
+    *
+    * @property publish
+    */
+    Q_PROPERTY(bool publish READ publish WRITE setPublish NOTIFY publishChanged)
+
+public:
+    /**
+      * @brief Constructor
+      *
+      * Read unsent message from settigs.
+      */
+    explicit UpdateLocation(QObject *parent = 0);
+
+    /**
+      * @brief Destructor
+      *
+      * Save unsent message to settings.
+      */
+    ~UpdateLocation();
+
+    /**
+      * @brief Getter for message.
+      *
+      * @returns Message
+      */
+    QString message() const;
+
+    /**
+      * @brief Getter for publish setting
+      *
+      * @returns True is update should be published on FB wall.
+      */
+    bool publish() const;
+
+public slots:
+    /**
+      * @brief Clear data.
+      */
+    void clear();
+
+    /**
+      * @brief Send location update
+      *
+      * Emits locationUpdate() signal.
+      */
+    void send();
+
+    /**
+      * @brief Setter for message
+      *
+      * @param message New message.
+      */
+    void setMessage(const QString &message);
+
+    /**
+      * @brief Setter for publish setting
+      *
+      * @param publish True is update should be published on FB wall.
+      */
+    void setPublish(bool publish);
+
+signals:
+    /**
+    * @brief Send location update
+    *
+    * @param status Status message
+    * @param publish Publish on Facebook?
+    */
+    void locationUpdate(const QString &status, bool publish);
+
+    /**
+      * @brief Notifies that message has changed
+      */
+    void messageChanged();
+
+    /**
+      * @brief Notifies that publish setting has changed
+      */
+    void publishChanged();
+
+private:
+    bool m_publish;         ///< Should the update be published on FB wall
+    QString m_message;      ///< Location update message
+};
+
+#endif // UPDATELOCATION_H
index 4579725..dce4aeb 100644 (file)
@@ -67,15 +67,12 @@ void FacebookAuthentication::browserDestroyed()
 
 void FacebookAuthentication::clearAccountInformation(bool clearUserInformation)
 {
+    /// @todo Parameter not needed
     qWarning() << __PRETTY_FUNCTION__ << "clearUserInformation:" << clearUserInformation;
 
-    QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
-
-    settings.remove(USER_UNSEND_MESSAGE);
-    settings.remove(USER_UNSEND_MESSAGE_PUBLISH);
-
     if (clearUserInformation) {
         NetworkCookieJar::clearCookiesSetting();
+        QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
         settings.remove(SETTINGS_AUTOMATIC_UPDATE_ENABLED);
         settings.remove(SETTINGS_AUTOMATIC_UPDATE_INTERVAL);
     }
index f632495..78f212e 100644 (file)
@@ -111,6 +111,8 @@ void SituareService::buildRequest(const QString &script, const QHash<QString, QS
         }
     }
 
+    /// @todo BUG: Url parameter strings are not url escaped
+
 //    qWarning() << __PRETTY_FUNCTION__ << "request url with parameters:" << url;
 
     if (!m_session.isEmpty()) {
index 1f8a171..a740c48 100644 (file)
@@ -204,7 +204,6 @@ signals:
 
     /**
     * @brief Signals when updateLocation request finished successfully
-    *
     */
     void updateWasSuccessful();
 
index 4337dda..4b3c123 100644 (file)
@@ -83,7 +83,8 @@ SOURCES += main.cpp \
     ui/zoombutton.cpp \
     ui/zoombuttonpanel.cpp \
     user/user.cpp \
-    ui/listitemcontextbuttonbar.cpp
+    ui/listitemcontextbuttonbar.cpp \
+    engine/updatelocation.cpp
 HEADERS += application.h \
     common.h \
     coordinates/geocoordinate.h \
@@ -168,7 +169,8 @@ HEADERS += application.h \
     ui/zoombutton.h \
     ui/zoombuttonpanel.h \
     user/user.h \
-    ui/listitemcontextbuttonbar.h
+    ui/listitemcontextbuttonbar.h \
+    engine/updatelocation.h
 QT += network \
     webkit
 DEFINES += QT_NO_DEBUG_OUTPUT
index aeaedac..e149901 100644 (file)
@@ -33,6 +33,7 @@
 #include <QMessageBox>
 
 #include "common.h"
+#include "engine/updatelocation.h"
 #include "error.h"
 #include "friendlistpanel.h"
 #include "fullscreenbutton.h"
@@ -77,7 +78,7 @@ MainWindow::MainWindow(QWidget *parent)
       m_fullScreenButton(0),
       m_indicatorButtonPanel(0),
       m_mapScale(0),
-      m_updateLocation(0)
+      m_updateLocationController(0)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -126,16 +127,6 @@ MainWindow::~MainWindow()
 
     qDeleteAll(m_error_queue.begin(), m_error_queue.end());
     m_error_queue.clear();
-
-    QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
-
-    if (!m_backupMessage.isEmpty()) {
-        settings.setValue(USER_UNSEND_MESSAGE, m_backupMessage.toAscii());
-        settings.setValue(USER_UNSEND_MESSAGE_PUBLISH, m_backupFacebookPublishPolicity);
-    } else {
-        settings.remove(USER_UNSEND_MESSAGE);
-        settings.remove(USER_UNSEND_MESSAGE_PUBLISH);
-    }
 }
 
 void MainWindow::automaticUpdateDialogFinished(int result)
@@ -153,14 +144,6 @@ void MainWindow::automaticUpdateDialogFinished(int result)
     m_automaticUpdateLocationDialog->deleteLater();
 }
 
-void MainWindow::backupUpdateLocationDialogData(const QString &status, bool publish)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    m_backupMessage = status;
-    m_backupFacebookPublishPolicity = publish;
-}
-
 void MainWindow::buildCrosshair()
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -507,14 +490,6 @@ void MainWindow::buildZoomButtonPanel()
             this, SIGNAL(draggingModeTriggered()));
 }
 
-void MainWindow::clearUpdateLocationDialogData()
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    m_backupMessage.clear();
-    m_backupFacebookPublishPolicity = false;
-}
-
 void MainWindow::createMenus()
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -684,6 +659,7 @@ void MainWindow::loggedIn(bool logged)
     } else {
         m_loginAct->setText(tr("Login"));
         m_userInfoPanel->showUserInfo(false);
+        m_updateLocationController->clear();
     }
     updateItemVisibility(logged);
 }
@@ -753,15 +729,6 @@ void MainWindow::readAutomaticLocationUpdateSettings()
     }
 }
 
-void MainWindow::restoreUnsendMessage()
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
-    m_backupMessage = settings.value(USER_UNSEND_MESSAGE).toString();
-    m_backupFacebookPublishPolicity = settings.value(USER_UNSEND_MESSAGE_PUBLISH, false).toBool();
-}
-
 void MainWindow::setCrosshairVisibility(bool visibility)
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -857,23 +824,23 @@ void MainWindow::showUpdateLocationDialog()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    delete m_updateLocation;
-    m_updateLocation = new UpdateLocationDialog(m_backupMessage, m_backupFacebookPublishPolicity,
-                                                this);
-
-    connect(this, SIGNAL(reverseGeoReady(QString)),
-            m_updateLocation, SLOT(setAddress(QString)));
-
-    connect(m_updateLocation, SIGNAL(statusUpdate(QString, bool)),
-            this, SIGNAL(statusUpdate(QString, bool)));
+    if (!m_updateLocationController) {
+        m_updateLocationController = new UpdateLocation(this);
+        if (!m_updateLocationController)
+            return;
+        else
+            connect(this, SIGNAL(updateWasSuccessful()), m_updateLocationController, SLOT(clear()));
+            connect(m_updateLocationController, SIGNAL(locationUpdate(QString,bool)),
+                    this, SIGNAL(locationUpdate(QString,bool)));
+    }
 
-    connect(m_updateLocation, SIGNAL(statusUpdate(QString, bool)),
-            this, SLOT(backupUpdateLocationDialogData(QString, bool)));
+    UpdateLocationDialog *updateLocationDialog
+            = new UpdateLocationDialog(m_updateLocationController, this);
 
-    connect(m_updateLocation, SIGNAL(finished(int)),
-            this, SLOT(updateLocationDialogFinished(int)));
+    connect(this, SIGNAL(reverseGeoReady(QString)),
+            updateLocationDialog, SLOT(setAddress(QString)));
 
-    m_updateLocation->show();
+    updateLocationDialog->show();
 
     emit requestReverseGeo();
 }
@@ -929,27 +896,3 @@ void MainWindow::updateItemVisibility(bool loggedIn)
 
     m_tabbedPanel->setTabsEnabled(m_situareTabsIndexes, loggedIn);
 }
-
-void MainWindow::updateLocationDialogFinished(int reason)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    Q_UNUSED(reason);
-
-    if (m_updateLocation) {
-        disconnect(this, SIGNAL(reverseGeoReady(QString)),
-                m_updateLocation, SLOT(setAddress(QString)));
-
-        disconnect(m_updateLocation, SIGNAL(statusUpdate(QString,bool)),
-                this, SIGNAL(statusUpdate(QString,bool)));
-
-        disconnect(m_updateLocation, SIGNAL(statusUpdate(QString,bool)),
-                this, SLOT(backupUpdateLocationDialogData(QString,bool)));
-
-        disconnect(m_updateLocation, SIGNAL(finished(int)),
-                this, SLOT(updateLocationDialogFinished(int)));
-
-        m_updateLocation->deleteLater();
-        m_updateLocation = 0;
-    }
-}
index c9e4caf..ea5683a 100644 (file)
@@ -56,7 +56,7 @@ class SceneCoordinate;
 class SettingsDialog;
 class SituareService;
 class TabbedPanel;
-class UpdateLocationDialog;
+class UpdateLocation;
 class User;
 class UserInfoPanel;
 class ZoomButtonPanel;
@@ -145,15 +145,6 @@ public:
 
 public slots:
     /**
-     * @brief Saves status message and Facebook publish setting
-     *
-     * @param status message that user sends. Message is stored to m_backupMessage data member
-     * @param publish setting that determines whether the user status message is published on
-     *        Facebook. This value is stored to m_backupFacebookPublishPolicity data member.
-     */
-    void backupUpdateLocationDialogData(const QString &status, bool publish);
-
-    /**
      * @brief Builds information box with message.
      *
      * @param message Information message
@@ -162,11 +153,6 @@ public slots:
     void buildInformationBox(const QString &message, bool modal=false);
 
     /**
-     * @brief Clears backups of message and publish on Facebook setting
-     */
-    void clearUpdateLocationDialogData();
-
-    /**
       * @brief Hides and deletes login dialog
       */
     void destroyLoginDialog();
@@ -287,11 +273,6 @@ private:
     void queueDialog(QDialog *dialog);
 
     /**
-     * @brief reads Unsend message from settings at startup
-     */
-    void restoreUnsendMessage();
-
-    /**
      * @brief Shows queued error information box
      *
      */
@@ -391,11 +372,6 @@ private slots:
      */
     void toggleFullScreen();
 
-    /**
-     * @brief Slot function to get indication when dialog is finished
-     */
-    void updateLocationDialogFinished(int reason);
-
 /*******************************************************************************
  * SIGNALS
  ******************************************************************************/
@@ -496,6 +472,14 @@ signals:
     void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
 
     /**
+    * @brief Send location update
+    *
+    * @param status Status message
+    * @param publish Publish on Facebook?
+    */
+    void locationUpdate(const QString &status, bool publish);
+
+    /**
      * @brief Signals when Login/Logout action is pressed
      *
      */
@@ -590,14 +574,6 @@ signals:
     void searchHistoryItemClicked(const QString &searchString);
 
     /**
-     * @brief Signal for requestLocationUpdate from SituareEngine
-     *
-     * @param status Status message
-     * @param publish Publish on Facebook
-     */
-    void statusUpdate(const QString &status, const bool &publish);
-
-    /**
     * @brief Dragging mode triggered.
     */
     void draggingModeTriggered();
@@ -608,6 +584,11 @@ signals:
     void viewZoomFinished();
 
     /**
+    * @brief Signals when updateLocation request finished successfully
+    */
+    void updateWasSuccessful();
+
+    /**
      * @brief Signal for use location ready.
      *
      * @param user User object
@@ -633,7 +614,6 @@ signals:
  * DATA MEMBERS
  ******************************************************************************/
 private:
-    bool m_backupFacebookPublishPolicity;   ///< Backup of publish on Facebook checkbox value
     bool m_errorShown;                      ///< Indicates if error dialog/note is shown
     bool m_loggedIn;                        ///< Indicates login state
     bool m_refresh;                         ///< Indicates when webpage is refreshed
@@ -658,8 +638,6 @@ private:
 
     QMessageBox *m_automaticUpdateLocationDialog;   ///< Automatic update location dialog
 
-    QString m_backupMessage;                ///< Backup of users message
-
     FriendListPanel *m_friendsListPanel;    ///< Instance of friends list panel
     FullScreenButton *m_fullScreenButton;   ///< Instance of the fullscreen toggle button
     IndicatorButtonPanel *m_indicatorButtonPanel;   ///< Instance of direction indicator button
@@ -668,7 +646,7 @@ private:
     MapView *m_mapView;                     ///< Instance of the map view
     RoutingPanel *m_routingPanel;           ///< Instance of routing panel
     TabbedPanel *m_tabbedPanel;             ///< Widget for tabbed panels
-    UpdateLocationDialog *m_updateLocation; ///< Update location dialog
+    UpdateLocation *m_updateLocationController;     ///< Controller for update location dialog
     UserInfoPanel *m_userInfoPanel;         ///< Instance of the user information panel
     ZoomButtonPanel *m_zoomButtonPanel;     ///< Instance of zoom button panel
 };
index 166e4bf..034e9bd 100644 (file)
 #include <QScrollArea>\r
 #include <QTextEdit>\r
 \r
+#include "engine/updatelocation.h"\r
+\r
 #include "updatelocationdialog.h"\r
 \r
 const int MESSAGE_MAX_LENGTH = 255;\r
 \r
-UpdateLocationDialog::UpdateLocationDialog(const QString &userMessage, bool publishOnFacebook,\r
-                                           QWidget *parent)\r
+UpdateLocationDialog::UpdateLocationDialog(UpdateLocation *controller, QWidget *parent)\r
     : QDialog(parent)\r
 {\r
     qDebug() << __PRETTY_FUNCTION__;\r
 \r
+    m_controller = controller;\r
+\r
     setWindowTitle(tr("Update Location"));\r
 \r
     QGridLayout *gridLayout = new QGridLayout();\r
@@ -49,7 +52,7 @@ UpdateLocationDialog::UpdateLocationDialog(const QString &userMessage, bool publ
     m_textEdit->setAcceptRichText(false);\r
     m_charCountLabel = new QLabel();\r
 \r
-    if (userMessage.isEmpty())\r
+    if (controller->message().isEmpty())\r
     {\r
         m_textEdit->setText(tr("Message:"));\r
         m_textEdit->selectAll();\r
@@ -60,7 +63,7 @@ UpdateLocationDialog::UpdateLocationDialog(const QString &userMessage, bool publ
     }\r
     else\r
     {\r
-        m_textEdit->setText(userMessage);\r
+        m_textEdit->setText(controller->message());\r
         m_textEdit->document()->setModified(true);\r
         textChanged();\r
     }\r
@@ -83,7 +86,7 @@ UpdateLocationDialog::UpdateLocationDialog(const QString &userMessage, bool publ
     m_locationLabel = new QLabel();\r
     m_locationLabel->setWordWrap(true);\r
     m_checkBox = new QCheckBox(tr("Publish on Facebook"));\r
-    m_checkBox->setChecked(publishOnFacebook);\r
+    m_checkBox->setChecked(controller->publish());\r
 \r
     QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Vertical);\r
     QPushButton *sendButton = buttonBox->addButton(QDialogButtonBox::Ok);\r
@@ -116,6 +119,8 @@ UpdateLocationDialog::UpdateLocationDialog(const QString &userMessage, bool publ
     connect(cancelButton, SIGNAL(clicked()),\r
             this, SLOT(reject()));\r
 \r
+    connect(this, SIGNAL(rejected()), controller, SLOT(clear()));\r
+\r
     connect(m_textEdit, SIGNAL(textChanged()),\r
             this, SLOT(textChanged()));\r
 \r
@@ -131,6 +136,8 @@ UpdateLocationDialog::UpdateLocationDialog(const QString &userMessage, bool publ
 #endif\r
 \r
     m_textEdit->setFocus(Qt::OtherFocusReason);\r
+\r
+    setAttribute(Qt::WA_DeleteOnClose);\r
 }\r
 \r
 UpdateLocationDialog::~UpdateLocationDialog()\r
@@ -149,11 +156,11 @@ void UpdateLocationDialog::sendUpdate()
 {\r
     qDebug() << __PRETTY_FUNCTION__;\r
 \r
-    // coordinates for this call will be get from somewhere, map etc...\r
-    emit statusUpdate(m_textEdit->document()->isModified() ? m_textEdit->toPlainText() : QString(),\r
-                      m_checkBox->isChecked());\r
+    m_controller->setMessage(m_textEdit->toPlainText());\r
+    m_controller->setPublish(m_checkBox->isChecked());\r
+    m_controller->send();\r
 \r
-    close();\r
+    accept();\r
 }\r
 \r
 void UpdateLocationDialog::textChanged()\r
index 2731061..4bb2987 100644 (file)
@@ -29,6 +29,8 @@
 #include <QAbstractKineticScroller>\r
 #endif // Q_WS_MAEMO_5\r
 \r
+class UpdateLocation;\r
+\r
 #include "texteditautoresizer.h"\r
 \r
 class QCheckBox;\r
@@ -53,13 +55,18 @@ public:
     /**\r
     * @brief Default constructor\r
     *\r
-    * @param userMessage update location dialog message\r
-    * @param publishOnFacebook update location dialog Facebook publish policity\r
+    * Is deleted automatically when closed.\r
+    *\r
+    * @param controller Controller for location update\r
     * @param parent\r
     */\r
-    UpdateLocationDialog(const QString &userMessage = "", bool publishOnFacebook = false,\r
-                         QWidget *parent = 0);\r
+    UpdateLocationDialog(UpdateLocation *controller, QWidget *parent = 0);\r
 \r
+    /**\r
+      * @brief Destructor\r
+      *\r
+      * Does nothing.\r
+      */\r
     ~UpdateLocationDialog();\r
 \r
 /*******************************************************************************\r
@@ -76,35 +83,20 @@ public slots:
 private slots:\r
     /**\r
     * @brief Used to connect send button\r
-    *\r
     */\r
     void sendUpdate();\r
 \r
     /**\r
     * @brief Used to get changes in messagetext\r
-    *\r
     */\r
     void textChanged();\r
 \r
     /**\r
     * @brief Used to clear default messagetext\r
-    *\r
     */\r
     void textSelectionChanged();\r
 \r
 /*******************************************************************************\r
- * SIGNALS\r
- ******************************************************************************/\r
-signals:\r
-    /**\r
-    * @brief Routing signal for requestLocationUpdate to SituareEngine via MainWindow class\r
-    *\r
-    * @param status Status message\r
-    * @param publish Publish on Facebook\r
-    */\r
-    void statusUpdate(const QString &status, const bool &publish);\r
-\r
-/*******************************************************************************\r
  * DATA MEMBERS\r
  ******************************************************************************/\r
 private:\r
@@ -112,6 +104,8 @@ private:
     QLabel *m_charCountLabel;       ///< Pointer to character counter label\r
     QLabel *m_locationLabel;        ///< Pointer to locationLabel\r
     QTextEdit *m_textEdit;          ///< Pointer to TextEdit\r
+\r
+    UpdateLocation *m_controller;   ///< Controller for location update dialog\r
 };\r
 \r
 #endif // UPDATELOCATIONDIALOG_H\r
index 83663a9..9301e6c 100644 (file)
@@ -112,8 +112,6 @@ UserInfo::UserInfo(QWidget *parent)
     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();
 }
 
 UserInfo::~UserInfo()