QGIS API Documentation  2.99.0-Master (90ae728)
qgsfieldcombobox.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfieldcombobox.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 QGSFIELDCOMBOBOX_H
17 #define QGSFIELDCOMBOBOX_H
18 
19 #include <QComboBox>
20 
21 #include "qgsfieldproxymodel.h"
22 #include "qgis_gui.h"
23 
24 class QgsMapLayer;
25 class QgsVectorLayer;
26 
34 class GUI_EXPORT QgsFieldComboBox : public QComboBox
35 {
36  Q_OBJECT
37  Q_FLAGS( QgsFieldProxyModel::Filters )
38  Q_PROPERTY( QgsFieldProxyModel::Filters filters READ filters WRITE setFilters )
39  Q_PROPERTY( bool allowEmptyFieldName READ allowEmptyFieldName WRITE setAllowEmptyFieldName )
40 
41  public:
42 
47  explicit QgsFieldComboBox( QWidget *parent = nullptr );
48 
50  void setFilters( QgsFieldProxyModel::Filters filters );
51 
53  QgsFieldProxyModel::Filters filters() const { return mFieldProxyModel->filters(); }
54 
60  void setAllowEmptyFieldName( bool allowEmpty );
61 
67  bool allowEmptyFieldName() const;
68 
70  QString currentField() const;
71 
76  QgsVectorLayer* layer() const;
77 
78  signals:
80  void fieldChanged( const QString& fieldName );
81 
82  public slots:
83 
89  void setLayer( QgsMapLayer* layer );
90 
92  void setField( const QString& fieldName );
93 
94  protected slots:
95  void indexChanged( int i );
96 
97  private:
98  QgsFieldProxyModel* mFieldProxyModel = nullptr;
99 };
100 
101 #endif // QGSFIELDCOMBOBOX_H
Base class for all map layer types.
Definition: qgsmaplayer.h:52
The QgsFieldComboBox is a combo box which displays the list of fields of a given layer.
The QgsFieldProxyModel class provides an easy to use model to display the list of fields of a layer...
const Filters & filters() const
Returns the filters controlling displayed fields.
Represents a vector layer which manages a vector based data sets.