QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgsfeaturelistcombobox.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsfeaturelistcombobox.h - QgsFeatureListComboBox
3 ---------------------
4 begin : 10.3.2017
5 copyright : (C) 2017 by Matthias Kuhn
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#ifndef QGSFIELDLISTCOMBOBOX_H
16#define QGSFIELDLISTCOMBOBOX_H
17
18#include <QComboBox>
19
20#include "qgsfeature.h"
21#include "qgis_gui.h"
22
23class QgsVectorLayer;
25class QgsAnimatedIcon;
28
37class GUI_EXPORT QgsFeatureListComboBox : public QComboBox
38{
39 Q_OBJECT
40
41 Q_PROPERTY( QgsVectorLayer *sourceLayer READ sourceLayer WRITE setSourceLayer NOTIFY sourceLayerChanged )
42 Q_PROPERTY( QString displayExpression READ displayExpression WRITE setDisplayExpression NOTIFY displayExpressionChanged )
43 Q_PROPERTY( QString filterExpression READ filterExpression WRITE setFilterExpression NOTIFY filterExpressionChanged )
44 Q_PROPERTY( QVariant identifierValue READ identifierValue WRITE setIdentifierValue NOTIFY identifierValueChanged )
45 Q_PROPERTY( QVariantList identifierValues READ identifierValues WRITE setIdentifierValues NOTIFY identifierValueChanged )
46 Q_PROPERTY( QString identifierField READ identifierField WRITE setIdentifierField NOTIFY identifierFieldChanged )
47 Q_PROPERTY( bool allowNull READ allowNull WRITE setAllowNull NOTIFY allowNullChanged )
48
49 public:
50
54 QgsFeatureListComboBox( QWidget *parent = nullptr );
55
59 QgsVectorLayer *sourceLayer() const;
60
64 void setSourceLayer( QgsVectorLayer *sourceLayer );
65
70 void setCurrentFeature( const QgsFeature &feature );
71
76 QString displayExpression() const;
77
82 void setDisplayExpression( const QString &displayExpression );
83
88 QString filterExpression() const;
89
96 int nullIndex() const;
97
102 void setFilterExpression( const QString &filterExpression );
103
109 Q_DECL_DEPRECATED QVariant identifierValue() const SIP_DEPRECATED;
110
116 QVariantList identifierValues() const;
117
118
124 Q_DECL_DEPRECATED void setIdentifierValue( const QVariant &identifierValue ) SIP_DEPRECATED;
125
131 void setIdentifierValues( const QVariantList &identifierValues );
132
137 void setIdentifierValuesToNull();
138
143 QgsFeatureRequest currentFeatureRequest() const;
144
148 bool allowNull() const;
149
153 void setAllowNull( bool allowNull );
154
159 int fetchLimit() const;
160
166 void setFetchLimit( int fetchLimit );
167
173 Q_DECL_DEPRECATED QString identifierField() const SIP_DEPRECATED;
174
180 QStringList identifierFields() const;
181
187 Q_DECL_DEPRECATED void setIdentifierField( const QString &identifierField ) SIP_DEPRECATED;
188
194 void setIdentifierFields( const QStringList &identifierFields );
195
199 QModelIndex currentModelIndex() const;
200
201 void focusOutEvent( QFocusEvent *event ) override;
202
203 void keyPressEvent( QKeyEvent *event ) override;
204
205 signals:
206
213
218
224
230
236
242
247
253
254 private slots:
255 void onCurrentTextChanged( const QString &text );
256 void onFilterLineEditCleared();
257 void onFilterUpdateCompleted();
258 void onLoadingChanged();
259 void onItemSelected( const QModelIndex &index );
260 void onCurrentIndexChanged( int i );
261 void onActivated( QModelIndex index );
262 void storeLineEditState();
263 void restoreLineEditState();
264 void onDataChanged( const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>() );
265
266 private:
267 QgsFeatureFilterModel *mModel = nullptr;
268 QCompleter *mCompleter = nullptr;
269 QgsFilterLineEdit *mLineEdit;
270 bool mPopupRequested = false;
271 bool mIsCurrentlyEdited = false;
272
273 friend class TestQgsFeatureListComboBox;
274};
275
276
277
278#endif // QGSFIELDLISTCOMBOBOX_H
Animated icon is keeping an animation running if there are listeners connected to frameChanged.
Provides a list of features based on filter conditions.
This offers a combobox with autocompleter that allows selecting features from a layer.
void allowNullChanged()
Determines if a NULL value should be available in the list.
void modelUpdated()
The underlying model has been updated.
void identifierValueChanged()
The identifier value of the currently selected feature.
void sourceLayerChanged()
The layer from which features should be listed.
void currentFeatureChanged()
Emitted when the current feature changes.
void displayExpressionChanged()
The display expression will be used to display features as well as the the value to match the typed t...
void identifierFieldChanged()
Field name that will be used to uniquely identify the current feature.
void filterExpressionChanged()
An additional expression to further restrict the available features.
This class wraps a request for features to a vector layer (or directly its vector data provider).
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
Represents a vector layer which manages a vector based data sets.
#define SIP_DEPRECATED
Definition: qgis_sip.h:106