Added method to engine to set progress indicator enabled/disabled.
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Tue, 16 Nov 2010 10:47:05 +0000 (12:47 +0200)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Tue, 16 Nov 2010 10:47:05 +0000 (12:47 +0200)
src/engine/engine.cpp
src/engine/engine.h
src/situareservice/database.cpp
src/situareservice/situareservice.cpp

index d4064c7..666515f 100644 (file)
@@ -216,12 +216,12 @@ void SituareEngine::error(const int context, const int error)
     {
     case SituareError::ERROR_GENERAL:
         if(context == ErrorContext::SITUARE) {
-            m_ui->toggleProgressIndicator(false);
+            //m_ui->toggleProgressIndicator(false);
             m_ui->buildInformationBox(tr("Unknown server error"), true);
         }
         break;
     case 1: //errors: SituareError::ERROR_MISSING_ARGUMENT and QNetworkReply::ConnectionRefusedError
-        m_ui->toggleProgressIndicator(false);
+        //m_ui->toggleProgressIndicator(false);
         if(context == ErrorContext::SITUARE) {
             m_ui->buildInformationBox(tr("Missing parameter from request"), true);
         } else if(context == ErrorContext::NETWORK) {
@@ -230,25 +230,25 @@ void SituareEngine::error(const int context, const int error)
         break;
     case QNetworkReply::RemoteHostClosedError:
         if(context == ErrorContext::NETWORK) {
-            m_ui->toggleProgressIndicator(false);
+            //m_ui->toggleProgressIndicator(false);
             m_ui->buildInformationBox(tr("Connection closed by the server"), true);
         }
         break;
     case QNetworkReply::HostNotFoundError:
         if(context == ErrorContext::NETWORK) {
-            m_ui->toggleProgressIndicator(false);
+            //m_ui->toggleProgressIndicator(false);
             m_ui->buildInformationBox(tr("Remote server not found"), true);
         }
         break;
     case QNetworkReply::TimeoutError:
         if(context == ErrorContext::NETWORK) {
-            m_ui->toggleProgressIndicator(false);
+            //m_ui->toggleProgressIndicator(false);
             m_ui->buildInformationBox(tr("Connection timed out"), true);
         }
         break;
     case QNetworkReply::UnknownNetworkError:
         if(context == ErrorContext::NETWORK) {
-            m_ui->toggleProgressIndicator(false);
+            //m_ui->toggleProgressIndicator(false);
             m_ui->buildInformationBox(tr("No network connection"), true);
         }
         break;
@@ -260,20 +260,20 @@ void SituareEngine::error(const int context, const int error)
         m_ui->loginFailed();
         break;
     case SituareError::LOGIN_FAILED:
-        m_ui->toggleProgressIndicator(false);
+        //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->toggleProgressIndicator(false);
         m_ui->buildInformationBox(tr("Update failed, please try again"), true);
         break;
     case SituareError::DATA_RETRIEVAL_FAILED:
-        m_ui->toggleProgressIndicator(false);
+        //m_ui->toggleProgressIndicator(false);
         m_ui->buildInformationBox(tr("Data retrieval failed, please try again"), true);
         break;
     case SituareError::ADDRESS_RETRIEVAL_FAILED:
-        m_ui->toggleProgressIndicator(false);
+        //m_ui->toggleProgressIndicator(false);
         m_ui->buildInformationBox(tr("Address retrieval failed"), true);
         break;
     case SituareError::IMAGE_DOWNLOAD_FAILED:
@@ -292,14 +292,14 @@ void SituareEngine::error(const int context, const int error)
         m_facebookAuthenticator->clearAccountInformation(false); // clean all
         break;
     case SituareError::ERROR_ROUTING_FAILED:
-        m_ui->toggleProgressIndicator(false);
+        //m_ui->toggleProgressIndicator(false);
         m_ui->buildInformationBox(tr("Routing failed"), true);
         break;
     case SituareError::ERROR_LOCATION_SEARCH_FAILED:
         m_ui->buildInformationBox(tr("No results found"), true);
         break;
     default:
-        m_ui->toggleProgressIndicator(false);
+        //m_ui->toggleProgressIndicator(false);
         if(context == ErrorContext::NETWORK)
             qCritical() << __PRETTY_FUNCTION__ << "QNetworkReply::NetworkError: " << error;
         else
@@ -423,7 +423,6 @@ void SituareEngine::refreshUserData()
     qDebug() << __PRETTY_FUNCTION__;
 
     if (m_networkAccessManager->isConnected()) {
-        m_ui->toggleProgressIndicator(true);
         m_situareService->fetchLocations();
     }
     else {
@@ -451,7 +450,6 @@ void SituareEngine::requestUpdateLocation(const QString &status, bool publish)
     qDebug() << __PRETTY_FUNCTION__;
 
     if (m_networkAccessManager->isConnected()) {
-        m_ui->toggleProgressIndicator(true);
 
         if (m_gps->isRunning())
             m_situareService->updateLocation(m_gps->lastPosition(), status, publish);
@@ -512,16 +510,12 @@ void SituareEngine::routeParsed(Route &route)
     qDebug() << __PRETTY_FUNCTION__;
 
     Q_UNUSED(route);
-
-    m_ui->toggleProgressIndicator(false);
 }
 
 void SituareEngine::routeTo(const GeoCoordinate &endPointCoordinates)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_ui->toggleProgressIndicator(true);
-
     if (m_gps->isRunning())
         m_routingService->requestRoute(m_gps->lastPosition(), endPointCoordinates);
     else
@@ -599,6 +593,16 @@ void SituareEngine::setPowerSaving(bool enabled)
         m_mapEngine->setAutoCentering(!enabled);
 }
 
+void SituareEngine::setProgressIndicatorDisabled()
+{
+    m_ui->toggleProgressIndicator(false);
+}
+
+void SituareEngine::setProgressIndicatorEnabled()
+{
+    m_ui->toggleProgressIndicator(true);
+}
+
 void SituareEngine::showContactDialog(const QString &facebookId)
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -715,28 +719,46 @@ void SituareEngine::signalsFromMainWindow()
             this, SLOT(requestAddress()));
 
     connect(m_ui, SIGNAL(statusUpdate(QString,bool)),
+            this, SLOT(setProgressIndicatorEnabled()));
+
+    connect(m_ui, SIGNAL(statusUpdate(QString,bool)),
             this, SLOT(requestUpdateLocation(QString,bool)));
 
     connect(m_ui, SIGNAL(enableAutomaticLocationUpdate(bool, int)),
             this, SLOT(enableAutomaticLocationUpdate(bool, int)));
 
     connect(m_ui, SIGNAL(addTags(QStringList)),
+            this, SLOT(setProgressIndicatorEnabled()));
+
+    connect(m_ui, SIGNAL(addTags(QStringList)),
             m_situareService, SLOT(addTags(QStringList)));
 
     connect(m_ui, SIGNAL(removeTags(QStringList)),
+            this, SLOT(setProgressIndicatorEnabled()));
+
+    connect(m_ui, SIGNAL(removeTags(QStringList)),
             m_situareService, SLOT(removeTags(QStringList)));
 
     // signals from user info tab
     connect(m_ui, SIGNAL(refreshUserData()),
+            this, SLOT(setProgressIndicatorEnabled()));
+
+    connect(m_ui, SIGNAL(refreshUserData()),
             this, SLOT(refreshUserData()));
 
     connect(m_ui, SIGNAL(centerToCoordinates(GeoCoordinate)),
             m_mapEngine, SLOT(centerToCoordinates(GeoCoordinate)));
 
     connect(m_ui, SIGNAL(requestPopularTags()),
+            this, SLOT(setProgressIndicatorEnabled()));
+
+    connect(m_ui, SIGNAL(requestPopularTags()),
             m_situareService, SLOT(fetchPopularTags()));
 
     // routing signal from friend list tab & search location tab
+    connect(m_ui, SIGNAL(routeTo(GeoCoordinate)),
+            this, SLOT(setProgressIndicatorEnabled()));
+
     connect(m_ui, SIGNAL(routeTo(const GeoCoordinate&)),
             this, SLOT(routeTo(const GeoCoordinate&)));
 
@@ -771,23 +793,38 @@ void SituareEngine::signalsFromMainWindow()
             this, SLOT(locationSearch(QString)));
 
     connect(m_ui, SIGNAL(requestSearchPeopleByTag(QString)),
+            this, SLOT(setProgressIndicatorEnabled()));
+
+    connect(m_ui, SIGNAL(requestSearchPeopleByTag(QString)),
             m_situareService, SLOT(searchPeopleByTag(QString)));
 
     // signals from meet people panel
     connect(m_ui, SIGNAL(requestInterestingPeople()),
+            this, SLOT(setProgressIndicatorEnabled()));
+
+    connect(m_ui, SIGNAL(requestInterestingPeople()),
             this, SLOT(requestInterestingPeople()));
 
     connect(m_ui, SIGNAL(requestMessageDialog(QPair<QString, QString>)),
             this, SLOT(showMessageDialog(QPair<QString, QString>)));
 
     connect(m_ui, SIGNAL(sendMessage(QString,QString,bool)),
+            this, SLOT(setProgressIndicatorEnabled()));
+
+    connect(m_ui, SIGNAL(sendMessage(QString,QString,bool)),
             this, SLOT(requestSendMessage(QString,QString,bool)));
 
     // signals from message panel
     connect(m_ui, SIGNAL(requestMessages()),
+            this, SLOT(setProgressIndicatorEnabled()));
+
+    connect(m_ui, SIGNAL(requestMessages()),
             m_situareService, SLOT(fetchMessages()));
 
     connect(m_ui, SIGNAL(requestRemoveMessage(QString)),
+            this, SLOT(setProgressIndicatorEnabled()));
+
+    connect(m_ui, SIGNAL(requestRemoveMessage(QString)),
             m_situareService, SLOT(removeMessage(QString)));
 }
 
