Skip to content
Permalink
Browse files

[saveas] Hide senseless options for sqlite

  • Loading branch information
m-kuhn committed Nov 19, 2013
1 parent 7d7ae56 commit 366375b0690c1acb4b65fa9af74aa0e5ecd7c91e
Showing with 109 additions and 24 deletions.
  1. +27 −5 src/app/ogr/qgsvectorlayersaveasdialog.cpp
  2. +70 −18 src/core/qgsvectorfilewriter.cpp
  3. +12 −1 src/core/qgsvectorfilewriter.h
@@ -139,14 +139,20 @@ QList<QPair<QLabel*, QWidget*> > QgsVectorLayerSaveAsDialog::createControls( con
control = le;
break;
}
}

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

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

controls << QPair<QLabel*, QWidget*>( label, control );
}
}

return controls;
@@ -353,6 +359,14 @@ QStringList QgsVectorLayerSaveAsDialog::datasourceOptions() const
options << QString( "%1=%2" ).arg( it.key() ).arg( le->text() );
break;
}

case QgsVectorFileWriter::Hidden:
{
QgsVectorFileWriter::HiddenOption* opt
= dynamic_cast<QgsVectorFileWriter::HiddenOption*>( it.value() );
options << QString( "%1=%2" ).arg( it.key() ).arg( opt->mValue );
break;
}
}
}
}
@@ -394,6 +408,14 @@ QStringList QgsVectorLayerSaveAsDialog::layerOptions() const
options << QString( "%1=%2" ).arg( it.key() ).arg( le->text() );
break;
}

case QgsVectorFileWriter::Hidden:
{
QgsVectorFileWriter::HiddenOption* opt
= dynamic_cast<QgsVectorFileWriter::HiddenOption*>( it.value() );
options << QString( "%1=%2" ).arg( it.key() ).arg( opt->mValue );
break;
}
}
}
}
@@ -1270,6 +1270,7 @@ QMap<QString, QgsVectorFileWriter::MetaData> QgsVectorFileWriter::initMetaData()
)
);

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

// Will be handled with the SpatiaLite driver alias
#if 0
datasetOptions.insert( "SPATIALITE", new BoolOption(
QObject::tr( "Create the SpatiaLite flavour of the metadata tables, which are a bit "
"differ from the metadata used by this OGR driver and from OGC "
"specifications. Implies METADATA=yes" )
// Will handle the spatialite alias
datasetOptions.insert( "SPATIALITE", new HiddenOption(
"NO"
) );


datasetOptions.insert( "INIT_WITH_EPSG", new HiddenOption(
"NO"
) );

layerOptions.insert( "FORMAT", new HiddenOption(
"WKT"
) );

layerOptions.insert( "LAUNDER", new BoolOption(
QObject::tr( "Controls whether layer and field names will be laundered for easier use "
"in SQLite. Laundered names will be convered to lower case and some special "
"characters(' - #) will be changed to underscores." )
, true // Default value
) );
#endif

layerOptions.insert( "SPATIAL_INDEX", new HiddenOption(
"NO"
) );

layerOptions.insert( "COMPRESS_GEOM", new HiddenOption(
"NO"
) );

layerOptions.insert( "SRID", new HiddenOption(
""
) );

layerOptions.insert( "COMPRESS_COLUMNS", new StringOption(
QObject::tr( "column_name1[,column_name2, ...] A list of (String) columns that "
"must be compressed with ZLib DEFLATE algorithm. This might be beneficial "
"for databases that have big string blobs. However, use with care, since "
"the value of such columns will be seen as compressed binary content with "
"other SQLite utilities (or previous OGR versions). With OGR, when inserting, "
"modifying or queryings compressed columns, compression/decompression is "
"done transparently. However, such columns cannot be (easily) queried with "
"an attribute filter or WHERE clause. Note: in table definition, such columns "
"have the 'VARCHAR_deflate' declaration type." )
, "" // Default value
) );

driverMetadata.insert( "SQLite",
MetaData(
"SQLite",
QObject::tr( "SQLite" ),
"*.sqlite",
"sqlite",
datasetOptions,
layerOptions
)
);
// SpatiaLite

datasetOptions.clear();
layerOptions.clear();

datasetOptions.insert( "METADATA", new BoolOption(
QObject::tr( "Can be used to avoid creating the geometry_columns and spatial_ref_sys "
"tables in a new database. By default these metadata tables are created "
"when a new database is created." )
, true // Default value
) );

datasetOptions.insert( "SPATIALITE", new HiddenOption(
"YES"
) );

datasetOptions.insert( "INIT_WITH_EPSG", new BoolOption(
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()
, "" // Default value
) );

driverMetadata.insert( "SQLite",
MetaData(
"SQLite",
QObject::tr( "SQLite" ),
"*.sqlite",
"sqlite",
datasetOptions,
layerOptions
)
);

driverMetadata.insert( "SpatiaLite",
MetaData(
"SpatiaLite",
@@ -46,7 +46,8 @@ class CORE_EXPORT QgsVectorFileWriter
{
Set,
String,
Int
Int,
Hidden
};

class Option
@@ -108,6 +109,16 @@ class CORE_EXPORT QgsVectorFileWriter
{}
};

class HiddenOption: public Option
{
public:
HiddenOption( const QString& value )
: Option( "", Hidden )
, mValue( value )
{}

QString mValue;
};

struct MetaData
{

0 comments on commit 366375b

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