Merge branch 'master' into network_handler
[situare] / src / ui / mainwindow.cpp
index 7901573..c886e90 100644 (file)
@@ -55,6 +55,7 @@ MainWindow::MainWindow(QWidget *parent)
     m_errorShown(false),
     m_loggedIn(false),
     m_refresh(false),
+    m_progressIndicatorCount(0),
     m_ownLocationCrosshair(0),
     m_email(),    
     m_password(),
@@ -94,8 +95,6 @@ MainWindow::MainWindow(QWidget *parent)
     m_mapScale->stackUnder(m_ownLocationCrosshair);
     m_mapView->stackUnder(m_mapScale);
 
-    this->toggleProgressIndicator(true);
-
     grabZoomKeys(true);
 
     // Set default screen size
@@ -254,6 +253,9 @@ void MainWindow::buildMap()
 
     connect(m_mapView, SIGNAL(viewZoomFinished()),
             this, SIGNAL(viewZoomFinished()));
+
+    connect(m_mapView, SIGNAL(zoomIn()),
+            this, SIGNAL(zoomIn()));
 }
 
 void MainWindow::buildMapScale()
@@ -669,9 +671,6 @@ void MainWindow::loginFailed()
     qDebug() << __PRETTY_FUNCTION__;
 
     clearCookieJar();
-
-    toggleProgressIndicator(false);
-
     startLoginProcess();
 }
 
@@ -686,6 +685,8 @@ void MainWindow::loginUsingCookies()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    toggleProgressIndicator(true);
+
     buildWebView();
     loadCookies();
     
@@ -878,6 +879,25 @@ void MainWindow::showInformationBox()
     }
 }
 
+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__;
@@ -899,20 +919,16 @@ void MainWindow::toggleProgressIndicator(bool value)
     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
@@ -922,11 +938,7 @@ void MainWindow::updateItemVisibility()
 {
     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);
@@ -939,7 +951,6 @@ void MainWindow::updateItemVisibility()
         m_userPanelSidebar->hide();
         setOwnLocationCrosshairVisibility(false);
     }
-    drawFullScreenButton(m_viewPortSize);
 }
 
 const QString MainWindow::username()
@@ -957,8 +968,7 @@ void MainWindow::webViewRequestFinished(QNetworkReply *reply)
     // 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());
     }
 }