Skip to content

Commit

Permalink
correctly emit NULL and not empty string for date/time widget for str…
Browse files Browse the repository at this point in the history
…ing fields
  • Loading branch information
3nids committed Mar 10, 2018
1 parent 8bd4896 commit 1d0b082
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/gui/editorwidgets/qgsdatetimeeditwrapper.cpp
Expand Up @@ -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;
}
Expand Down

0 comments on commit 1d0b082

Please sign in to comment.