QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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
34class GUI_EXPORT QgsMapLayerComboBox : public QComboBox
35{
36 Q_OBJECT
37 Q_PROPERTY( Qgis::LayerFilters filters READ filters WRITE setFilters )
38 Q_PROPERTY( bool allowEmptyLayer READ allowEmptyLayer WRITE setAllowEmptyLayer )
39 Q_PROPERTY( bool showCrs READ showCrs WRITE setShowCrs )
40 Q_PROPERTY( QStringList excludedProviders READ excludedProviders WRITE setExcludedProviders )
41
42 public:
43
48 explicit QgsMapLayerComboBox( QWidget *parent SIP_TRANSFERTHIS = nullptr );
49
51 void setFilters( Qgis::LayerFilters filters ) { mProxyModel->setFilters( filters ); }
52
59 Q_DECL_DEPRECATED void setFilters( int filters ) SIP_DEPRECATED { setFilters( static_cast<Qgis::LayerFilters>( filters ) ); }
60
62 Qgis::LayerFilters filters() const { return mProxyModel->filters(); }
63
65 void setExceptedLayerList( const QList<QgsMapLayer *> &layerList ) { mProxyModel->setExceptedLayerList( layerList );}
66
68 QList<QgsMapLayer *> exceptedLayerList() const {return mProxyModel->exceptedLayerList();}
69
75 void setExcludedProviders( const QStringList &providers );
76
82 QStringList excludedProviders() const;
83
91 void setProject( QgsProject *project );
92
93
102 void setAllowEmptyLayer( bool allowEmpty, const QString &text = QString(), const QIcon &icon = QIcon() );
103
109 bool allowEmptyLayer() const;
110
116 void setShowCrs( bool showCrs );
117
123 bool showCrs() const;
124
132 void setAdditionalItems( const QStringList &items );
133
139 QStringList additionalItems() const;
140
150 void setAdditionalLayers( const QList<QgsMapLayer *> &layers );
151
158 QList< QgsMapLayer * > additionalLayers() const;
159
164 QgsMapLayer *currentLayer() const;
165
172 QgsMapLayer *layer( int layerIndex ) const;
173
174 public slots:
176 void setLayer( QgsMapLayer *layer );
177
178 signals:
180 void layerChanged( QgsMapLayer *layer );
181
182 protected:
183
184 void dragEnterEvent( QDragEnterEvent *event ) override;
185 void dragLeaveEvent( QDragLeaveEvent *event ) override;
186 void dropEvent( QDropEvent *event ) override;
187 void paintEvent( QPaintEvent *e ) override;
188
189 protected slots:
190 void indexChanged( int i );
191 void rowsChanged();
192
193 private:
194 QgsMapLayerProxyModel *mProxyModel = nullptr;
195 bool mDragActive = false;
196 bool mHighlight = false;
197
202 QgsMapLayer *compatibleMapLayerFromMimeData( const QMimeData *data ) const;
203
204 friend class QgsProcessingMapLayerComboBox;
205};
206
207#endif // QGSMAPLAYERCOMBOBOX_H
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
The QgsMapLayerComboBox class is a combo box which displays the list of layers.
void setFilters(Qgis::LayerFilters filters)
Filters according to layer type and/or geometry type.
QList< QgsMapLayer * > exceptedLayerList() const
returns the list of excepted layers
void setExceptedLayerList(const QList< QgsMapLayer * > &layerList)
except a list of layers not to be listed
Q_DECL_DEPRECATED void setFilters(int filters)
Filters according to layer type and/or geometry type.
Qgis::LayerFilters filters() const
currently used filter on list 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:74
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