22#include "qcalendarwidget.h"
46 if ( ! mDateTimeEdit )
49 const bool fieldIsoFormat =
config( QStringLiteral(
"field_iso_format" ),
false ).toBool();
53 return mDateTimeEdit->
dateTime().toString( Qt::ISODate );
57 return mDateTimeEdit->
dateTime().toString( fieldFormat );
78 return fieldName +
" IS NULL";
80 return fieldName +
" IS NOT NULL";
82 const QVariant v =
value();
87 return fieldName +
"='" + v.toString() +
'\'';
89 return fieldName +
"<>'" + v.toString() +
'\'';
91 return fieldName +
">'" + v.toString() +
'\'';
93 return fieldName +
"<'" + v.toString() +
'\'';
95 return fieldName +
">='" + v.toString() +
'\'';
97 return fieldName +
"<='" + v.toString() +
'\'';
114 mDateTimeEdit->setEnabled( enabled );
128 const QString
str = QStringLiteral(
"%1 = '%3'" )
130 exp.replace(
'\'', QLatin1String(
"''" ) )
135void QgsDateTimeSearchWidgetWrapper::dateTimeChanged(
const QDateTime &dt )
139 const QString exp =
value().toString();
141 if ( dt.isValid() && !dt.isNull() )
158 mDateTimeEdit = qobject_cast<QgsDateTimeEdit *>( editor );
165 mDateTimeEdit->setDisplayFormat( displayFormat );
167 const bool calendar =
config( QStringLiteral(
"calendar_popup" ),
false ).toBool();
168 mDateTimeEdit->setCalendarPopup( calendar );
169 if ( calendar && mDateTimeEdit->calendarWidget() )
172 QTextCharFormat todayFormat;
173 todayFormat.setBackground( QColor( 160, 180, 200 ) );
174 mDateTimeEdit->calendarWidget()->setDateTextFormat( QDate::currentDate(), todayFormat );
179 connect( mDateTimeEdit, &QDateTimeEdit::dateTimeChanged,
this, &QgsDateTimeSearchWidgetWrapper::dateTimeChanged );
The QgsDateTimeEdit class is a QDateTimeEdit with the capability of setting/reading null date/times.
void setAllowNull(bool allowNull)
Determines if the widget allows setting null date/time.
QDateTime dateTime() const
Returns the date time which can be a null date/time.
void setEmpty()
Resets the widget to show no value (ie, an "unknown" state).
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).
Represents a vector layer which manages a vector based data sets.
QgsFields fields() const FINAL
Returns the list of fields of this layer.