QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgssearchwidgetwrapper.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgssearchwidgetwrapper.h
3  --------------------------------------
4  Date : 31.5.2015
5  Copyright : (C) 2015 Karolina Alexiou (carolinux)
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 QGSSEARCHWIDGETWRAPPER_H
17 #define QGSSEARCHWIDGETWRAPPER_H
18 
19 #include <QObject>
20 #include <QMap>
21 #include <QVariant>
22 
23 class QgsVectorLayer;
24 class QgsField;
25 
26 #include "qgseditorwidgetconfig.h"
28 #include "qgswidgetwrapper.h"
29 
40 class GUI_EXPORT QgsSearchWidgetWrapper : public QgsWidgetWrapper
41 {
42  Q_OBJECT
43  public:
44 
48  {
49  EqualTo = 1 << 1,
50  NotEqualTo = 1 << 2,
51  GreaterThan = 1 << 3,
52  LessThan = 1 << 4,
53  GreaterThanOrEqualTo = 1 << 5,
54  LessThanOrEqualTo = 1 << 6,
55  Between = 1 << 7,
56  CaseInsensitive = 1 << 8,
57  Contains = 1 << 9,
58  DoesNotContain = 1 << 10,
59  IsNull = 1 << 11,
60  IsNotBetween = 1 << 12,
61  IsNotNull = 1 << 13,
62  };
63  Q_DECLARE_FLAGS( FilterFlags, FilterFlag )
64 
65 
69  static QList< FilterFlag > exclusiveFilterFlags();
70 
75  static QList< FilterFlag > nonExclusiveFilterFlags();
76 
81  static QString toString( FilterFlag flag );
82 
90  explicit QgsSearchWidgetWrapper( QgsVectorLayer* vl, int fieldIdx, QWidget* parent = nullptr );
91 
96  virtual FilterFlags supportedFlags() const;
97 
102  virtual FilterFlags defaultFlags() const;
103 
113  virtual QString expression() = 0;
114 
119  virtual bool applyDirectly() = 0;
120 
127  // TODO QGIS 3.0 - make pure virtual
128  virtual QString createExpression( FilterFlags flags ) const { Q_UNUSED( flags ); return "TRUE"; }
129 
130  public slots:
131 
135  virtual void clearWidget() {}
136 
140  virtual void setEnabled( bool enabled ) override { Q_UNUSED( enabled ); }
141 
142  signals:
143 
148  void expressionChanged( const QString& exp );
149 
153  void valueChanged();
154 
159  void valueCleared();
160 
161  protected slots:
162 
163  virtual void setExpression( QString value ) = 0;
164  void setFeature( const QgsFeature& feature ) override;
165 
166  protected:
168  void clearExpression();
169 
172 
173 };
174 // We'll use this class inside a QVariant in the widgets properties
176 
177 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsSearchWidgetWrapper::FilterFlags )
178 
179 #endif // QGSSEARCHWIDGETWRAPPER_H
Manages an editor widget Widget and wrapper share the same parent.
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 setEnabled(bool enabled) override
Toggles whether the search widget is enabled or disabled.
Q_DECLARE_METATYPE(QgsMimeDataUtils::UriList)
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:187
FilterFlag
Flags which indicate what types of filtering and searching is possible using the widget.
virtual void setFeature(const QgsFeature &feature)=0
Is called, when the value of the widget needs to be changed.
virtual void clearWidget()
Clears the widget&#39;s current value and resets it back to the default state.
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:44
Represents a vector layer which manages a vector based data sets.
Manages an editor widget Widget and wrapper share the same parent.