QGIS API Documentation 3.43.0-Master (c67cf405802)
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
6 email : matthias@opengis.ch
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
89 int nullIndex() const;
90
95 QString filterExpression() const;
96
101 void setFilterExpression( const QString &filterExpression );
102
107 QgsFeature formFeature() const;
108
113 void setFormFeature( const QgsFeature &feature );
114
119 QgsFeature parentFormFeature() const;
120
125 void setParentFormFeature( const QgsFeature &feature );
126
132 Q_DECL_DEPRECATED QVariant identifierValue() const SIP_DEPRECATED;
133
139 QVariantList identifierValues() const;
140
141
147 Q_DECL_DEPRECATED void setIdentifierValue( const QVariant &identifierValue ) SIP_DEPRECATED;
148
154 void setIdentifierValues( const QVariantList &identifierValues );
155
160 void setIdentifierValuesToNull();
161
166 QgsFeatureRequest currentFeatureRequest() const;
167
171 bool allowNull() const;
172
176 void setAllowNull( bool allowNull );
177
182 int fetchLimit() const;
183
189 void setFetchLimit( int fetchLimit );
190
196 Q_DECL_DEPRECATED QString identifierField() const SIP_DEPRECATED;
197
203 QStringList identifierFields() const;
204
210 Q_DECL_DEPRECATED void setIdentifierField( const QString &identifierField ) SIP_DEPRECATED;
211
217 void setIdentifierFields( const QStringList &identifierFields );
218
222 QModelIndex currentModelIndex() const;
223
224 void focusOutEvent( QFocusEvent *event ) override;
225
226 void keyPressEvent( QKeyEvent *event ) override;
227
228 signals:
229
235 void modelUpdated();
236
240 void sourceLayerChanged();
241
246 void displayExpressionChanged();
247
252 void filterExpressionChanged();
253
258 void formFeatureChanged();
259
264 void parentFormFeatureChanged();
265
270 void identifierValueChanged();
271
276 void identifierFieldChanged();
277
281 void allowNullChanged();
282
287 void currentFeatureChanged();
288
293 void currentFeatureFoundChanged( bool found );
294
295 private slots:
296 void onCurrentTextChanged( const QString &text );
297 void onFilterLineEditCleared();
298 void onFilterUpdateCompleted();
299 void onLoadingChanged();
300 void onItemSelected( const QModelIndex &index );
301 void onCurrentIndexChanged( int i );
302 void onActivated( QModelIndex index );
303 void storeLineEditState();
304 void restoreLineEditState();
305 void onDataChanged( const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>() );
306
307 private:
308 QgsFeatureFilterModel *mModel = nullptr;
309 QCompleter *mCompleter = nullptr;
310 QgsFilterLineEdit *mLineEdit;
311 bool mPopupRequested = false;
312 bool mIsCurrentlyEdited = false;
313
314 friend class TestQgsFeatureListComboBox;
315};
316
317
318#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.
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 dataset.
#define SIP_DEPRECATED
Definition qgis_sip.h:106