| 
    QGIS API Documentation
    3.26.3-Buenos Aires (65e4edfdad)
    
   | 
 
 
 
 
Go to the documentation of this file.
   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   const 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()->setContentsMargins( 0, 0, 0, 0 );
 
  261   if ( fldType == QVariant::String )
 
  271   mContainer->layout()->addWidget( mLineEdit );
 
  272   mContainer->setFocusProxy( mLineEdit );
 
  274   if ( fldType == QVariant::String )
 
  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" );
 
  304 void QgsDefaultSearchWidgetWrapper::filterChanged()
 
  309 void QgsDefaultSearchWidgetWrapper::textChanged( 
const QString &text )
 
  311   if ( text.isEmpty() )
 
  
static QString quotedString(QString text)
Returns a quoted version of a string (in single quotes)
 
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
 
QgsFields fields() const FINAL
Returns the list of fields of this layer.
 
static QString nullRepresentation()
This string is used to represent the value NULL throughout QGIS.
 
A line edit with an autocompleter which takes unique values from a vector layer's fields....
 
Represents a vector layer which manages a vector based data sets.
 
static QString quotedColumnRef(QString name)
Returns a quoted column reference (in double quotes)
 
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).