QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgssearchwidgetwrapper.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgssearchwidgetwrapper.cpp
3  --------------------------------------
4  Date : 10.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 #include "qgssearchwidgetwrapper.h"
17 #include "qgsvectorlayer.h"
18 #include "qgsvectordataprovider.h"
19 #include "qgsfield.h"
20 
21 #include <QWidget>
22 
24 {
25  return QList<FilterFlag>()
26  << EqualTo
27  << NotEqualTo
28  << GreaterThan
29  << LessThan
32  << Between
33  << Contains
35  << IsNull
36  << IsNotBetween
37  << IsNotNull;
38 }
39 
41 {
42  return QList<FilterFlag>()
43  << CaseInsensitive;
44 }
45 
47 {
48  switch ( flag )
49  {
50  case EqualTo:
51  return QObject::tr( "Equal to (=)" );
52  case NotEqualTo:
53  return QObject::tr( "Not equal to" );
54  case GreaterThan:
55  return QObject::tr( "Greater than (>)" );
56  case LessThan:
57  return QObject::tr( "Less than (<)" );
59  return QObject::tr( "Greater than or equal to (>=)" );
60  case LessThanOrEqualTo:
61  return QObject::tr( "Less than or equal to (<=)" );
62  case Between:
63  return QObject::tr( "Between (inclusive)" );
64  case CaseInsensitive:
65  return QObject::tr( "Case insensitive" );
66  case Contains:
67  return QObject::tr( "Contains" );
68  case DoesNotContain:
69  return QObject::tr( "Does not contain" );
70  case IsNull:
71  return QObject::tr( "Is missing (null)" );
72  case IsNotNull:
73  return QObject::tr( "Is not missing (not null)" );
74  case IsNotBetween:
75  return QObject::tr( "Is not between (inclusive)" );
76 
77  }
78  return QString();
79 }
80 
82  : QgsWidgetWrapper( vl, nullptr, parent )
83  , mExpression( QString() )
84  , mFieldIdx( fieldIdx )
85 {
86 }
87 
88 QgsSearchWidgetWrapper::FilterFlags QgsSearchWidgetWrapper::supportedFlags() const
89 {
90  return EqualTo;
91 }
92 
93 QgsSearchWidgetWrapper::FilterFlags QgsSearchWidgetWrapper::defaultFlags() const
94 {
95  return FilterFlags();
96 }
97 
98 
100 {
101  Q_UNUSED( feature )
102 }
103 
105 {
106  mExpression = QString( "TRUE" );
107 }
108 
static QString toString(FilterFlag flag)
Returns a translated string representing a filter flag.
void clearExpression()
clears the expression to search for all features
static QList< FilterFlag > exclusiveFilterFlags()
Returns a list of exclusive filter flags, which cannot be combined with other flags (eg EqualTo/NotEq...
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.
QString tr(const char *sourceText, const char *disambiguation, int n)
QgsSearchWidgetWrapper(QgsVectorLayer *vl, int fieldIdx, QWidget *parent=nullptr)
Create a new widget wrapper.
void setFeature(const QgsFeature &feature) override
virtual FilterFlags defaultFlags() const
Returns the filter flags which should be set by default for the search widget.
static QList< FilterFlag > nonExclusiveFilterFlags()
Returns a list of non-exclusive filter flags, which can be combined with other flags (eg CaseInsensit...
QObject * parent() const
Represents a vector layer which manages a vector based data sets.
Manages an editor widget Widget and wrapper share the same parent.
virtual FilterFlags supportedFlags() const
Returns filter flags supported by the search widget.