Skip to content
Permalink
Browse files

vector file writer: support QVariant::UInt, ::ULongLong and ::Time (f…

…ixes #12841)

(cherry picked from commit 8d0c281)
  • Loading branch information
jef-n committed Jun 11, 2015
1 parent 1bf1b33 commit 10fbfcf1d34209e2f8f405f6b151f8b1f0fdd879
Showing with 11 additions and 1 deletion.
  1. +11 −1 src/core/qgsvectorfilewriter.cpp
@@ -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;
@@ -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;

0 comments on commit 10fbfcf

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