QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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
51 QgsFilteredTableWidget( QWidget *parent, bool showSearch );
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 friend class TestQgsValueRelationWidgetWrapper;
108};
109
111
134{
135 Q_OBJECT
136
137 public:
138
149 explicit QgsValueRelationWidgetWrapper( QgsVectorLayer *layer, int fieldIdx, QWidget *editor = nullptr, QWidget *parent = nullptr );
150
151 QVariant value() const override;
152
153 void showIndeterminateState() override;
154
155 void setEnabled( bool enabled ) override;
156
157 public slots:
158
159 void parentFormValueChanged( const QString &attribute, const QVariant &value ) override;
160
161 protected:
162 QWidget *createWidget( QWidget *parent ) override;
163 void initWidget( QWidget *editor ) override;
164 bool valid() const override;
165
178 void widgetValueChanged( const QString &attribute, const QVariant &newValue, bool attributeChanged );
179
188 void setFeature( const QgsFeature &feature ) override;
189
190 private slots:
191 void emitValueChangedInternal( const QString &value );
192
193 private:
194 void updateValues( const QVariant &value, const QVariantList & = QVariantList() ) override;
195
196
201 int columnCount() const;
202
204 QVariant::Type fkType() const;
205
207 void populate( );
208
209 QgsToolTipComboBox *mComboBox = nullptr;
210 QgsFilteredTableWidget *mTableWidget = nullptr;
211 QLineEdit *mLineEdit = nullptr;
212
214 QgsVectorLayer *mLayer = nullptr;
215
216 bool mEnabled = true;
217 QString mExpression;
218
220 friend class TestQgsValueRelationWidgetWrapper;
221
222};
223
224#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:56
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
QComboBox subclass which features a tooltip when mouse hovering the combobox.
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