Skip to content
Permalink
Browse files

correctly emit NULL and not empty string for date/time widget for str…

…ing fields
  • Loading branch information
3nids committed Mar 7, 2018
1 parent 8bd4896 commit 1d0b082e8526d567debe146c651200e80a2c608d
Showing with 12 additions and 5 deletions.
  1. +12 −5 src/gui/editorwidgets/qgsdatetimeeditwrapper.cpp
@@ -126,15 +126,22 @@ void QgsDateTimeEditWrapper::dateTimeChanged( const QDateTime &dateTime )
emit valueChanged( dateTime.time() );
break;
default:
const bool fieldIsoFormat = config( QStringLiteral( "field_iso_format" ), false ).toBool();
const QString fieldFormat = config( QStringLiteral( "field_format" ), QgsDateTimeFieldFormatter::defaultFormat( field().type() ) ).toString();
if ( fieldIsoFormat )
if ( !dateTime.isValid() || dateTime.isNull() )
{
emit valueChanged( dateTime.toString( Qt::ISODate ) );
emit valueChanged( QVariant( field().type() ) );
}
else
{
emit valueChanged( dateTime.toString( fieldFormat ) );
const bool fieldIsoFormat = config( QStringLiteral( "field_iso_format" ), false ).toBool();
const QString fieldFormat = config( QStringLiteral( "field_format" ), QgsDateTimeFieldFormatter::defaultFormat( field().type() ) ).toString();
if ( fieldIsoFormat )
{
emit valueChanged( dateTime.toString( Qt::ISODate ) );
}
else
{
emit valueChanged( dateTime.toString( fieldFormat ) );
}
}
break;
}

0 comments on commit 1d0b082

Please sign in to comment.
You can’t perform that action at this time.