25 #include <QHBoxLayout>
29 , mCaseString( QStringLiteral(
"LIKE" ) )
38 void QgsDefaultSearchWidgetWrapper::setCaseString(
int caseSensitiveCheckState )
40 if ( caseSensitiveCheckState == Qt::Checked )
42 mCaseString = QStringLiteral(
"LIKE" );
46 mCaseString = QStringLiteral(
"ILIKE" );
58 bool numeric = ( fldType == QVariant::Int || fldType == QVariant::Double || fldType == QVariant::LongLong );
64 if ( exp == nullValue )
70 str = QStringLiteral(
"%1 %2 '%3'" )
72 numeric ? QStringLiteral(
"=" ) : mCaseString,
74 exp.replace(
'\'', QLatin1String(
"''" ) )
76 '%' + exp.replace(
'\'', QLatin1String(
"''" ) ) +
'%' );
83 return new QWidget( parent );
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 QStringLiteral(
"lower(%1)" ).arg( fieldName )
211 + ( ( flags &
EqualTo ) ?
"=" :
"<>" ) +
216 QString exp = fieldName + ( mCheckbox && mCheckbox->isChecked() ?
" LIKE " :
" ILIKE " );
219 value = value.remove( 0, 1 );
228 exp.prepend(
"NOT (" ).append(
')' );
244 mLineEdit->setText( QString() );
249 mLineEdit->setEnabled( enabled );
251 mCheckbox->setEnabled( enabled );
257 mContainer->setLayout(
new QHBoxLayout() );
258 mContainer->layout()->setMargin( 0 );
259 mContainer->layout()->setContentsMargins( 0, 0, 0, 0 );
262 if ( fldType == QVariant::String )
272 mContainer->layout()->addWidget( mLineEdit );
273 mContainer->setFocusProxy( mLineEdit );
275 if ( fldType == QVariant::String )
277 mCheckbox =
new QCheckBox( QStringLiteral(
"Case sensitive" ) );
278 mContainer->layout()->addWidget( mCheckbox );
279 connect( mCheckbox, &QCheckBox::stateChanged,
this, &QgsDefaultSearchWidgetWrapper::setCaseString );
280 mCheckbox->setChecked( Qt::Unchecked );
283 connect( mLineEdit, &QLineEdit::textChanged,
this, &QgsDefaultSearchWidgetWrapper::textChanged );
284 connect( mLineEdit, &QLineEdit::returnPressed,
this, &QgsDefaultSearchWidgetWrapper::filterChanged );
287 mCaseString = QStringLiteral(
"ILIKE" );
305 void QgsDefaultSearchWidgetWrapper::filterChanged()
310 void QgsDefaultSearchWidgetWrapper::textChanged(
const QString &text )
312 if ( text.isEmpty() )