From 4606e8531aee2f730531d757f51d70829d3ee2ae Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sami=20R=C3=A4m=C3=B6?= Date: Thu, 11 Nov 2010 09:31:54 +0200 Subject: [PATCH] Moved UpdateLocationDialog to be managed by MainWindow. --- src/engine/engine.cpp | 10 +---- src/engine/engine.h | 6 --- src/ui/mainwindow.cpp | 104 +++++++++++++++++++++++++++++++++++++++------- src/ui/mainwindow.h | 40 +++++++++++++++--- src/ui/userinfo.cpp | 89 +-------------------------------------- src/ui/userinfo.h | 64 +--------------------------- src/ui/userinfopanel.cpp | 17 +------- src/ui/userinfopanel.h | 36 ++-------------- 8 files changed, 133 insertions(+), 233 deletions(-) diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 9b82514..7f2f32d 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -376,14 +376,8 @@ void SituareEngine::onLogout() qDebug() << __PRETTY_FUNCTION__; m_ui->loggedIn(false); - - // signal to clear locationUpdateDialog's data - connect(this, SIGNAL(clearUpdateLocationDialogData()), - m_ui, SIGNAL(clearUpdateLocationDialogData())); - emit clearUpdateLocationDialogData(); - + m_ui->clearUpdateLocationDialogData(); m_situareService->updateSession(""); // empty session string means logged out - m_automaticUpdateFirstStart = true; } @@ -750,7 +744,7 @@ void SituareEngine::signalsFromSituareService() this, SLOT(updateWasSuccessful())); connect(m_situareService, SIGNAL(updateWasSuccessful()), - m_ui, SIGNAL(clearUpdateLocationDialogData())); + m_ui, SLOT(clearUpdateLocationDialogData())); } void SituareEngine::startAutomaticUpdate() diff --git a/src/engine/engine.h b/src/engine/engine.h index 4e1930a..25ad5cc 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -316,12 +316,6 @@ signals: void automaticLocationUpdateEnabled(bool enabled); /** - * @brief Signal to clear locationUpdateDialog's data - * - */ - void clearUpdateLocationDialogData(); - - /** * @brief Signal when direction and distance from current map center point to current GPS * location is changed * diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 7bdb807..aeaedac 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -47,6 +47,7 @@ #include "settingsdialog.h" #include "situareservice/situarecommon.h" #include "tabbedpanel.h" +#include "updatelocation/updatelocationdialog.h" #include "userinfopanel.h" #include "zoombuttonpanel.h" @@ -75,7 +76,8 @@ MainWindow::MainWindow(QWidget *parent) m_crosshair(0), m_fullScreenButton(0), m_indicatorButtonPanel(0), - m_mapScale(0) + m_mapScale(0), + m_updateLocation(0) { qDebug() << __PRETTY_FUNCTION__; @@ -124,6 +126,16 @@ 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) @@ -141,6 +153,14 @@ 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__; @@ -449,26 +469,14 @@ void MainWindow::buildUserInfoPanel() connect(this, SIGNAL(userLocationReady(User*)), m_userInfoPanel, SLOT(userDataReceived(User*))); - connect(this, SIGNAL(reverseGeoReady(QString)), - m_userInfoPanel, SIGNAL(reverseGeoReady(QString))); - - connect(this, SIGNAL(clearUpdateLocationDialogData()), - m_userInfoPanel, SIGNAL(clearUpdateLocationDialogData())); - connect(m_userInfoPanel, SIGNAL(findUser(GeoCoordinate)), this, SIGNAL(centerToCoordinates(GeoCoordinate))); - connect(m_userInfoPanel, SIGNAL(requestReverseGeo()), - this, SIGNAL(requestReverseGeo())); - - connect(m_userInfoPanel, SIGNAL(statusUpdate(QString,bool)), - this, SIGNAL(statusUpdate(QString,bool))); - connect(m_userInfoPanel, SIGNAL(refreshUserData()), this, SIGNAL(refreshUserData())); - connect(m_userInfoPanel, SIGNAL(notificateUpdateFailing(QString, bool)), - this, SLOT(buildInformationBox(QString, bool))); + connect(m_userInfoPanel, SIGNAL(updateLocationMessageButtonClicked()), + this, SLOT(showUpdateLocationDialog())); } void MainWindow::buildZoomButtonPanel() @@ -499,6 +507,14 @@ void MainWindow::buildZoomButtonPanel() this, SIGNAL(draggingModeTriggered())); } +void MainWindow::clearUpdateLocationDialogData() +{ + qDebug() << __PRETTY_FUNCTION__; + + m_backupMessage.clear(); + m_backupFacebookPublishPolicity = false; +} + void MainWindow::createMenus() { qDebug() << __PRETTY_FUNCTION__; @@ -737,6 +753,15 @@ 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__; @@ -828,6 +853,31 @@ void MainWindow::showInformationBox() } } +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))); + + connect(m_updateLocation, SIGNAL(statusUpdate(QString, bool)), + this, SLOT(backupUpdateLocationDialogData(QString, bool))); + + connect(m_updateLocation, SIGNAL(finished(int)), + this, SLOT(updateLocationDialogFinished(int))); + + m_updateLocation->show(); + + emit requestReverseGeo(); +} + void MainWindow::sslErrors(QNetworkReply *reply, const QList &errors) { qWarning() << __PRETTY_FUNCTION__; @@ -879,3 +929,27 @@ 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; + } +} diff --git a/src/ui/mainwindow.h b/src/ui/mainwindow.h index f7e508b..c9e4caf 100644 --- a/src/ui/mainwindow.h +++ b/src/ui/mainwindow.h @@ -56,6 +56,7 @@ class SceneCoordinate; class SettingsDialog; class SituareService; class TabbedPanel; +class UpdateLocationDialog; class User; class UserInfoPanel; class ZoomButtonPanel; @@ -144,6 +145,15 @@ 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 @@ -152,6 +162,11 @@ 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(); @@ -272,6 +287,11 @@ private: void queueDialog(QDialog *dialog); /** + * @brief reads Unsend message from settings at startup + */ + void restoreUnsendMessage(); + + /** * @brief Shows queued error information box * */ @@ -352,6 +372,11 @@ private slots: void settingsDialogAccepted(); /** + * @brief Show update location dialog + */ + void showUpdateLocationDialog(); + + /** * @brief Ignore SSL error from the reply */ void sslErrors(QNetworkReply *reply, const QList &errors); @@ -366,6 +391,11 @@ private slots: */ void toggleFullScreen(); + /** + * @brief Slot function to get indication when dialog is finished + */ + void updateLocationDialogFinished(int reason); + /******************************************************************************* * SIGNALS ******************************************************************************/ @@ -568,12 +598,6 @@ signals: void statusUpdate(const QString &status, const bool &publish); /** - * @brief Signals when updateLocationDialog's data must be cleared - * - */ - void clearUpdateLocationDialogData(); - - /** * @brief Dragging mode triggered. */ void draggingModeTriggered(); @@ -609,6 +633,7 @@ 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 @@ -633,6 +658,8 @@ 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 @@ -641,6 +668,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 UserInfoPanel *m_userInfoPanel; ///< Instance of the user information panel ZoomButtonPanel *m_zoomButtonPanel; ///< Instance of zoom button panel }; diff --git a/src/ui/userinfo.cpp b/src/ui/userinfo.cpp index eb34132..83663a9 100644 --- a/src/ui/userinfo.cpp +++ b/src/ui/userinfo.cpp @@ -47,8 +47,7 @@ const int LABEL_MAX_WIDTH = BACKGROUND_WIDTH - ICON_WIDTH - 5 * MARGIN; UserInfo::UserInfo(QWidget *parent) : QWidget(parent), - m_expanded(false), - m_updateLocation(0) + m_expanded(false) { qDebug() << __PRETTY_FUNCTION__; @@ -114,38 +113,12 @@ UserInfo::UserInfo(QWidget *parent) m_backgroundMiddleImage.load(":/res/images/list_item_middle.png"); m_backgroundBottomImage.load(":/res/images/list_item_bottom.png"); - restoreUnsendMessage(); +// restoreUnsendMessage(); } UserInfo::~UserInfo() { qDebug() << __PRETTY_FUNCTION__; - - 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 UserInfo::backupUpdateLocationDialogData(const QString &status, bool publish) -{ - qDebug() << __PRETTY_FUNCTION__; - - m_backupMessage = status; - m_backupFacebookPublishPolicity = publish; -} - -void UserInfo::clearUpdateLocationDialogData() -{ - qDebug() << __PRETTY_FUNCTION__; - - m_backupMessage.clear(); - m_backupFacebookPublishPolicity = false; } void UserInfo::collapse() @@ -162,31 +135,6 @@ void UserInfo::findButtonClicked() emit findUser(m_coordinates); } -void UserInfo::messageUpdate() -{ - 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))); - - connect(m_updateLocation, SIGNAL(statusUpdate(QString, bool)), - this, SLOT(backupUpdateLocationDialogData(QString, bool))); - - connect(m_updateLocation, SIGNAL(finished(int)), - this, SLOT(updateLocationDialogFinished(int))); - - m_updateLocation->show(); - - emit requestReverseGeo(); -} - void UserInfo::mousePressEvent(QMouseEvent *event) { qDebug() << __PRETTY_FUNCTION__ << " " << event->pos(); @@ -233,15 +181,6 @@ void UserInfo::paintEvent(QPaintEvent *event) painter.drawPixmap(bottomRect, m_backgroundBottomImage); } -void UserInfo::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 UserInfo::setAddress(const QString &address) { qDebug() << __PRETTY_FUNCTION__; @@ -302,27 +241,3 @@ void UserInfo::setUserName(const QString &name) m_nameLabel->setText(TextModifier::shortenText(m_nameLabel->fontMetrics(), m_userName, LABEL_MAX_WIDTH)); } - -void UserInfo::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; - } -} diff --git a/src/ui/userinfo.h b/src/ui/userinfo.h index e15e917..3dc23b9 100644 --- a/src/ui/userinfo.h +++ b/src/ui/userinfo.h @@ -29,7 +29,8 @@ #include #include "coordinates/geocoordinate.h" -#include "updatelocation/updatelocationdialog.h" + +class QLabel; class ImageButton; @@ -122,20 +123,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 Clears backups of message and publish on Facebook setting - */ - void clearUpdateLocationDialogData(); - - /** * @brief Sets the message text * * @param text Reference to user message @@ -144,11 +131,6 @@ public slots: private: /** - * @brief reads Unsend message from settings at startup - */ - void restoreUnsendMessage(); - - /** * @brief Set shortened or full-length text to labels. * * @param expanded true if full-length text is set, false otherwise @@ -166,16 +148,6 @@ private slots: */ void findButtonClicked(); - /** - * @brief Slot function to forward messageUpdate launch signal - */ - void messageUpdate(); - - /** - * @brief Slot function to get indication when dialog is finished - */ - void updateLocationDialogFinished(int reason); - /****************************************************************************** * SIGNALS ******************************************************************************/ @@ -187,40 +159,10 @@ signals: */ void findUser(const GeoCoordinate &coordinates); - /** - * @brief Signal that used to inform user that his message/location update tp Situare server - * was failed. - * This signal is originally sended from UserInfo - * @param message message for notification - * @param modal true if modal notification otherwice false - */ - void notificateUpdateFailing(const QString &message, bool modal); - - /** - * @brief Signal for requesting reverseGeo from SituareEngine - */ - void requestReverseGeo(); - - /** - * @brief Signals, when address data is ready - * - * @param address Street address - */ - void reverseGeoReady(const QString &address); - - /** - * @brief Signal for requestLocationUpdate from SituareEngine via MainWindow class - * - * @param status Status message - * @param publish Publish on Facebook - */ - void statusUpdate(const QString &status, const bool &publish); - /****************************************************************************** * DATA MEMBERS ******************************************************************************/ private: - bool m_backupFacebookPublishPolicity; ///< Backup of publish on Facebook checkbox value bool m_expanded; ///< Item expanded state QLabel *m_locationLabel; ///< Location label @@ -234,13 +176,11 @@ private: QPoint m_mousePosition; ///< Current mouse press position - QString m_backupMessage; ///< Backup of users message QString m_messageText; ///< User's message QString m_userName; ///< User's name GeoCoordinate m_coordinates; ///< User current coordinates ImageButton *m_avatar; ///< User find button - UpdateLocationDialog *m_updateLocation; ///< Update location dialog }; #endif // USERINFO_H diff --git a/src/ui/userinfopanel.cpp b/src/ui/userinfopanel.cpp index c8a1d51..ae8b29c 100644 --- a/src/ui/userinfopanel.cpp +++ b/src/ui/userinfopanel.cpp @@ -64,21 +64,6 @@ UserInfoPanel::UserInfoPanel(QWidget *parent) connect(m_userInfo, SIGNAL(findUser(GeoCoordinate)), this, SIGNAL(findUser(GeoCoordinate))); - connect(m_userInfo,SIGNAL(requestReverseGeo()), - this, SIGNAL(requestReverseGeo())); - - connect(m_userInfo, SIGNAL(statusUpdate(QString, bool)), - this, SIGNAL(statusUpdate(QString, bool))); - - connect(m_userInfo, SIGNAL(notificateUpdateFailing(QString, bool)), - this, SIGNAL(notificateUpdateFailing(QString, bool))); - - connect(this, SIGNAL(reverseGeoReady(QString)), - m_userInfo, SIGNAL(reverseGeoReady(QString))); - - connect(this, SIGNAL(clearUpdateLocationDialogData()), - m_userInfo, SLOT(clearUpdateLocationDialogData())); - connect(this, SIGNAL(collapse()), m_userInfo, SLOT(collapse())); @@ -96,7 +81,7 @@ UserInfoPanel::UserInfoPanel(QWidget *parent) this, SIGNAL(refreshUserData())); connect(updateStatusMessageButton, SIGNAL(clicked()), - m_userInfo, SLOT(messageUpdate())); + this, SIGNAL(updateLocationMessageButtonClicked())); } diff --git a/src/ui/userinfopanel.h b/src/ui/userinfopanel.h index df11c04..d631a78 100644 --- a/src/ui/userinfopanel.h +++ b/src/ui/userinfopanel.h @@ -83,44 +83,14 @@ signals: void findUser(const GeoCoordinate &coordinates); /** - * @brief Signal that used to inform user that his message/location update tp Situare server - * was failed. - * This signal is originally sended from UserInfo - * - * @param message message for notification - * @param modal true if modal notification otherwice false - */ - void notificateUpdateFailing(const QString &message, bool modal); - - /** * @brief Signal for refreshing user data. */ void refreshUserData(); /** - * @brief Signal for requesting reverseGeo from SituareEngine - */ - void requestReverseGeo(); - - /** - * @brief Signals, when address data is ready - * - * @param address Street address - */ - void reverseGeoReady(const QString &address); - - /** - * @brief Signal Signal for requestLocationUpdate from SituareEngine via MainWindow class - * - * @param status Status message - * @param publish Publish on Facebook - */ - void statusUpdate(const QString &status, const bool &publish); - - /** - * @brief Signals when updateLocationDialog's data must be cleared - */ - void clearUpdateLocationDialogData(); + * @brief Notify that update location message button was clicked + */ + void updateLocationMessageButtonClicked(); /******************************************************************************* * DATA MEMBERS -- 1.7.9.5