From: Ville Tiensuu Date: Mon, 7 Jun 2010 10:50:41 +0000 (+0300) Subject: basic functionality of error handling ready X-Git-Tag: v0.6~27^2~9^2~3 X-Git-Url: http://git.maemo.org/git/?a=commitdiff_plain;h=11655ac1d2e1174674f7a551fa3e7b51d74c30a4;p=situare basic functionality of error handling ready --- diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 65b5b0a..a74a993 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -183,6 +183,7 @@ void SituareEngine::enableAutomaticLocationUpdate(bool enabled, int updateInterv void SituareEngine::error(const QString &error) { qDebug() << __PRETTY_FUNCTION__; + qDebug() << "ERROR MESSAGE: " << error; m_ui->showMaemoInformationBox(error, true); @@ -437,6 +438,9 @@ void SituareEngine::signalsFromMainWindow() connect(m_ui, SIGNAL(refreshUserData()), this, SLOT(refreshUserData())); + connect (m_ui, SIGNAL(notificateUpdateFailing(QString)), + this, SLOT(error(QString))); + connect(m_ui, SIGNAL(findUser(QPointF)), m_mapEngine, SLOT(setViewLocation(QPointF))); diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 0c93be4..d89b9d2 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -249,6 +249,9 @@ void MainWindow::buildUserInfoPanel() connect(this, SIGNAL(messageSendingFailed(QString)), m_userPanel, SIGNAL(messageSendingFailed(QString))); + + connect(m_userPanel, SIGNAL(notificateUpdateFailing(QString)), + this, SIGNAL(notificateUpdateFailing(QString))); } void MainWindow::buildWebView() diff --git a/src/ui/mainwindow.h b/src/ui/mainwindow.h index c940119..6bcaced 100644 --- a/src/ui/mainwindow.h +++ b/src/ui/mainwindow.h @@ -446,6 +446,7 @@ signals: void messageUpdatedToSituare(); void messageSendingFailed(const QString &error); + void notificateUpdateFailing(const QString &message); /** * @brief MapView has finished zooming diff --git a/src/ui/updatelocation/updatelocationdialog.cpp b/src/ui/updatelocation/updatelocationdialog.cpp index 608a1d4..92e404e 100755 --- a/src/ui/updatelocation/updatelocationdialog.cpp +++ b/src/ui/updatelocation/updatelocationdialog.cpp @@ -60,8 +60,7 @@ UpdateLocationDialog::UpdateLocationDialog(QWidget *parent) connect(sendButton, SIGNAL(clicked()), this, SLOT(sendUpdate())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject())); - scrollArea->show(); - //setAttribute(Qt::WA_DeleteOnClose, true); + scrollArea->show(); } UpdateLocationDialog::~UpdateLocationDialog() @@ -71,14 +70,6 @@ UpdateLocationDialog::~UpdateLocationDialog() // emit m_textEdit sisältö userInfo luokalle talteen } -//void UpdateLocationDialog::saveMessageAndClose(const QString &message) -//{ -// qDebug() << __PRETTY_FUNCTION__ << "NONIIN NONIIN"; - -// emit saveMessage(m_textEdit->toPlainText()); -// this->close(); -//} - void UpdateLocationDialog::setAddress(const QString &address) { qDebug() << __PRETTY_FUNCTION__; diff --git a/src/ui/userinfo.cpp b/src/ui/userinfo.cpp index 1a2bff4..e620de8 100644 --- a/src/ui/userinfo.cpp +++ b/src/ui/userinfo.cpp @@ -35,8 +35,8 @@ const int BACKGROUND_BOTTOM_HEIGHT = 15; ///< Height for item bottom //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 -const int IMAGE_WIDTH = 60; ///< Profile image width +//const int IMAGE_HEIGHT = 60; ///< Profile image height +//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 @@ -96,6 +96,7 @@ UserInfo::UserInfo(QWidget *parent) m_messageDialog = new UpdateLocationDialog(this); m_messageDialog->hide(); + m_messageDialog->setWindowModality(Qt::NonModal); ImageButton *updateFriendsButton = new ImageButton(this, ":/res/images/refresh.png", ":/res/images/refresh_s.png"); @@ -116,11 +117,25 @@ UserInfo::UserInfo(QWidget *parent) connect(updateStatusMessageButton,SIGNAL(clicked()), this,SLOT(messageUpdate())); + connect(updateFriendsButton,SIGNAL(clicked()), this, SIGNAL(refreshUserData())); + connect(m_findButton, SIGNAL(clicked()), this, SLOT(findButtonClicked())); + connect(this, SIGNAL(reverseGeoReady(QString)), + m_messageDialog, SLOT(setAddress(QString))); + + connect(m_messageDialog, SIGNAL(statusUpdate(QString,bool)), + this, SIGNAL(statusUpdate(QString,bool))); + + connect(m_messageDialog, SIGNAL(statusUpdate(QString,bool)), + this, SLOT(backupUpdateLocationDialogData(QString,bool))); + + connect(this, SIGNAL(messageUpdatedToSituare()), + this, SLOT(clearUpdateLocationDialogData())); + setFixedWidth(BACKGROUND_WIDTH); this->setFont(NOKIA_FONT_SMALL); @@ -151,6 +166,26 @@ UserInfo::~UserInfo() } +void UserInfo::backupUpdateLocationDialogData(const QString &status, const bool &publish) +{ + qDebug() << __PRETTY_FUNCTION__; + + m_backupMessage = status; + m_backupFacebookPublishPolicity = publish; + + m_messageUpdateVerified = false; +} + +void UserInfo::clearUpdateLocationDialogData() +{ + qDebug() << __PRETTY_FUNCTION__; + + qDebug() << "Message Before Clearing: " << m_backupMessage; + m_backupMessage.clear(); + qDebug() << "Message After Clearing: " << m_backupMessage; + m_backupFacebookPublishPolicity = false; +} + void UserInfo::restoreUnsendMessage() { QSettings settings(DIRECTORY_NAME, FILE_NAME); @@ -176,7 +211,7 @@ void UserInfo::setCoordinates(const QPointF &coordinates) void UserInfo::setMessageText(const QString &text) { - qDebug() << __PRETTY_FUNCTION__ << "VIESTI LAITETAAN TALTEEN"; + qDebug() << __PRETTY_FUNCTION__; m_messageText = text; setText(false); @@ -236,6 +271,26 @@ void UserInfo::setText(bool expanded) } } +void UserInfo::verifyMessageUpdateToServer(QString errorMessage) +{ + qDebug() << __PRETTY_FUNCTION__; + + Q_UNUSED(errorMessage); + + if (!m_messageUpdateVerified) { + QString message = QObject::tr("Status update failed\n\nYour message is saved to textbox " + "until sending will succeed"); + + qDebug() << "m_messageText: " << m_messageText; + qDebug() << "m_backupMessage: " << m_backupMessage; + + if (m_messageText != m_backupMessage && !m_backupMessage.isEmpty()) + emit notificateUpdateFailing(message); + } + + m_messageUpdateVerified = true; +} + void UserInfo::mouseReleaseEvent(QMouseEvent *event) { qDebug() << __PRETTY_FUNCTION__ << " " << event->pos(); @@ -284,53 +339,18 @@ void UserInfo::findButtonClicked() emit findUser(m_coordinates); } -QString UserInfo::messageText() const -{ - return m_messageText; -} - void UserInfo::messageUpdate() { qDebug() << __PRETTY_FUNCTION__; + emit requestReverseGeo(); + m_messageDialog->show(); m_messageDialog->m_textEdit->setPlainText(m_backupMessage); m_messageDialog->m_checkBox->setCheckState(Qt::Unchecked); if (m_backupFacebookPublishPolicity == true) - m_messageDialog->m_checkBox->setCheckState(Qt::Checked); - - emit requestReverseGeo(); - - connect(this, SIGNAL(reverseGeoReady(QString)), - m_messageDialog, SLOT(setAddress(QString))); - - connect(m_messageDialog, SIGNAL(statusUpdate(QString,bool)), - this, SIGNAL(statusUpdate(QString,bool))); - - connect(m_messageDialog, SIGNAL(statusUpdate(QString,bool)), - this, SLOT(backupUpdateLocationDialogData(QString,bool))); - - connect(this, SIGNAL(messageUpdatedToSituare()), - this, SLOT(clearUpdateLocationDialogData())); + m_messageDialog->m_checkBox->setCheckState(Qt::Checked); m_messageDialog->exec(); } - -void UserInfo::backupUpdateLocationDialogData(const QString &status, const bool &publish) -{ - qDebug() << __PRETTY_FUNCTION__; - - m_backupMessage = status; - m_backupFacebookPublishPolicity = publish; -} - -void UserInfo::clearUpdateLocationDialogData() -{ - qDebug() << __PRETTY_FUNCTION__; - - qDebug() << "TEKSTIN SISALTO ENNEN: " << m_backupMessage; - m_backupMessage.clear(); - qDebug() << "TEKSTIN SISALTO JALKEEN: " << m_backupMessage; - m_backupFacebookPublishPolicity = false; -} diff --git a/src/ui/userinfo.h b/src/ui/userinfo.h index 053442a..45d8877 100644 --- a/src/ui/userinfo.h +++ b/src/ui/userinfo.h @@ -77,7 +77,6 @@ protected: * MEMBER FUNCTIONS AND SLOTS ******************************************************************************/ public: - QString messageText() const; /** * @brief Sets the users current address * @@ -122,6 +121,7 @@ public slots: */ void setMessageText(const QString &text); void backupUpdateLocationDialogData(const QString &status, const bool &publish); + void verifyMessageUpdateToServer(const QString errorMessage); private: void restoreUnsendMessage(); @@ -190,6 +190,7 @@ signals: void statusUpdate(const QString &status, const bool &publish); void messageUpdatedToSituare(); void messageSendingFailed(const QString &error); + void notificateUpdateFailing(const QString &message); /****************************************************************************** * DATA MEMBERS @@ -197,6 +198,7 @@ signals: private: bool m_expanded; ///< Item expanded state bool m_backupFacebookPublishPolicity; ///< Backup of publish on Facebook checkbox value + bool m_messageUpdateVerified; QLabel *m_locationLabel; ///< Location label QLabel *m_nameLabel; ///< Name label QLabel *m_statusTextLabel; ///< Status text label diff --git a/src/ui/userinfopanel.cpp b/src/ui/userinfopanel.cpp index 50a2975..3daf485 100644 --- a/src/ui/userinfopanel.cpp +++ b/src/ui/userinfopanel.cpp @@ -68,6 +68,12 @@ UserInfoPanel::UserInfoPanel(QWidget *parent) connect(this, SIGNAL(messageSendingFailed(QString)), m_userInfo, SIGNAL(messageSendingFailed(QString))); + + connect (this, SIGNAL(messageSendingFailed(QString)), + m_userInfo, SLOT(verifyMessageUpdateToServer(QString))); + + connect (m_userInfo, SIGNAL(notificateUpdateFailing(QString)), + this, SIGNAL(notificateUpdateFailing(QString))); } void UserInfoPanel::userDataReceived(User *user) diff --git a/src/ui/userinfopanel.h b/src/ui/userinfopanel.h index f0f907c..3f8f712 100644 --- a/src/ui/userinfopanel.h +++ b/src/ui/userinfopanel.h @@ -97,6 +97,7 @@ signals: void statusUpdate(const QString &status, const bool &publish); void messageUpdatedToSituare(); void messageSendingFailed(const QString &error); + void notificateUpdateFailing(const QString &message); /******************************************************************************* * DATA MEMBERS