backup before changing update dialog to be a data member of UserInfo
authorVille Tiensuu <ville.tiensuu@ixonos.com>
Fri, 4 Jun 2010 10:16:42 +0000 (13:16 +0300)
committerVille Tiensuu <ville.tiensuu@ixonos.com>
Fri, 4 Jun 2010 10:16:42 +0000 (13:16 +0300)
src/situareservice/situareservice.cpp
src/ui/updatelocation/updatelocationdialog.cpp
src/ui/updatelocation/updatelocationdialog.h
src/ui/userinfo.cpp
src/ui/userinfo.h

index 3a0c225..255a15e 100644 (file)
@@ -250,6 +250,8 @@ void SituareService::requestFinished(QNetworkReply *reply)
 
         if (reply->error()) {
             emit error(reply->errorString());
+            emit error("Terve");
+            qDebug() << "TMP MESSAGE VILLE";
         } else {
             qint64 max = reply->size();
             QByteArray replyArray = reply->read(max);
index e087f10..61ef860 100755 (executable)
@@ -61,6 +61,7 @@ UpdateLocationDialog::UpdateLocationDialog(QWidget *parent)
     connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
 
     scrollArea->show();
+    //setAttribute(Qt::WA_DeleteOnClose, true);
 }
 
 UpdateLocationDialog::~UpdateLocationDialog()
@@ -70,13 +71,13 @@ UpdateLocationDialog::~UpdateLocationDialog()
     // emit m_textEdit sisältö userInfo luokalle talteen
 }
 
-void UpdateLocationDialog::saveMessageAndClose()
-{
-    qDebug() << __PRETTY_FUNCTION__ << "NONIIN NONIIN";
-    qDebug() << "MIKSET TOIMI!!!!!!!!!";
-
+//void UpdateLocationDialog::saveMessageAndClose(const QString &message)
+//{
+//    qDebug() << __PRETTY_FUNCTION__ << "NONIIN NONIIN";
 
-}
+//    emit saveMessage(m_textEdit->toPlainText());
+//    this->close();
+//}
 
 void UpdateLocationDialog::setAddress(const QString &address)
 {
@@ -89,7 +90,8 @@ void UpdateLocationDialog::sendUpdate()
     qDebug() << __PRETTY_FUNCTION__;   
 
     // coordinates for this call will be get from somewhere, map etc...
-    emit statusUpdate(m_textEdit->toPlainText(), m_checkBox->isChecked());    
+    emit statusUpdate(m_textEdit->toPlainText(), m_checkBox->isChecked());
 
-    //this->close();
+    //this->hide();
+    this->close();
 }
index 9f8ecd1..fec5430 100755 (executable)
@@ -69,8 +69,8 @@ public slots:
     *
     * @param address Street address, result from SituareService's reverseGeo
     */
-    void setAddress(const QString &address);
-    void saveMessageAndClose();
+    void setAddress(const QString &address);    
+//    void saveMessageAndClose(const QString &message);
 
 private slots:
 
@@ -85,7 +85,7 @@ private slots:
  ******************************************************************************/
 
 signals:
-    void saveMessage(const QString &message);
+//    void saveMessage(const QString &message);
 
     /**
     * @brief Signal Signal for requestLocationUpdate from SituareEngine via MainWindow class
@@ -100,10 +100,9 @@ signals:
  ******************************************************************************/
 
 private:
-    //bool m_messageReceivedOnSituareServer; ///< Indicates when message is received on Situare server
-
     QCheckBox *m_checkBox; ///< Pointer to CheckBox
     QLabel *m_locationLabel; ///< Pointer to locationLabel
+public:
     QTextEdit *m_textEdit; ///< Pointer to TextEdit
 };
 
index 4a700e4..846b330 100644 (file)
@@ -147,7 +147,7 @@ void UserInfo::setCoordinates(const QPointF &coordinates)
 
 void UserInfo::setMessageText(const QString &text)
 {
-    qDebug() << __PRETTY_FUNCTION__;
+    qDebug() << __PRETTY_FUNCTION__ << "VIESTI LAITETAAN TALTEEN";
 
     m_messageText = text;
     setText(false);
@@ -255,22 +255,60 @@ void UserInfo::findButtonClicked()
     emit findUser(m_coordinates);
 }
 
+QString UserInfo::messageText() const
+{
+    return m_messageText;
+}
+
 void UserInfo::messageUpdate()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
     UpdateLocationDialog updateLocationDialog(this);
 
+    //updateLocationDialog.m_textEdit->setPlainText("");
+    updateLocationDialog.m_textEdit->setPlainText(messageText());
+    //updateLocationDialog.m_textEdit->setPlainText("Messaging around the world");
+
     emit requestReverseGeo();
 
     connect(this, SIGNAL(reverseGeoReady(QString)),
             &updateLocationDialog, SLOT(setAddress(QString)));
+
     connect(&updateLocationDialog, SIGNAL(statusUpdate(QString, bool)),
             this, SIGNAL(statusUpdate(QString, bool)));
+
+//    connect(this, SIGNAL(messageUpdatedToSituare()),
+//            &updateLocationDialog, SLOT(close())); //poistuu
+
+//    /*connect(this, SIGNAL(messageSendingFailed(QString)),
+//            &updateLocationDialog, SLOT(saveMessageAndClose(QString)))*/;
+
+//    connect(&updateLocationDialog, SIGNAL(saveMessage(QString)),
+//            this, SLOT(setMessageText(QString)));
+
+    connect(&updateLocationDialog, SIGNAL(statusUpdate(QString,bool)),
+            this, SLOT(updateUserData(QString,bool)));
+
     connect(this, SIGNAL(messageUpdatedToSituare()),
-            &updateLocationDialog, SLOT(close()));
-    connect(this, SIGNAL(messageSendingFailed(QString)),
-            &updateLocationDialog, SLOT(saveMessageAndClose()));
+            this, SLOT(deleteUserData()));
 
     updateLocationDialog.exec();
 }
+
+void UserInfo::updateUserData(const QString &status, const bool &publish)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    setMessageText(status);
+    //laita loputkin talteen (publish ja koordinaatit)
+}
+
+void UserInfo::deleteUserData()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    qDebug() << "TEKSTIN SISALTO ENNEN: " << m_messageText;
+    m_messageText.clear();
+    qDebug() << "TEKSTIN SISALTO JALKEEN: " << m_messageText;
+}
index 81207e2..3ba78a8 100644 (file)
@@ -76,6 +76,7 @@ protected:
 * MEMBER FUNCTIONS AND SLOTS
 ******************************************************************************/
 public:
+    QString messageText() const;
     /**
     * @brief Sets the users current address
     *
@@ -88,14 +89,7 @@ public:
     *
     * @param coordinates Reference to users current coordinates
     */
-    void setCoordinates(const QPointF &coordinates);
-
-    /**
-    * @brief Sets the message text
-    *
-    * @param text Reference to user message
-    */
-    void setMessageText(const QString &text);
+    void setCoordinates(const QPointF &coordinates);    
 
     /**
     * @brief Sets the user picture
@@ -118,6 +112,16 @@ public:
     */
     void setUserName(const QString &name);
 
+public slots:
+    void deleteUserData();
+    /**
+    * @brief Sets the message text
+    *
+    * @param text Reference to user message
+    */
+    void setMessageText(const QString &text);
+    void updateUserData(const QString &status, const bool &publish);
+
 private:
     /**
     * @brief Set shortened or full-length text to labels.