@@ -828,7 +865,7 @@ void SituareEngine::signalsFromRoutingService()
     qDebug() << __PRETTY_FUNCTION__;
 
     connect(m_routingService, SIGNAL(routeParsed(Route&)),
-            this, SLOT(routeParsed(Route&)));
+            this, SLOT(setProgressIndicatorDisabled()));
 
     connect(m_routingService, SIGNAL(routeParsed(Route&)),
             m_mapEngine, SLOT(setRoute(Route&)));
@@ -853,22 +890,35 @@ void SituareEngine::signalsFromSituareService()
     connect(m_situareService, SIGNAL(reverseGeoReady(QString)),
             m_ui, SIGNAL(reverseGeoReady(QString)));
 
+    connect(m_situareService, SIGNAL(userDataChanged(User*,QList<User*>&)),
+            this, SLOT(setProgressIndicatorDisabled()));
+
     connect(m_situareService, SIGNAL(userDataChanged(User*, QList<User*>&)),
             this, SLOT(userDataChanged(User*, QList<User*>&)));
 
     connect(m_situareService, SIGNAL(updateWasSuccessful(SituareService::SuccessfulMethod)),
-            this, SLOT(updateWasSuccessful(SituareService::SuccessfulMethod)));
+            m_ui, SIGNAL(clearUpdateLocationDialogData()));
 
     connect(m_situareService, SIGNAL(updateWasSuccessful(SituareService::SuccessfulMethod)),
-            m_ui, SIGNAL(clearUpdateLocationDialogData()));
+            this, SLOT(updateWasSuccessful(SituareService::SuccessfulMethod)));
 
     connect(m_situareService, SIGNAL(interestingPeopleReceived(QList<User>&,QList<User>&)),
             m_ui, SIGNAL(interestingPeopleReceived(QList<User>&,QList<User>&)));
 
