<context>
<name>FriendListPanel</name>
<message>
-- <location filename="../../src/ui/friendlistpanel.cpp" line="44"/>
++ <location filename="../../src/ui/friendlistpanel.cpp" line="45"/>
<source>Show all</source>
<translation>Näytä kaikki</translation>
</message>
<message>
-- <location filename="../../src/ui/friendlistpanel.cpp" line="108"/>
++ <location filename="../../src/ui/friendlistpanel.cpp" line="110"/>
<source>Selected: %1</source>
<translation>Valittu: %1</translation>
</message>
<context>
<name>MainWindow</name>
<message>
-- <location filename="../../src/ui/mainwindow.cpp" line="87"/>
++ <location filename="../../src/ui/mainwindow.cpp" line="838"/>
<source>Automatic location update</source>
<translation>Automaattinen paikan päivitys</translation>
</message>
<message>
-- <location filename="../../src/ui/mainwindow.cpp" line="94"/>
++ <location filename="../../src/ui/mainwindow.cpp" line="84"/>
<source>Situare</source>
<translation>Situare</translation>
</message>
<message>
-- <location filename="../../src/ui/mainwindow.cpp" line="406"/>
-- <location filename="../../src/ui/mainwindow.cpp" line="665"/>
++ <location filename="../../src/ui/mainwindow.cpp" line="402"/>
++ <location filename="../../src/ui/mainwindow.cpp" line="666"/>
<source>Login</source>
<translation>Kirjaudu</translation>
</message>
<message>
-- <location filename="../../src/ui/mainwindow.cpp" line="411"/>
++ <location filename="../../src/ui/mainwindow.cpp" line="407"/>
<source>Settings</source>
<translation>Asetukset</translation>
</message>
<message>
-- <location filename="../../src/ui/mainwindow.cpp" line="416"/>
++ <location filename="../../src/ui/mainwindow.cpp" line="412"/>
<source>GPS</source>
<translation>GPS</translation>
</message>
<message>
-- <location filename="../../src/ui/mainwindow.cpp" line="423"/>
++ <location filename="../../src/ui/mainwindow.cpp" line="419"/>
<source>Auto centering</source>
<translation>Automaattinen keskitys</translation>
</message>
<message>
-- <location filename="../../src/ui/mainwindow.cpp" line="429"/>
++ <location filename="../../src/ui/mainwindow.cpp" line="425"/>
<source>Main</source>
<translation>Päävalikko</translation>
</message>
<message>
-- <location filename="../../src/ui/mainwindow.cpp" line="434"/>
++ <location filename="../../src/ui/mainwindow.cpp" line="430"/>
<source>Menu</source>
<translation>Valikko</translation>
</message>
<message>
-- <location filename="../../src/ui/mainwindow.cpp" line="537"/>
++ <location filename="../../src/ui/mainwindow.cpp" line="538"/>
<source>GPS timeout</source>
<translation>GPS pyyntö aikakatkaistiin</translation>
</message>
<message>
-- <location filename="../../src/ui/mainwindow.cpp" line="659"/>
++ <location filename="../../src/ui/mainwindow.cpp" line="660"/>
<source>Logout</source>
<translation>Kirjaudu ulos</translation>
</message>
<translation>Asetukset</translation>
</message>
<message>
-- <location filename="../../src/ui/settingsdialog.cpp" line="47"/>
++ <location filename="../../src/ui/settingsdialog.cpp" line="48"/>
<source>Use automatic location update</source>
<translation>Sijainnin automaattinen päivitys</translation>
</message>
<message>
-- <location filename="../../src/ui/settingsdialog.cpp" line="54"/>
-- <location filename="../../src/ui/settingsdialog.cpp" line="86"/>
++ <location filename="../../src/ui/settingsdialog.cpp" line="55"/>
++ <location filename="../../src/ui/settingsdialog.cpp" line="87"/>
<source>Update interval</source>
<translation>Päivitysväli</translation>
</message>
<message>
-- <location filename="../../src/ui/settingsdialog.cpp" line="131"/>
++ <location filename="../../src/ui/settingsdialog.cpp" line="120"/>
<source>%1 min</source>
<translation>%1 min</translation>
</message>
<context>
<name>SituareEngine</name>
<message>
-- <location filename="../../src/engine/engine.cpp" line="140"/>
++ <location filename="../../src/engine/engine.cpp" line="133"/>
<source>Auto centering disabled</source>
<translation>Automaattinen keskitys pois päältä</translation>
</message>
<message>
-- <location filename="../../src/engine/engine.cpp" line="180"/>
++ <location filename="../../src/engine/engine.cpp" line="183"/>
<source>Unable to start GPS</source>
<translation>GPS käynnistys epäonnistui</translation>
</message>
<message>
-- <location filename="../../src/engine/engine.cpp" line="195"/>
++ <location filename="../../src/engine/engine.cpp" line="196"/>
<source>Do you want to enable automatic location update with %1 min update interval?</source>
<translation>Asetetaanko automaattinen paikan päivitys %1 minuutin välein päälle?</translation>
</message>
<message>
-- <location filename="../../src/engine/engine.cpp" line="200"/>
++ <location filename="../../src/engine/engine.cpp" line="201"/>
<source>Automatic location update enabled</source>
<translation>Automaattinen paikan päivitys päällä</translation>
</message>
<message>
-- <location filename="../../src/engine/engine.cpp" line="221"/>
++ <location filename="../../src/engine/engine.cpp" line="230"/>
++ <source>Unknown server error</source>
++ <translation type="unfinished"></translation>
++ </message>
++ <message>
++ <location filename="../../src/engine/engine.cpp" line="236"/>
++ <source>Missing argument from request</source>
++ <translation type="unfinished"></translation>
++ </message>
++ <message>
++ <location filename="../../src/engine/engine.cpp" line="238"/>
<source>Connection refused by the server</source>
<translation>Palvelin ei vastaa pyyntöihin</translation>
</message>
<message>
-- <location filename="../../src/engine/engine.cpp" line="224"/>
++ <location filename="../../src/engine/engine.cpp" line="244"/>
<source>Connection closed by the server</source>
<translation>Palvelin sulki yhteyden</translation>
</message>
<message>
-- <location filename="../../src/engine/engine.cpp" line="227"/>
++ <location filename="../../src/engine/engine.cpp" line="250"/>
<source>Remote server not found</source>
<translation>Palvelinta ei löydy</translation>
</message>
<message>
-- <location filename="../../src/engine/engine.cpp" line="230"/>
++ <location filename="../../src/engine/engine.cpp" line="256"/>
<source>Connection timed out</source>
<translation>Yhteys aikakatkaistiin</translation>
</message>
<message>
-- <location filename="../../src/engine/engine.cpp" line="233"/>
++ <location filename="../../src/engine/engine.cpp" line="262"/>
++ <source>No network connection</source>
++ <translation>Ei verkkoyhteyttä</translation>
++ </message>
++ <message>
++ <location filename="../../src/engine/engine.cpp" line="266"/>
<source>Session expired. Please login again</source>
<translation>Istunto vanhentunut. Kirjaudu uudelleen</translation>
</message>
<message>
-- <location filename="../../src/engine/engine.cpp" line="241"/>
++ <location filename="../../src/engine/engine.cpp" line="274"/>
<source>Invalid E-mail address or password</source>
<translation>Virheellinen sähköpostiosoite tai salasana</translation>
</message>
<message>
-- <location filename="../../src/engine/engine.cpp" line="244"/>
++ <location filename="../../src/engine/engine.cpp" line="279"/>
<source>Update failed, please try again</source>
<translation>Päivitys epäonnistui. Yritä uudelleen</translation>
</message>
<message>
-- <location filename="../../src/engine/engine.cpp" line="247"/>
++ <location filename="../../src/engine/engine.cpp" line="283"/>
<source>Data retrieval failed, please try again</source>
<translation>Tiedon haku epäonnistui. Yritä uudelleen</translation>
</message>
<message>
-- <location filename="../../src/engine/engine.cpp" line="250"/>
++ <location filename="../../src/engine/engine.cpp" line="286"/>
<source>Address retrieval failed</source>
<translation>Osoitteen haku epäonnistui</translation>
</message>
<message>
-- <location filename="../../src/engine/engine.cpp" line="266"/>
++ <location filename="../../src/engine/engine.cpp" line="299"/>
<source>Malformatted reply from server</source>
<translation>Viallisesti muotoiltu serverin vastaus</translation>
</message>
<message>
++ <location filename="../../src/engine/engine.cpp" line="305"/>
++ <source>Geolocation server not responding</source>
++ <translation type="unfinished"></translation>
++ </message>
++ <message>
++ <location filename="../../src/engine/engine.cpp" line="309"/>
++ <source>Geolocation request failed, please try again</source>
++ <translation type="unfinished"></translation>
++ </message>
++ <message>
++ <location filename="../../src/engine/engine.cpp" line="313"/>
++ <source>Invalid lat/lon value, please try again</source>
++ <translation type="unfinished"></translation>
++ </message>
++ <message>
++ <location filename="../../src/engine/engine.cpp" line="462"/>
++ <source>Automatic location update.</source>
++ <translation type="unfinished"></translation>
++ </message>
++ <message>
<source>Address retrieval failed, please try again</source>
<translation type="obsolete">Osoitteen haku epäonnistui. Yritä uudelleen</translation>
</message>
<message>
-- <location filename="../../src/engine/engine.cpp" line="253"/>
++ <location filename="../../src/engine/engine.cpp" line="289"/>
<source>Image download failed</source>
<translation>Kuvan haku epäonnistui</translation>
</message>
<message>
-- <location filename="../../src/engine/engine.cpp" line="256"/>
++ <location filename="../../src/engine/engine.cpp" line="292"/>
<source>Map image download failed</source>
<translation>Karttakuvan lataaminen epäonnistui</translation>
</message>
<message>
-- <location filename="../../src/engine/engine.cpp" line="260"/>
++ <location filename="../../src/engine/engine.cpp" line="296"/>
<source>GPS initialization failed</source>
<translation>GPS alustus epäonnistui</translation>
</message>
<message>
-- <location filename="../../src/engine/engine.cpp" line="263"/>
<source>Unknown server response</source>
-- <translation>Tuntematon vastaus palvelimelta</translation>
++ <translation type="obsolete">Tuntematon vastaus palvelimelta</translation>
</message>
<message>
<source>JSON parsing failed, invalid JSON string</source>
<translation type="obsolete">Virheellinen JSON, parsiminen epäonnistui</translation>
</message>
<message>
-- <location filename="../../src/engine/engine.cpp" line="302"/>
-- <location filename="../../src/engine/engine.cpp" line="310"/>
++ <location filename="../../src/engine/engine.cpp" line="351"/>
++ <location filename="../../src/engine/engine.cpp" line="359"/>
<source>GPS enabled</source>
<translation>GPS päällä</translation>
</message>
<message>
-- <location filename="../../src/engine/engine.cpp" line="303"/>
-- <location filename="../../src/engine/engine.cpp" line="313"/>
++ <location filename="../../src/engine/engine.cpp" line="352"/>
++ <location filename="../../src/engine/engine.cpp" line="362"/>
<source>Auto centering enabled</source>
<translation>Automaattinen keskitys päällä</translation>
</message>
<translation>Päivitä sijainti</translation>
</message>
<message>
-- <location filename="../../src/ui/updatelocation/updatelocationdialog.cpp" line="71"/>
++ <location filename="../../src/ui/updatelocation/updatelocationdialog.cpp" line="74"/>
<source>Publish on Facebook</source>
<translation>Julkaise Facebookissa</translation>
</message>
<message>
-- <location filename="../../src/ui/updatelocation/updatelocationdialog.cpp" line="77"/>
++ <location filename="../../src/ui/updatelocation/updatelocationdialog.cpp" line="80"/>
<source>Send</source>
<translation>Lähetä</translation>
</message>
<translation>Sijainti:</translation>
</message>
<message>
-- <location filename="../../src/ui/updatelocation/updatelocationdialog.cpp" line="42"/>
++ <location filename="../../src/ui/updatelocation/updatelocationdialog.cpp" line="43"/>
<source>Message:</source>
<translation>Viesti:</translation>
</message>
<translation type="obsolete">Sijainnin päivitys epäonnistui\n\nVistisi on tallennettu kunnes pävitys on onnistunut</translation>
</message>
<message>
-- <location filename="../../src/ui/userinfo.cpp" line="338"/>
++ <location filename="../../src/ui/userinfo.cpp" line="357"/>
<source>Location update failed, please try again</source>
<translation>Paikkatiedon päivitys epäonnistui, yritä uudelleen</translation>
</message>
#include "map/mapengine.h"
#include "situareservice/situareservice.h"
#include "ui/mainwindow.h"
++#include "network/networkaccessmanager.h"
+ #include "mce.h"
#include <cmath>
#include "engine.h"
: QObject(parent),
m_autoCenteringEnabled(false),
m_automaticUpdateFirstStart(true),
+ m_automaticUpdateRequest(false),
m_userMoved(false),
m_automaticUpdateIntervalTimer(0),
m_lastUpdatedGPSPosition(QPointF())
- {
+ {
qDebug() << __PRETTY_FUNCTION__;
m_ui = new MainWindow;
m_ui->updateItemVisibility();
++ m_networkAccessManager = NetworkAccessManager::instance();
++
// build MapEngine
m_mapEngine = new MapEngine(this);
m_ui->setMapViewScene(m_mapEngine->scene());
m_automaticUpdateIntervalTimer = new QTimer(this);
connect(m_automaticUpdateIntervalTimer, SIGNAL(timeout()),
- this, SLOT(automaticUpdateIntervalTimerTimeout()));
+ this, SLOT(startAutomaticUpdate()));
// signals connected, now it's time to show the main window
// but init the MapEngine before so starting location is set
m_gps->setMode(GPSPosition::Default);
initializeGpsAndAutocentering();
+
+ m_mce = new MCE(this);
+ connect(m_mce, SIGNAL(displayStateChanged(bool)), this, SLOT(displayStateChanged(bool)));
}
SituareEngine::~SituareEngine()
settings.setValue(SETTINGS_AUTO_CENTERING_ENABLED, m_autoCenteringEnabled);
}
- void SituareEngine::automaticUpdateIntervalTimerTimeout()
- {
- qDebug() << __PRETTY_FUNCTION__;
-
- if (m_gps->isRunning() && m_userMoved) {
- requestUpdateLocation();
- m_userMoved = false;
- }
- }
-
void SituareEngine::changeAutoCenteringSetting(bool enabled)
{
qDebug() << __PRETTY_FUNCTION__;
m_ui->buildInformationBox(tr("Auto centering disabled"));
}
+ void SituareEngine::displayStateChanged(bool enabled)
+ {
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_gps->enablePowerSave(!enabled);
+
+ if (m_autoCenteringEnabled)
+ enableAutoCentering(enabled);
+ }
+
void SituareEngine::enableAutoCentering(bool enabled)
{
qDebug() << __PRETTY_FUNCTION__;
else
m_automaticUpdateIntervalTimer->setInterval(updateIntervalMsecs);
+ connect(m_gps, SIGNAL(position(QPointF,qreal)),
+ this, SLOT(requestAutomaticUpdateIfMoved(QPointF)));
+
m_automaticUpdateIntervalTimer->start();
} else {
+ disconnect(m_gps, SIGNAL(position(QPointF,qreal)),
+ this, SLOT(requestAutomaticUpdateIfMoved(QPointF)));
+
m_automaticUpdateIntervalTimer->stop();
}
}
}
- void SituareEngine::error(const int error)
+ void SituareEngine::error(const int context, const int error)
{
- qWarning() << __PRETTY_FUNCTION__;
+ qDebug() << __PRETTY_FUNCTION__;
switch(error)
{
- case QNetworkReply::ConnectionRefusedError:
- m_ui->buildInformationBox(tr("Connection refused by the server"), true);
+ case SituareError::ERROR_GENERAL:
+ if(context == ErrorContext::SITUARE) {
+ m_ui->toggleProgressIndicator(false);
+ m_ui->buildInformationBox(tr("Unknown server error"), true);
+ }
+ break;
+ case SituareError::ERROR_MISSING_ARGUMENT | QNetworkReply::ConnectionRefusedError :
+ m_ui->toggleProgressIndicator(false);
+ if(context == ErrorContext::SITUARE) {
+ m_ui->buildInformationBox(tr("Missing argument from request"), true);
+ } else if(context == ErrorContext::NETWORK) {
+ m_ui->buildInformationBox(tr("Connection refused by the server"), true);
+ }
break;
case QNetworkReply::RemoteHostClosedError:
- m_ui->buildInformationBox(tr("Connection closed by the server"), true);
+ if(context == ErrorContext::NETWORK) {
+ m_ui->toggleProgressIndicator(false);
+ m_ui->buildInformationBox(tr("Connection closed by the server"), true);
+ }
break;
case QNetworkReply::HostNotFoundError:
- m_ui->buildInformationBox(tr("Remote server not found"), true);
+ if(context == ErrorContext::NETWORK) {
+ m_ui->toggleProgressIndicator(false);
+ m_ui->buildInformationBox(tr("Remote server not found"), true);
+ }
break;
case QNetworkReply::TimeoutError:
- m_ui->buildInformationBox(tr("Connection timed out"), true);
+ if(context == ErrorContext::NETWORK) {
+ m_ui->toggleProgressIndicator(false);
+ m_ui->buildInformationBox(tr("Connection timed out"), true);
+ }
break;
+ case QNetworkReply::UnknownNetworkError:
- m_ui->buildInformationBox(tr("Network error. Please connect to network"), true);
- m_ui->toggleProgressIndicator(false);
++ if(context == ErrorContext::NETWORK) {
++ m_ui->toggleProgressIndicator(false);
++ m_ui->buildInformationBox(tr("No network connection"), true);
++ }
+ break;
case SituareError::SESSION_EXPIRED:
m_ui->buildInformationBox(tr("Session expired. Please login again"), true);
m_facebookAuthenticator->clearAccountInformation(true); // keep username = true
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:
enableGPS(false);
m_ui->buildInformationBox(tr("GPS initialization failed"), true);
break;
- case SituareError::UNKNOWN_REPLY:
- 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;
+ case SituareError::ERROR_GEOLOCATION_SERVER_UNAVAILABLE:
+ m_ui->toggleProgressIndicator(false);
+ m_ui->buildInformationBox(tr("Geolocation server not responding"), true);
+ break;
+ case SituareError::ERROR_GEOLOCATION_REQUEST_FAIL:
+ m_ui->toggleProgressIndicator(false);
+ m_ui->buildInformationBox(tr("Geolocation request failed, please try again"), true);
+ break;
+ case SituareError::ERROR_GEOLOCATION_LONLAT_INVALID:
+ m_ui->toggleProgressIndicator(false);
+ m_ui->buildInformationBox(tr("Invalid lat/lon value, please try again"), true);
+ break;
default:
- qCritical() << "QNetworkReply::NetworkError :" << error;
+ m_ui->toggleProgressIndicator(false);
+ if(context == ErrorContext::NETWORK)
+ qCritical() << "QNetworkReply::NetworkError: " << error;
+ else
+ qCritical() << "Unknown error: " << error;
+
break;
}
}
}
}
- bool SituareEngine::isUserMoved()
- {
- qDebug() << __PRETTY_FUNCTION__;
-
- return m_userMoved;
- }
-
void SituareEngine::loginActionPressed()
{
qDebug() << __PRETTY_FUNCTION__;
-- if(m_ui->loginState()) {
-- logout();
-- m_situareService->clearUserData();
-- } else {
-- m_facebookAuthenticator->start();
++ if (m_networkAccessManager->isConnected()) {
++ if(m_ui->loginState()) {
++ logout();
++ m_situareService->clearUserData();
++ } else {
++ m_facebookAuthenticator->start();
++ }
++ }
++ else {
++ error(ErrorContext::NETWORK, QNetworkReply::UnknownNetworkError);
}
}
{
qDebug() << __PRETTY_FUNCTION__;
-- m_ui->toggleProgressIndicator(true);
--
-- m_situareService->fetchLocations();
++ if (m_networkAccessManager->isConnected()) {
++ m_ui->toggleProgressIndicator(true);
++ m_situareService->fetchLocations();
++ }
++ else {
++ error(ErrorContext::NETWORK, QNetworkReply::UnknownNetworkError);
++ }
}
void SituareEngine::requestAddress()
{
qDebug() << __PRETTY_FUNCTION__;
-- if (m_gps->isRunning())
-- m_situareService->reverseGeo(m_gps->lastPosition());
-- else
-- m_situareService->reverseGeo(m_mapEngine->centerGeoCoordinate());
++ if (m_networkAccessManager->isConnected()) {
++ if (m_gps->isRunning())
++ m_situareService->reverseGeo(m_gps->lastPosition());
++ else
++ m_situareService->reverseGeo(m_mapEngine->centerGeoCoordinate());
++ }
++ else {
++ error(ErrorContext::NETWORK, QNetworkReply::UnknownNetworkError);
++ }
}
void SituareEngine::requestUpdateLocation(const QString &status, bool publish)
{
qDebug() << __PRETTY_FUNCTION__;
-- m_ui->toggleProgressIndicator(true);
++ if (m_networkAccessManager->isConnected()) {
++ m_ui->toggleProgressIndicator(true);
-- if (m_gps->isRunning())
-- m_situareService->updateLocation(m_gps->lastPosition(), status, publish);
-- else
-- m_situareService->updateLocation(m_mapEngine->centerGeoCoordinate(), status, publish);
++ if (m_gps->isRunning())
++ m_situareService->updateLocation(m_gps->lastPosition(), status, publish);
++ else
++ m_situareService->updateLocation(m_mapEngine->centerGeoCoordinate(), status, publish);
++ }
++ else {
++ error(ErrorContext::NETWORK, QNetworkReply::UnknownNetworkError);
++ }
}
- void SituareEngine::saveGPSPosition(QPointF position)
+ void SituareEngine::requestAutomaticUpdateIfMoved(QPointF position)
{
qDebug() << __PRETTY_FUNCTION__;
m_lastUpdatedGPSPosition = position;
m_userMoved = true;
}
+
+ if (m_automaticUpdateRequest && m_userMoved) {
+ requestUpdateLocation(tr("Automatic location update."));
+ m_automaticUpdateRequest = false;
+ m_userMoved = false;
+ }
}
void SituareEngine::setFirstStartZoomLevel(QPointF latLonCoordinate, qreal accuracy)
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)),
{
qDebug() << __PRETTY_FUNCTION__;
- connect(m_facebookAuthenticator, SIGNAL(error(int)),
- this, SLOT(error(int)));
+ connect(m_facebookAuthenticator, SIGNAL(error(int, int)),
+ this, SLOT(error(int, int)));
connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)),
m_situareService, SLOT(credentialsReady(FacebookCredentials)));
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()));
connect(m_gps, SIGNAL(timeout()),
m_ui, SLOT(gpsTimeout()));
- connect(m_gps, SIGNAL(error(int)),
- this, SLOT(error(int)));
-
- connect(m_gps, SIGNAL(position(QPointF,qreal)),
- this, SLOT(saveGPSPosition(QPointF)));
+ connect(m_gps, SIGNAL(error(int, int)),
+ this, SLOT(error(int, int)));
}
void SituareEngine::signalsFromMainWindow()
{
- qDebug() << __PRETTY_FUNCTION__;
+ qDebug() << __PRETTY_FUNCTION__;
- connect(m_ui, SIGNAL(error(int)),
- this, SLOT(error(int)));
+ connect(m_ui, SIGNAL(error(int, int)),
+ this, SLOT(error(int, int)));
connect(m_ui, SIGNAL(fetchUsernameFromSettings()),
this, SLOT(fetchUsernameFromSettings()));
// 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()
{
qDebug() << __PRETTY_FUNCTION__;
- connect(m_mapEngine, SIGNAL(error(int)),
- this, SLOT(error(int)));
+ connect(m_mapEngine, SIGNAL(error(int, int)),
+ this, SLOT(error(int, int)));
connect(m_mapEngine, SIGNAL(locationChanged(QPoint)),
m_ui, SIGNAL(centerToSceneCoordinates(QPoint)));
{
qDebug() << __PRETTY_FUNCTION__;
- connect(m_situareService, SIGNAL(error(int)),
- this, SLOT(error(int)));
+ connect(m_situareService, SIGNAL(error(int, int)),
+ this, SLOT(error(int, int)));
- connect(m_situareService, SIGNAL(error(int)),
+ connect(m_situareService, SIGNAL(error(int, int)),
m_ui, SIGNAL(messageSendingFailed(int)));
connect(m_situareService, SIGNAL(reverseGeoReady(QString)),
m_ui, SIGNAL(clearUpdateLocationDialogData()));
}
+ void SituareEngine::startAutomaticUpdate()
+ {
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_gps->requestUpdate();
+ m_automaticUpdateRequest = true;
+ }
+
void SituareEngine::updateWasSuccessful()
{
qDebug() << __PRETTY_FUNCTION__;
-- m_situareService->fetchLocations();
++ if (m_networkAccessManager->isConnected())
++ m_situareService->fetchLocations();
++ else
++ error(ErrorContext::NETWORK, QNetworkReply::UnknownNetworkError);
}
void SituareEngine::userDataChanged(User *user, QList<User *> &friendsList)
qDebug() << __PRETTY_FUNCTION__;
m_ui->toggleProgressIndicator(false);
+ m_ui->showPanels();
emit userLocationReady(user);
emit friendsLocationsReady(friendsList);
class GPSPosition;
class MainWindow;
class MapEngine;
++class NetworkAccessManager;
class SituareService;
class User;
+ class MCE;
class QTimer;
/**
* @brief Slot to intercept error signal from ImageFetcher and SituareService
*
+ * @param context Error context
* @param error Error message
*/
- void error(const int error);
+ void error(const int context, const int error);
/**
* @brief Slot to intercept signal when username is fetched from settings
private:
/**
- * @brief Checks if user is moved enough for position auto update.
- *
- * @return true if moved engouh, false otherwise
- */
- bool isUserMoved();
-
- /**
* @brief Read settings and determine whether to use GPS and autocentering.
* When values does not found on the settings, GPS and autocentering are enabled as a default.
*/
private slots:
/**
- * @brief Automatic update interval timer timeout.
- *
- * Requests update location if user has moved.
- */
- void automaticUpdateIntervalTimerTimeout();
-
- /**
* @brief Set auto centering feature enabled / disabled
*
* @param enabled true if enabled, false otherwise
void disableAutoCentering();
/**
+ * @brief Slot for display state changed.
+ *
+ * @param enabled true if enabled, false otherwise
+ */
+ void displayStateChanged(bool enabled);
+
+ /**
* @brief Slot for auto centering enabling.
*
* Calls gps to send last known position
void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
/**
+ * @brief Requests automatic update.
+ *
+ * Makes automatic location update request if user has moved enough.
+ *
+ * @param position geo coordinates
+ */
+ void requestAutomaticUpdateIfMoved(QPointF position);
+
+ /**
* @brief Sets zoom level to default when first GPS location is received if autocentering
* is enabled.
*
void setFirstStartZoomLevel(QPointF latLonCoordinate, qreal accuracy);
/**
- * @brief Saves GPS position.
- *
- * Saves GPS position if it has changed enough and sets m_userMoved flag.
+ * @brief Automatic update interval timer timeout.
*
- * @param position geo coordinates
+ * Requests update location if user has moved.
*/
- void saveGPSPosition(QPointF position);
+ void startAutomaticUpdate();
/*******************************************************************************
* SIGNALS
private:
bool m_autoCenteringEnabled; ///< Auto centering flag
bool m_automaticUpdateFirstStart; ///< Automatic location update first start flag
- bool m_userMoved; ///< Flag for user moving
+ bool m_automaticUpdateRequest; ///< Flag for automatic update request
+ bool m_userMoved; ///< Flag for user move
+
FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
GPSPosition *m_gps; ///< Instance of the gps position
MainWindow *m_ui; ///< Instance of the MainWindow UI
MapEngine *m_mapEngine; ///< MapEngine
++ NetworkAccessManager *m_networkAccessManager; ///< NetworkAccessManager
SituareService *m_situareService; ///< Instance of the situare server communication service
+ MCE *m_mce; ///< Instance of the MCE
QTimer *m_automaticUpdateIntervalTimer; ///< Automatic update interval timer
QPointF m_lastUpdatedGPSPosition; ///< Last updated GPS position
#include <QNetworkRequest>
#include <QNetworkAccessManager>
#include <QDebug>
+#include <QTimer>
#include "networkhandler.h"
#include "networkaccessmanager.h"
#include "networkreply.h"
+#include "common.h"
NetworkAccessManager *NetworkAccessManager::m_instance = 0;
NetworkAccessManager::NetworkAccessManager()
-- : m_networkHandler(0),
++ : m_connected(false),
++ m_networkHandler(0),
m_networkAccessManagerPrivate(0)
{
qDebug() << __PRETTY_FUNCTION__;
connect(m_networkHandler, SIGNAL(connected()),
this, SLOT(connected()));
++ connect(m_networkHandler, SIGNAL(disconnected()),
++ this, SLOT(disconnected()));
connect(m_networkAccessManagerPrivate, SIGNAL(finished(QNetworkReply*)),
this, SLOT(downloadFinished(QNetworkReply*)));
{
qDebug() << __PRETTY_FUNCTION__;
++ m_connected = true;
++
//Loop through all requests and calls get method.
foreach (const QNetworkRequest &request, m_requestQueue) {
QNetworkReply *reply = m_networkAccessManagerPrivate->get(request);
m_requestQueue.clear();
}
++void NetworkAccessManager::disconnected()
++{
++ qDebug() << __PRETTY_FUNCTION__;
++
++ m_connected = false;
++}
++
void NetworkAccessManager::downloadFinished(QNetworkReply *reply)
{
qDebug() << __PRETTY_FUNCTION__;
}
}
-QNetworkReply *NetworkAccessManager::get(const QNetworkRequest &request)
+QNetworkReply *NetworkAccessManager::get(const QNetworkRequest &request, bool onlineRequestsOnly)
{
qDebug() << __PRETTY_FUNCTION__;
m_requestQueue.append(request);
m_networkHandler->connect();
QNetworkReply *reply = new NetworkReply(request, this);
- m_offlineReplyQueue.insert(request.url().toString(), reply);
+
+ if (onlineRequestsOnly) {
+ ((NetworkReply*)reply)->setErrorCode(QNetworkReply::UnknownNetworkError);
+ emit finished(reply);
+ }
+ else {
+ m_offlineReplyQueue.insert(request.url().toString(), reply);
+ }
+
return reply;
}
//Connected, use normal get method.
}
}
--
NetworkAccessManager *NetworkAccessManager::instance()
{
qDebug() << __PRETTY_FUNCTION__;
return m_instance;
}
++bool NetworkAccessManager::isConnected()
++{
++ qDebug() << __PRETTY_FUNCTION__;
++
++ return m_connected;
++}
++
void NetworkAccessManager::setCache(QAbstractNetworkCache *cache)
{
qDebug() << __PRETTY_FUNCTION__;
static NetworkAccessManager *instance();
/**
++ * @brief Returns connection state.
++ *
++ * @return true if connected, false otherwise
++ */
++ bool isConnected();
++
++ /**
* @brief Makes request and return reply.
*
* @param request QNetworkRequest
* @return QNetworkReply
*/
- QNetworkReply *get(const QNetworkRequest &request);
+ QNetworkReply *get(const QNetworkRequest &request, bool onlineRequestsOnly = false);
/**
* @brief Sets cache.
void connected();
/**
++ * @brief Slot for network disconnected state.
++ */
++ void disconnected();
++
++ /**
* @brief Slot for finished download.
*
* @param reply reply from network
* DATA MEMBERS
******************************************************************************/
private:
++ bool m_connected; ///< Connection flag
static NetworkAccessManager *m_instance; ///< Instance of NetworkAccessManager
NetworkHandler *m_networkHandler; ///< Instance of NetworkHandler
QNetworkAccessManager *m_networkAccessManagerPrivate; ///< Instance of QNetworkAccessManager
m_networkManager = NetworkAccessManager::instance();
connect(m_networkManager, SIGNAL(finished(QNetworkReply*)),
- this, SLOT(requestFinished(QNetworkReply*)));
+ this, SLOT(requestFinished(QNetworkReply*)), Qt::QueuedConnection);
m_imageFetcher = new ImageFetcher(NetworkAccessManager::instance(), this);
connect(this, SIGNAL(fetchImage(QUrl)),
m_imageFetcher, SLOT(fetchImage(QUrl)));
connect(m_imageFetcher, SIGNAL(imageReceived(QUrl,QPixmap)),
this, SLOT(imageReceived(QUrl, QPixmap)));
- connect(m_imageFetcher, SIGNAL(error(int)),
- this, SIGNAL(error(int)));
+ connect(m_imageFetcher, SIGNAL(error(int, int)),
+ this, SIGNAL(error(int, int)));
}
SituareService::~SituareService()
m_credentials.sig(), EN_LOCALE);
QString urlParameters = formUrlParameters(coordinates);
+ urlParameters.append(JSON_FORMAT);
QUrl url = formUrl(SITUARE_URL, REVERSE_GEO, urlParameters);
sendRequest(url, COOKIE, cookie);
request.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false);
request.setRawHeader(cookieType.toAscii(), cookie.toUtf8());
- QNetworkReply *reply = m_networkManager->get(request);
+ QNetworkReply *reply = m_networkManager->get(request, true);
m_currentRequests.append(reply);
}
//Reply from situare
if (m_currentRequests.contains(reply)) {
qDebug() << "BytesAvailable: " << reply->bytesAvailable();
if (reply->error()) {
- emit error(reply->error());
+ emit error(ErrorContext::NETWORK, reply->error());
} else {
- qint64 max = reply->size();
- QByteArray replyArray = reply->read(max);
- qDebug() << "Reply from: " << url << "reply " << replyArray;
+ QByteArray replyArray = reply->readAll();
+ qDebug() << "Reply from: " << reply->url() << "reply " << replyArray;
if(replyArray == ERROR_LAT.toAscii()) {
qDebug() << "Error: " << ERROR_LAT;
- emit error(SituareError::UPDATE_FAILED);
+ emit error(ErrorContext::SITUARE, SituareError::UPDATE_FAILED);
} else if(replyArray == ERROR_LON.toAscii()) {
qDebug() << "Error: " << ERROR_LON;
- emit error(SituareError::UPDATE_FAILED);
+ emit error(ErrorContext::SITUARE, SituareError::UPDATE_FAILED);
} else if(replyArray.contains(ERROR_SESSION.toAscii())) {
qDebug() << "Error: " << ERROR_SESSION;
- emit error(SituareError::SESSION_EXPIRED);
+ emit error(ErrorContext::SITUARE, SituareError::SESSION_EXPIRED);
} else if(replyArray.startsWith(OPENING_BRACE_MARK.toAscii())) {
qDebug() << "JSON string";
parseUserData(replyArray);
} else if(replyArray.isEmpty()) {
- if(url.toString().contains(UPDATE_LOCATION.toAscii())) {
+ if(reply->url().toString().contains(UPDATE_LOCATION.toAscii())) {
emit updateWasSuccessful();
- } else if(url.toString().contains(REVERSE_GEO.toAscii())) {
- // reversegeo failed
- emit error(SituareError::ADDRESS_RETRIEVAL_FAILED);
} else {
// session credentials are invalid
- emit error(SituareError::SESSION_EXPIRED);
+ emit error(ErrorContext::SITUARE, SituareError::SESSION_EXPIRED);
}
- } else if(url.toString().contains(REVERSE_GEO.toAscii())) {
- // Street address ready
- QString address = QString::fromUtf8(replyArray);
- emit reverseGeoReady(address);
} else {
// unknown reply
- emit error(SituareError::UNKNOWN_REPLY);
+ emit error(ErrorContext::SITUARE, SituareError::ERROR_GENERAL);
}
}
m_currentRequests.removeAll(reply);
m_credentials = credentials;
}
- void SituareService::parseUserData(/*const*/ QByteArray &jsonReply)
+ void SituareService::parseUserData(const QByteArray &jsonReply)
{
qDebug() << __PRETTY_FUNCTION__;
QVariantMap result = parser.parse (jsonReply, &ok).toMap();
if (!ok) {
- emit error(SituareError::INVALID_JSON);
+ emit error(ErrorContext::SITUARE, SituareError::INVALID_JSON);
return;
} else {
- QVariant userVariant = result.value("user");
- QMap<QString, QVariant> userMap = userVariant.toMap();
+ if(result.contains("ErrorCode")) {
+ QVariant errorVariant = result.value("ErrorCode");
+ emit error(ErrorContext::SITUARE, errorVariant.toInt());
+ return;
+ } else if(result.contains("user")) {
- QPointF coordinates(userMap["longitude"].toReal(), userMap["latitude"].toReal());
+ QVariant userVariant = result.value("user");
+ QMap<QString, QVariant> userMap = userVariant.toMap();
- QUrl imageUrl = userMap[NORMAL_SIZE_PROFILE_IMAGE].toUrl();
+ QPointF coordinates(userMap["longitude"].toReal(), userMap["latitude"].toReal());
- if(imageUrl.isEmpty()) {
- // user doesn't have profile image, so we need to get him a silhouette image
- m_defaultImage = true;
- }
-
- m_user = new User(userMap["address"].toString(), coordinates, userMap["name"].toString(),
- userMap["note"].toString(), imageUrl, userMap["timestamp"].toString(),
- true, userMap["uid"].toString());
-
- foreach (QVariant friendsVariant, result["friends"].toList()) {
- QMap<QString, QVariant> friendMap = friendsVariant.toMap();
- QVariant distance = friendMap["distance"];
- QMap<QString, QVariant> distanceMap = distance.toMap();
+ QUrl imageUrl = userMap[NORMAL_SIZE_PROFILE_IMAGE].toUrl();
- QPointF coordinates(friendMap["longitude"].toReal(), friendMap["latitude"].toReal());
-
- QUrl imageUrl = friendMap["profile_pic"].toUrl();
+ if(imageUrl.isEmpty()) {
+ // user doesn't have profile image, so we need to get him a silhouette image
+ m_defaultImage = true;
+ }
- if(imageUrl.isEmpty()) {
- // friend doesn't have profile image, so we need to get him a silhouette image
- m_defaultImage = true;
- }
+ QString address = userMap["address"].toString();
+ if(address.isEmpty()) {
+ QStringList location;
+ location.append(QString::number(coordinates.y()));
+ location.append(QString::number(coordinates.x()));
+ address = location.join(", ");
+ }
- User *user = new User(friendMap["address"].toString(), coordinates,
- friendMap["name"].toString(),
- friendMap["note"].toString(), imageUrl,
- friendMap["timestamp"].toString(),
- false, friendMap["uid"].toString(),
- distanceMap["units"].toString(),
- distanceMap["value"].toDouble());
+ m_user = new User(address, coordinates, userMap["name"].toString(),
+ userMap["note"].toString(), imageUrl, userMap["timestamp"].toString(),
+ true, userMap["uid"].toString());
+
+ foreach (QVariant friendsVariant, result["friends"].toList()) {
+ QMap<QString, QVariant> friendMap = friendsVariant.toMap();
+ QVariant distance = friendMap["distance"];
+ QMap<QString, QVariant> distanceMap = distance.toMap();
+
+ QPointF coordinates(friendMap["longitude"].toReal(), friendMap["latitude"].toReal());
+
+ QUrl imageUrl = friendMap["profile_pic"].toUrl();
+
+ if(imageUrl.isEmpty()) {
+ // friend doesn't have profile image, so we need to get him a silhouette image
+ m_defaultImage = true;
+ }
+
+ QString address = friendMap["address"].toString();
+ if(address.isEmpty()) {
+ QStringList location;
+ location.append(QString::number(coordinates.y()));
+ location.append(QString::number(coordinates.x()));
+ address = location.join(", ");
+ }
+
+ User *user = new User(address, coordinates,
+ friendMap["name"].toString(),
+ friendMap["note"].toString(), imageUrl,
+ friendMap["timestamp"].toString(),
+ false, friendMap["uid"].toString(),
+ distanceMap["units"].toString(),
+ distanceMap["value"].toDouble());
+
+ m_friendsList.append(user);
+ }
+ addProfileImages();
+ } else {
+ QVariant address = result.value("address");
+ if(!address.toString().isEmpty()) {
+ emit reverseGeoReady(address.toString());
+ } else {
+ QStringList coordinates;
+ coordinates.append(result.value("lat").toString());
+ coordinates.append(result.value("lon").toString());
- m_friendsList.append(user);
+ emit error(ErrorContext::SITUARE, SituareError::ADDRESS_RETRIEVAL_FAILED);
+ emit reverseGeoReady(coordinates.join(", "));
+ }
}
- addProfileImages();
}
}
m_errorShown(false),
m_loggedIn(false),
m_refresh(false),
+ m_progressIndicatorCount(0),
m_ownLocationCrosshair(0),
m_email(),
m_password(),
m_mapScale->stackUnder(m_ownLocationCrosshair);
m_mapView->stackUnder(m_mapScale);
-- this->toggleProgressIndicator(true);
--
grabZoomKeys(true);
// Set default screen size
connect(m_mapView, SIGNAL(viewZoomFinished()),
this, SIGNAL(viewZoomFinished()));
+
+ connect(m_mapView, SIGNAL(zoomIn()),
+ this, SIGNAL(zoomIn()));
}
void MainWindow::buildMapScale()
qDebug() << __PRETTY_FUNCTION__;
clearCookieJar();
-
- toggleProgressIndicator(false);
-
startLoginProcess();
}
{
qDebug() << __PRETTY_FUNCTION__;
++ toggleProgressIndicator(true);
++
buildWebView();
loadCookies();
}
}
+ void MainWindow::showPanels()
+ {
+ qDebug() << __PRETTY_FUNCTION__;
+
+ drawFullScreenButton(m_viewPortSize);
+
+ if(m_loggedIn) {
+ if(!m_friendsListPanel->isVisible()) {
+ m_friendsListPanel->show();
+ m_friendsListPanelSidebar->show();
+ }
+
+ if(!m_userPanel->isVisible()) {
+ m_userPanel->show();
+ m_userPanelSidebar->show();
+ }
+ }
+ }
+
void MainWindow::startLoginProcess()
{
qDebug() << __PRETTY_FUNCTION__;
qDebug() << __PRETTY_FUNCTION__;
#ifdef Q_WS_MAEMO_5
- static int counter = 0;
-
- if (value)
- counter++;
- else
- counter--;
-
- if (counter < 0)
- counter = 0;
-
- if (counter == 0)
- setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
- else
+ if(value) {
+ m_progressIndicatorCount++;
setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
+ } else {
+ if(m_progressIndicatorCount > 0)
+ m_progressIndicatorCount--;
+
+ if(m_progressIndicatorCount == 0)
+ setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
+ }
#else
Q_UNUSED(value);
#endif // Q_WS_MAEMO_5
{
qDebug() << __PRETTY_FUNCTION__;
- if(m_loggedIn) {
- m_friendsListPanel->show();
- m_friendsListPanelSidebar->show();
- m_userPanel->show();
- m_userPanelSidebar->show();
+ if(m_loggedIn) {
if(!m_gpsToggleAct->isChecked())
setOwnLocationCrosshairVisibility(true);
m_userPanelSidebar->hide();
setOwnLocationCrosshairVisibility(false);
}
- drawFullScreenButton(m_viewPortSize);
}
const QString MainWindow::username()
// qwebview starts to load a new page while the current page loading is not finished
if(reply->error() != QNetworkReply::OperationCanceledError &&
reply->error() != QNetworkReply::NoError) {
- emit error(reply->error());
- toggleProgressIndicator(false);
+ emit error(ErrorContext::NETWORK, reply->error());
}
}
#include "../user/user.h"
#include "userinfo.h"
- 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 int ICON_HEIGHT = 24; ///< Icon height
- const int ICON_WIDTH = 24; ///< Icon 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 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 int ICON_HEIGHT = 24; ///< Icon height
+ const int ICON_WIDTH = 24; ///< Icon width
+ const int MARGIN = 5; ///< Icon margin
+ const int LINE_LENGTH = 17; ///< Line length
+ 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
/**
* @var LABEL_MAX_WIDTH
qDebug() << __PRETTY_FUNCTION__;
m_messageText = text;
+ m_expandedMessageText = text;
+ int textWidth = fontMetrics().width(m_expandedMessageText);
+
+ if (textWidth > 150){
+ QStringList words = m_expandedMessageText.split(" ");
+
+ for (int i = 0; i < words.count();i++){
+ QString temp = words.at(i);
+
+ if(temp.length() >= LINE_LENGTH) {
+ temp.insert(LINE_LENGTH,QString("\n"));
+ words.replace(i,temp);
+ }
+ }
+ m_expandedMessageText = words.join(" ");
+ }
+
setText(false);
}
qDebug() << __PRETTY_FUNCTION__;
if (expanded) {
- m_nameLabel->setText(m_userName);
- m_statusTextLabel->setText(m_messageText);
+ m_statusTextLabel->setText(m_expandedMessageText);
}
else {
m_nameLabel->setText(shortenText(m_nameLabel, m_userName, LABEL_MAX_WIDTH));
{
qDebug() << __PRETTY_FUNCTION__;
-- emit requestReverseGeo();
--
delete m_updateLocation;
m_updateLocation = new UpdateLocationDialog(m_backupMessage, m_backupFacebookPublishPolicity,
this);
this, SLOT(updateLocationDialogFinished(int)));
m_updateLocation->show();
++
++ emit requestReverseGeo();
}
void UserInfo::paintEvent(QPaintEvent *aPaintEvent)
qDebug() << __PRETTY_FUNCTION__;
QFontMetrics labelMetrics = label->fontMetrics();
-
QString textParam = text;
int index = textParam.indexOf('\n');
+ int textWidth = fontMetrics().width(textParam);
- if (index > 0) {
- textParam.truncate(index);
- textParam.append("...");
- }
+ if (index > 0) {
+ textParam.truncate(index);
+ textParam.append("...");
+ }
+ if (textWidth > 150)
+ textParam.insert(LINE_LENGTH, QString("\n"));
return labelMetrics.elidedText(textParam, Qt::ElideRight, textMaxWidth);
}