QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
qgsmaplayercombobox.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmaplayercombobox.h
3 --------------------------------------
4 Date : 01.04.2014
5 Copyright : (C) 2014 Denis Rouzaud
7***************************************************************************
8* *
9* This program is free software; you can redistribute it and/or modify *
10* it under the terms of the GNU General Public License as published by *
11* the Free Software Foundation; either version 2 of the License, or *
12* (at your option) any later version. *
13* *
14***************************************************************************/
15
16#ifndef QGSMAPLAYERCOMBOBOX_H
17#define QGSMAPLAYERCOMBOBOX_H
18
19#include <QComboBox>
20
22#include "qgis_gui.h"
23
24#include "qgis_sip.h"
25
26class QgsMapLayer;
27class QgsVectorLayer;
28
33class GUI_EXPORT QgsMapLayerComboBox : public QComboBox
34{
35 Q_OBJECT
36 Q_PROPERTY( Qgis::LayerFilters filters READ filters WRITE setFilters )
37 Q_PROPERTY( bool allowEmptyLayer READ allowEmptyLayer WRITE setAllowEmptyLayer )
38 Q_PROPERTY( bool showCrs READ showCrs WRITE setShowCrs )
39 Q_PROPERTY( QStringList excludedProviders READ excludedProviders WRITE setExcludedProviders )
40
41 public:
42
47 explicit QgsMapLayerComboBox( QWidget *parent SIP_TRANSFERTHIS = nullptr );
48
56 void setFilters( Qgis::LayerFilters filters ) { mProxyModel->setFilters( filters ); }
57
64 Q_DECL_DEPRECATED void setFilters( int filters ) SIP_DEPRECATED { setFilters( static_cast<Qgis::LayerFilters>( filters ) ); }
65
71 Qgis::LayerFilters filters() const { return mProxyModel->filters(); }
72
78 void setExceptedLayerList( const QList<QgsMapLayer *> &layerList ) { mProxyModel->setExceptedLayerList( layerList );}
79
85 QList<QgsMapLayer *> exceptedLayerList() const {return mProxyModel->exceptedLayerList();}
86
91 void setExcludedProviders( const QStringList &providers );
92
97 QStringList excludedProviders() const;
98
106 void setProject( QgsProject *project );
107
108
116 void setAllowEmptyLayer( bool allowEmpty, const QString &text = QString(), const QIcon &icon = QIcon() );
117
122 bool allowEmptyLayer() const;
123
128 void setShowCrs( bool showCrs );
129
134 bool showCrs() const;
135
142 void setAdditionalItems( const QStringList &items );
143
148 QStringList additionalItems() const;
149
159 void setAdditionalLayers( const QList<QgsMapLayer *> &layers );
160
167 QList< QgsMapLayer * > additionalLayers() const;
168
173 QgsMapLayer *currentLayer() const;
174
180 QgsMapLayer *layer( int layerIndex ) const;
181
182 public slots:
183
187 void setLayer( QgsMapLayer *layer );
188
189 signals:
191 void layerChanged( QgsMapLayer *layer );
192
193 protected:
194
195 void dragEnterEvent( QDragEnterEvent *event ) override;
196 void dragLeaveEvent( QDragLeaveEvent *event ) override;
197 void dropEvent( QDropEvent *event ) override;
198 void paintEvent( QPaintEvent *e ) override;
199
200 protected slots:
201 void indexChanged( int i );
202 void rowsChanged();
203
204 private:
205 QgsMapLayerProxyModel *mProxyModel = nullptr;
206 bool mDragActive = false;
207 bool mHighlight = false;
208
213 QgsMapLayer *compatibleMapLayerFromMimeData( const QMimeData *data ) const;
214
215 friend class QgsProcessingMapLayerComboBox;
216};
217
218#endif // QGSMAPLAYERCOMBOBOX_H
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
QFlags< LayerFilter > LayerFilters
Definition qgis.h:206
The QgsMapLayerComboBox class is a combo box which displays the list of layers.
void setFilters(Qgis::LayerFilters filters)
Sets filters for the layers displayed in the combo box.
QList< QgsMapLayer * > exceptedLayerList() const
Returns a list of layers which should be excluded from the combo box.
void setExceptedLayerList(const QList< QgsMapLayer * > &layerList)
Sets a list of layers which should be excluded from the combo box.
Q_DECL_DEPRECATED void setFilters(int filters)
Filters according to layer type and/or geometry type.
Qgis::LayerFilters filters() const
Returns any currently used filters on the listed layers.
void layerChanged(QgsMapLayer *layer)
Emitted whenever the currently selected layer changes.
The QgsMapLayerProxyModel class provides an easy to use model to display the list of layers in widget...
Base class for all map layer types.
Definition qgsmaplayer.h:76
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:107
Represents a vector layer which manages a vector based data sets.
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53