Skip to content
Permalink
Browse files

Implement sourceSelectProviders() for all providers

  • Loading branch information
elpaso committed Sep 4, 2017
1 parent fd7bcb3 commit d47fdbc79cc7fc4dfd2188d218332d759c831c78
@@ -23,6 +23,11 @@
#include "geometry/qgsgeometry.h"
#include "qgsnetworkaccessmanager.h"

#ifdef HAVE_GUI
#include "qgsafssourceselect.h"
#include "qgssourceselectprovider.h"
#endif

#include <QEventLoop>
#include <QMessageBox>
#include <QNetworkRequest>
@@ -196,3 +201,33 @@ void QgsAfsProvider::reloadData()
{
mSharedData->mCache.clear();
}


#ifdef HAVE_GUI

//! Provider for AFS layers source select
class QgsAfsSourceSelectProvider : public QgsSourceSelectProvider
{
public:

virtual QString providerKey() const override { return QStringLiteral( "arcgisfeatureserver" ); }
virtual QString text() const override { return QObject::tr( "ArcGIS Feature Server" ); }
virtual int ordering() const override { return 140; }
virtual QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddAfsLayer.svg" ) ); }
virtual QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override
{
return new QgsAfsSourceSelect( parent, fl, widgetMode );
}
};


QGISEXTERN QList<QgsSourceSelectProvider *> *sourceSelectProviders()
{
QList<QgsSourceSelectProvider *> *providers = new QList<QgsSourceSelectProvider *>();

*providers
<< new QgsAfsSourceSelectProvider;

return providers;
}
#endif
@@ -24,6 +24,11 @@
#include "qgsfeaturestore.h"
#include "qgsgeometry.h"

#ifdef HAVE_GUI
#include "qgsamssourceselect.h"
#include "qgssourceselectprovider.h"
#endif

#include <cstring>
#include <QJsonDocument>
#include <QJsonObject>
@@ -449,3 +454,32 @@ void QgsAmsProvider::readBlock( int /*bandNo*/, const QgsRectangle &viewExtent,
}
std::memcpy( data, mCachedImage.constBits(), mCachedImage.bytesPerLine() * mCachedImage.height() );
}

#ifdef HAVE_GUI

//! Provider for AMS layers source select
class QgsAmsSourceSelectProvider : public QgsSourceSelectProvider
{
public:

virtual QString providerKey() const override { return QStringLiteral( "arcgismapserver" ); }
virtual QString text() const override { return QObject::tr( "ArcGIS Map Server" ); }
virtual int ordering() const override { return 130; }
virtual QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddAmsLayer.svg" ) ); }
virtual QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override
{
return new QgsAmsSourceSelect( parent, fl, widgetMode );
}
};


QGISEXTERN QList<QgsSourceSelectProvider *> *sourceSelectProviders()
{
QList<QgsSourceSelectProvider *> *providers = new QList<QgsSourceSelectProvider *>();

*providers
<< new QgsAmsSourceSelectProvider;

return providers;
}
#endif
@@ -28,7 +28,7 @@ class QgsAmsSourceSelect: public QgsArcGisServiceSourceSelect
Q_OBJECT

public:
QgsAmsSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
QgsAmsSourceSelect( QWidget *parent = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );

protected:
bool connectToService( const QgsOwsConnection &connection ) override;
@@ -27,6 +27,7 @@

#ifdef HAVE_GUI
#include "qgsdb2sourceselect.h"
#include "qgssourceselectprovider.h"
#endif

static const QString PROVIDER_KEY = QStringLiteral( "DB2" );
@@ -1748,3 +1749,34 @@ QGISEXTERN QgsVectorLayerExporter::ExportError createEmptyLayer(
oldToNewAttrIdxMap, errorMessage, options
);
}


#ifdef HAVE_GUI

//! Provider for DB2 source select
class QgsDb2SourceSelectProvider : public QgsSourceSelectProvider
{
public:

virtual QString providerKey() const override { return QStringLiteral( "DB2" ); }
virtual QString text() const override { return QObject::tr( "DB2" ); }
virtual int ordering() const override { return 70; }
virtual QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddDb2Layer.svg" ) ); }
virtual QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override
{
return new QgsDb2SourceSelect( parent, fl, widgetMode );
}
};


QGISEXTERN QList<QgsSourceSelectProvider *> *sourceSelectProviders()
{
QList<QgsSourceSelectProvider *> *providers = new QList<QgsSourceSelectProvider *>();

*providers
<< new QgsDb2SourceSelectProvider;

return providers;
}

#endif
@@ -41,6 +41,9 @@
#include "qgsspatialindex.h"
#include "qgis.h"
#include "qgsproviderregistry.h"
#ifdef HAVE_GUI
#include "qgssourceselectprovider.h"
#endif

