Support Qt version which have no qHash(QUrl)
authorunc0rr
Mon, 05 Sep 2011 15:49:14 +0400
changeset 5780 528dd4a14861
parent 5779 060d7572f9f6
child 5781 1fa54e5ea479
Support Qt version which have no qHash(QUrl)
QTfrontend/databrowser.cpp
QTfrontend/databrowser.h
--- a/QTfrontend/databrowser.cpp	Sun Sep 04 17:26:38 2011 -0400
+++ b/QTfrontend/databrowser.cpp	Mon Sep 05 15:49:14 2011 +0400
@@ -2,6 +2,7 @@
 #include <QNetworkRequest>
 #include <QNetworkReply>
 #include <QDebug>
+#include <QUrl>
 
 #include "databrowser.h"
 
@@ -19,15 +20,15 @@
 {
     if(type == QTextDocument::ImageResource || type == QTextDocument::StyleSheetResource)
     {
-        if(resources.contains(name))
+        if(resources.contains(name.toString()))
         {
-            return resources.take(name);
+            return resources.take(name.toString());
         }
         else
-            if(!requestedResources.contains(name))
+            if(!requestedResources.contains(name.toString()))
             {
                 qDebug() << "Requesting resource" << name.toString();
-                requestedResources.insert(name);
+                requestedResources.insert(name.toString());
 
                 QNetworkRequest newRequest(QUrl("http://www.hedgewars.org" + name.toString()));
                 newRequest.setAttribute(typeAttribute, type);
@@ -49,7 +50,7 @@
     {
         int type = reply->request().attribute(typeAttribute).toInt();
         QUrl url = reply->request().attribute(urlAttribute).toUrl();
-        resources.insert(url, reply->readAll());
+        resources.insert(url.toString(), reply->readAll());
         document()->addResource(type, reply->request().url(), QVariant());
         update();
     }
--- a/QTfrontend/databrowser.h	Sun Sep 04 17:26:38 2011 -0400
+++ b/QTfrontend/databrowser.h	Mon Sep 05 15:49:14 2011 +0400
@@ -18,8 +18,11 @@
 
 private:
     QNetworkAccessManager *manager;
-    QHash<QUrl, QByteArray> resources;
-    QSet<QUrl> requestedResources;
+    
+    // hash and set of QString instead of QUrl to support Qt versions 
+    // older than 4.7 (those have no support for qHash(const QUrl &))
+    QHash<QString, QByteArray> resources;
+    QSet<QString> requestedResources;
 
     QVariant loadResource(int type, const QUrl & name);