QTfrontend/ui/page/pagedata.cpp
changeset 8876 bd8df772dbe6
parent 8059 07661fb20586
child 9080 9b42757d7e71
equal deleted inserted replaced
8874:8121ce2b0a88 8876:bd8df772dbe6
    58 {
    58 {
    59     initPage();
    59     initPage();
    60 
    60 
    61     web->setOpenLinks(false);
    61     web->setOpenLinks(false);
    62 //    fetchList();
    62 //    fetchList();
    63 
    63     web->setHtml(QString(
       
    64         "<center><h2>Hedgewars Downloadable Content</h2><br><br>"
       
    65         "<i>%1</i></center>")
       
    66         .arg(tr("Loading, please wait.")));
    64     m_contentDownloaded = false;
    67     m_contentDownloaded = false;
    65 }
    68 }
    66 
    69 
    67 void PageDataDownload::request(const QUrl &url)
    70 void PageDataDownload::request(const QUrl &url)
    68 {
    71 {
   104 
   107 
   105 void PageDataDownload::pageDownloaded()
   108 void PageDataDownload::pageDownloaded()
   106 {
   109 {
   107     QNetworkReply * reply = qobject_cast<QNetworkReply *>(sender());
   110     QNetworkReply * reply = qobject_cast<QNetworkReply *>(sender());
   108 
   111 
   109     if(reply)
   112     if (reply && (reply->error() == QNetworkReply::NoError)) {
   110     {
       
   111         QString html = QString::fromUtf8(reply->readAll());
   113         QString html = QString::fromUtf8(reply->readAll());
   112         int begin = html.indexOf("<!-- BEGIN -->");
   114         int begin = html.indexOf("<!-- BEGIN -->");
   113         int end = html.indexOf("<!-- END -->");
   115         int end = html.indexOf("<!-- END -->");
   114         if(begin != -1 && begin < end)
   116         if(begin != -1 && begin < end)
   115         {
   117         {
   116             html.truncate(end);
   118             html.truncate(end);
   117             html.remove(0, begin);
   119             html.remove(0, begin);
   118         }
   120         }
   119         web->setHtml(html);
   121         web->setHtml(html);
   120     }
   122     } else
       
   123         web->setHtml(QString(
       
   124             "<center><h2>Hedgewars Downloadable Content</h2><br><br>"
       
   125             "<p><i><h4>%1</i></h4></p></center>")
       
   126             .arg(tr("This page requires an internet connection.")));
   121 }
   127 }
   122 
   128 
   123 void PageDataDownload::fileDownloaded()
   129 void PageDataDownload::fileDownloaded()
   124 {
   130 {
   125     QNetworkReply * reply = qobject_cast<QNetworkReply *>(sender());
   131     QNetworkReply * reply = qobject_cast<QNetworkReply *>(sender());