Skip to content
Permalink
Browse files

Add a bit more structure to provider source select ordering

  • Loading branch information
nyalldawson committed Sep 12, 2017
1 parent b89c16e commit 15f9241109fc6bfc953245d931f0ca785a9d7228
@@ -21,6 +21,16 @@ class QgsSourceSelectProvider
#include "qgssourceselectprovider.h"
%End
public:

enum Ordering
{
OrderLocalProvider,
OrderDatabaseProvider,
OrderRemoteProvider,
OrderGeoCmsProvider,
OrderOtherProvider,
};

virtual ~QgsSourceSelectProvider();

virtual QString providerKey() const = 0;
@@ -34,6 +34,17 @@ class QWidget;
class GUI_EXPORT QgsSourceSelectProvider
{
public:

//! Provider ordering groups
enum Ordering
{
OrderLocalProvider = 0, //!< Starting point for local file providers (e.g. OGR)
OrderDatabaseProvider = 1000, //!< Starting point for database providers (e.g. Postgres)
OrderRemoteProvider = 2000, //!< Starting point for remote (online) providers (e.g. WMS)
OrderGeoCmsProvider = 3000, //!< Starting point for GeoCMS type providers (e.g. GeoNode)
OrderOtherProvider = 4000, //!< Starting point for other providers (e.g. plugin based providers)
};

virtual ~QgsSourceSelectProvider() = default;

//! Data Provider key
@@ -62,7 +73,7 @@ class GUI_EXPORT QgsSourceSelectProvider
/** Ordering: the source select provider registry will be able to sort
* the source selects (ascending) using this integer value
*/
virtual int ordering( ) const { return 0; }
virtual int ordering( ) const { return OrderOtherProvider; }

/** Create a new instance of QgsAbstractDataSourceWidget (or null).
* Caller takes responsibility of deleting created.
@@ -212,7 +212,7 @@ class QgsAfsSourceSelectProvider : public QgsSourceSelectProvider

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 int ordering() const override { return QgsSourceSelectProvider::OrderRemoteProvider + 150; }
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
{
@@ -1760,7 +1760,7 @@ class QgsDb2SourceSelectProvider : public QgsSourceSelectProvider

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 int ordering() const override { return QgsSourceSelectProvider::OrderDatabaseProvider + 40; }
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
{
@@ -1204,7 +1204,7 @@ class QgsDelimitedTextSourceSelectProvider : public QgsSourceSelectProvider

QString providerKey() const override { return QStringLiteral( "delimitedtext" ); }
QString text() const override { return QObject::tr( "Delimited Text" ); }
int ordering() const override { return 30; }
int ordering() const override { return QgsSourceSelectProvider::OrderLocalProvider + 30; }
QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddDelimitedTextLayer.svg" ) ); }
QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override
{
@@ -3066,7 +3066,7 @@ class QgsGdalRasterSourceSelectProvider : public QgsSourceSelectProvider

QString providerKey() const override { return QStringLiteral( "gdal" ); }
QString text() const override { return QObject::tr( "Raster" ); }
int ordering() const override { return 20; }
int ordering() const override { return QgsSourceSelectProvider::OrderLocalProvider + 20; }
QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddRasterLayer.svg" ) ); }
QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override
{
@@ -2319,7 +2319,7 @@ class QgsMssqlSourceSelectProvider : public QgsSourceSelectProvider

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 int ordering() const override { return QgsSourceSelectProvider::OrderDatabaseProvider + 30; }
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
{
@@ -4402,7 +4402,7 @@ class QgsOgrVectorSourceSelectProvider : public QgsSourceSelectProvider

QString providerKey() const override { return QStringLiteral( "ogr" ); }
QString text() const override { return QObject::tr( "Vector" ); }
int ordering() const override { return 10; }
int ordering() const override { return QgsSourceSelectProvider::OrderLocalProvider + 10; }
QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddOgrLayer.svg" ) ); }
QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override
{
@@ -4418,7 +4418,7 @@ class QgsGeoPackageSourceSelectProvider : public QgsSourceSelectProvider

QString providerKey() const override { return QStringLiteral( "ogr" ); }
QString text() const override { return QObject::tr( "GeoPackage" ); }
int ordering() const override { return 45; }
int ordering() const override { return QgsSourceSelectProvider::OrderLocalProvider + 45; }
QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddGeoPackageLayer.svg" ) ); }
QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override
{
@@ -4435,7 +4435,7 @@ class QgsSpatiaLiteSourceSelectProvider : public QgsSourceSelectProvider
virtual QString providerKey() const override { return QStringLiteral( "ogr" ); }
virtual QString text() const override { return QObject::tr( "SQLite" ); }
virtual int ordering() const override { return 46; }
virtual int ordering() const override { return QgsSourceSelectProvider::OrderLocalProvider + 46; }
virtual QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mIconSpatialite.svg" ) ); }
virtual QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override
{
@@ -4839,7 +4839,7 @@ class QgsPostgresSourceSelectProvider : public QgsSourceSelectProvider //#spell

QString providerKey() const override { return QStringLiteral( "postgres" ); }
QString text() const override { return QObject::tr( "PostgreSQL" ); }
int ordering() const override { return 40; }
int ordering() const override { return QgsSourceSelectProvider::OrderDatabaseProvider + 10; }
QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddPostgisLayer.svg" ) ); }
QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override
{
@@ -5930,7 +5930,7 @@ class QgsSpatialiteSourceSelectProvider : public QgsSourceSelectProvider

QString providerKey() const override { return QStringLiteral( "spatialite" ); }
QString text() const override { return QObject::tr( "SpatiaLite" ); }
int ordering() const override { return 50; }
int ordering() const override { return QgsSourceSelectProvider::OrderDatabaseProvider + 20; }
QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddSpatiaLiteLayer.svg" ) ); }
QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override
{
@@ -663,7 +663,7 @@ class QgsVirtualSourceSelectProvider : public QgsSourceSelectProvider

virtual QString providerKey() const override { return QStringLiteral( "virtual" ); }
virtual QString text() const override { return QObject::tr( "Virtual Layer" ); }
virtual int ordering() const override { return 90; }
virtual int ordering() const override { return QgsSourceSelectProvider::OrderDatabaseProvider + 50; }
virtual QString toolTip() const override { return QObject::tr( "Add Virtual Layer" ); }
virtual QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddVirtualLayer.svg" ) ); }
virtual QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override
@@ -1940,7 +1940,7 @@ class QgsWcsSourceSelectProvider : public QgsSourceSelectProvider

virtual QString providerKey() const override { return QStringLiteral( "wcs" ); }
virtual QString text() const override { return QObject::tr( "WCS" ); }
virtual int ordering() const override { return 110; }
virtual int ordering() const override { return QgsSourceSelectProvider::OrderRemoteProvider + 20; }
virtual QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddWcsLayer.svg" ) ); }
virtual QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override
{
@@ -1713,7 +1713,7 @@ class QgsWfsSourceSelectProvider : public QgsSourceSelectProvider

virtual QString providerKey() const override { return QStringLiteral( "WFS" ); }
virtual QString text() const override { return QObject::tr( "WFS" ); }
virtual int ordering() const override { return 120; }
virtual int ordering() const override { return QgsSourceSelectProvider::OrderRemoteProvider + 40; }
virtual QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddWfsLayer.svg" ) ); }
virtual QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override
{
@@ -4236,7 +4236,7 @@ class QgsWmsSourceSelectProvider : public QgsSourceSelectProvider

virtual QString providerKey() const override { return QStringLiteral( "wms" ); }
virtual QString text() const override { return QObject::tr( "WMS" ); }
virtual int ordering() const override { return 100; }
virtual int ordering() const override { return QgsSourceSelectProvider::OrderRemoteProvider + 10; }
virtual QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddWmsLayer.svg" ) ); }
virtual QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const override
{

0 comments on commit 15f9241

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