QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
qgsvaluerelationwidgetwrapper.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsvaluerelationwidgetwrapper.h
3 --------------------------------------
4 Date : 5.1.2014
5 Copyright : (C) 2014 Matthias Kuhn
6 Email : matthias at opengis dot 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
16#ifndef QGSVALUERELATIONWIDGETWRAPPER_H
17#define QGSVALUERELATIONWIDGETWRAPPER_H
18
19#include <QTableWidget>
20
23#include "qgstooltipcombobox.h"
24#include "qgis_gui.h"
25
26class QLineEdit;
29
31
33
40class QgsFilteredTableWidget : public QWidget
41{
42 Q_OBJECT
43
44 public:
51 QgsFilteredTableWidget( QWidget *parent, bool showSearch, bool displayGroupName );
52
53 bool eventFilter( QObject *watched, QEvent *event ) override;
54
58 QStringList selection() const;
59
63 void checkItems( const QStringList &checked );
64
69
73 void setIndeterminateState();
74
78 void setEnabledTable( const bool enabled );
79
83 void setColumnCount( const int count );
84
88 int rowCount() const { return mTableWidget->rowCount(); }
89
90 signals:
91
95 void itemChanged( QTableWidgetItem *item );
96
97 private:
98 void filterStringChanged( const QString &filterString );
99 void itemChanged_p( QTableWidgetItem *item );
100 QTableWidgetItem *item( const int row, const int column ) const { return mTableWidget->item( row, column ); }
101
102 int mColumnCount = 1;
103 QgsFilterLineEdit *mSearchWidget = nullptr;
104 QTableWidget *mTableWidget = nullptr;
105 bool mEnabledTable = true;
106 QVector<QPair<QgsValueRelationFieldFormatter::ValueRelationItem, Qt::CheckState>> mCache;
107 bool mDisplayGroupName = false;
108
109 friend class TestQgsValueRelationWidgetWrapper;
110};
111
113
136{
137 Q_OBJECT
138
139 public:
150 explicit QgsValueRelationWidgetWrapper( QgsVectorLayer *layer, int fieldIdx, QWidget *editor = nullptr, QWidget *parent = nullptr );
151
152 QVariant value() const override;
153
154 void showIndeterminateState() override;
155
156 void setEnabled( bool enabled ) override;
157
158 public slots:
159
160 void parentFormValueChanged( const QString &attribute, const QVariant &value ) override;
161
162 protected:
163 QWidget *createWidget( QWidget *parent ) override;
164 void initWidget( QWidget *editor ) override;
165 bool valid() const override;
166
179 void widgetValueChanged( const QString &attribute, const QVariant &newValue, bool attributeChanged );
180
189 void setFeature( const QgsFeature &feature ) override;
190
191 private slots:
192 void emitValueChangedInternal( const QString &value );
193
194 private:
195 void updateValues( const QVariant &value, const QVariantList & = QVariantList() ) override;
196
207 void updateValue( const QVariant &value, bool forceComboInsertion );
208
213 int columnCount() const;
214
216 QMetaType::Type fkType() const;
217
219 void populate();
220
221 QComboBox *mComboBox = nullptr;
222 QgsFilteredTableWidget *mTableWidget = nullptr;
223 QLineEdit *mLineEdit = nullptr;
224 int mSubWidgetSignalBlocking = 0;
225
227
228 bool mEnabled = true;
229 QString mExpression;
230
232 friend class TestQgsValueRelationWidgetWrapper;
233};
234
235#endif // QGSVALUERELATIONWIDGETWRAPPER_H
Manages an editor widget Widget and wrapper share the same parent.
virtual QVariant value() const =0
Will be used to access the widget's value.
virtual void parentFormValueChanged(const QString &attribute, const QVariant &value)
Is called in embedded form widgets when an attribute value in the parent form has changed.
virtual void showIndeterminateState()
Sets the widget to display in an indeterminate "mixed value" state.
void setFeature(const QgsFeature &feature) override
Will be called when the feature changes.
void setEnabled(bool enabled) override
Is used to enable or disable the edit functionality of the managed widget.
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...
QVector< QgsValueRelationFieldFormatter::ValueRelationItem > ValueRelationCache
Represents a vector layer which manages a vector based data sets.
virtual bool valid() const =0
Returns true if the widget has been properly initialized.
virtual void initWidget(QWidget *editor)
This method should initialize the editor widget with runtime data.
virtual QWidget * createWidget(QWidget *parent)=0
This method should create a new widget with the provided parent.
#define SIP_NO_FILE