29 , mCaseString( QStringLiteral(
"LIKE" ) )
38void QgsDefaultSearchWidgetWrapper::setCaseString(
int caseSensitiveCheckState )
40 if ( caseSensitiveCheckState == Qt::Checked )
42 mCaseString = QStringLiteral(
"LIKE" );
46 mCaseString = QStringLiteral(
"ILIKE" );
58 const bool numeric = ( fldType == QMetaType::Type::Int || fldType == QMetaType::Type::Double || fldType == QMetaType::Type::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 );
98 case QMetaType::Type::Int:
99 case QMetaType::Type::UInt:
100 case QMetaType::Type::Double:
101 case QMetaType::Type::LongLong:
102 case QMetaType::Type::ULongLong:
103 case QMetaType::Type::QDate:
104 case QMetaType::Type::QDateTime:
105 case QMetaType::Type::QTime:
109 case QMetaType::Type::QString:
125 case QMetaType::Type::Int:
126 case QMetaType::Type::UInt:
127 case QMetaType::Type::Double:
128 case QMetaType::Type::LongLong:
129 case QMetaType::Type::ULongLong:
132 case QMetaType::Type::QDate:
133 case QMetaType::Type::QDateTime:
134 case QMetaType::Type::QTime:
137 case QMetaType::Type::QString:
155 return fieldName +
" IS NULL";
157 return fieldName +
" IS NOT NULL";
161 case QMetaType::Type::Int:
162 case QMetaType::Type::UInt:
163 case QMetaType::Type::Double:
164 case QMetaType::Type::LongLong:
165 case QMetaType::Type::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();
182 case QMetaType::Type::QDate:
183 case QMetaType::Type::QDateTime:
184 case QMetaType::Type::QTime:
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 QMetaType::Type::QString:
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()->setContentsMargins( 0, 0, 0, 0 );
261 if ( fldType == QMetaType::Type::QString )
271 mContainer->layout()->addWidget( mLineEdit );
272 mContainer->setFocusProxy( mLineEdit );
274 if ( fldType == QMetaType::Type::QString )
276 mCheckbox =
new QCheckBox( QStringLiteral(
"Case sensitive" ) );
277 mContainer->layout()->addWidget( mCheckbox );
278 connect( mCheckbox, &QCheckBox::stateChanged,
this, &QgsDefaultSearchWidgetWrapper::setCaseString );
279 mCheckbox->setChecked( Qt::Unchecked );
282 connect( mLineEdit, &QLineEdit::textChanged,
this, &QgsDefaultSearchWidgetWrapper::textChanged );
283 connect( mLineEdit, &QLineEdit::returnPressed,
this, &QgsDefaultSearchWidgetWrapper::filterChanged );
286 mCaseString = QStringLiteral(
"ILIKE" );
304void QgsDefaultSearchWidgetWrapper::filterChanged()
309void QgsDefaultSearchWidgetWrapper::textChanged(
const QString &text )
311 if ( text.isEmpty() )
static QString nullRepresentation()
Returns the string used to represent the value NULL throughout QGIS.
static QString quotedString(QString text)
Returns a quoted version of a string (in single quotes)
static QString quotedColumnRef(QString name)
Returns a quoted column reference (in double quotes)
A line edit with an autocompleter which takes unique values from a vector layer's fields.
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
Represents a vector layer which manages a vector based data sets.