@@ -89,6 +89,15 @@ QgsVectorFileWriter::QgsVectorFileWriter(
89
89
dsOptions.append ( " SPATIALITE=YES" );
90
90
}
91
91
}
92
+ else if ( driverName == " DBF file" )
93
+ {
94
+ ogrDriverName = " ESRI Shapefile" ;
95
+ if ( !layOptions.contains ( " SHPT=NULL" ) )
96
+ {
97
+ layOptions.append ( " SHPT=NULL" );
98
+ }
99
+ srs = 0 ;
100
+ }
92
101
else
93
102
{
94
103
ogrDriverName = driverName;
@@ -109,7 +118,7 @@ QgsVectorFileWriter::QgsVectorFileWriter(
109
118
return ;
110
119
}
111
120
112
- if ( driverName == " ESRI Shapefile" )
121
+ if ( ogrDriverName == " ESRI Shapefile" )
113
122
{
114
123
if ( layOptions.join ( " " ).toUpper ().indexOf ( " ENCODING=" ) == -1 )
115
124
{
@@ -118,11 +127,14 @@ QgsVectorFileWriter::QgsVectorFileWriter(
118
127
119
128
CPLSetConfigOption ( " SHAPE_ENCODING" , " " );
120
129
121
- if ( !vectorFileName.endsWith ( " .shp" , Qt::CaseInsensitive ) &&
122
- !vectorFileName.endsWith ( " .dbf" , Qt::CaseInsensitive ) )
130
+ if ( driverName == " ESRI Shapefile" && !vectorFileName.endsWith ( " .shp" , Qt::CaseInsensitive ) )
123
131
{
124
132
vectorFileName += " .shp" ;
125
133
}
134
+ else if ( driverName == " DBF file" && !vectorFileName.endsWith ( " .dbf" , Qt::CaseInsensitive ) )
135
+ {
136
+ vectorFileName += " .dbf" ;
137
+ }
126
138
127
139
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM < 1700
128
140
// check for unique fieldnames
@@ -270,7 +282,7 @@ QgsVectorFileWriter::QgsVectorFileWriter(
270
282
271
283
if ( srs )
272
284
{
273
- if ( driverName == " ESRI Shapefile" )
285
+ if ( ogrDriverName == " ESRI Shapefile" )
274
286
{
275
287
QString layerName = vectorFileName.left ( vectorFileName.indexOf ( " .shp" , Qt::CaseInsensitive ) );
276
288
QFile prjFile ( layerName + " .qpj" );
@@ -730,7 +742,7 @@ QgsVectorFileWriter::writeAsVectorFormat( QgsVectorLayer* layer,
730
742
QgsCoordinateTransform* ct = 0 ;
731
743
int shallTransform = false ;
732
744
733
- if ( layer == NULL )
745
+ if ( ! layer )
734
746
{
735
747
return ErrInvalidLayer;
736
748
}
@@ -1023,6 +1035,10 @@ QMap<QString, QString> QgsVectorFileWriter::ogrDriverList()
1023
1035
CPLFree ( options[0 ] );
1024
1036
delete [] options;
1025
1037
}
1038
+ else if ( drvName == " ESRI Shapefile" )
1039
+ {
1040
+ writableDrivers << " DBF file" ;
1041
+ }
1026
1042
writableDrivers << drvName;
1027
1043
}
1028
1044
}
@@ -1117,6 +1133,13 @@ bool QgsVectorFileWriter::driverMetadata( QString driverName, QString &longName,
1117
1133
glob = " *.shp" ;
1118
1134
ext = " shp" ;
1119
1135
}
1136
+ else if ( driverName.startsWith ( " DBF file" ) )
1137
+ {
1138
+ longName = " DBF File" ;
1139
+ trLongName = QObject::tr ( " DBF file" );
1140
+ glob = " *.dbf" ;
1141
+ ext = " dbf" ;
1142
+ }
1120
1143
else if ( driverName.startsWith ( " FMEObjects Gateway" ) )
1121
1144
{
1122
1145
longName = " FMEObjects Gateway" ;
0 commit comments