Skip to content
Permalink
Browse files

Fix loading of XYZ tile layer data item provider

  • Loading branch information
wonder-sk committed Aug 31, 2016
1 parent 4a1b4fd commit b919198e465e3556425bd51758e22b7407bf1e0e
@@ -21,6 +21,8 @@
#include "qgslogger.h"
#include "qgsproviderregistry.h"

typedef QList<QgsDataItemProvider*> dataItemProviders_t();


/**
* \ingroup core
@@ -64,6 +66,17 @@ QgsDataItemProviderRegistry::QgsDataItemProviderRegistry()
if ( !library )
continue;

// new / better way of returning data items from providers

dataItemProviders_t* dataItemProvidersFn = reinterpret_cast< dataItemProviders_t * >( cast_to_fptr( library->resolve( "dataItemProviders" ) ) );
if ( dataItemProvidersFn )
{
// the function is a factory - we keep ownership of the returned providers
mProviders << dataItemProvidersFn();
}

// legacy support - using dataItem() and dataCapabilities() methods

dataCapabilities_t * dataCapabilities = reinterpret_cast< dataCapabilities_t * >( cast_to_fptr( library->resolve( "dataCapabilities" ) ) );
if ( !dataCapabilities )
{
@@ -420,23 +420,15 @@ void QgsWMSRootItem::newConnection()
QGISEXTERN void registerGui( QMainWindow *mainWindow )
{
QgsTileScaleWidget::showTileScale( mainWindow );

// with dataItem(...) at provider level we can only have one root item,
// so we have a data item provider for XYZ tile layers
QgsDataItemProviderRegistry::instance()->addProvider( new QgsXyzTileDataItemProvider );
}

QGISEXTERN QgsWMSSourceSelect * selectWidget( QWidget * parent, Qt::WindowFlags fl )
{
return new QgsWMSSourceSelect( parent, fl );
}

QGISEXTERN int dataCapabilities()
{
return QgsDataProvider::Net;
}

QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
QgsDataItem* QgsWmsDataItemProvider::createDataItem( const QString& thePath, QgsDataItem *parentItem )
{
QgsDebugMsg( "thePath = " + thePath );
if ( thePath.isEmpty() )
@@ -458,6 +450,12 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
return nullptr;
}

QGISEXTERN QList<QgsDataItemProvider*> dataItemProviders()
{
return QList<QgsDataItemProvider*>()
<< new QgsWmsDataItemProvider
<< new QgsXyzTileDataItemProvider;
}

// ---------------------------------------------------------------------------

@@ -106,6 +106,19 @@ class QgsWMSRootItem : public QgsDataCollectionItem
void newConnection();
};


//! Provider for WMS root data item
class QgsWmsDataItemProvider : public QgsDataItemProvider
{
public:
virtual QString name() override { return "WMS"; }

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

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


//! Root item for XYZ tile layers
class QgsXyzTileRootItem : public QgsDataCollectionItem
{

0 comments on commit b919198

Please sign in to comment.
You can’t perform that action at this time.