QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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 "qgis_gui.h"
19#include "qgsfeature.h"
20
21#include <QComboBox>
22#include <QCompleter>
23#include <QLineEdit>
24#include <QWidget>
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 )
50 Q_PROPERTY( bool allowNull READ allowNull WRITE setAllowNull NOTIFY allowNullChanged )
52 Q_PROPERTY( int fetchLimit READ fetchLimit WRITE setFetchLimit NOTIFY fetchLimitChanged )
54
55 public:
59 QgsFeaturePickerWidget( QWidget *parent = nullptr );
60
64 QgsVectorLayer *layer() const;
65
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
152
153
157 QModelIndex currentModelIndex() const;
158
159 void focusOutEvent( QFocusEvent *event ) override;
160
161 void keyPressEvent( QKeyEvent *event ) override;
162
163 signals:
164
169
174
180
186
189
194
199
204
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.
void keyPressEvent(QKeyEvent *event) override
void setAllowNull(bool allowNull)
Determines if a NULL value should be available in the list.
QgsFeaturePickerWidget(QWidget *parent=nullptr)
Create a new QgsFeaturePickerWidget, optionally specifying a parent.
void setFilterExpression(const QString &filterExpression)
An additional expression to further restrict the available features.
void allowNullChanged()
Determines if a NULL value should be available in the list.
QgsFeature feature() const
Returns the current feature.
void filterExpressionChanged()
An additional expression to further restrict the available features.
void displayExpressionChanged()
The display expression will be used to display features as well as the the value to match the typed t...
void layerChanged()
The layer from which features should be listed.
void modelUpdated()
The underlying model has been updated.
void setFetchLimit(int fetchLimit)
Defines the feature request fetch limit If set to 0, no limit is applied when fetching.
void setLayer(QgsVectorLayer *layer)
The layer from which features should be listed.
void showBrowserButtonsChanged()
Emitted when showing the browser buttons changes.
void setShowBrowserButtons(bool showBrowserButtons)
Defines if the browsing buttons are shown.
void fetchGeometryChanged()
Emitted when the fetching of the geometry changes.
void setFeature(QgsFeatureId featureId)
Sets the current index by using the given feature.
void featureChanged(const QgsFeature &feature)
Sends the feature as soon as it is chosen.
QModelIndex currentModelIndex() const
The index of the currently selected item.
void setDisplayExpression(const QString &displayExpression)
The display expression will be used to display features as well as the value to match the typed text ...
int nullIndex() const
Returns the current index of the NULL value, or -1 if NULL values are not allowed.
void fetchLimitChanged()
Emitted when the fetching limit for the feature request changes.
void focusOutEvent(QFocusEvent *event) override
void setFetchGeometry(bool fetchGeometry)
Defines if the geometry will be fetched.
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.
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features