Skip to content
Permalink
Browse files

[afs] Use new style data item provider

  • Loading branch information
nyalldawson committed Nov 7, 2018
1 parent 8125366 commit 94896703dc889e14f9c9cda240300bf88c12d6d7
@@ -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;
}
@@ -18,6 +18,7 @@
#include "qgsdataitem.h"
#include "qgsdatasourceuri.h"
#include "qgswkbtypes.h"
#include "qgsdataitemprovider.h"

class QgsAfsRootItem : public QgsDataCollectionItem
{
@@ -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
@@ -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"
@@ -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
@@ -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.
You can’t perform that action at this time.