From 2769e0b50f414f281bb542085e3f9f446eed6cfb Mon Sep 17 00:00:00 2001 From: lampehe-local Date: Mon, 14 Jun 2010 12:28:57 +0300 Subject: [PATCH] backup --- src/engine/engine.cpp | 17 ++++++----------- src/engine/engine.h | 3 +-- src/ui/mainwindow.cpp | 16 +++++++++++----- src/ui/mainwindow.h | 10 ++++++++-- 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 53b9e87..6940e58 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -46,14 +46,13 @@ SituareEngine::SituareEngine(QMainWindow *parent) : QObject(parent), m_autoCenteringEnabled(false), m_automaticUpdateFirstStart(true), - m_loggedIn(false), m_userMoved(false), m_automaticUpdateIntervalTimer(0), m_lastUpdatedGPSPosition(QPointF()) { qDebug() << __PRETTY_FUNCTION__; m_ui = new MainWindow; - m_ui->updateItemVisibility(m_loggedIn); + m_ui->updateItemVisibility(); // build MapEngine m_mapEngine = new MapEngine(this); @@ -165,7 +164,7 @@ void SituareEngine::enableGPS(bool enabled) enableAutoCentering(m_autoCenteringEnabled); m_gps->requestLastPosition(); - if (m_loggedIn) + if(m_ui->loginState()) m_ui->readAutomaticLocationUpdateSettings(); } else if (!enabled && m_gps->isRunning()) { @@ -229,7 +228,6 @@ void SituareEngine::error(const int error) case SituareError::SESSION_EXPIRED: m_ui->buildInformationBox(tr("Session expired. Please login again"), true); m_facebookAuthenticator->clearAccountInformation(true); // keep username = true - m_loggedIn = false; m_situareService->clearUserData(); m_ui->loggedIn(false); m_ui->loginFailed(); @@ -261,7 +259,6 @@ void SituareEngine::error(const int error) break; case SituareError::INVALID_JSON: m_ui->buildInformationBox(tr("Malformatted reply from server"), true); - m_loggedIn = false; m_ui->loggedIn(false); m_facebookAuthenticator->clearAccountInformation(false); // clean all break; @@ -325,7 +322,7 @@ void SituareEngine::loginActionPressed() { qDebug() << __PRETTY_FUNCTION__; - if(m_loggedIn) { + if(m_ui->loginState()) { logout(); m_situareService->clearUserData(); } @@ -338,8 +335,7 @@ void SituareEngine::loginOk() { qDebug() << __PRETTY_FUNCTION__; - m_loggedIn = true; - m_ui->loggedIn(m_loggedIn); + m_ui->loggedIn(true); m_ui->show(); m_situareService->fetchLocations(); // request user locations @@ -353,15 +349,14 @@ void SituareEngine::loginProcessCancelled() qDebug() << __PRETTY_FUNCTION__; m_ui->toggleProgressIndicator(false); - m_ui->updateItemVisibility(m_loggedIn); + m_ui->updateItemVisibility(); } void SituareEngine::logout() { qDebug() << __PRETTY_FUNCTION__; - m_loggedIn = false; - m_ui->loggedIn(m_loggedIn); + m_ui->loggedIn(false); // signal to clear locationUpdateDialog's data connect(this, SIGNAL(clearUpdateLocationDialogData()), diff --git a/src/engine/engine.h b/src/engine/engine.h index 72467a8..9bbef2d 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -282,8 +282,7 @@ signals: private: bool m_autoCenteringEnabled; ///< Auto centering flag bool m_automaticUpdateFirstStart; ///< Automatic location update first start flag - bool m_loggedIn; ///< Login state - bool m_userMoved; ///< Flag for user moving + bool m_userMoved; ///< Flag for user moving FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator GPSPosition *m_gps; ///< Instance of the gps position diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 55206bc..fc6d624 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -654,7 +654,7 @@ void MainWindow::loggedIn(bool logged) m_loginAct->setText(tr("Login")); } - updateItemVisibility(m_loggedIn); + updateItemVisibility(); } void MainWindow::loginFailed() @@ -668,6 +668,13 @@ void MainWindow::loginFailed() startLoginProcess(); } +bool MainWindow::loginState() +{ + qDebug() << __PRETTY_FUNCTION__; + + return m_loggedIn; +} + void MainWindow::loginUsingCookies() { qDebug() << __PRETTY_FUNCTION__; @@ -892,18 +899,17 @@ void MainWindow::toggleProgressIndicator(bool value) #endif // Q_WS_MAEMO_5 } -void MainWindow::updateItemVisibility(bool show) +void MainWindow::updateItemVisibility() { qDebug() << __PRETTY_FUNCTION__; - if(show) { + if(m_loggedIn) { m_friendsListPanel->show(); m_friendsListPanelSidebar->show(); m_userPanel->show(); m_userPanelSidebar->show(); if(!m_gpsToggleAct->isChecked()) - setOwnLocationCrosshairVisibility(show); - + setOwnLocationCrosshairVisibility(true); } else { m_friendsListPanel->closePanel(); m_friendsListPanel->hide(); diff --git a/src/ui/mainwindow.h b/src/ui/mainwindow.h index bb57fe6..4f572fb 100644 --- a/src/ui/mainwindow.h +++ b/src/ui/mainwindow.h @@ -96,6 +96,13 @@ public: void loggedIn(bool logged); /** + * @brief Gets the login state (logged in/logged out) + * + * @return bool Login state + */ + bool loginState(); + + /** * @brief Reads automatic location update settings. */ void readAutomaticLocationUpdateSettings(); @@ -195,9 +202,8 @@ public slots: /** * @brief Shows / hides Situare related UI items * - * @param show */ - void updateItemVisibility(bool show); + void updateItemVisibility(); private: /** -- 1.7.9.5