QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
qgsfeaturepickerwidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsfeaturepickerwidget.h - QgsFeaturePickerWidget
3 ---------------------
4 begin : 03.04.2020
5 copyright : (C) 2020 by Denis Rouzaud
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 QGSFEATURECHOOSER_H
16#define QGSFEATURECHOOSER_H
17
18#include <QWidget>
19#include <QComboBox>
20#include <QLineEdit>
21#include <QCompleter>
22
23#include "qgsfeature.h"
24#include "qgis_gui.h"
25
26class QToolButton;
27
28class QgsVectorLayer;
30class QgsAnimatedIcon;
32
33
43class GUI_EXPORT QgsFeaturePickerWidget : public QWidget
44{
45 Q_OBJECT
46
47 Q_PROPERTY( QgsVectorLayer *layer READ layer WRITE setLayer NOTIFY layerChanged )
48 Q_PROPERTY( QString displayExpression READ displayExpression WRITE setDisplayExpression NOTIFY displayExpressionChanged )
49 Q_PROPERTY( QString filterExpression READ filterExpression WRITE setFilterExpression NOTIFY filterExpressionChanged )
50 Q_PROPERTY( bool allowNull READ allowNull WRITE setAllowNull NOTIFY allowNullChanged )
51 Q_PROPERTY( bool fetchGeometry READ fetchGeometry WRITE setFetchGeometry NOTIFY fetchGeometryChanged )
52 Q_PROPERTY( int fetchLimit READ fetchLimit WRITE setFetchLimit NOTIFY fetchLimitChanged )
53 Q_PROPERTY( bool showBrowserButtons READ showBrowserButtons WRITE setShowBrowserButtons NOTIFY showBrowserButtonsChanged )
54
55 public:
59 QgsFeaturePickerWidget( QWidget *parent = nullptr );
60
64 QgsVectorLayer *layer() const;
65
69 void setLayer( QgsVectorLayer *layer );
70
74 void setFeature( QgsFeatureId featureId );
75
79 QgsFeature feature() const;
80
85 QString displayExpression() const;
86
91 void setDisplayExpression( const QString &displayExpression );
92
97 QString filterExpression() const;
98
103 int nullIndex() const;
104
109 void setFilterExpression( const QString &filterExpression );
110
114 bool allowNull() const;
115
119 void setAllowNull( bool allowNull );
120
124 bool fetchGeometry() const;
125
129 void setFetchGeometry( bool fetchGeometry );
130
134 int fetchLimit() const;
135
140 void setFetchLimit( int fetchLimit );
141
145 bool showBrowserButtons() const;
146
151 void setShowBrowserButtons( bool showBrowserButtons );
152
153
157 QModelIndex currentModelIndex() const;
158
159 void focusOutEvent( QFocusEvent *event ) override;
160
161 void keyPressEvent( QKeyEvent *event ) override;
162
163 signals:
164
168 void modelUpdated();
169
173 void layerChanged();
174
179 void displayExpressionChanged();
180
185 void filterExpressionChanged();
186
188 void featureChanged( const QgsFeature &feature );
189
193 void allowNullChanged();
194
198 void fetchGeometryChanged();
199
203 void fetchLimitChanged();
204
206 void showBrowserButtonsChanged();
207
208 private slots:
209 void onCurrentTextChanged( const QString &text );
210 void onFilterUpdateCompleted();
211 void onLoadingChanged();
212 void onItemSelected( const QModelIndex &index );
213 void onCurrentIndexChanged( int i );
214 void onActivated( QModelIndex index );
215 void storeLineEditState();
216 void restoreLineEditState();
217 void onDataChanged( const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>() );
218 void browseFeatures( int direction );
219
220 private:
221 QComboBox *mComboBox;
222 QToolButton *mPreviousButton;
223 QToolButton *mNextButton;
224 QgsFeaturePickerModel *mModel = nullptr;
225 QCompleter *mCompleter = nullptr;
226 QgsFilterLineEdit *mLineEdit;
227 bool mPopupRequested = false;
228 bool mIsCurrentlyEdited = false;
229 bool mShowBrowserButtons = false;
230};
231
232
233#endif // QGSFEATURECHOOSER_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.
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.
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features