QGIS API Documentation 3.99.0-Master (21b3aa880ba)
Loading...
Searching...
No Matches
qgsfieldvalueslineedit.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsfieldvalueslineedit.h
3 -----------------------
4 Date : 20-08-2016
5 Copyright : (C) 2016 by Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
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 QGSFIELDVALUESLINEEDIT_H
16#define QGSFIELDVALUESLINEEDIT_H
17
18#include "qgis_gui.h"
19#include "qgis_sip.h"
20#include "qgsfeedback.h"
21#include "qgsfilterlineedit.h"
22
23#include <QFocusEvent>
24#include <QHeaderView>
25#include <QMutex>
26#include <QStringListModel>
27#include <QThread>
28#include <QTimer>
29#include <QTreeView>
30
32class QgsVectorLayer;
33
34
35#ifndef SIP_RUN
36
37// just internal guff - definitely not for exposing to public API!
39
44class QgsFieldValuesLineEditValuesGatherer : public QThread
45{
46 Q_OBJECT
47
48 public:
49 QgsFieldValuesLineEditValuesGatherer( QgsVectorLayer *layer, int attributeIndex )
50 : mLayer( layer )
51 , mAttributeIndex( attributeIndex )
52 {}
53
57 void setSubstring( const QString &string ) { mSubstring = string; }
58
59 void run() override;
60
62 void stop();
63
65 bool wasCanceled() const { return mWasCanceled; }
66
67 signals:
68
73 void collectedValues( const QStringList &values );
74
75 private:
76 QgsVectorLayer *mLayer = nullptr;
77 int mAttributeIndex;
78 QString mSubstring;
79 QStringList mValues;
80 QgsFeedback *mFeedback = nullptr;
81 QMutex mFeedbackMutex;
82 bool mWasCanceled = false;
83};
84
86
87#endif
88
98{
99 Q_OBJECT
100
101 Q_PROPERTY( QgsVectorLayer *layer READ layer WRITE setLayer NOTIFY layerChanged )
103
104 public:
109 QgsFieldValuesLineEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
110
111 ~QgsFieldValuesLineEdit() override;
112
120
126 QgsVectorLayer *layer() const { return mLayer; }
127
134 void setAttributeIndex( int index );
135
141 int attributeIndex() const { return mAttributeIndex; }
142
143 signals:
144
150
155 void attributeIndexChanged( int index );
156
157 private slots:
158
163 void requestCompleterUpdate();
164
169 void triggerCompleterUpdate();
170
175 void updateCompleter( const QStringList &values );
176
182 void gathererThreadFinished();
183
184 private:
185 QgsVectorLayer *mLayer = nullptr;
186 int mAttributeIndex = -1;
187
189 bool mUpdateRequested = false;
190
192 QTimer mShowPopupTimer;
193
195 QgsFieldValuesLineEditValuesGatherer *mGatherer = nullptr;
196
198 QString mRequestedCompletionText;
199
201 void updateCompletionList( const QString &substring );
202};
203
204
205#endif //QGSFIELDVALUESLINEEDIT_H
void attributeIndexChanged(int index)
Emitted when the field associated with the widget changes.
QgsFieldValuesLineEdit(QWidget *parent=nullptr)
Constructor for QgsFieldValuesLineEdit.
void setLayer(QgsVectorLayer *layer)
Sets the layer containing the field that values will be shown from.
void layerChanged(QgsVectorLayer *layer)
Emitted when the layer associated with the widget changes.
void setAttributeIndex(int index)
Sets the attribute index for the field containing values to show in the widget.
int attributeIndex() const
Returns the attribute index for the field containing values shown in the widget.
QgsFilterLineEdit(QWidget *parent=nullptr, const QString &nullValue=QString())
Constructor for QgsFilterLineEdit.
A QWidget subclass for creating widgets which float outside of the normal Qt layout system.
Represents a vector layer which manages a vector based dataset.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53