Skip to content

Commit

Permalink
Add sourceSelectProviders() to the ogr data provider
Browse files Browse the repository at this point in the history
This is the first data provider real implementation,
all other data provider will follow.
  • Loading branch information
elpaso committed Sep 4, 2017
1 parent 90f8730 commit 42bd913
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/providers/ogr/qgsogrdataitems.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ class QgsOgrDataCollectionItem : public QgsDataCollectionItem
};



#endif // QGSOGRDATAITEMS_H
28 changes: 28 additions & 0 deletions src/providers/ogr/qgsogrprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ email : sherman at mrcc.com
#include "qgsogrdataitems.h"
#include "qgsgeopackagedataitems.h"
#include "qgswkbtypes.h"
#include "qgssourceselectprovider.h"
#include "qgsogrsourceselect.h"
#include "qgis.h"


Expand Down Expand Up @@ -4346,3 +4348,29 @@ QGISEXTERN bool deleteLayer( const QString &uri, QString &errCause )
errCause = QObject::tr( "Layer not found: %1" ).arg( uri );
return false;
}


//! Provider for OGR vector source select
class QgsOgrVectorSourceSelectProvider : public QgsSourceSelectProvider
{
public:

virtual QString providerKey() const override { return QStringLiteral( "ogr" ); }
virtual QString text() const override { return QObject::tr( "Vector" ); }
virtual QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddOgrLayer.svg" ) ); }
virtual QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr ) const override
{
return new QgsOgrSourceSelect( parent );
}
};


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

*providers
<< new QgsOgrVectorSourceSelectProvider;

return providers;
}

0 comments on commit 42bd913

Please sign in to comment.