: QObject(parent),
m_autoCenteringEnabled(false),
m_automaticUpdateFirstStart(true),
- m_loggedIn(false),
m_userMoved(false),
- m_automaticUpdateEnabled(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);
{
qDebug() << __PRETTY_FUNCTION__;
+ m_ui->setOwnLocationCrosshairVisibility(!enabled);
+
if (m_gps->isInitialized()) {
m_ui->setGPSButtonEnabled(enabled);
m_mapEngine->setGPSEnabled(enabled);
enableAutoCentering(m_autoCenteringEnabled);
m_gps->requestLastPosition();
- if (!m_automaticUpdateEnabled && m_loggedIn)
- m_ui->requestAutomaticLocationUpdateSettings();
+ if(m_ui->loginState())
+ m_ui->readAutomaticLocationUpdateSettings();
}
else if (!enabled && m_gps->isRunning()) {
m_gps->stop();
{
qDebug() << __PRETTY_FUNCTION__;
- m_automaticUpdateEnabled = enabled;
-
//Show automatic update confirmation dialog
- if (m_automaticUpdateFirstStart && m_gps->isRunning() && m_automaticUpdateEnabled) {
+ if (m_automaticUpdateFirstStart && m_gps->isRunning() && enabled) {
m_ui->showEnableAutomaticUpdateLocationDialog(
tr("Do you want to enable automatic location update with %1 min update interval?")
.arg(updateIntervalMsecs/1000/60));
m_automaticUpdateFirstStart = false;
} else {
- if (m_automaticUpdateEnabled && m_gps->isRunning()) {
+ if (enabled && m_gps->isRunning()) {
m_ui->buildInformationBox(tr("Automatic location update enabled"));
if (updateIntervalMsecs < MIN_UPDATE_INTERVAL_MSECS)
m_automaticUpdateIntervalTimer->setInterval(MIN_UPDATE_INTERVAL_MSECS);
void SituareEngine::error(const int error)
{
- qDebug() << __PRETTY_FUNCTION__;
+ qDebug() << __PRETTY_FUNCTION__;
switch(error)
{
case QNetworkReply::ConnectionRefusedError:
+ m_ui->toggleProgressIndicator(false);
m_ui->buildInformationBox(tr("Connection refused by the server"), true);
break;
case QNetworkReply::RemoteHostClosedError:
+ m_ui->toggleProgressIndicator(false);
m_ui->buildInformationBox(tr("Connection closed by the server"), true);
break;
case QNetworkReply::HostNotFoundError:
+ m_ui->toggleProgressIndicator(false);
m_ui->buildInformationBox(tr("Remote server not found"), true);
break;
case QNetworkReply::TimeoutError:
+ m_ui->toggleProgressIndicator(false);
m_ui->buildInformationBox(tr("Connection timed out"), true);
break;
case SituareError::SESSION_EXPIRED:
m_ui->buildInformationBox(tr("Session expired. Please login again"), true);
m_facebookAuthenticator->clearAccountInformation(true); // keep username = true
+ m_situareService->clearUserData();
m_ui->loggedIn(false);
m_ui->loginFailed();
break;
case SituareError::LOGIN_FAILED:
+ m_ui->toggleProgressIndicator(false);
m_ui->buildInformationBox(tr("Invalid E-mail address or password"), true);
+ m_ui->loginFailed();
break;
case SituareError::UPDATE_FAILED:
+ m_ui->toggleProgressIndicator(false);
m_ui->buildInformationBox(tr("Update failed, please try again"), true);
break;
case SituareError::DATA_RETRIEVAL_FAILED:
+ m_ui->toggleProgressIndicator(false);
m_ui->buildInformationBox(tr("Data retrieval failed, please try again"), true);
break;
case SituareError::ADDRESS_RETRIEVAL_FAILED:
m_ui->buildInformationBox(tr("GPS initialization failed"), true);
break;
case SituareError::UNKNOWN_REPLY:
+ m_ui->toggleProgressIndicator(false);
m_ui->buildInformationBox(tr("Unknown server response"), true);
break;
+ case SituareError::INVALID_JSON:
+ m_ui->buildInformationBox(tr("Malformatted reply from server"), true);
+ m_ui->loggedIn(false);
+ m_facebookAuthenticator->clearAccountInformation(false); // clean all
+ break;
default:
+ m_ui->toggleProgressIndicator(false);
qCritical() << "QNetworkReply::NetworkError :" << error;
break;
}
{
qDebug() << __PRETTY_FUNCTION__;
- if(m_loggedIn) {
+ if(m_ui->loginState()) {
logout();
m_situareService->clearUserData();
- }
- else {
+ } else {
m_facebookAuthenticator->start();
}
}
{
qDebug() << __PRETTY_FUNCTION__;
- m_loggedIn = true;
- m_ui->loggedIn(m_loggedIn);
+ m_ui->loggedIn(true);
m_ui->show();
m_situareService->fetchLocations(); // request user locations
if (m_gps->isRunning())
- m_ui->requestAutomaticLocationUpdateSettings();
+ m_ui->readAutomaticLocationUpdateSettings();
}
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()),
+ m_ui, SIGNAL(clearUpdateLocationDialogData()));
+ emit clearUpdateLocationDialogData();
+
m_facebookAuthenticator->clearAccountInformation(); // clear all
- m_automaticUpdateEnabled = false;
m_automaticUpdateFirstStart = true;
}
Q_UNUSED(latLonCoordinate);
Q_UNUSED(accuracy);
- if (m_autoCenteringEnabled) // autocentering is disabled when map is scrolled
+ if (m_autoCenteringEnabled) // autocentering is disabled when map is scrolled
m_mapEngine->setZoomLevel(DEFAULT_ZOOM_LEVEL_WHEN_GPS_IS_AVAILABLE);
disconnect(m_gps, SIGNAL(position(QPointF,qreal)),
connect(m_facebookAuthenticator, SIGNAL(newLoginRequest()),
m_ui, SLOT(startLoginProcess()));
- connect(m_facebookAuthenticator, SIGNAL(loginFailure()),
- m_ui, SLOT(loginFailed()));
-
connect(m_facebookAuthenticator, SIGNAL(saveCookiesRequest()),
m_ui, SLOT(saveCookies()));
void SituareEngine::signalsFromMainWindow()
{
- qDebug() << __PRETTY_FUNCTION__;
+ qDebug() << __PRETTY_FUNCTION__;
connect(m_ui, SIGNAL(error(int)),
this, SLOT(error(int)));
// signals from map view
connect(m_ui, SIGNAL(mapViewScrolled(QPoint)),
- m_mapEngine, SLOT(setLocation(QPoint)));
+ m_mapEngine, SLOT(setCenterPosition(QPoint)));
connect(m_ui, SIGNAL(mapViewResized(QSize)),
m_mapEngine, SLOT(viewResized(QSize)));
this, SLOT(requestUpdateLocation(QString,bool)));
connect(m_ui, SIGNAL(enableAutomaticLocationUpdate(bool, int)),
- this, SLOT(enableAutomaticLocationUpdate(bool, int)));
+ this, SLOT(enableAutomaticLocationUpdate(bool, int)));
// signals from user info tab
connect(m_ui, SIGNAL(refreshUserData()),
this, SLOT(refreshUserData()));
connect(m_ui, SIGNAL(findUser(QPointF)),
- m_mapEngine, SLOT(setViewLocation(QPointF)));
+ m_mapEngine, SLOT(centerToCoordinates(QPointF)));
// signals from friend list tab
connect(m_ui, SIGNAL(findFriend(QPointF)),
- m_mapEngine, SLOT(setViewLocation(QPointF)));
+ m_mapEngine, SLOT(centerToCoordinates(QPointF)));
}
void SituareEngine::signalsFromMapEngine()
connect(m_situareService, SIGNAL(error(int)),
this, SLOT(error(int)));
+ connect(m_situareService, SIGNAL(error(int)),
+ m_ui, SIGNAL(messageSendingFailed(int)));
+
connect(m_situareService, SIGNAL(reverseGeoReady(QString)),
m_ui, SIGNAL(reverseGeoReady(QString)));
this, SLOT(updateWasSuccessful()));
connect(m_situareService, SIGNAL(updateWasSuccessful()),
- m_ui, SIGNAL(updateWasSuccessful()));
-
- connect(m_situareService, SIGNAL(error(int)),
- m_ui, SIGNAL(messageSendingFailed(int)));
+ m_ui, SIGNAL(clearUpdateLocationDialogData()));
}
void SituareEngine::updateWasSuccessful()
qDebug() << __PRETTY_FUNCTION__;
m_ui->toggleProgressIndicator(false);
+ m_ui->showPanels();
emit userLocationReady(user);
emit friendsLocationsReady(friendsList);