#include "qgsdelimitedtextfeatureiterator.h"
#include "qgsdelimitedtextfile.h"
@@ -1196,4 +1199,33 @@ QGISEXTERN QgsDelimitedTextSourceSelect *selectWidget( QWidget *parent, Qt::Wind
{
return new QgsDelimitedTextSourceSelect( parent, fl, widgetMode );
}

//! Provider for delimited text source select
class QgsDelimitedTextSourceSelectProvider : public QgsSourceSelectProvider
{
public:

virtual QString providerKey() const override { return QStringLiteral( "delimitedtext" ); }
virtual QString text() const override { return QObject::tr( "Delimited Text" ); }
virtual int ordering() const override { return 30; }
virtual QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddDelimitedTextLayer.svg" ) ); }
virtual QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override
{
return new QgsDelimitedTextSourceSelect( parent, fl, widgetMode );
}
};


QGISEXTERN QList<QgsSourceSelectProvider *> *sourceSelectProviders()
{
QList<QgsSourceSelectProvider *> *providers = new QList<QgsSourceSelectProvider *>();

*providers
<< new QgsDelimitedTextSourceSelectProvider;

return providers;
}

#endif


@@ -35,6 +35,11 @@
#include "qgspointxy.h"
#include "qgssettings.h"

#ifdef HAVE_GUI
#include "qgssourceselectprovider.h"
#include "qgsgdalsourceselect.h"
#endif

#include <QImage>
#include <QColor>
#include <QProcess>
@@ -3041,3 +3046,34 @@ QGISEXTERN void cleanupProvider()
// nothing to do here, QgsApplication takes care of
// calling GDALDestroyDriverManager()
}


#ifdef HAVE_GUI

//! Provider for gdal raster source select
class QgsGdalRasterSourceSelectProvider : public QgsSourceSelectProvider
{
public:

virtual QString providerKey() const override { return QStringLiteral( "gdal" ); }
virtual QString text() const override { return QObject::tr( "Raster" ); }
virtual int ordering() const override { return 20; }
virtual QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddRasterLayer.svg" ) ); }
virtual QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override
{
return new QgsGdalSourceSelect( parent, fl, widgetMode );
}
};


QGISEXTERN QList<QgsSourceSelectProvider *> *sourceSelectProviders()
{
QList<QgsSourceSelectProvider *> *providers = new QList<QgsSourceSelectProvider *>();

*providers
<< new QgsGdalRasterSourceSelectProvider;

return providers;
}

#endif
@@ -49,6 +49,7 @@

#ifdef HAVE_GUI
#include "qgsmssqlsourceselect.h"
#include "qgssourceselectprovider.h"
#endif

static const QString TEXT_PROVIDER_KEY = QStringLiteral( "mssql" );
@@ -2307,3 +2308,34 @@ QGISEXTERN QString getStyleById( const QString &uri, QString styleId, QString &e
}
return style;
}


#ifdef HAVE_GUI

//! Provider for msssql raster source select
class QgsMssqlSourceSelectProvider : public QgsSourceSelectProvider
{
public:

virtual QString providerKey() const override { return QStringLiteral( "mssql" ); }
virtual QString text() const override { return QObject::tr( "MSSQL" ); }
virtual int ordering() const override { return 60; }
virtual QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddMssqlLayer.svg" ) ); }
virtual QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override
{
return new QgsMssqlSourceSelect( parent, fl, widgetMode );
}
};


QGISEXTERN QList<QgsSourceSelectProvider *> *sourceSelectProviders()
{
QList<QgsSourceSelectProvider *> *providers = new QList<QgsSourceSelectProvider *>();

*providers
<< new QgsMssqlSourceSelectProvider ;

return providers;
}

#endif
@@ -35,8 +35,12 @@ email : sherman at mrcc.com
#include "qgsogrdataitems.h"
#include "qgsgeopackagedataitems.h"
#include "qgswkbtypes.h"

#ifdef HAVE_GUI
#include "qgssourceselectprovider.h"
#include "qgsogrsourceselect.h"
#endif

#include "qgis.h"


@@ -4349,6 +4353,7 @@ QGISEXTERN bool deleteLayer( const QString &uri, QString &errCause )
return false;
}

#ifdef HAVE_GUI

//! Provider for OGR vector source select
class QgsOgrVectorSourceSelectProvider : public QgsSourceSelectProvider
@@ -4357,10 +4362,11 @@ class QgsOgrVectorSourceSelectProvider : public QgsSourceSelectProvider

virtual QString providerKey() const override { return QStringLiteral( "ogr" ); }
virtual QString text() const override { return QObject::tr( "Vector" ); }
virtual int ordering() const override { return 10; }
virtual QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddOgrLayer.svg" ) ); }
virtual QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr ) const override
virtual QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override
{
return new QgsOgrSourceSelect( parent );
return new QgsOgrSourceSelect( parent, fl, widgetMode );
}
};

@@ -4374,3 +4380,5 @@ QGISEXTERN QList<QgsSourceSelectProvider *> *sourceSelectProviders()

return providers;
}

#endif
@@ -33,6 +33,7 @@

#ifdef HAVE_GUI
#include "qgsoraclesourceselect.h"
#include "qgssourceselectprovider.h"
#endif

#include <QSqlRecord>
@@ -3582,4 +3583,36 @@ QGISEXTERN QString getStyleById( const QString &uri, QString styleId, QString &e
return style;
}

// vim: set sw=2 :

#ifdef HAVE_GUI

//! Provider for Oracle source select
class QgsOracleSourceSelectProvider : public QgsSourceSelectProvider
{
public:

virtual QString providerKey() const override { return QStringLiteral( "oracle" ); }
virtual QString text() const override { return QObject::tr( "Oracle" ); }
virtual int ordering() { return 80; }
virtual QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddOracleLayer.svg" ) ); }
virtual QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override
{
return new QgsOracleSourceSelect( parent, fl, widgetMode );
}
};


QGISEXTERN QList<QgsSourceSelectProvider *> *sourceSelectProviders()
{
QList<QgsSourceSelectProvider *> *providers = new QList<QgsSourceSelectProvider *>();

*providers
<< new QgsOracleSourceSelectProvider;

return providers;
}

#endif


// vim: set sw=2

0 comments on commit d47fdbc

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