QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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.h"
22#include "qgis_gui.h"
23#include "qgsbrowserguimodel.h"
25#include "qgsmimedatautils.h"
26
27#include <QDialog>
28#include <QLabel>
29#include <QObject>
30
45class GUI_EXPORT QgsDataSourceSelectWidget : public QgsPanelWidget, private Ui::QgsDataSourceSelectDialog
46{
47 Q_OBJECT
48 public:
57 QgsDataSourceSelectWidget( QgsBrowserGuiModel *browserModel = nullptr, bool setFilterByLayerType = false, Qgis::LayerType layerType = Qgis::LayerType::Vector, QWidget *parent = nullptr );
58
59
61
65 void setLayerTypeFilter( Qgis::LayerType layerType );
66
73 void setDescription( const QString &description );
74
84 void expandPath( const QString &path, bool selectPath = false );
85
90
92 void showFilterWidget( bool visible );
94 void setFilterSyntax( QAction * );
96 void setCaseSensitive( bool caseSensitive );
98 void setFilter();
100 void showEvent( QShowEvent *e ) override;
101
102 void dragEnterEvent( QDragEnterEvent *event ) override;
103 void dropEvent( QDropEvent *event ) 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:
133 void refreshModel( const QModelIndex &index );
134
135 void setValid( bool valid );
136
138 QString acceptableFilePath( QDropEvent *event ) const;
139
140 QgsBrowserProxyModel mBrowserProxyModel;
141 QgsBrowserGuiModel *mBrowserModel = nullptr;
143 QLabel *mDescriptionLabel = nullptr;
144 bool mIsValid = true;
145};
146
147
162class GUI_EXPORT QgsDataSourceSelectDialog : public QDialog
163{
164 Q_OBJECT
165
166 public:
175 QgsDataSourceSelectDialog( QgsBrowserGuiModel *browserModel = nullptr, bool setFilterByLayerType = false, Qgis::LayerType layerType = Qgis::LayerType::Vector, QWidget *parent = nullptr );
176
180 void setLayerTypeFilter( Qgis::LayerType layerType );
181
188 void setDescription( const QString &description );
189
199 void expandPath( const QString &path, bool selectPath = false );
200
205
207 void showFilterWidget( bool visible );
209 void setFilterSyntax( QAction * );
211 void setCaseSensitive( bool caseSensitive );
213 void setFilter();
214
215 private:
216 QgsDataSourceSelectWidget *mWidget = nullptr;
217};
218
219#endif // QGSDATASOURCESELECTDIALOG_H
LayerType
Types of layers that can be added to a map.
Definition qgis.h:190
@ Vector
Vector layer.
Definition qgis.h:191
A model for showing available data sources and other items in a structured tree.
A QSortFilterProxyModel subclass for filtering and sorting browser model items.
void setFilter()
Apply filter to the model.
void showFilterWidget(bool visible)
Show/hide filter widget.
void setCaseSensitive(bool caseSensitive)
Sets filter case sensitivity.
void setFilterSyntax(QAction *)
Sets filter syntax.
QgsMimeDataUtils::Uri uri() const
Returns the (possibly invalid) uri of the selected data source.
void expandPath(const QString &path, bool selectPath=false)
Expands out a file path in the view.
void setDescription(const QString &description)
Sets a description label.
QgsDataSourceSelectDialog(QgsBrowserGuiModel *browserModel=nullptr, bool setFilterByLayerType=false, Qgis::LayerType layerType=Qgis::LayerType::Vector, QWidget *parent=nullptr)
Constructs a QgsDataSourceSelectDialog, optionally filtering by layer type.
void setLayerTypeFilter(Qgis::LayerType layerType)
Sets layer type filter to layerType and activates the filtering.
Embeds the browser view to select an existing data source.
void expandPath(const QString &path, bool selectPath=false)
Expands out a file path in the view.
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 setFilter()
Apply filter to the model.
QgsDataSourceSelectWidget(QgsBrowserGuiModel *browserModel=nullptr, bool setFilterByLayerType=false, Qgis::LayerType layerType=Qgis::LayerType::Vector, QWidget *parent=nullptr)
Constructs a QgsDataSourceSelectWidget, optionally filtering by layer type.
void dropEvent(QDropEvent *event) override
void showFilterWidget(bool visible)
Show/hide filter widget.
void setDescription(const QString &description)
Sets a description label.
void validationChanged(bool isValid)
This signal is emitted whenever the validation status of the widget changes.
void showEvent(QShowEvent *e) override
Scroll to last selected index and expand it's children.
~QgsDataSourceSelectWidget() override
void setCaseSensitive(bool caseSensitive)
Sets filter case sensitivity.
void dragEnterEvent(QDragEnterEvent *event) override
void setFilterSyntax(QAction *)
Sets filter syntax.
QgsMimeDataUtils::Uri uri() const
Returns the (possibly invalid) uri of the selected data source.
void setLayerTypeFilter(Qgis::LayerType layerType)
Sets layer type filter to layerType and activates the filtering.
QgsPanelWidget(QWidget *parent=nullptr)
Base class for any widget that can be shown as an inline panel.