QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
23 class QgsMapLayer;
24 class QgsVectorLayer;
25 
30 class GUI_EXPORT QgsMapLayerComboBox : public QComboBox
31 {
32  Q_OBJECT
33  Q_FLAGS( QgsMapLayerProxyModel::Filters )
34  Q_PROPERTY( QgsMapLayerProxyModel::Filters filters READ filters WRITE setFilters )
35 
36  public:
41  explicit QgsMapLayerComboBox( QWidget *parent = nullptr );
42 
44  void setFilters( const QgsMapLayerProxyModel::Filters& filters ) { mProxyModel->setFilters( filters ); }
45 
47  QgsMapLayerProxyModel::Filters filters() const { return mProxyModel->filters(); }
48 
50  void setExceptedLayerList( const QList<QgsMapLayer*>& layerList ) { mProxyModel->setExceptedLayerList( layerList );}
51 
53  QList<QgsMapLayer*> exceptedLayerList() const {return mProxyModel->exceptedLayerList();}
54 
58  QgsMapLayer* currentLayer() const;
59 
65  QgsMapLayer* layer( int layerIndex ) const;
66 
67  public slots:
69  void setLayer( QgsMapLayer* layer );
70 
71  signals:
73  void layerChanged( QgsMapLayer* layer );
74 
75  protected slots:
76  void indexChanged( int i );
77  void rowsChanged();
78 
79  private:
80  QgsMapLayerProxyModel* mProxyModel;
81 };
82 
83 #endif // QGSMAPLAYERCOMBOBOX_H
Base class for all map layer types.
Definition: qgsmaplayer.h:49
QList< QgsMapLayer * > exceptedLayerList() const
returns the list of excepted layers
QgsMapLayerProxyModel::Filters filters() const
currently used filter on list layers
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 setFilters(const QgsMapLayerProxyModel::Filters &filters)
setFilters allows fitering according to layer type and/or geometry type.
void setExceptedLayerList(const QList< QgsMapLayer *> &layerList)
except a list of layers not to be listed