Skip to content

Commit 366375b

Browse files
committedNov 21, 2013
[saveas] Hide senseless options for sqlite
1 parent 7d7ae56 commit 366375b

File tree

3 files changed

+109
-24
lines changed

3 files changed

+109
-24
lines changed
 

‎src/app/ogr/qgsvectorlayersaveasdialog.cpp

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,20 @@ QList<QPair<QLabel*, QWidget*> > QgsVectorLayerSaveAsDialog::createControls( con
139139
control = le;
140140
break;
141141
}
142-
}
143142

144-
// Pack the tooltip in some html element, so it gets linebreaks.
145-
label->setToolTip( QString( "<p>%1</p>" ).arg( option->docString ) );
146-
control->setToolTip( QString( "<p>%1</p>" ).arg( option->docString ) );
143+
case QgsVectorFileWriter::Hidden:
144+
control = 0;
145+
break;
146+
}
147147

148-
controls << QPair<QLabel*, QWidget*>( label, control );
148+
if ( control )
149+
{
150+
// Pack the tooltip in some html element, so it gets linebreaks.
151+
label->setToolTip( QString( "<p>%1</p>" ).arg( option->docString ) );
152+
control->setToolTip( QString( "<p>%1</p>" ).arg( option->docString ) );
149153

154+
controls << QPair<QLabel*, QWidget*>( label, control );
155+
}
150156
}
151157

152158
return controls;
@@ -353,6 +359,14 @@ QStringList QgsVectorLayerSaveAsDialog::datasourceOptions() const
353359
options << QString( "%1=%2" ).arg( it.key() ).arg( le->text() );
354360
break;
355361
}
362+
363+
case QgsVectorFileWriter::Hidden:
364+
{
365+
QgsVectorFileWriter::HiddenOption* opt
366+
= dynamic_cast<QgsVectorFileWriter::HiddenOption*>( it.value() );
367+
options << QString( "%1=%2" ).arg( it.key() ).arg( opt->mValue );
368+
break;
369+
}
356370
}
357371
}
358372
}
@@ -394,6 +408,14 @@ QStringList QgsVectorLayerSaveAsDialog::layerOptions() const
394408
options << QString( "%1=%2" ).arg( it.key() ).arg( le->text() );
395409
break;
396410
}
411+
412+
case QgsVectorFileWriter::Hidden:
413+
{
414+
QgsVectorFileWriter::HiddenOption* opt
415+
= dynamic_cast<QgsVectorFileWriter::HiddenOption*>( it.value() );
416+
options << QString( "%1=%2" ).arg( it.key() ).arg( opt->mValue );
417+
break;
418+
}
397419
}
398420
}
399421
}

‎src/core/qgsvectorfilewriter.cpp

Lines changed: 70 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,7 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
12701270
)
12711271
);
12721272

1273+
// SQLite
12731274
// SQLite
12741275
datasetOptions.clear();
12751276
layerOptions.clear();
@@ -1281,15 +1282,77 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
12811282
, true // Default value
12821283
) );
12831284

