Skip to content
Permalink
Browse files

[gdal] update data item creation to new methods

  • Loading branch information
nirvn committed Oct 2, 2018
1 parent e877050 commit af0bae67f7376b63823573153b77de9e8f995592
@@ -12,6 +12,7 @@
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgsgdaldataitems.h"
#include "qgsgdalprovider.h"
#include "qgslogger.h"
@@ -125,13 +126,9 @@ static QStringList sExtensions = QStringList();
static QStringList sWildcards = QStringList();
static QMutex sBuildingFilters;

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

QGISEXTERN QgsDataItem *dataItem( QString path, QgsDataItem *parentItem )
QgsDataItem *QgsGdalDataItemProvider::createDataItem( const QString &pathIn, QgsDataItem *parentItem )
{
QString path( pathIn );
if ( path.isEmpty() )
return nullptr;

@@ -261,15 +258,12 @@ QGISEXTERN QgsDataItem *dataItem( QString path, QgsDataItem *parentItem )
QStringList ogrSupportedDbDriverNames;
ogrSupportedDbDriverNames << QStringLiteral( "GPKG" ) << QStringLiteral( "db" ) << QStringLiteral( "gdb" );

// skip archived item in favor of OGR if scanExtSetting && scanZipSetting is basic
if ( scanExtSetting && ( is_vsizip || is_vsitar || is_vsigzip ) && scanZipSetting == QLatin1String( "basic" ) )
{
return nullptr;
}

// return item without testing if scanExtSetting is true
// netCDF files can be both raster or vector, so fallback to opening
if ( scanExtSetting && !is_vsizip && !is_vsigzip && !is_vsitar && suffix != QLatin1String( "nc" ) )
// return item without testing if:
// scanExtSetting
// or zipfile and scan zip == "Basic scan"
if ( ( scanExtSetting ||
( ( is_vsizip || is_vsitar ) && scanZipSetting == QLatin1String( "basic" ) ) ) &&
suffix != QLatin1String( "nc" ) )
{
// Skip this layer if it's handled by ogr:
if ( ogrSupportedDbLayersExtensions.contains( suffix ) )
@@ -16,6 +16,8 @@
#define QGSGDALDATAITEMS_H

#include "qgsdataitem.h"
#include "qgsdataitemprovider.h"
#include "qgsdataprovider.h"

class QgsGdalLayerItem : public QgsLayerItem
{
@@ -37,4 +39,15 @@ class QgsGdalLayerItem : public QgsLayerItem
QString layerName() const override;
};

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

int capabilities() override { return QgsDataProvider::File | QgsDataProvider::Dir; }

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

#endif // QGSGDALDATAITEMS_H
@@ -25,7 +25,9 @@
#include "qgsauthmanager.h"
#include "qgscoordinatetransform.h"
#include "qgsdataitem.h"
#include "qgsdataitemprovider.h"
#include "qgsdatasourceuri.h"
#include "qgsgdaldataitems.h"
#include "qgshtmlutils.h"
#include "qgsmessagelog.h"
#include "qgsrectangle.h"
@@ -3220,6 +3222,12 @@ QGISEXTERN void cleanupProvider()
// calling GDALDestroyDriverManager()
}

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

#ifdef HAVE_GUI

0 comments on commit af0bae6

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