22 #include <QHBoxLayout> 26 , mLineEdit( nullptr )
27 , mCheckbox( nullptr )
28 , mContainer( nullptr )
29 , mCaseString(
QString(
"LIKE" ) )
38 void QgsDefaultSearchWidgetWrapper::setCaseString(
int caseSensitiveCheckState )
40 if ( caseSensitiveCheckState == Qt::Checked )
46 mCaseString =
"ILIKE";
58 bool numeric = ( fldType == QVariant::Int || fldType == QVariant::Double || fldType == QVariant::LongLong );
64 if ( exp == nullValue )
72 numeric ?
"=" : mCaseString,
76 '%' + exp.
replace(
'\'',
"''" ) +
'%' );
100 case QVariant::Double:
101 case QVariant::LongLong:
102 case QVariant::ULongLong:
104 case QVariant::DateTime:
109 case QVariant::String:
126 case QVariant::Double:
127 case QVariant::LongLong:
128 case QVariant::ULongLong:
133 case QVariant::DateTime:
137 case QVariant::String:
155 return fieldName +
" IS NULL";
157 return fieldName +
" IS NOT NULL";
163 case QVariant::Double:
164 case QVariant::LongLong:
165 case QVariant::ULongLong:
168 return fieldName +
'=' + mLineEdit->
text();
170 return fieldName +
"<>" + mLineEdit->
text();
172 return fieldName +
'>' + mLineEdit->
text();
174 return fieldName +
'<' + mLineEdit->
text();
176 return fieldName +
">=" + mLineEdit->
text();
178 return fieldName +
"<=" + mLineEdit->
text();
183 case QVariant::DateTime:
187 return fieldName +
"='" + mLineEdit->
text() +
'\'';
189 return fieldName +
"<>'" + mLineEdit->
text() +
'\'';
191 return fieldName +
">'" + mLineEdit->
text() +
'\'';
193 return fieldName +
"<'" + mLineEdit->
text() +
'\'';
195 return fieldName +
">='" + mLineEdit->
text() +
'\'';
197 return fieldName +
"<='" + mLineEdit->
text() +
'\'';
201 case QVariant::String:
206 if ( mCheckbox && mCheckbox->
isChecked() )
207 return fieldName + ( flags &
EqualTo ?
"=" :
"<>" )
210 return QString(
"lower(%1)" ).
arg( fieldName )
211 + ( flags & EqualTo ?
"=" :
"<>" ) +
216 QString exp = fieldName + ( mCheckbox && mCheckbox->
isChecked() ?
" LIKE " :
" ILIKE " );
219 value = value.remove( 0, 1 );
220 exp +=
"'%" + value +
"%'";
221 if ( flags & DoesNotContain )
258 if ( fldType == QVariant::String )
260 mCheckbox =
new QCheckBox(
"Case sensitive" );
262 connect( mCheckbox, SIGNAL( stateChanged(
int ) ),
this, SLOT( setCaseString(
int ) ) );
267 connect( mLineEdit, SIGNAL( returnPressed() ),
this, SLOT( filterChanged() ) );
270 mCaseString =
"ILIKE";
288 void QgsDefaultSearchWidgetWrapper::filterChanged()
293 void QgsDefaultSearchWidgetWrapper::textChanged(
const QString& text )
QString & append(QChar ch)
void setContentsMargins(int left, int top, int right, int bottom)
static QString quotedColumnRef(QString name)
Returns a quoted column reference (in double quotes)
QString & prepend(QChar ch)
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
QgsFields fields() const
Returns the list of fields of this layer.
const char * name() const
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
void setMargin(int margin)
QString & replace(int position, int n, QChar after)
QVariant value(const QString &key, const QVariant &defaultValue) const
static QString quotedString(QString text)
Returns a quoted version of a string (in single quotes)
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Represents a vector layer which manages a vector based data sets.
QVariant::Type type() const
Gets variant type of the field as it will be retrieved from data source.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const