|
21 | 21 | #include <QString>
|
22 | 22 | #include <QStringList>
|
23 | 23 | #include <QTextStream>
|
24 |
| -#include <QScriptEngine> |
25 |
| -#include <QScriptValue> |
26 |
| -#include <QScriptValueIterator> |
27 | 24 |
|
28 | 25 | #include "qgsapplication.h"
|
29 | 26 | #include "qgsdatasourceuri.h"
|
@@ -121,56 +118,52 @@ void TestQgsWcsPublicServers::init()
|
121 | 118 | QString data = file.readAll();
|
122 | 119 | //QgsDebugMsg("servers: \n" + str );
|
123 | 120 | file.close();
|
124 |
| - QScriptEngine engine; |
125 |
| - QScriptValue result = engine.evaluate( data ); |
| 121 | + QJsonDocument doc = QJsonDocument::fromJson( data.toUtf8() ); |
| 122 | + const QJsonObject result = doc.object(); |
126 | 123 |
|
127 |
| - QScriptValueIterator serverIt( result ); |
128 |
| - while ( serverIt.hasNext() ) |
| 124 | + QJsonObject::ConstIterator serverIt = result.constBegin(); |
| 125 | + for ( ; serverIt != result.constEnd(); serverIt++ ) |
129 | 126 | {
|
130 |
| - serverIt.next(); |
131 |
| - QScriptValue serverValue = serverIt.value(); |
| 127 | + const QJsonObject serverObject = serverIt.value().toObject(); |
| 128 | + const QString serverUrl = serverObject.value( QLatin1String( "url" ) ).toString(); |
132 | 129 |
|
133 |
| - QString serverUrl = serverValue.property( QStringLiteral( "url" ) ).toString(); |
134 | 130 | QgsDebugMsg( "serverUrl: " + serverUrl );
|
135 | 131 |
|
136 | 132 | Server server( serverUrl );
|
137 |
| - server.description = serverValue.property( QStringLiteral( "description" ) ).toString(); |
| 133 | + server.description = serverObject.value( QLatin1String( "description" ) ).toString(); |
138 | 134 |
|
139 |
| - QScriptValueIterator paramsIt( serverValue.property( QStringLiteral( "params" ) ) ); |
140 |
| - while ( paramsIt.hasNext() ) |
| 135 | + const QJsonObject serverParams = serverObject.value( QLatin1String( "params" ) ).toObject(); |
| 136 | + QJsonObject::ConstIterator paramsIt = serverParams.constBegin(); |
| 137 | + for ( ; paramsIt != serverParams.constEnd(); paramsIt++ ) |
141 | 138 | {
|
142 |
| - paramsIt.next(); |
143 | 139 | QgsDebugMsg( QString( "params value: %1" ).arg( paramsIt.value().toString() ) );
|
144 |
| - server.params.insert( paramsIt.name(), paramsIt.value().toString() ); |
| 140 | + server.params.insert( paramsIt.key(), paramsIt.value().toString() ); |
145 | 141 | }
|
146 | 142 |
|
147 |
| - QScriptValue issuesValue = serverValue.property( QStringLiteral( "issues" ) ); |
| 143 | + QJsonObject issuesObject = serverObject.value( QLatin1String( "issues" ) ).toObject(); |
148 | 144 |
|
149 |
| - QScriptValueIterator issuesIt( issuesValue ); |
150 |
| - while ( issuesIt.hasNext() ) |
| 145 | + QJsonObject::ConstIterator issuesIt = issuesObject.constBegin(); |
| 146 | + for ( ; issuesIt != issuesObject.constEnd(); ++issuesIt ) |
151 | 147 | {
|
152 |
| - issuesIt.next(); |
153 |
| - QScriptValue issueValue = issuesIt.value(); |
| 148 | + QJsonObject issueObject = issuesIt.value().toObject(); |
154 | 149 |
|
155 |
| - QString description = issueValue.property( QStringLiteral( "description" ) ).toString(); |
| 150 | + QString description = issueObject.value( QLatin1String( "description" ) ).toString(); |
156 | 151 | QgsDebugMsg( "description: " + description );
|
157 | 152 | Issue issue( description );
|
158 | 153 |
|
159 |
| - issue.offender = issueValue.property( QStringLiteral( "offender" ) ).toString(); |
| 154 | + issue.offender = issueObject.value( QLatin1String( "offender" ) ).toString(); |
160 | 155 |
|
161 |
| - QScriptValue coveragesValue = issueValue.property( QStringLiteral( "coverages" ) ); |
162 |
| - QScriptValueIterator coveragesIt( coveragesValue ); |
163 |
| - while ( coveragesIt.hasNext() ) |
| 156 | + QJsonObject coveragesObject = issueObject.value( QLatin1String( "coverages" ) ).toObject(); |
| 157 | + QJsonObject::ConstIterator coverageIt = coveragesObject.constBegin(); |
| 158 | + for ( ; coverageIt != coveragesObject.constEnd(); ++coverageIt ) |
164 | 159 | {
|
165 |
| - coveragesIt.next(); |
166 |
| - issue.coverages << coveragesIt.value().toString(); |
| 160 | + issue.coverages << coverageIt.value().toString(); |
167 | 161 | }
|
168 | 162 |
|
169 |
| - QScriptValue versionsValue = issueValue.property( QStringLiteral( "versions" ) ); |
170 |
| - QScriptValueIterator versionsIt( versionsValue ); |
171 |
| - while ( versionsIt.hasNext() ) |
| 163 | + QJsonObject versionsObject = issueObject.value( QLatin1String( "versions" ) ).toObject(); |
| 164 | + QJsonObject::ConstIterator versionsIt = versionsObject.constBegin(); |
| 165 | + for ( ; versionsIt != versionsObject.constEnd(); ++versionsIt ) |
172 | 166 | {
|
173 |
| - versionsIt.next(); |
174 | 167 | issue.versions << versionsIt.value().toString();
|
175 | 168 | }
|
176 | 169 |
|
|
0 commit comments