17#include "moc_qgsdatetimesearchwidgetwrapper.cpp"
23#include "qcalendarwidget.h"
50 const bool fieldIsoFormat =
config( QStringLiteral(
"field_iso_format" ),
false ).toBool();
54 return mDateTimeEdit->
dateTime().toString( Qt::ISODate );
58 return mDateTimeEdit->
dateTime().toString( fieldFormat );
79 return fieldName +
" IS NULL";
81 return fieldName +
" IS NOT NULL";
83 const QVariant v =
value();
88 return fieldName +
"='" + v.toString() +
'\'';
90 return fieldName +
"<>'" + v.toString() +
'\'';
92 return fieldName +
">'" + v.toString() +
'\'';
94 return fieldName +
"<'" + v.toString() +
'\'';
96 return fieldName +
">='" + v.toString() +
'\'';
98 return fieldName +
"<='" + v.toString() +
'\'';
115 mDateTimeEdit->setEnabled( enabled );
129 const QString str = QStringLiteral(
"%1 = '%3'" )
134void QgsDateTimeSearchWidgetWrapper::dateTimeChanged(
const QDateTime &dt )
138 const QString exp =
value().toString();
140 if ( dt.isValid() && !dt.isNull() )
157 mDateTimeEdit = qobject_cast<QgsDateTimeEdit *>( editor );
164 mDateTimeEdit->setDisplayFormat( displayFormat );
166 const bool calendar =
config( QStringLiteral(
"calendar_popup" ),
false ).toBool();
167 mDateTimeEdit->setCalendarPopup( calendar );
168 if ( calendar && mDateTimeEdit->calendarWidget() )
171 QTextCharFormat todayFormat;
172 todayFormat.setBackground( QColor( 160, 180, 200 ) );
173 mDateTimeEdit->calendarWidget()->setDateTextFormat( QDate::currentDate(), todayFormat );
178 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.