make DLC trigger data reload
authorsheepluva
Thu, 26 Apr 2012 09:47:35 +0200
changeset 6932 005393616925
parent 6931 86c951cd0f3f
child 6933 78d194a30520
make DLC trigger data reload
QTfrontend/ui/page/pagedata.cpp
QTfrontend/ui/page/pagedata.h
--- a/QTfrontend/ui/page/pagedata.cpp	Thu Apr 26 07:44:44 2012 +0200
+++ b/QTfrontend/ui/page/pagedata.cpp	Thu Apr 26 09:47:35 2012 +0200
@@ -30,6 +30,7 @@
 #include "pagedata.h"
 #include "databrowser.h"
 #include "hwconsts.h"
+#include "DataManager.h"
 
 #include "quazip.h"
 #include "quazipfile.h"
@@ -52,6 +53,7 @@
 void PageDataDownload::connectSignals()
 {
     connect(web, SIGNAL(anchorClicked(QUrl)), this, SLOT(request(const QUrl&)));
+    connect(this, SIGNAL(goBack()), this, SLOT(onPageLeave()));
 }
 
 PageDataDownload::PageDataDownload(QWidget* parent) : AbstractPage(parent)
@@ -60,6 +62,8 @@
 
     web->setOpenLinks(false);
 //    fetchList();
+
+    m_contentDownloaded = false;
 }
 
 void PageDataDownload::request(const QUrl &url)
@@ -217,6 +221,8 @@
                 qWarning("read all but not EOF");
                 return false;
             }
+
+            m_contentDownloaded = true;
         }
 
         file.close();
@@ -232,3 +238,13 @@
 
     return true;
 }
+
+
+void PageDataDownload::onPageLeave()
+{
+    if (m_contentDownloaded)
+    {
+        m_contentDownloaded = false;
+        DataManager::instance().reload();
+    }
+}
--- a/QTfrontend/ui/page/pagedata.h	Thu Apr 26 07:44:44 2012 +0200
+++ b/QTfrontend/ui/page/pagedata.h	Thu Apr 26 09:47:35 2012 +0200
@@ -46,6 +46,8 @@
         QHash<QNetworkReply*, QProgressBar *> progressBars;
         QVBoxLayout *progressBarsLayout;
 
+        bool m_contentDownloaded; ///< true if something was downloaded since last page leave
+
         bool extractDataPack(QByteArray * buf);
 
     private slots:
@@ -54,6 +56,8 @@
         void pageDownloaded();
         void fileDownloaded();
         void downloadProgress(qint64, qint64);
+
+        void onPageLeave();
 };
 
 #endif