Skip to content

Commit ee57c1f

Browse files
manisandronyalldawson
authored andcommitted
[ArcGIS REST] Port to Qt5
1 parent 83ad380 commit ee57c1f

8 files changed

+16
-45
lines changed

CMakeLists.txt

-5
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,6 @@ ENDIF (WITH_TOUCH)
292292
# search for QScintilla2 (C++ lib)
293293
FIND_PACKAGE(QScintilla REQUIRED)
294294

295-
# search for QJSON and decide whether to enable ArcGIS providers
296-
297-
# TODO - needs to be ported to qt5
298-
SET (WITH_ARCGIS FALSE)
299-
300295
# Master password hash and authentication encryption
301296
FIND_PACKAGE(QCA REQUIRED)
302297
# Check for runtime dependency of qca-ossl plugin

cmake_templates/qgsconfig.h.in

-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,5 @@
5656

5757
#cmakedefine ENABLE_MODELTEST
5858

59-
#cmakedefine WITH_ARCGIS
60-
6159
#endif
6260

src/app/qgisapp.cpp

-13
Original file line numberDiff line numberDiff line change
@@ -1732,13 +1732,6 @@ void QgisApp::createActions()
17321732
mActionAddPgLayer = 0;
17331733
#endif
17341734

1735-
#ifndef WITH_ARCGIS
1736-
delete mActionAddAfsLayer;
1737-
mActionAddAfsLayer = 0;
1738-
delete mActionAddAmsLayer;
1739-
mActionAddAmsLayer = 0;
1740-
#endif
1741-
17421735
#ifndef HAVE_ORACLE
17431736
delete mActionAddOracleLayer;
17441737
mActionAddOracleLayer = nullptr;
@@ -2188,7 +2181,6 @@ void QgisApp::createToolBars()
21882181
newLayerAction->setObjectName( "ActionNewLayer" );
21892182
connect( bt, SIGNAL( triggered( QAction * ) ), this, SLOT( toolButtonActionTriggered( QAction * ) ) );
21902183

2191-
#ifdef WITH_ARCGIS
21922184
// map service tool button
21932185
bt = new QToolButton();
21942186
bt->setPopupMode( QToolButton::MenuButtonPopup );
@@ -2230,9 +2222,6 @@ void QgisApp::createToolBars()
22302222
mLayerToolBar->removeAction( mActionAddWfsLayer );
22312223
featureServiceAction->setObjectName( "ActionFeatureService" );
22322224
connect( bt, SIGNAL( triggered( QAction * ) ), this, SLOT( toolButtonActionTriggered( QAction * ) ) );
2233-
#else
2234-
QAction* mapServiceAction = mActionAddWmsLayer;
2235-
#endif
22362225

22372226
// add db layer button
22382227
bt = new QToolButton();
@@ -2618,10 +2607,8 @@ void QgisApp::setTheme( const QString& theThemeName )
26182607
mActionAddWmsLayer->setIcon( QgsApplication::getThemeIcon( "/mActionAddWmsLayer.svg" ) );
26192608
mActionAddWcsLayer->setIcon( QgsApplication::getThemeIcon( "/mActionAddWcsLayer.svg" ) );
26202609
mActionAddWfsLayer->setIcon( QgsApplication::getThemeIcon( "/mActionAddWfsLayer.svg" ) );
2621-
#ifdef WITH_ARCGIS
26222610
mActionAddAfsLayer->setIcon( QgsApplication::getThemeIcon( "/mActionAddAfsLayer.svg" ) );
26232611
mActionAddAmsLayer->setIcon( QgsApplication::getThemeIcon( "/mActionAddAmsLayer.svg" ) );
2624-
#endif
26252612
mActionAddToOverview->setIcon( QgsApplication::getThemeIcon( "/mActionInOverview.svg" ) );
26262613
mActionAnnotation->setIcon( QgsApplication::getThemeIcon( "/mActionAnnotation.svg" ) );
26272614
mActionFormAnnotation->setIcon( QgsApplication::getThemeIcon( "/mActionFormAnnotation.svg" ) );

src/providers/CMakeLists.txt

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_PLUGIN_SUBDIR})
33
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_PLUGIN_SUBDIR})
44

5-
IF(WITH_ARCGIS)
6-
ADD_SUBDIRECTORY(arcgisrest)
7-
ENDIF(WITH_ARCGIS)
5+
ADD_SUBDIRECTORY(arcgisrest)
86
ADD_SUBDIRECTORY(memory)
97
ADD_SUBDIRECTORY(ogr)
108
ADD_SUBDIRECTORY(wms)

src/providers/arcgisrest/CMakeLists.txt

