QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 
33 
42 class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
43 {
44  Q_OBJECT
45 
46  public:
47 
52  void setMapCanvas( const QgsMapCanvas *mapCanvas );
53 
54 
55  public slots:
56 
61  virtual void refresh() {}
62 
68  virtual void addButtonClicked();
69 
79  virtual void reset();
80 
81  signals:
82 
88 
90  void addDatabaseLayers( const QStringList &paths, const QString &providerKey );
91 
93  void addRasterLayer( const QString &rasterLayerPath, const QString &baseName, const QString &providerKey );
94 
101  void addVectorLayer( const QString &uri, const QString &layerName, const QString &providerKey = QString() );
102 
107  void addMeshLayer( const QString &url, const QString &baseName, const QString &providerKey );
108 
113  void addVectorTileLayer( const QString &url, const QString &baseName );
114 
121  void addVectorLayers( const QStringList &layerList, const QString &encoding, const QString &dataSourceType );
122 
130  void replaceVectorLayer( const QString &oldId, const QString &source, const QString &name, const QString &provider );
131 
137  Q_DECL_DEPRECATED void progress( int, int ) SIP_DEPRECATED;
138 
140  void progressMessage( QString message );
141 
143  void enableButtons( bool enable );
144 
149  void pushMessage( const QString &title, const QString &message, const Qgis::MessageLevel level = Qgis::MessageLevel::Info );
150 
151 
152  protected:
153 
155  QgsAbstractDataSourceWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
156 
158  QgsProviderRegistry::WidgetMode widgetMode() const;
159 
161  const QgsMapCanvas *mapCanvas() const;
162 
164  void setupButtons( QDialogButtonBox *buttonBox );
165 
167  QPushButton *addButton( ) const { return mAddButton; }
168 
169  private:
170  QPushButton *mAddButton = nullptr;
172  QgsMapCanvas const *mMapCanvas = nullptr;
173 
174 };
175 
176 #endif // QGSABSTRACTDATASOURCEWIDGET_H
qgsproviderguimetadata.h
QgsAbstractDataSourceWidget::addDatabaseLayers
void addDatabaseLayers(const QStringList &paths, const QString &providerKey)
Emitted when a DB layer has been selected for addition.
QgsAbstractDataSourceWidget
Abstract base Data Source Widget to create connections and add layers This class provides common func...
Definition: qgsabstractdatasourcewidget.h:43
QgsAbstractDataSourceWidget::addRasterLayer
void addRasterLayer(const QString &rasterLayerPath, const QString &baseName, const QString &providerKey)
Emitted when a raster layer has been selected for addition.
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:85
QgsAbstractDataSourceWidget::addVectorLayers
void addVectorLayers(const QStringList &layerList, const QString &encoding, const QString &dataSourceType)
Emitted when one or more OGR supported layers are selected for addition.
QgsAbstractDataSourceWidget::replaceVectorLayer
void replaceVectorLayer(const QString &oldId, const QString &source, const QString &name, const QString &provider)
Emitted when a layer needs to be replaced.
QgsAbstractDataSourceWidget::connectionsChanged
void connectionsChanged()
Emitted when the provider's connections have changed This signal is normally forwarded the app and us...
SIP_DEPRECATED
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
QgsAbstractDataSourceWidget::progressMessage
void progressMessage(QString message)
Emitted when a progress dialog is shown by the provider dialog.
QgsProviderRegistry::WidgetMode
WidgetMode
Different ways a source select dialog can be used.
Definition: qgsproviderregistry.h:65
qgsproviderregistry.h
QgsAbstractDataSourceWidget::addVectorLayer
void addVectorLayer(const QString &uri, const QString &layerName, const QString &providerKey=QString())
Emitted when a vector layer has been selected for addition.
QgsAbstractDataSourceWidget::enableButtons
void enableButtons(bool enable)
Emitted when the ok/add buttons should be enabled/disabled.
qgis_sip.h
QgsAbstractDataSourceWidget::addVectorTileLayer
void addVectorTileLayer(const QString &url, const QString &baseName)
Emitted when a vector tile layer has been selected for addition.
QgsAbstractDataSourceWidget::progress
Q_DECL_DEPRECATED void progress(int, int)
Emitted when a progress dialog is shown by the provider dialog.
Qgis::MessageLevel
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Definition: qgis.h:89
QgsAbstractDataSourceWidget::addMeshLayer
void addMeshLayer(const QString &url, const QString &baseName, const QString &providerKey)
Emitted when a mesh layer has been selected for addition.
QgsAbstractDataSourceWidget::addButton
QPushButton * addButton() const
Returns the add Button.
Definition: qgsabstractdatasourcewidget.h:167
QgsAbstractDataSourceWidget::pushMessage
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...
qgsguiutils.h
QgsAbstractDataSourceWidget::refresh
virtual void refresh()
Triggered when the provider's connections need to be refreshed The default implementation does nothin...
Definition: qgsabstractdatasourcewidget.h:61
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53