QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgsdatasourceselectdialog.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdatasourceselectdialog.h - QgsDataSourceSelectDialog
3 
4  ---------------------
5  begin : 1.11.2018
6  copyright : (C) 2018 by Alessandro Pasotti
7  email : [email protected]
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 #ifndef QGSDATASOURCESELECTDIALOG_H
17 #define QGSDATASOURCESELECTDIALOG_H
18 
19 #include "ui_qgsdatasourceselectdialog.h"
20 
21 #include "qgis_gui.h"
22 #include "qgis.h"
23 #include "qgsmimedatautils.h"
24 #include "qgsbrowserguimodel.h"
25 #include "qgsbrowserproxymodel.h"
26 
27 #include <QObject>
28 #include <QLabel>
29 #include <QDialog>
30 
46 class GUI_EXPORT QgsDataSourceSelectWidget: public QgsPanelWidget, private Ui::QgsDataSourceSelectDialog
47 {
48  Q_OBJECT
49  public:
50 
59  QgsDataSourceSelectWidget( QgsBrowserGuiModel *browserModel = nullptr,
60  bool setFilterByLayerType = false,
62  QWidget *parent = nullptr );
63 
64 
66 
70  void setLayerTypeFilter( QgsMapLayerType layerType );
71 
78  void setDescription( const QString &description );
79 
83  QgsMimeDataUtils::Uri uri() const;
84 
86  void showFilterWidget( bool visible );
88  void setFilterSyntax( QAction * );
90  void setCaseSensitive( bool caseSensitive );
92  void setFilter();
94  void showEvent( QShowEvent *e ) override;
95 
96  signals:
97 
103  void validationChanged( bool isValid );
104 
109 
114 
115  private slots:
116 
118  void onLayerSelected( const QModelIndex &index );
119 
120  void itemDoubleClicked( const QModelIndex &index );
121 
122  private:
123 
125  void refreshModel( const QModelIndex &index );
126 
127  void setValid( bool valid );
128 
129  QgsBrowserProxyModel mBrowserProxyModel;
130  QgsBrowserGuiModel *mBrowserModel = nullptr;
132  QLabel *mDescriptionLabel = nullptr;
133  bool mIsValid = true;
134 };
135 
136 
152 class GUI_EXPORT QgsDataSourceSelectDialog: public QDialog
153 {
154  Q_OBJECT
155 
156  public:
157 
166  QgsDataSourceSelectDialog( QgsBrowserGuiModel *browserModel = nullptr,
167  bool setFilterByLayerType = false,
169  QWidget *parent = nullptr );
170 
174  void setLayerTypeFilter( QgsMapLayerType layerType );
175 
182  void setDescription( const QString &description );
183 
187  QgsMimeDataUtils::Uri uri() const;
188 
190  void showFilterWidget( bool visible );
192  void setFilterSyntax( QAction * );
194  void setCaseSensitive( bool caseSensitive );
196  void setFilter();
197 
198  private:
199 
200  QgsDataSourceSelectWidget *mWidget = nullptr;
201 
202 };
203 
204 #endif // QGSDATASOURCESELECTDIALOG_H
A model for showing available data sources and other items in a structured tree.
A QSortFilterProxyModel subclass for filtering and sorting browser model items.
The QgsDataSourceSelectDialog class embeds the browser view to select an existing data source.
The QgsDataSourceSelectWidget class embeds the browser view to select an existing data source.
void selectionChanged()
Emitted when the current selection changes in the widget.
void itemTriggered(const QgsMimeDataUtils::Uri &uri)
Emitted when an item is triggered, e.g.
void validationChanged(bool isValid)
This signal is emitted whenever the validation status of the widget changes.
~QgsDataSourceSelectWidget() override
Base class for any widget that can be shown as a inline panel.
QgsMapLayerType
Types of layers that can be added to a map.
Definition: qgis.h:46