QGIS API Documentation  2.99.0-Master (ae4d26a)
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 : [email protected]
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 #include "qgis.h"
25 
26 class QgsMapLayer;
27 class QgsVectorLayer;
28 
34 class GUI_EXPORT QgsMapLayerComboBox : public QComboBox
35 {
36  Q_OBJECT
37  Q_FLAGS( QgsMapLayerProxyModel::Filters )
38  Q_PROPERTY( QgsMapLayerProxyModel::Filters filters READ filters WRITE setFilters )
39  Q_PROPERTY( bool allowEmptyLayer READ allowEmptyLayer WRITE setAllowEmptyLayer )
40  Q_PROPERTY( bool showCrs READ showCrs WRITE setShowCrs )
41  Q_PROPERTY( QStringList excludedProviders READ excludedProviders WRITE setExcludedProviders )
42 
43  public:
44 
49  explicit QgsMapLayerComboBox( QWidget *parent SIP_TRANSFERTHIS = nullptr );
50 
52  void setFilters( QgsMapLayerProxyModel::Filters filters ) { mProxyModel->setFilters( filters ); }
53 
55  QgsMapLayerProxyModel::Filters filters() const { return mProxyModel->filters(); }
56 
58  void setExceptedLayerList( const QList<QgsMapLayer *> &layerList ) { mProxyModel->setExceptedLayerList( layerList );}
59 
61  QList<QgsMapLayer *> exceptedLayerList() const {return mProxyModel->exceptedLayerList();}
62 
68  void setExcludedProviders( const QStringList &providers );
69 
75  QStringList excludedProviders() const;
76 
82  void setAllowEmptyLayer( bool allowEmpty );
83 
89  bool allowEmptyLayer() const;
90 
96  void setShowCrs( bool showCrs );
97 
103  bool showCrs() const;
104 
112  void setAdditionalItems( const QStringList &items );
113 
119  QStringList additionalItems() const;
120 
125  QgsMapLayer *currentLayer() const;
126 
133  QgsMapLayer *layer( int layerIndex ) const;
134 
135  public slots:
137  void setLayer( QgsMapLayer *layer );
138 
139  signals:
141  void layerChanged( QgsMapLayer *layer );
142 
143  protected slots:
144  void indexChanged( int i );
145  void rowsChanged();
146 
147  private:
148  QgsMapLayerProxyModel *mProxyModel = nullptr;
149 };
150 
151 #endif // QGSMAPLAYERCOMBOBOX_H
Base class for all map layer types.
Definition: qgsmaplayer.h:56
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
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...
QList< QgsMapLayer * > exceptedLayerList() const
returns the list of excepted layers
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