QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgsvaluerelationsearchwidgetwrapper.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvaluerelationwidgetwrapper.h
3  --------------------------------------
4  Date : 19.6.2015
5  Copyright : (C) 2015 Karolina Alexiou
6  Email : carolinegr 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 
16 #ifndef QGSVALUERELATIONSEARCHWIDGETWRAPPER_H
17 #define QGSVALUERELATIONSEARCHWIDGETWRAPPER_H
18 
19 #include "qgssearchwidgetwrapper.h"
20 #include "qgis.h"
22 
23 #include <QComboBox>
24 #include <QLineEdit>
25 #include "qgis_gui.h"
26 
28 
37 {
38  Q_OBJECT
39  public:
40 
42  explicit QgsValueRelationSearchWidgetWrapper( QgsVectorLayer *vl, int fieldIdx, QWidget *parent SIP_TRANSFERTHIS = nullptr );
43  bool applyDirectly() override;
44  QString expression() const override;
45  bool valid() const override;
46  QVariant value() const;
47  QgsSearchWidgetWrapper::FilterFlags supportedFlags() const override;
48  QgsSearchWidgetWrapper::FilterFlags defaultFlags() const override;
49  QString createExpression( QgsSearchWidgetWrapper::FilterFlags flags ) const override;
50 
51  public slots:
52  void clearWidget() override;
53  void setEnabled( bool enabled ) override;
54 
55  protected:
56  QWidget *createWidget( QWidget *parent ) override;
57  void initWidget( QWidget *editor ) override;
58 
59  protected slots:
61  void onValueChanged();
62 
63  void setExpression( const QString &exp ) override;
64 
65  private:
66  QComboBox *mComboBox = nullptr;
67  QLineEdit *mLineEdit = nullptr;
68 
70  QgsVectorLayer *mLayer = nullptr;
71 
73 };
74 
75 #endif // QGSVALUERELATIONSEARCHWIDGETWRAPPER_H
Shows a search widget on a filter form.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
void setEnabled(bool enabled) override
Toggles whether the search widget is enabled or disabled.
QVector< QgsValueRelationFieldFormatter::ValueRelationItem > ValueRelationCache
virtual QString createExpression(FilterFlags flags) const
Creates a filter expression based on the current state of the search widget and the specified filter ...
virtual void clearWidget()
Clears the widget&#39;s current value and resets it back to the default state.
Wraps a value relation search widget.
virtual bool valid() const =0
Returns true if the widget has been properly initialized.
virtual FilterFlags defaultFlags() const
Returns the filter flags which should be set by default for the search widget.
virtual QWidget * createWidget(QWidget *parent)=0
This method should create a new widget with the provided parent.
virtual void initWidget(QWidget *editor)
This method should initialize the editor widget with runtime data.
virtual bool applyDirectly()=0
If this is true, then this search widget should take effect directly when its expression changes...
virtual QString expression() const =0
Will be used to access the widget&#39;s value.
virtual void setExpression(const QString &expression)=0
Set the expression which is currently used as filter for this widget.
Represents a vector layer which manages a vector based data sets.
virtual FilterFlags supportedFlags() const
Returns filter flags supported by the search widget.