QGIS API Documentation  2.99.0-Master (9ed189e)
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
6  Email : denis.rouzaud@gmail.com
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 
21 #include "qgsmaplayerproxymodel.h"
22 #include "qgis_gui.h"
23 
24 class QgsMapLayer;
25 class QgsVectorLayer;
26 
31 class GUI_EXPORT QgsMapLayerComboBox : public QComboBox
32 {
33  Q_OBJECT
34  Q_FLAGS( QgsMapLayerProxyModel::Filters )
35  Q_PROPERTY( QgsMapLayerProxyModel::Filters filters READ filters WRITE setFilters )
36  Q_PROPERTY( bool allowEmptyLayer READ allowEmptyLayer WRITE setAllowEmptyLayer )
37  Q_PROPERTY( bool showCrs READ showCrs WRITE setShowCrs )
38  Q_PROPERTY( QStringList excludedProviders READ excludedProviders WRITE setExcludedProviders )
39 
40  public:
41 
46  explicit QgsMapLayerComboBox( QWidget *parent = nullptr );
47 
49  void setFilters( QgsMapLayerProxyModel::Filters filters ) { mProxyModel->setFilters( filters ); }
50 
52  QgsMapLayerProxyModel::Filters filters() const { return mProxyModel->filters(); }
53 
55  void setExceptedLayerList( const QList<QgsMapLayer*>& layerList ) { mProxyModel->setExceptedLayerList( layerList );}
56 
58  QList<QgsMapLayer*> exceptedLayerList() const {return mProxyModel->exceptedLayerList();}
59 
65  void setExcludedProviders( const QStringList& providers );
66 
72  QStringList excludedProviders() const;
73 
79  void setAllowEmptyLayer( bool allowEmpty );
80 
86  bool allowEmptyLayer() const;
87 
93  void setShowCrs( bool showCrs );
94 
100  bool showCrs() const;
101 
109  void setAdditionalItems( const QStringList& items );
110 
116  QStringList additionalItems() const;
117 
121  QgsMapLayer* currentLayer() const;
122 
128  QgsMapLayer* layer( int layerIndex ) const;
129 
130  public slots:
132  void setLayer( QgsMapLayer* layer );
133 
134  signals:
136  void layerChanged( QgsMapLayer* layer );
137 
138  protected slots:
139  void indexChanged( int i );
140  void rowsChanged();
141 
142  private:
143  QgsMapLayerProxyModel* mProxyModel = nullptr;
144 };
145 
146 #endif // QGSMAPLAYERCOMBOBOX_H
Base class for all map layer types.
Definition: qgsmaplayer.h:52
QList< QgsMapLayer * > exceptedLayerList() const
returns the list of excepted layers
QgsMapLayerProxyModel::Filters filters() const
currently used filter on list layers
void setFilters(QgsMapLayerProxyModel::Filters filters)
setFilters allows fitering according to layer type and/or geometry type.
The QgsMapLayerComboBox class is a combo box which displays the list of layers.
The QgsMapLayerProxyModel class provides an easy to use model to display the list of layers in widget...
Represents a vector layer which manages a vector based data sets.
void setExceptedLayerList(const QList< QgsMapLayer *> &layerList)
except a list of layers not to be listed