SelectEncodingCapability.patch
python/core/qgsvectordataprovider.sip | ||
---|---|---|
27 | 27 |
RandomSelectGeometryAtId = 1024, |
28 | 28 |
SequentialSelectGeometryAtId = 2048, |
29 | 29 |
CreateAttributeIndex = 4096, |
30 |
SetEncoding = 8192,
|
|
30 |
SelectEncoding = 8192,
|
|
31 | 31 |
}; |
32 | 32 | |
33 | 33 |
/** bitmask of all provider's editing capabilities */ |
src/app/qgsvectorlayerproperties.cpp | ||
---|---|---|
144 | 144 |
pbnIndex->setEnabled( false ); |
145 | 145 |
} |
146 | 146 | |
147 |
if ( capabilities & QgsVectorDataProvider::SetEncoding ) |
|
147 |
if ( capabilities & QgsVectorDataProvider::SelectEncoding )
|
|
148 | 148 |
{ |
149 | 149 |
cboProviderEncoding->addItems( QgsVectorDataProvider::availableEncodings() ); |
150 | 150 |
QString enc = layer->dataProvider()->encoding(); |
... | ... | |
156 | 156 |
} |
157 | 157 |
cboProviderEncoding->setCurrentIndex( encindex ); |
158 | 158 |
} |
159 |
else if ( layer->dataProvider()->name() == "ogr" ) |
|
160 |
{ |
|
161 |
// if OGR_L_TestCapability(OLCStringsAsUTF8) returns true, OGR provider encoding can be set to only UTF-8 |
|
162 |
// so make encoding box grayed out |
|
163 |
cboProviderEncoding->addItem( layer->dataProvider()->encoding() ); |
|
164 |
cboProviderEncoding->setEnabled( false ); |
|
165 |
} |
|
159 | 166 |
else |
160 | 167 |
{ |
161 |
// currently only encoding can be set in this group, so hide it completely
|
|
168 |
// other providers do not use mEncoding, so hide the group completely
|
|
162 | 169 |
grpProviderOptions->hide(); |
163 | 170 |
} |
164 | 171 |
} |
... | ... | |
386 | 393 |
// provider-specific options |
387 | 394 |
if ( layer->dataProvider() ) |
388 | 395 |
{ |
389 |
if ( layer->dataProvider()->capabilities() & QgsVectorDataProvider::SetEncoding ) |
|
396 |
if ( layer->dataProvider()->capabilities() & QgsVectorDataProvider::SelectEncoding )
|
|
390 | 397 |
{ |
391 | 398 |
layer->setProviderEncoding( cboProviderEncoding->currentText() ); |
392 | 399 |
} |
src/core/qgsvectordataprovider.h | ||
---|---|---|
84 | 84 |
/** DEPRECATED - do not use */ |
85 | 85 |
SequentialSelectGeometryAtId = 1 << 11, |
86 | 86 |
CreateAttributeIndex = 1 << 12, |
87 |
/** Uses mEncoding for conversion of 8-bit strings to unicode */
|
|
88 |
SetEncoding = 1 << 13,
|
|
87 |
/** allows user to select encoding */
|
|
88 |
SelectEncoding = 1 << 13,
|
|
89 | 89 |
}; |
90 | 90 | |
91 | 91 |
/** bitmask of all provider's editing capabilities */ |
src/providers/ogr/qgsogrprovider.cpp | ||
---|---|---|
1198 | 1198 | |
1199 | 1199 |
int QgsOgrProvider::capabilities() const |
1200 | 1200 |
{ |
1201 |
int ability = SetEncoding;
|
|
1201 |
int ability = 0;
|
|
1202 | 1202 | |
1203 | 1203 |
// collect abilities reported by OGR |
1204 | 1204 |
if ( ogrLayer ) |
... | ... | |
1289 | 1289 |
ability |= DeleteAttributes; |
1290 | 1290 |
} |
1291 | 1291 | |
1292 |
#if defined(OLCStringsAsUTF8) |
|
1293 |
if ( !OGR_L_TestCapability( ogrLayer, OLCStringsAsUTF8 ) ) |
|
1294 |
{ |
|
1295 |
ability |= SelectEncoding; |
|
1296 |
} |
|
1297 |
#else |
|
1298 |
ability |= SelectEncoding; |
|
1299 |
#endif |
|
1300 | ||
1292 | 1301 |
// OGR doesn't handle shapefiles without attributes, ie. missing DBFs well, fixes #803 |
1293 | 1302 |
if ( ogrDriverName == "ESRI Shapefile" ) |
1294 | 1303 |
{ |
1295 |
- |