17#include "moc_qgsdatetimesearchwidgetwrapper.cpp"
23#include "qcalendarwidget.h"
47 if ( ! mDateTimeEdit )
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'" )
131 exp.replace(
'\'', QLatin1String(
"''" ) )
136void QgsDateTimeSearchWidgetWrapper::dateTimeChanged(
const QDateTime &dt )
140 const QString exp =
value().toString();
142 if ( dt.isValid() && !dt.isNull() )
159 mDateTimeEdit = qobject_cast<QgsDateTimeEdit *>( editor );
166 mDateTimeEdit->setDisplayFormat( displayFormat );
168 const bool calendar =
config( QStringLiteral(
"calendar_popup" ),
false ).toBool();
169 mDateTimeEdit->setCalendarPopup( calendar );
170 if ( calendar && mDateTimeEdit->calendarWidget() )
173 QTextCharFormat todayFormat;
174 todayFormat.setBackground( QColor( 160, 180, 200 ) );
175 mDateTimeEdit->calendarWidget()->setDateTextFormat( QDate::currentDate(), todayFormat );
180 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.