QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
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:
53 QgsFeatureListComboBox( QWidget *parent = nullptr );
54
58 QgsVectorLayer *sourceLayer() const;
59
63 void setSourceLayer( QgsVectorLayer *sourceLayer );
64
69 void setCurrentFeature( const QgsFeature &feature );
70
75 QString displayExpression() const;
76
81 void setDisplayExpression( const QString &displayExpression );
82
87 QString filterExpression() const;
88
95 int nullIndex() const;
96
101 void setFilterExpression( const QString &filterExpression );
102
108 Q_DECL_DEPRECATED QVariant identifierValue() const SIP_DEPRECATED;
109
115 QVariantList identifierValues() const;
116
117
123 Q_DECL_DEPRECATED void setIdentifierValue( const QVariant &identifierValue ) SIP_DEPRECATED;
124
130 void setIdentifierValues( const QVariantList &identifierValues );
131
136 void setIdentifierValuesToNull();
137
142 QgsFeatureRequest currentFeatureRequest() const;
143
147 bool allowNull() const;
148
152 void setAllowNull( bool allowNull );
153
158 int fetchLimit() const;
159
165 void setFetchLimit( int fetchLimit );
166
172 Q_DECL_DEPRECATED QString identifierField() const SIP_DEPRECATED;
173
179 QStringList identifierFields() const;
180
186 Q_DECL_DEPRECATED void setIdentifierField( const QString &identifierField ) SIP_DEPRECATED;
187
193 void setIdentifierFields( const QStringList &identifierFields );
194
198 QModelIndex currentModelIndex() const;
199
200 void focusOutEvent( QFocusEvent *event ) override;
201
202 void keyPressEvent( QKeyEvent *event ) override;
203
204 signals:
205
211 void modelUpdated();
212
216 void sourceLayerChanged();
217
222 void displayExpressionChanged();
223
228 void filterExpressionChanged();
229
234 void identifierValueChanged();
235
240 void identifierFieldChanged();
241
245 void allowNullChanged();
246
251 void currentFeatureChanged();
252
257 void currentFeatureFoundChanged( bool found );
258
259 private slots:
260 void onCurrentTextChanged( const QString &text );
261 void onFilterLineEditCleared();
262 void onFilterUpdateCompleted();
263 void onLoadingChanged();
264 void onItemSelected( const QModelIndex &index );
265 void onCurrentIndexChanged( int i );
266 void onActivated( QModelIndex index );
267 void storeLineEditState();
268 void restoreLineEditState();
269 void onDataChanged( const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>() );
270
271 private:
272 QgsFeatureFilterModel *mModel = nullptr;
273 QCompleter *mCompleter = nullptr;
274 QgsFilterLineEdit *mLineEdit;
275 bool mPopupRequested = false;
276 bool mIsCurrentlyEdited = false;
277
278 friend class TestQgsFeatureListComboBox;
279};
280
281
282#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.
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:58
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