backup
authorVille Tiensuu <ville.tiensuu@ixonos.com>
Fri, 4 Jun 2010 13:10:16 +0000 (16:10 +0300)
committerVille Tiensuu <ville.tiensuu@ixonos.com>
Fri, 4 Jun 2010 13:10:16 +0000 (16:10 +0300)
src/situareservice/situareservice.cpp
src/ui/updatelocation/updatelocationdialog.cpp
src/ui/updatelocation/updatelocationdialog.h
src/ui/userinfo.cpp
src/ui/userinfo.h

index 255a15e..cdd921f 100644 (file)
@@ -249,8 +249,7 @@ void SituareService::requestFinished(QNetworkReply *reply)
         qDebug() << "BytesAvailable: " << reply->bytesAvailable();
 
         if (reply->error()) {
-            emit error(reply->errorString());
-            emit error("Terve");
+            emit error(reply->errorString());            
             qDebug() << "TMP MESSAGE VILLE";
         } else {
             qint64 max = reply->size();
index 61ef860..608a1d4 100755 (executable)
@@ -91,7 +91,8 @@ void UpdateLocationDialog::sendUpdate()
 
     // coordinates for this call will be get from somewhere, map etc...
     emit statusUpdate(m_textEdit->toPlainText(), m_checkBox->isChecked());
+    m_textEdit->clear();
 
-    //this->hide();
-    this->close();
+    this->hide();
+    //this->close();
 }
index fec5430..9263bec 100755 (executable)
@@ -100,9 +100,10 @@ signals:
  ******************************************************************************/
 
 private:
-    QCheckBox *m_checkBox; ///< Pointer to CheckBox
+
     QLabel *m_locationLabel; ///< Pointer to locationLabel
 public:
+    QCheckBox *m_checkBox; ///< Pointer to CheckBox
     QTextEdit *m_textEdit; ///< Pointer to TextEdit
 };
 
index 846b330..1a2bff4 100644 (file)
@@ -22,6 +22,7 @@
    USA.
 */
 
+#include "common.h"
 #include "imagebutton.h"
 #include "../user/user.h"
 #include "userinfo.h"
@@ -29,9 +30,9 @@
 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 QColor COLOR_GRAY = QColor(152, 152, 152); ///< Gray color
-const QFont NOKIA_FONT_NORMAL = QFont("Nokia Sans", 18, QFont::Normal); ///< Normal font
-const QFont NOKIA_FONT_SMALL = QFont("Nokia Sans", 13, QFont::Normal);  ///< Small font
+//const QColor COLOR_GRAY = QColor(152, 152, 152); ///< Gray color
+//const QFont NOKIA_FONT_NORMAL = QFont("Nokia Sans", 18, QFont::Normal); ///< Normal font
+//const QFont NOKIA_FONT_SMALL = QFont("Nokia Sans", 13, QFont::Normal);  ///< Small font
 const int ICON_HEIGHT = 24; ///< Icon height
 const int ICON_WIDTH = 24;  ///< Icon width
 const int IMAGE_HEIGHT = 60;    ///< Profile image height
@@ -39,6 +40,8 @@ const int IMAGE_WIDTH = 60;     ///< Profile image 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 QString USER_UNSEND_MESSAGE = "User_unsend_message_content";
+const QString USER_UNSEND_MESSAGE_PUBLISH_POLICITY = "User_unsend_message_publish";
 
 /**
 * @var LABEL_MAX_WIDTH
@@ -91,6 +94,9 @@ UserInfo::UserInfo(QWidget *parent)
     m_updatedLabel = new QLabel();
     m_updatedLabel->setWordWrap(true);
 
+    m_messageDialog = new UpdateLocationDialog(this);
+    m_messageDialog->hide();
+
     ImageButton *updateFriendsButton = new ImageButton(this, ":/res/images/refresh.png",
                                                              ":/res/images/refresh_s.png");
     ImageButton *updateStatusMessageButton = new ImageButton(this, ":/res/images/send_position.png",
@@ -129,6 +135,29 @@ UserInfo::UserInfo(QWidget *parent)
     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");
+
+    restoreUnsendMessage();
+}
+
+UserInfo::~UserInfo()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    if (!m_backupMessage.isEmpty()) {
+        QSettings settings(DIRECTORY_NAME, FILE_NAME);
+        settings.setValue(USER_UNSEND_MESSAGE, m_backupMessage.toAscii());
+        settings.setValue(USER_UNSEND_MESSAGE_PUBLISH_POLICITY, m_backupFacebookPublishPolicity);
+    }
+
+}
+
+void UserInfo::restoreUnsendMessage()
+{
+    QSettings settings(DIRECTORY_NAME, FILE_NAME);
+    m_backupMessage = settings.value(USER_UNSEND_MESSAGE, "").toString();
+    m_backupFacebookPublishPolicity =
+            settings.value(USER_UNSEND_MESSAGE_PUBLISH_POLICITY, false).toBool();
+
 }
 
 void UserInfo::setAddress(const QString &address)
@@ -264,51 +293,44 @@ void UserInfo::messageUpdate()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    UpdateLocationDialog updateLocationDialog(this);
+    m_messageDialog->show();
+    m_messageDialog->m_textEdit->setPlainText(m_backupMessage);
+    m_messageDialog->m_checkBox->setCheckState(Qt::Unchecked);
 
-    //updateLocationDialog.m_textEdit->setPlainText("");
-    updateLocationDialog.m_textEdit->setPlainText(messageText());
-    //updateLocationDialog.m_textEdit->setPlainText("Messaging around the world");
+    if (m_backupFacebookPublishPolicity == true)
+        m_messageDialog->m_checkBox->setCheckState(Qt::Checked);
 
     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)))*/;
