QGIS API Documentation 3.41.0-Master (181b2f43d8e)
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:
45
52 QgsFilteredTableWidget( QWidget *parent, bool showSearch, bool displayGroupName );
53
54 bool eventFilter( QObject *watched, QEvent *event ) override;
55
59 QStringList selection() const;
60
64 void checkItems( const QStringList &checked );
65
70
74 void setIndeterminateState();
75
79 void setEnabledTable( const bool enabled );
80
84 void setColumnCount( const int count );
85
89 int rowCount() const { return mTableWidget->rowCount(); }
90
91 signals:
92
96 void itemChanged( QTableWidgetItem *item );
97
98 private:
99 void filterStringChanged( const QString &filterString );
100 void itemChanged_p( QTableWidgetItem *item );
101 QTableWidgetItem *item( const int row, const int column ) const { return mTableWidget->item( row, column ); }
102
103 int mColumnCount = 1;
104 QgsFilterLineEdit *mSearchWidget = nullptr;
105 QTableWidget *mTableWidget = nullptr;
106 bool mEnabledTable = true;
107 QVector<QPair<QgsValueRelationFieldFormatter::ValueRelationItem, Qt::CheckState>> mCache;
108 bool mDisplayGroupName = false;
109
110 friend class TestQgsValueRelationWidgetWrapper;
111};
112
114
137{
138 Q_OBJECT
139
140 public:
141
152 explicit QgsValueRelationWidgetWrapper( QgsVectorLayer *layer, int fieldIdx, QWidget *editor = nullptr, QWidget *parent = nullptr );
153
154 QVariant value() const override;
155
156 void showIndeterminateState() override;
157
158 void setEnabled( bool enabled ) override;
159
160 public slots:
161
162 void parentFormValueChanged( const QString &attribute, const QVariant &value ) override;
163
164 protected:
165 QWidget *createWidget( QWidget *parent ) override;
166 void initWidget( QWidget *editor ) override;
167 bool valid() const override;
168
181 void widgetValueChanged( const QString &attribute, const QVariant &newValue, bool attributeChanged );
182
191 void setFeature( const QgsFeature &feature ) override;
192
193 private slots:
194 void emitValueChangedInternal( const QString &value );
195
196 private:
197 void updateValues( const QVariant &value, const QVariantList & = QVariantList() ) override;
198
209 void updateValue( const QVariant &value, bool forceComboInsertion );
210
215 int columnCount() const;
216
218 QMetaType::Type fkType() const;
219
221 void populate( );
222
223 QComboBox *mComboBox = nullptr;
224 QgsFilteredTableWidget *mTableWidget = nullptr;
225 QLineEdit *mLineEdit = nullptr;
226 int mSubWidgetSignalBlocking = 0;
227
229
230 bool mEnabled = true;
231 QString mExpression;
232
234 friend class TestQgsValueRelationWidgetWrapper;
235
236};
237
238#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