-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
FIND_PACKAGE(QJSON)
2-
31
INCLUDE_DIRECTORIES(
42
../../core
53
../../core/auth
@@ -8,7 +6,6 @@ INCLUDE_DIRECTORIES(
86
../../gui
97
../../gui/auth
108
${GEOS_INCLUDE_DIR}
11-
${QJSON_INCLUDE_DIR}
129
${QSCINTILLA_INCLUDE_DIR}
1310
${CMAKE_CURRENT_BINARY_DIR}/../../ui
1411
)
@@ -38,8 +35,6 @@ ADD_LIBRARY(arcgisfeatureserverprovider MODULE ${AFS_SRCS} ${AFS_MOC_SRCS})
3835
TARGET_LINK_LIBRARIES(arcgisfeatureserverprovider
3936
qgis_core
4037
qgis_gui
41-
${QJSON_LIBRARIES}
42-
${qjson_LIBRARIES}
4338
)
4439

4540
INSTALL (TARGETS arcgisfeatureserverprovider
@@ -69,8 +64,6 @@ ADD_LIBRARY(arcgismapserverprovider MODULE ${AMS_SRCS} ${AMS_MOC_SRCS})
6964
TARGET_LINK_LIBRARIES(arcgismapserverprovider
7065
qgis_core
7166
qgis_gui
72-
${QJSON_LIBRARIES}
73-
${qjson_LIBRARIES}
7467
)
7568

7669
INSTALL (TARGETS arcgismapserverprovider

src/providers/arcgisrest/qgsafsprovider.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "geometry/qgsgeometry.h"
2424
#include "qgsnetworkaccessmanager.h"
2525

26-
#include <qjson/parser.h>
2726
#include <QEventLoop>
2827
#include <QMessageBox>
2928
#include <QNetworkRequest>

src/providers/arcgisrest/qgsamsprovider.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
#include "qgsgeometry.h"
2626

2727
#include <cstring>
28-
#include <qjson/parser.h>
28+
#include <QJsonDocument>
29+
#include <QJsonObject>
2930
#include <QNetworkRequest>
3031
#include <QNetworkReply>
3132
#include <QPainter>
@@ -57,13 +58,13 @@ void QgsAmsLegendFetcher::handleError( QString errorTitle, QString errorMsg )
5758
void QgsAmsLegendFetcher::handleFinished()
5859
{
5960
// Parse result
60-
QJson::Parser parser;
61-
bool ok = false;
62-
QVariantMap queryResults = parser.parse( mQueryReply, &ok ).toMap();
63-
if ( !ok )
61+
QJsonParseError err;
62+
QJsonDocument doc = QJsonDocument::fromJson( mQueryReply, &err );
63+
if ( doc.isNull() )
6464
{
65-
emit error( QString( "Parsing error at line %1: %2" ).arg( parser.errorLine() ).arg( parser.errorString() ) );
65+
emit error( QString( "Parsing error:" ).arg( err.errorString() ) );
6666
}
67+
QVariantMap queryResults = doc.object().toVariantMap();
6768
QgsDataSourceUri dataSource( mProvider->dataSourceUri() );
6869
QList< QPair<QString, QImage> > legendEntries;
6970
foreach ( const QVariant& result, queryResults["layers"].toList() )

src/providers/arcgisrest/qgsarcgisrestutils.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
#include <QNetworkRequest>
3333
#include <QNetworkReply>
3434
#include <QThread>
35-
#include <qjson/parser.h>
35+
#include <QJsonDocument>
36+
#include <QJsonObject>
3637

3738

3839
QVariant::Type QgsArcGisRestUtils::mapEsriFieldType( const QString &esriFieldType )
@@ -464,17 +465,16 @@ QVariantMap QgsArcGisRestUtils::queryServiceJSON( const QUrl &url, QString &erro
464465
}
465466

466467
// Parse data
467-
QJson::Parser parser;
468-
bool ok = false;
469-
QVariantMap map = parser.parse( reply, &ok ).toMap();
470-
if ( !ok )
468+
QJsonParseError err;
469+
QJsonDocument doc = QJsonDocument::fromJson( reply, &err );
470+
if ( doc.isNull() )
471471
{
472472
errorTitle = "Parsing error";
473-
errorText = QString( "Line %1: %2" ).arg( parser.errorLine() ).arg( parser.errorString() );
474-
QgsDebugMsg( QString( "Parsing error: %1 (line %2" ).arg( parser.errorString() ).arg( parser.errorLine() ) );
473+
errorText = err.errorString();
474+
QgsDebugMsg( QString( "Parsing error: %1" ).arg( err.errorString() ) );
475475
return QVariantMap();
476476
}
477-
return map;
477+
return doc.object().toVariantMap();
478478
}
479479

480480
///////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)