QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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
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"
26
27#include <QObject>
28#include <QLabel>
29#include <QDialog>
30
46class 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( Qgis::LayerType layerType );
71
78 void setDescription( const QString &description );
79
87 void expandPath( const QString &path );
88
92 QgsMimeDataUtils::Uri uri() const;
93
95 void showFilterWidget( bool visible );
97 void setFilterSyntax( QAction * );
99 void setCaseSensitive( bool caseSensitive );
101 void setFilter();
103 void showEvent( QShowEvent *e ) override;
104
105 signals:
106
112 void validationChanged( bool isValid );
113
118
123
124 private slots:
125
127 void onLayerSelected( const QModelIndex &index );
128
129 void itemDoubleClicked( const QModelIndex &index );
130
131 private:
132
134 void refreshModel( const QModelIndex &index );
135
136 void setValid( bool valid );
137
138 QgsBrowserProxyModel mBrowserProxyModel;
139 QgsBrowserGuiModel *mBrowserModel = nullptr;
141 QLabel *mDescriptionLabel = nullptr;
142 bool mIsValid = true;
143};
144
145
161class GUI_EXPORT QgsDataSourceSelectDialog: public QDialog
162{
163 Q_OBJECT
164
165 public:
166
175 QgsDataSourceSelectDialog( QgsBrowserGuiModel *browserModel = nullptr,
176 bool setFilterByLayerType = false,
178 QWidget *parent = nullptr );
179
183 void setLayerTypeFilter( Qgis::LayerType layerType );
184
191 void setDescription( const QString &description );
192
200 void expandPath( const QString &path );
201
205 QgsMimeDataUtils::Uri uri() const;
206
208 void showFilterWidget( bool visible );
210 void setFilterSyntax( QAction * );
212 void setCaseSensitive( bool caseSensitive );
214 void setFilter();
215
216 private:
217
218 QgsDataSourceSelectWidget *mWidget = nullptr;
219
220};
221
222#endif // QGSDATASOURCESELECTDIALOG_H
LayerType
Types of layers that can be added to a map.
Definition: qgis.h:114
@ Vector
Vector layer.
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.