QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
53  void setMapCanvas( const QgsMapCanvas *mapCanvas );
54 
61  void setBrowserModel( QgsBrowserModel *model );
62 
63  public slots:
64 
69  virtual void refresh() {}
70 
76  virtual void addButtonClicked();
77 
87  virtual void reset();
88 
89  signals:
90 
96 
98  void addDatabaseLayers( const QStringList &paths, const QString &providerKey );
99 
101  void addRasterLayer( const QString &rasterLayerPath, const QString &baseName, const QString &providerKey );
102 
109  void addVectorLayer( const QString &uri, const QString &layerName, const QString &providerKey = QString() );
110 
115  void addMeshLayer( const QString &url, const QString &baseName, const QString &providerKey );
116 
121  void addVectorTileLayer( const QString &url, const QString &baseName );
122 
127  void addPointCloudLayer( const QString &url, const QString &baseName, const QString &providerKey );
128 
135  void addVectorLayers( const QStringList &layerList, const QString &encoding, const QString &dataSourceType );
136 
144  void replaceVectorLayer( const QString &oldId, const QString &source, const QString &name, const QString &provider );
145 
151  Q_DECL_DEPRECATED void progress( int, int ) SIP_DEPRECATED;
152 
154  void progressMessage( QString message );
155 
157  void enableButtons( bool enable );
158 
163  void pushMessage( const QString &title, const QString &message, const Qgis::MessageLevel level = Qgis::MessageLevel::Info );
164 
165 
166  protected:
167 
169  QgsAbstractDataSourceWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
170 
172  QgsProviderRegistry::WidgetMode widgetMode() const;
173 
175  const QgsMapCanvas *mapCanvas() const;
176 
182  QgsBrowserModel *browserModel();
183 
185  void setupButtons( QDialogButtonBox *buttonBox );
186 
188  QPushButton *addButton( ) const { return mAddButton; }
189 
190  private:
191  QPushButton *mAddButton = nullptr;
193  QgsMapCanvas const *mMapCanvas = nullptr;
194  QgsBrowserModel *mBrowserModel = nullptr;
195 
196 };
197 
198 #endif // QGSABSTRACTDATASOURCEWIDGET_H
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Definition: qgis.h:89
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.
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 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...
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:86
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