QGIS API Documentation  3.2.0-Bonn (bc43194)
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.h"
24 #include "qgis_gui.h"
25 
26 #include "qgsproviderregistry.h"
27 #include "qgsguiutils.h"
28 #include <QDialog>
29 #include <QDialogButtonBox>
30 
31 class QgsMapCanvas;
32 
41 class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
42 {
43  Q_OBJECT
44 
45  public:
46 
51  void setMapCanvas( const QgsMapCanvas *mapCanvas );
52 
53 
54  public slots:
55 
60  virtual void refresh() {}
61 
67  virtual void addButtonClicked() { }
68 
69 
70  signals:
71 
76  void connectionsChanged();
77 
79  void addDatabaseLayers( const QStringList &paths, const QString &providerKey );
80 
82  void addRasterLayer( const QString &rasterLayerPath, const QString &baseName, const QString &providerKey );
83 
90  void addVectorLayer( const QString &uri, const QString &layerName, const QString &providerKey = QString() );
91 
98  void addVectorLayers( const QStringList &layerList, const QString &encoding, const QString &dataSourceType );
99 
107  void replaceVectorLayer( const QString &oldId, const QString &source, const QString &name, const QString &provider );
108 
109 
111  void progress( int, int );
112 
114  void progressMessage( QString message );
115 
117  void enableButtons( bool enable );
118 
119 
120  protected:
121 
123  QgsAbstractDataSourceWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
124 
126  QgsProviderRegistry::WidgetMode widgetMode() const;
127 
129  const QgsMapCanvas *mapCanvas() const;
130 
132  void setupButtons( QDialogButtonBox *buttonBox );
133 
135  QPushButton *addButton( ) const { return mAddButton; }
136 
137  private:
138  QPushButton *mAddButton = nullptr;
140  QgsMapCanvas const *mMapCanvas = nullptr;
141 
142 };
143 
144 #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:74
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.
virtual void addButtonClicked()
Triggered when the add button is clicked, the add layer signal is emitted Concrete classes should imp...