QGIS API Documentation  3.25.0-Master (10b47c2603)
qgsabstractdatasourcewidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsabstractdatasourcewidget.h - base class for source selector widgets
3  -------------------
4  begin : 10 July 2017
5  original : (C) 2017 by Alessandro Pasotti
6  email : apasotti at boundlessgeo dot com
7 
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 #ifndef QGSABSTRACTDATASOURCEWIDGET_H
20 #define QGSABSTRACTDATASOURCEWIDGET_H
21 
22 #include "qgis_sip.h"
23 #include "qgis_gui.h"
24 
25 #include "qgsproviderguimetadata.h"
26 #include "qgsproviderregistry.h"
27 #include "qgsguiutils.h"
28 #include <QDialog>
29 #include <QDialogButtonBox>
30 
31 class QgsMapCanvas;
32 class QgsBrowserModel;
33 
34 
43 class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
44 {
45  Q_OBJECT
46 
47  public:
48 
55  void setBrowserModel( QgsBrowserModel *model );
56 
62  virtual QgsMapCanvas *mapCanvas() {return mMapCanvas; }
63 
68  virtual void setMapCanvas( QgsMapCanvas *mapCanvas ) { mMapCanvas = mapCanvas; }
69 
70  public slots:
71 
76  virtual void refresh() {}
77 
83  virtual void addButtonClicked();
84 
94  virtual void reset();
95 
96  signals:
97 
103 
105  void addDatabaseLayers( const QStringList &paths, const QString &providerKey );
106 
108  void addRasterLayer( const QString &rasterLayerPath, const QString &baseName, const QString &providerKey );
109 
115  void addRasterLayers( const QStringList &layersList );
116 
123  void addVectorLayer( const QString &uri, const QString &layerName, const QString &providerKey = QString() );
124 
129  void addMeshLayer( const QString &url, const QString &baseName, const QString &providerKey );
130 
135  void addVectorTileLayer( const QString &url, const QString &baseName );
136 
141  void addPointCloudLayer( const QString &url, const QString &baseName, const QString &providerKey );
142 
149  void addVectorLayers( const QStringList &layerList, const QString &encoding, const QString &dataSourceType );
150 
158  void replaceVectorLayer( const QString &oldId, const QString &source, const QString &name, const QString &provider );
159 
165  Q_DECL_DEPRECATED void progress( int, int ) SIP_DEPRECATED;
166 
168  void progressMessage( QString message );
169 
171  void enableButtons( bool enable );
172 
177  void pushMessage( const QString &title, const QString &message, const Qgis::MessageLevel level = Qgis::MessageLevel::Info );
178 
179  protected:
180 
182  QgsAbstractDataSourceWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
183 
185  QgsProviderRegistry::WidgetMode widgetMode() const;
186 
192  QgsBrowserModel *browserModel();
193 
195  void setupButtons( QDialogButtonBox *buttonBox );
196 
198  QPushButton *addButton( ) const { return mAddButton; }
199 
200  private:
201  QPushButton *mAddButton = nullptr;
203  QgsBrowserModel *mBrowserModel = nullptr;
204  QgsMapCanvas *mMapCanvas = nullptr;
205 
206 };
207 
208 #endif // QGSABSTRACTDATASOURCEWIDGET_H
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Definition: qgis.h:115
Abstract base Data Source Widget to create connections and add layers This class provides common func...
void addPointCloudLayer(const QString &url, const QString &baseName, const QString &providerKey)
Emitted when a point cloud layer has been selected for addition.
void enableButtons(bool enable)
Emitted when the ok/add buttons should be enabled/disabled.
void pushMessage(const QString &title, const QString &message, const Qgis::MessageLevel level=Qgis::MessageLevel::Info)
Emitted when a message with title and level must be shown to the user using the parent visible messag...
Q_DECL_DEPRECATED void progress(int, int)
Emitted when a progress dialog is shown by the provider dialog.
QPushButton * addButton() const
Returns the add Button.
virtual void setMapCanvas(QgsMapCanvas *mapCanvas)
Sets the dialog map canvas.
void replaceVectorLayer(const QString &oldId, const QString &source, const QString &name, const QString &provider)
Emitted when a layer needs to be replaced.
void connectionsChanged()
Emitted when the provider's connections have changed This signal is normally forwarded the app and us...
void addRasterLayers(const QStringList &layersList)
Emitted when one or more GDAL supported layers are selected for addition.
void addMeshLayer(const QString &url, const QString &baseName, const QString &providerKey)
Emitted when a mesh layer has been selected for addition.
void addRasterLayer(const QString &rasterLayerPath, const QString &baseName, const QString &providerKey)
Emitted when a raster layer has been selected for addition.
virtual void refresh()
Triggered when the provider's connections need to be refreshed The default implementation does nothin...
virtual QgsMapCanvas * mapCanvas()
Returns the dialog map canvas.
void progressMessage(QString message)
Emitted when a progress dialog is shown by the provider dialog.
void addVectorLayers(const QStringList &layerList, const QString &encoding, const QString &dataSourceType)
Emitted when one or more OGR supported layers are selected for addition.
void addVectorLayer(const QString &uri, const QString &layerName, const QString &providerKey=QString())
Emitted when a vector layer has been selected for addition.
void addDatabaseLayers(const QStringList &paths, const QString &providerKey)
Emitted when a DB layer has been selected for addition.
void addVectorTileLayer(const QString &url, const QString &baseName)
Emitted when a vector tile layer has been selected for addition.
A model for showing available data sources and other items in a structured tree.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:90
WidgetMode
Different ways a source select dialog can be used.
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53