QGIS API Documentation 3.37.0-Master (684a802617f)
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
50 void setFilters( Qgis::LayerFilters filters ) { mProxyModel->setFilters( filters ); }
51
58 Q_DECL_DEPRECATED void setFilters( int filters ) SIP_DEPRECATED { setFilters( static_cast<Qgis::LayerFilters>( filters ) ); }
59
61 Qgis::LayerFilters filters() const { return mProxyModel->filters(); }
62
64 void setExceptedLayerList( const QList<QgsMapLayer *> &layerList ) { mProxyModel->setExceptedLayerList( layerList );}
65
67 QList<QgsMapLayer *> exceptedLayerList() const {return mProxyModel->exceptedLayerList();}
68
73 void setExcludedProviders( const QStringList &providers );
74
79 QStringList excludedProviders() const;
80
88 void setProject( QgsProject *project );
89
90
98 void setAllowEmptyLayer( bool allowEmpty, const QString &text = QString(), const QIcon &icon = QIcon() );
99
104 bool allowEmptyLayer() const;
105
110 void setShowCrs( bool showCrs );
111
116 bool showCrs() const;
117
124 void setAdditionalItems( const QStringList &items );
125
130 QStringList additionalItems() const;
131
141 void setAdditionalLayers( const QList<QgsMapLayer *> &layers );
142
149 QList< QgsMapLayer * > additionalLayers() const;
150
155 QgsMapLayer *currentLayer() const;
156
162 QgsMapLayer *layer( int layerIndex ) const;
163
164 public slots:
166 void setLayer( QgsMapLayer *layer );
167
168 signals:
170 void layerChanged( QgsMapLayer *layer );
171
172 protected:
173
174 void dragEnterEvent( QDragEnterEvent *event ) override;
175 void dragLeaveEvent( QDragLeaveEvent *event ) override;
176 void dropEvent( QDropEvent *event ) override;
177 void paintEvent( QPaintEvent *e ) override;
178
179 protected slots:
180 void indexChanged( int i );
181 void rowsChanged();
182
183 private:
184 QgsMapLayerProxyModel *mProxyModel = nullptr;
185 bool mDragActive = false;
186 bool mHighlight = false;
187
192 QgsMapLayer *compatibleMapLayerFromMimeData( const QMimeData *data ) const;
193
194 friend class QgsProcessingMapLayerComboBox;
195};
196
197#endif // QGSMAPLAYERCOMBOBOX_H
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
QFlags< LayerFilter > LayerFilters
Definition qgis.h:151
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:75
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