1284-
// Will be handled with the SpatiaLite driver alias
1285-
#if 0
1286-
datasetOptions.insert( "SPATIALITE", new BoolOption(
1287-
QObject::tr( "Create the SpatiaLite flavour of the metadata tables, which are a bit "
1288-
"differ from the metadata used by this OGR driver and from OGC "
1289-
"specifications. Implies METADATA=yes" )
1285+
// Will handle the spatialite alias
1286+
datasetOptions.insert( "SPATIALITE", new HiddenOption(
1287+
"NO"
1288+
) );
1289+
1290+
1291+
datasetOptions.insert( "INIT_WITH_EPSG", new HiddenOption(
1292+
"NO"
1293+
) );
1294+
1295+
layerOptions.insert( "FORMAT", new HiddenOption(
1296+
"WKT"
1297+
) );
1298+
1299+
layerOptions.insert( "LAUNDER", new BoolOption(
1300+
QObject::tr( "Controls whether layer and field names will be laundered for easier use "
1301+
"in SQLite. Laundered names will be convered to lower case and some special "
1302+
"characters(' - #) will be changed to underscores." )
12901303
, true // Default value
12911304
) );
1292-
#endif
1305+
1306+
layerOptions.insert( "SPATIAL_INDEX", new HiddenOption(
1307+
"NO"
1308+
) );
1309+
1310+
layerOptions.insert( "COMPRESS_GEOM", new HiddenOption(
1311+
"NO"
1312+
) );
1313+
1314+
layerOptions.insert( "SRID", new HiddenOption(
1315+
""
1316+
) );
1317+
1318+
layerOptions.insert( "COMPRESS_COLUMNS", new StringOption(
1319+
QObject::tr( "column_name1[,column_name2, ...] A list of (String) columns that "
1320+
"must be compressed with ZLib DEFLATE algorithm. This might be beneficial "
1321+
"for databases that have big string blobs. However, use with care, since "
1322+
"the value of such columns will be seen as compressed binary content with "
1323+
"other SQLite utilities (or previous OGR versions). With OGR, when inserting, "
1324+
"modifying or queryings compressed columns, compression/decompression is "
1325+
"done transparently. However, such columns cannot be (easily) queried with "
1326+
"an attribute filter or WHERE clause. Note: in table definition, such columns "
1327+
"have the 'VARCHAR_deflate' declaration type." )
1328+
, "" // Default value
1329+
) );
1330+
1331+
driverMetadata.insert( "SQLite",
1332+
MetaData(
1333+
"SQLite",
1334+
QObject::tr( "SQLite" ),
1335+
"*.sqlite",
1336+
"sqlite",
1337+
datasetOptions,
1338+
layerOptions
1339+
)
1340+
);
1341+
// SpatiaLite
1342+
1343+
datasetOptions.clear();
1344+
layerOptions.clear();
1345+
1346+
datasetOptions.insert( "METADATA", new BoolOption(
1347+
QObject::tr( "Can be used to avoid creating the geometry_columns and spatial_ref_sys "
1348+
"tables in a new database. By default these metadata tables are created "
1349+
"when a new database is created." )
1350+
, true // Default value
1351+
) );
1352+
1353+
datasetOptions.insert( "SPATIALITE", new HiddenOption(
1354+
"YES"
1355+
) );
12931356

12941357
datasetOptions.insert( "INIT_WITH_EPSG", new BoolOption(
12951358
QObject::tr( "Insert the content of the EPSG CSV files into the spatial_ref_sys table. "
@@ -1356,17 +1419,6 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
13561419
, "" // Default value
13571420
) );
13581421

1359-
driverMetadata.insert( "SQLite",
1360-
MetaData(
1361-
"SQLite",
1362-
QObject::tr( "SQLite" ),
1363-
"*.sqlite",
1364-
"sqlite",
1365-
datasetOptions,
1366-
layerOptions
1367-
)
1368-
);
1369-
13701422
driverMetadata.insert( "SpatiaLite",
13711423
MetaData(
13721424
"SpatiaLite",

‎src/core/qgsvectorfilewriter.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ class CORE_EXPORT QgsVectorFileWriter
4646
{
4747
Set,
4848
String,
49-
Int
49+
Int,
50+
Hidden
5051
};
5152

5253
class Option
@@ -108,6 +109,16 @@ class CORE_EXPORT QgsVectorFileWriter
108109
{}
109110
};
110111

112+
class HiddenOption: public Option
113+
{
114+
public:
115+
HiddenOption( const QString& value )
116+
: Option( "", Hidden )
117+
, mValue( value )
118+
{}
119+
120+
QString mValue;
121+
};
111122

112123
struct MetaData
113124
{

0 commit comments

Comments
 (0)
Please sign in to comment.