QGIS API Documentation 3.41.0-Master (af5edcb665c)
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:
46 explicit QgsMapLayerComboBox( QWidget *parent SIP_TRANSFERTHIS = nullptr );
47
55 void setFilters( Qgis::LayerFilters filters ) { mProxyModel->setFilters( filters ); }
56
63 Q_DECL_DEPRECATED void setFilters( int filters ) SIP_DEPRECATED { setFilters( static_cast<Qgis::LayerFilters>( filters ) ); }
64
70 Qgis::LayerFilters filters() const { return mProxyModel->filters(); }
71
77 void setExceptedLayerList( const QList<QgsMapLayer *> &layerList ) { mProxyModel->setExceptedLayerList( layerList ); }
78
84 QList<QgsMapLayer *> exceptedLayerList() const { return mProxyModel->exceptedLayerList(); }
85
90 void setExcludedProviders( const QStringList &providers );
91
96 QStringList excludedProviders() const;
97
105 void setProject( QgsProject *project );
106
107
115 void setAllowEmptyLayer( bool allowEmpty, const QString &text = QString(), const QIcon &icon = QIcon() );
116
121 bool allowEmptyLayer() const;
122
127 void setShowCrs( bool showCrs );
128
133 bool showCrs() const;
134
141 void setAdditionalItems( const QStringList &items );
142
147 QStringList additionalItems() const;
148
158 void setAdditionalLayers( const QList<QgsMapLayer *> &layers );
159
166 QList<QgsMapLayer *> additionalLayers() const;
167
172 QgsMapLayer *currentLayer() const;
173
179 QgsMapLayer *layer( int layerIndex ) const;
180
181 public slots:
182
186 void setLayer( QgsMapLayer *layer );
187
188 signals:
190 void layerChanged( QgsMapLayer *layer );
191
192 protected:
193 void dragEnterEvent( QDragEnterEvent *event ) override;
194 void dragLeaveEvent( QDragLeaveEvent *event ) override;
195 void dropEvent( QDropEvent *event ) override;
196 void paintEvent( QPaintEvent *e ) override;
197
198 protected slots:
199 void indexChanged( int i );
200 void rowsChanged();
201
202 private:
203 QgsMapLayerProxyModel *mProxyModel = nullptr;
204 bool mDragActive = false;
205 bool mHighlight = false;
206
211 QgsMapLayer *compatibleMapLayerFromMimeData( const QMimeData *data ) const;
212
213 friend class QgsProcessingMapLayerComboBox;
214};
215
216#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