+            m_messageDialog, SLOT(setAddress(QString)));
 
-//    connect(&updateLocationDialog, SIGNAL(saveMessage(QString)),
-//            this, SLOT(setMessageText(QString)));
+    connect(m_messageDialog, SIGNAL(statusUpdate(QString,bool)),
+            this, SIGNAL(statusUpdate(QString,bool)));
 
-    connect(&updateLocationDialog, SIGNAL(statusUpdate(QString,bool)),
-            this, SLOT(updateUserData(QString,bool)));
+    connect(m_messageDialog, SIGNAL(statusUpdate(QString,bool)),
+            this, SLOT(backupUpdateLocationDialogData(QString,bool)));
 
     connect(this, SIGNAL(messageUpdatedToSituare()),
-            this, SLOT(deleteUserData()));
+            this, SLOT(clearUpdateLocationDialogData()));
 
-    updateLocationDialog.exec();
+    m_messageDialog->exec();
 }
 
-void UserInfo::updateUserData(const QString &status, const bool &publish)
+void UserInfo::backupUpdateLocationDialogData(const QString &status, const bool &publish)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    setMessageText(status);
-    //laita loputkin talteen (publish ja koordinaatit)
+    m_backupMessage = status;
+    m_backupFacebookPublishPolicity = publish;
 }
 
-void UserInfo::deleteUserData()
+void UserInfo::clearUpdateLocationDialogData()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    qDebug() << "TEKSTIN SISALTO ENNEN: " << m_messageText;
-    m_messageText.clear();
-    qDebug() << "TEKSTIN SISALTO JALKEEN: " << m_messageText;
+    qDebug() << "TEKSTIN SISALTO ENNEN: " << m_backupMessage;
+    m_backupMessage.clear();
+    qDebug() << "TEKSTIN SISALTO JALKEEN: " << m_backupMessage;
+    m_backupFacebookPublishPolicity = false;
 }
index 3ba78a8..053442a 100644 (file)
@@ -45,6 +45,7 @@ public:
     * @param parent Parent
     */
     UserInfo(QWidget *parent=0);
+    ~UserInfo();
 
 /*******************************************************************************
 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
@@ -113,16 +114,17 @@ public:
     void setUserName(const QString &name);
 
 public slots:
-    void deleteUserData();
+    void clearUpdateLocationDialogData();
     /**
     * @brief Sets the message text
     *
     * @param text Reference to user message
     */
     void setMessageText(const QString &text);
-    void updateUserData(const QString &status, const bool &publish);
+    void backupUpdateLocationDialogData(const QString &status, const bool &publish);
 
 private:
+    void restoreUnsendMessage();
     /**
     * @brief Set shortened or full-length text to labels.
     *
@@ -194,6 +196,7 @@ signals:
 ******************************************************************************/
 private:
     bool m_expanded;                    ///< Item expanded state
+    bool m_backupFacebookPublishPolicity; ///< Backup of publish on Facebook checkbox value
     QLabel *m_locationLabel;            ///< Location label
     QLabel *m_nameLabel;                ///< Name label
     QLabel *m_statusTextLabel;          ///< Status text label
@@ -203,11 +206,13 @@ private:
     QPixmap m_backgroundTopImage;       ///< Top background image
     QPoint m_mousePosition;             ///< Current mouse press position
     QPointF m_coordinates;              ///< User current coordinates
-    QString m_address;                  ///< Address from where the new message was sent.
+    QString m_address;                  ///< Address from where the new message was sent
+    QString m_backupMessage;            ///< Backup of users message
     QString m_messageText;              ///< User's message
     QString m_time;                     ///< Time when the new message was sent
     QString m_userName;                 ///< User's name
     ImageButton *m_findButton;          ///< User find button
+    UpdateLocationDialog *m_messageDialog;  ///< Dialog for sending message and location
 };
 
 #endif // USERINFO_H