Skip to content

Commit

Permalink
[FEATURE]postgres provider: add support for timestamp types
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Nov 18, 2015
1 parent 7b0815b commit f6e4e75
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
4 changes: 0 additions & 4 deletions src/gui/editorwidgets/qgsdatetimeedit.cpp
Expand Up @@ -136,7 +136,3 @@ void QgsDateTimeEdit::resizeEvent( QResizeEvent * event )
mNullLabel->setMinimumSize( rect().adjusted( 0, 0, -spinButtonWidth(), 0 ).size() );
mNullLabel->setMaximumSize( rect().adjusted( 0, 0, -spinButtonWidth(), 0 ).size() );
}




14 changes: 13 additions & 1 deletion src/gui/editorwidgets/qgsdatetimeeditwrapper.cpp
Expand Up @@ -106,6 +106,18 @@ QVariant QgsDateTimeEditWrapper::value()
if ( !mQDateTimeEdit )
return QVariant( field().type() );

if ( field().type() == QVariant::DateTime )
{
if ( mQgsDateTimeEdit )
{
return mQgsDateTimeEdit->dateTime();
}
else
{
return mQDateTimeEdit->dateTime();
}
}

const QString fieldFormat = config( "field_format", QGSDATETIMEEDIT_DATEFORMAT ).toString();

if ( mQgsDateTimeEdit )
Expand All @@ -124,7 +136,7 @@ void QgsDateTimeEditWrapper::setValue( const QVariant &value )
return;

const QString fieldFormat = config( "field_format", QGSDATETIMEEDIT_DATEFORMAT ).toString();
const QDateTime date = QDateTime::fromString( value.toString(), fieldFormat );
const QDateTime date = field().type() == QVariant::DateTime ? value.toDateTime() : QDateTime::fromString( value.toString(), fieldFormat );

if ( mQgsDateTimeEdit )
{
Expand Down
5 changes: 5 additions & 0 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -878,6 +878,11 @@ bool QgsPostgresProvider::loadFields()
fieldType = QVariant::Date;
fieldSize = -1;
}
else if ( fieldTypeName == "timestamp" )
{
fieldType = QVariant::DateTime;
fieldSize = -1;
}
else if ( fieldTypeName == "text" ||
fieldTypeName == "bool" ||
fieldTypeName == "geometry" ||
Expand Down

0 comments on commit f6e4e75

Please sign in to comment.