Skip to content

Commit

Permalink
[afs] Use new style data item provider
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 7, 2018
1 parent 8125366 commit 9489670
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 46 deletions.
25 changes: 25 additions & 0 deletions src/providers/arcgisrest/qgsafsdataitems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,28 @@ QgsAfsLayerItem::QgsAfsLayerItem( QgsDataItem *parent, const QString &name, cons
setState( Populated );
mIconName = QStringLiteral( "mIconAfs.svg" );
}

//
// QgsAfsDataItemProvider
//

QgsDataItem *QgsAfsDataItemProvider::createDataItem( const QString &path, QgsDataItem *parentItem )
{
if ( path.isEmpty() )
{
return new QgsAfsRootItem( parentItem, QStringLiteral( "ArcGisFeatureServer" ), QStringLiteral( "arcgisfeatureserver:" ) );
}

// path schema: afs:/connection name (used by OWS)
if ( path.startsWith( QLatin1String( "afs:/" ) ) )
{
QString connectionName = path.split( '/' ).last();
if ( QgsOwsConnection::connectionList( QStringLiteral( "arcgisfeatureserver" ) ).contains( connectionName ) )
{
QgsOwsConnection connection( QStringLiteral( "arcgisfeatureserver" ), connectionName );
return new QgsAfsConnectionItem( parentItem, QStringLiteral( "ArcGisFeatureServer" ), path, connection.uri().param( QStringLiteral( "url" ) ) );
}
}

return nullptr;
}
12 changes: 12 additions & 0 deletions src/providers/arcgisrest/qgsafsdataitems.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "qgsdataitem.h"
#include "qgsdatasourceuri.h"
#include "qgswkbtypes.h"
#include "qgsdataitemprovider.h"

class QgsAfsRootItem : public QgsDataCollectionItem
{
Expand Down Expand Up @@ -72,4 +73,15 @@ class QgsAfsLayerItem : public QgsLayerItem
QgsAfsLayerItem( QgsDataItem *parent, const QString &name, const QString &url, const QString &title, const QString &authid, const QString &authcfg );
};

//! Provider for afs root data item
class QgsAfsDataItemProvider : public QgsDataItemProvider
{
public:
QString name() override { return QStringLiteral( "AFS" ); }

int capabilities() override { return QgsDataProvider::Net; }

QgsDataItem *createDataItem( const QString &path, QgsDataItem *parentItem ) override;
};

#endif // QGSAFSDATAITEMS_H
13 changes: 13 additions & 0 deletions src/providers/arcgisrest/qgsafsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
#include "qgsarcgisrestutils.h"
#include "qgsafsfeatureiterator.h"
#include "qgsdatasourceuri.h"
#include "qgsafsdataitems.h"
#include "qgslogger.h"
#include "geometry/qgsgeometry.h"
#include "qgsnetworkaccessmanager.h"
#include "qgsdataitemprovider.h"

#ifdef HAVE_GUI
#include "qgsafssourceselect.h"
Expand Down Expand Up @@ -333,4 +335,15 @@ QGISEXTERN QList<QgsSourceSelectProvider *> *sourceSelectProviders()

return providers;
}

QGISEXTERN QList<QgsDataItemProvider *> *dataItemProviders()
{
QList<QgsDataItemProvider *> *providers = new QList<QgsDataItemProvider *>();

*providers
<< new QgsAfsDataItemProvider;

return providers;
}

#endif
46 changes: 0 additions & 46 deletions src/providers/arcgisrest/qgsafsproviderextern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,49 +59,3 @@ QGISEXTERN int dataCapabilities()
{
return QgsDataProvider::Net;
}

QGISEXTERN QgsDataItem *dataItem( QString path, QgsDataItem *parentItem )
{
if ( path.isEmpty() )
{
return new QgsAfsRootItem( parentItem, QStringLiteral( "ArcGisFeatureServer" ), QStringLiteral( "arcgisfeatureserver:" ) );
}

// path schema: afs:/connection name (used by OWS)
if ( path.startsWith( QLatin1String( "afs:/" ) ) )
{
QString connectionName = path.split( '/' ).last();
if ( QgsOwsConnection::connectionList( QStringLiteral( "arcgisfeatureserver" ) ).contains( connectionName ) )
{
QgsOwsConnection connection( QStringLiteral( "arcgisfeatureserver" ), connectionName );
return new QgsAfsConnectionItem( parentItem, QStringLiteral( "ArcGisFeatureServer" ), path, connection.uri().param( QStringLiteral( "url" ) ) );
}
}

return nullptr;
}

/*
QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QString& sldStyle,
const QString& styleName, const QString& styleDescription,
const QString& uiFileContent, bool useAsDefault, QString& errCause )
{
}
QGISEXTERN QString loadStyle( const QString& uri, QString& errCause )
{
}
QGISEXTERN int listStyles( const QString &uri, QStringList &ids, QStringList &names,
QStringList &descriptions, QString& errCause )
{
}
QGISEXTERN QString getStyleById( const QString& uri, QString styleId, QString& errCause )
{
}
*/

0 comments on commit 9489670

Please sign in to comment.