QGIS API Documentation  3.13.0-Master (740be229cb)
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 #include "qgis_sip.h"
25 
26 class QgsMapLayer;
27 class QgsVectorLayer;
28 class QgsFields;
29 
38 class GUI_EXPORT QgsFieldComboBox : public QComboBox
39 {
40  Q_OBJECT
41  Q_PROPERTY( QgsFieldProxyModel::Filters filters READ filters WRITE setFilters )
42  Q_PROPERTY( bool allowEmptyFieldName READ allowEmptyFieldName WRITE setAllowEmptyFieldName )
43 
44  public:
45 
50  explicit QgsFieldComboBox( QWidget *parent SIP_TRANSFERTHIS = nullptr );
51 
53  void setFilters( QgsFieldProxyModel::Filters filters );
54 
56  QgsFieldProxyModel::Filters filters() const { return mFieldProxyModel->filters(); }
57 
63  void setAllowEmptyFieldName( bool allowEmpty );
64 
70  bool allowEmptyFieldName() const;
71 
73  QString currentField() const;
74 
79  QgsVectorLayer *layer() const;
80 
91  void setFields( const QgsFields &fields );
92 
101  QgsFields fields() const;
102 
103  signals:
105  void fieldChanged( const QString &fieldName );
106 
107  public slots:
108 
114  void setLayer( QgsMapLayer *layer );
115 
117  void setField( const QString &fieldName );
118 
119  protected slots:
120  void indexChanged( int i );
121 
122  private:
123  QgsFieldProxyModel *mFieldProxyModel = nullptr;
124 };
125 
126 #endif // QGSFIELDCOMBOBOX_H
Base class for all map layer types.
Definition: qgsmaplayer.h:80
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
Container of fields for a vector layer.
Definition: qgsfields.h:42
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.