QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
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:
58 QgsDataSourceSelectWidget( QgsBrowserGuiModel *browserModel = nullptr, bool setFilterByLayerType = false, Qgis::LayerType layerType = Qgis::LayerType::Vector, QWidget *parent = nullptr );
59
60
62
66 void setLayerTypeFilter( Qgis::LayerType layerType );
67
74 void setDescription( const QString &description );
75
85 void expandPath( const QString &path, bool selectPath = false );
86
90 QgsMimeDataUtils::Uri uri() const;
91
93 void showFilterWidget( bool visible );
95 void setFilterSyntax( QAction * );
97 void setCaseSensitive( bool caseSensitive );
99 void setFilter();
101 void showEvent( QShowEvent *e ) override;
102
103 void dragEnterEvent( QDragEnterEvent *event ) override;
104 void dropEvent( QDropEvent *event ) override;
105
106 signals:
107
113 void validationChanged( bool isValid );
114
119
124
125 private slots:
126
128 void onLayerSelected( const QModelIndex &index );
129
130 void itemDoubleClicked( const QModelIndex &index );
131
132 private:
134 void refreshModel( const QModelIndex &index );
135
136 void setValid( bool valid );
137
139 QString acceptableFilePath( QDropEvent *event ) const;
140
141 QgsBrowserProxyModel mBrowserProxyModel;
142 QgsBrowserGuiModel *mBrowserModel = nullptr;
144 QLabel *mDescriptionLabel = nullptr;
145 bool mIsValid = true;
146};
147
148
164class GUI_EXPORT QgsDataSourceSelectDialog : public QDialog
165{
166 Q_OBJECT
167
168 public:
177 QgsDataSourceSelectDialog( QgsBrowserGuiModel *browserModel = nullptr, bool setFilterByLayerType = false, Qgis::LayerType layerType = Qgis::LayerType::Vector, QWidget *parent = nullptr );
178
182 void setLayerTypeFilter( Qgis::LayerType layerType );
183
190 void setDescription( const QString &description );
191
201 void expandPath( const QString &path, bool selectPath = false );
202
206 QgsMimeDataUtils::Uri uri() const;
207
209 void showFilterWidget( bool visible );
211 void setFilterSyntax( QAction * );
213 void setCaseSensitive( bool caseSensitive );
215 void setFilter();
216
217 private:
218 QgsDataSourceSelectWidget *mWidget = nullptr;
219};
220
221#endif // QGSDATASOURCESELECTDIALOG_H
LayerType
Types of layers that can be added to a map.
Definition qgis.h:169
@ 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.