Skip to content

Commit

Permalink
vector file writer: support QVariant::UInt, ::ULongLong and ::Time (f…
Browse files Browse the repository at this point in the history
…ixes #12841)

(cherry picked from commit 8d0c281)
  • Loading branch information
jef-n committed Jun 29, 2015
1 parent 1bf1b33 commit 10fbfcf
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/core/qgsvectorfilewriter.cpp
Expand Up @@ -1665,6 +1665,8 @@ OGRFeatureH QgsVectorFileWriter::createFeature( QgsFeature& feature )
OGR_F_SetFieldDouble( poFeature, ogrField, attrValue.toDouble() );
break;
case QVariant::LongLong:
case QVariant::UInt:
case QVariant::ULongLong:
case QVariant::String:
OGR_F_SetFieldString( poFeature, ogrField, mCodec->fromUnicode( attrValue.toString() ).data() );
break;
Expand All @@ -1685,13 +1687,21 @@ OGRFeatureH QgsVectorFileWriter::createFeature( QgsFeature& feature )
attrValue.toDateTime().time().second(),
0 );
break;
case QVariant::Time:
OGR_F_SetFieldDateTime( poFeature, ogrField,
0, 0, 0,
attrValue.toDateTime().time().hour(),
attrValue.toDateTime().time().minute(),
attrValue.toDateTime().time().second(),
0 );
break;
case QVariant::Invalid:
break;
default:
mErrorMessage = QObject::tr( "Invalid variant type for field %1[%2]: received %3 with type %4" )
.arg( mFields[fldIdx].name() )
.arg( ogrField )
.arg( QMetaType::typeName( attrValue.type() ) )
.arg( attrValue.typeName() )
.arg( attrValue.toString() );
QgsMessageLog::logMessage( mErrorMessage, QObject::tr( "OGR" ) );
mError = ErrFeatureWriteFailed;
Expand Down

0 comments on commit 10fbfcf

Please sign in to comment.