QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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 "qgsproviderregistry.h"
26 #include "qgsguiutils.h"
27 #include <QDialog>
28 #include <QDialogButtonBox>
29 
30 class QgsMapCanvas;
31 
40 class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
41 {
42  Q_OBJECT
43 
44  public:
45 
50  void setMapCanvas( const QgsMapCanvas *mapCanvas );
51 
52 
53  public slots:
54 
59  virtual void refresh() {}
60 
66  virtual void addButtonClicked() { }
67 
68 
69  signals:
70 
75  void connectionsChanged();
76 
78  void addDatabaseLayers( const QStringList &paths, const QString &providerKey );
79 
81  void addRasterLayer( const QString &rasterLayerPath, const QString &baseName, const QString &providerKey );
82 
89  void addVectorLayer( const QString &uri, const QString &layerName, const QString &providerKey = QString() );
90 
95  void addMeshLayer( const QString &url, const QString &baseName, const QString &providerKey );
96 
103  void addVectorLayers( const QStringList &layerList, const QString &encoding, const QString &dataSourceType );
104 
112  void replaceVectorLayer( const QString &oldId, const QString &source, const QString &name, const QString &provider );
113 
119  Q_DECL_DEPRECATED void progress( int, int ) SIP_DEPRECATED;
120 
122  void progressMessage( QString message );
123 
125  void enableButtons( bool enable );
126 
127 
128  protected:
129 
131  QgsAbstractDataSourceWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
132 
134  QgsProviderRegistry::WidgetMode widgetMode() const;
135 
137  const QgsMapCanvas *mapCanvas() const;
138 
140  void setupButtons( QDialogButtonBox *buttonBox );
141 
143  QPushButton *addButton( ) const { return mAddButton; }
144 
145  private:
146  QPushButton *mAddButton = nullptr;
148  QgsMapCanvas const *mMapCanvas = nullptr;
149 
150 };
151 
152 #endif // QGSABSTRACTDATASOURCEWIDGET_H
WidgetMode
Different ways a source select dialog can be used (embedded is for the data source manager dialog) ...
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
Abstract base Data Source Widget to create connections and add layers This class provides common func...
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:73
virtual void refresh()
Triggered when the provider&#39;s connections need to be refreshed The default implementation does nothin...
QPushButton * addButton() const
Returns the add Button.
#define SIP_DEPRECATED
Definition: qgis_sip.h:99
virtual void addButtonClicked()
Triggered when the add button is clicked, the add layer signal is emitted Concrete classes should imp...