+    connect(m_situareService, SIGNAL(interestingPeopleReceived(QList<User>&,QList<User>&)),
+            this, SLOT(setProgressIndicatorDisabled()));
+
+    connect(m_situareService, SIGNAL(messagesReceived(QList<Message>&, QList<Message> &)),
+            this, SLOT(setProgressIndicatorDisabled()));
+
+
     connect(m_situareService, SIGNAL(messagesReceived(QList<Message>&, QList<Message> &)),
             m_ui, SIGNAL(messagesReceived(QList<Message>&, QList<Message>&)));
 
     connect(m_situareService, SIGNAL(popularTagsReceived(QHash<QString,QString>&)),
+            this, SLOT(setProgressIndicatorDisabled()));
+
+    connect(m_situareService, SIGNAL(popularTagsReceived(QHash<QString,QString>&)),
             m_ui, SIGNAL(popularTagsReceived(QHash<QString,QString>&)));
 }
 
@@ -889,7 +939,7 @@ void SituareEngine::topmostWindowChanged(bool isMainWindow)
 
 void SituareEngine::updateWasSuccessful(SituareService::SuccessfulMethod successfulMethod)
 {
-    qWarning() << __PRETTY_FUNCTION__;
+    qDebug() << __PRETTY_FUNCTION__;
 
     if (m_networkAccessManager->isConnected()) {
         if (successfulMethod == SituareService::SuccessfulUpdateLocation)
@@ -909,8 +959,6 @@ void SituareEngine::userDataChanged(User *user, QList<User *> &friendsList)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_ui->toggleProgressIndicator(false);
-
     emit userLocationReady(user);
     emit friendsLocationsReady(friendsList);
 }
index 2cd2341..4c689d7 100644 (file)
@@ -313,6 +313,16 @@ private slots:
     void setPowerSaving(bool enabled);
 
     /**
+    * @brief Sets progress indicator disabled
+    */
+    void setProgressIndicatorDisabled();
+
+    /**
+    * @brief Sets progress indicator enabled
+    */
+    void setProgressIndicatorEnabled();
+
+    /**
     * @brief Shows contact dialog.
     *
     * Calls MainWindow showContactDialog with contact guid defined by contact's Facebook ID.
index dd35a8c..495c727 100644 (file)
@@ -18,7 +18,7 @@ Database::~Database()
 
 bool Database::addTag(qulonglong userId, const QString &tag)
 {
-    qDebug() << __PRETTY_FUNCTION__;
+    qWarning() << __PRETTY_FUNCTION__;
 
     bool ret = false;
     qulonglong tagId = 0;
@@ -30,18 +30,15 @@ bool Database::addTag(qulonglong userId, const QString &tag)
 
         //Tag already exists
         if (ret && tagQuery.next()) {
-            qWarning() << tagQuery.value(1).toInt();
             int count = tagQuery.value(1).toInt() + 1;
-            qWarning() << count;
             QSqlQuery tagUpdateQuery;
             tagUpdateQuery.exec(QString("UPDATE tag SET count = '%1' WHERE id = '%2'")
                              .arg(count).arg(tagQuery.value(0).toString()));
             tagId = tagQuery.value(0).toULongLong();
-            qWarning() << tagUpdateQuery.lastQuery();
         }
         else {
             QSqlQuery tagInsertQuery;
-            ret = tagInsertQuery.exec(QString("INSERT INTO tag VALUES(NULL, '%1')")
+            ret = tagInsertQuery.exec(QString("INSERT INTO tag VALUES(NULL, '%1', NULL)")
                              .arg(tag));
 
             if (ret) {
@@ -473,7 +470,7 @@ QByteArray Database::getPopularTags()
         result.remove(result.lastIndexOf(","), 1);
 
     result.append("]}");
-    qWarning() << result;
+
     return result.toUtf8();
 }
 
index 6a95911..c0c2560 100644 (file)
@@ -746,7 +746,7 @@ void SituareService::removeMessage(const QString &id)
 
 void SituareService::addTags(const QStringList &tags)
 {
-    qDebug() << __PRETTY_FUNCTION__;
+    qWarning() << __PRETTY_FUNCTION__ << tags.count();
 
     foreach (QString tag, tags)
         m_database->addTag(613374451, tag);