QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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 "qgis_gui.h"
20#include "qgis_sip.h"
22
23#include <QComboBox>
24
25class QgsMapLayer;
26class QgsVectorLayer;
27
52class GUI_EXPORT QgsMapLayerComboBox : public QComboBox
53{
54 Q_OBJECT
57 Q_PROPERTY( bool showCrs READ showCrs WRITE setShowCrs )
58 Q_PROPERTY( QStringList excludedProviders READ excludedProviders WRITE setExcludedProviders )
59
60 public:
66 explicit QgsMapLayerComboBox( QWidget *parent SIP_TRANSFERTHIS = nullptr );
67
75 void setFilters( Qgis::LayerFilters filters ) { mProxyModel->setFilters( filters ); }
76
83 Q_DECL_DEPRECATED void setFilters( int filters ) SIP_DEPRECATED { setFilters( static_cast<Qgis::LayerFilters>( filters ) ); }
84
90 Qgis::LayerFilters filters() const { return mProxyModel->filters(); }
91
97 void setExceptedLayerList( const QList<QgsMapLayer *> &layerList ) { mProxyModel->setExceptedLayerList( layerList ); }
98
104 QList<QgsMapLayer *> exceptedLayerList() const { return mProxyModel->exceptedLayerList(); }
105
110 void setExcludedProviders( const QStringList &providers );
111
116 QStringList excludedProviders() const;
117
125 void setProject( QgsProject *project );
126
127
135 void setAllowEmptyLayer( bool allowEmpty, const QString &text = QString(), const QIcon &icon = QIcon() );
136
141 bool allowEmptyLayer() const;
142
147 void setShowCrs( bool showCrs );
148
153 bool showCrs() const;
154
161 void setAdditionalItems( const QStringList &items );
162
167 QStringList additionalItems() const;
168
178 void setAdditionalLayers( const QList<QgsMapLayer *> &layers );
179
186 QList<QgsMapLayer *> additionalLayers() const;
187
192 QgsMapLayer *currentLayer() const;
193
199 QgsMapLayer *layer( int layerIndex ) const;
200
201 public slots:
202
206 void setLayer( QgsMapLayer *layer );
207
208 signals:
211
212 protected:
213 void dragEnterEvent( QDragEnterEvent *event ) override;
214 void dragLeaveEvent( QDragLeaveEvent *event ) override;
215 void dropEvent( QDropEvent *event ) override;
216 void paintEvent( QPaintEvent *e ) override;
217
218 protected slots:
219 void indexChanged( int i );
220 void rowsChanged();
221
222 private:
223 QgsMapLayerProxyModel *mProxyModel = nullptr;
224 bool mDragActive = false;
225 bool mHighlight = false;
226
231 QgsMapLayer *compatibleMapLayerFromMimeData( const QMimeData *data ) const;
232
234};
235
236#endif // QGSMAPLAYERCOMBOBOX_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:56
QFlags< LayerFilter > LayerFilters
Definition qgis.h:227
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 dragLeaveEvent(QDragLeaveEvent *event) override
QgsMapLayerComboBox(QWidget *parent=nullptr)
QgsMapLayerComboBox creates a combo box to display the list of layers currently in the project.
void paintEvent(QPaintEvent *e) override
void setExceptedLayerList(const QList< QgsMapLayer * > &layerList)
Sets a list of layers which should be excluded from the combo box.
void setExcludedProviders(const QStringList &providers)
Sets a list of data providers which should be excluded from the combobox.
Qgis::LayerFilters filters
Q_DECL_DEPRECATED void setFilters(int filters)
Filters according to layer type and/or geometry type.
void dropEvent(QDropEvent *event) override
QgsMapLayer * layer(int layerIndex) const
Returns the layer currently shown at the specified index within the combo box.
Qgis::LayerFilters filters() const
Returns any currently used filters on the listed layers.
void setShowCrs(bool showCrs)
Sets whether the CRS of layers is also included in the combo box text.
void setAllowEmptyLayer(bool allowEmpty, const QString &text=QString(), const QIcon &icon=QIcon())
Sets whether an optional empty layer ("not set") option is shown in the combo box.
friend class QgsProcessingMapLayerComboBox
void layerChanged(QgsMapLayer *layer)
Emitted whenever the currently selected layer changes.
void dragEnterEvent(QDragEnterEvent *event) override
A proxy model which provides an easy to use model to display the list of layers in widgets.
Base class for all map layer types.
Definition qgsmaplayer.h:80
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:109
Represents a vector layer which manages a vector based dataset.
#define SIP_DEPRECATED
Definition qgis_sip.h:114
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53