mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Add the option to include a primary key when creating a new spatialite
layer. git-svn-id: http://svn.osgeo.org/qgis/trunk@13279 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
d037836c4e
commit
c396d6ea6e
@ -10,6 +10,8 @@ Enter a name for the geometry column or accept the default.
|
||||
Choose the type of layer you want to create.
|
||||
<h4>EPSG SRID</h4>
|
||||
Enter the EPSG number for the spatial reference id (SRID). By default the SRID for WGS 84 is filled in for you. Click on <label>Find SRID</label> button to change the coordinate reference system of the layer if needed. The SRID must exist within the spatial_ref_sys in your Spatialite database. You can search for the SRID using partial matches on both name and SRID.
|
||||
<h4>Create an Autoincrementing Primary Key</h4>
|
||||
Clicking this checkbox will add a primary key to the new layer. This key field will be autoincrementing, meaning you don't have to enter a value for it when adding features to the attribute table of the layer.
|
||||
<h4>New attribute</h4>
|
||||
Add the desired attributes by clicking on the <label>Add to attributes list</label> button after you have specified a name and type for the attribute. Only real, integer, and string attributes are supported.<br/>
|
||||
Width and precision are irrelevant in a Spatialite database so you do not have to specify these.
|
||||
|
@ -3131,7 +3131,16 @@ void QgisApp::newSpatialiteLayer()
|
||||
|
||||
// Build up the sql statement for creating the table
|
||||
//
|
||||
QString sql = QString( "create table %1(" ).arg( quotedIdentifier( newLayerName ) );
|
||||
QString baseSQL;
|
||||
if ( spatialiteDialog.includePrimaryKey() )
|
||||
{
|
||||
baseSQL = "create table %1(pkuid integer primary key autoincrement, ";
|
||||
}
|
||||
else
|
||||
{
|
||||
baseSQL = "create table %1(";
|
||||
}
|
||||
QString sql = baseSQL.arg( quotedIdentifier( newLayerName ) );
|
||||
// iterate through the field names and add them to the create statement
|
||||
// (use indexed access since this is just as fast as iterators
|
||||
for ( int i = 0; i < items->size(); ++i )
|
||||
|
@ -232,6 +232,11 @@ QString QgsNewSpatialiteLayerDialog::geometryColumn() const
|
||||
return leGeometryColumn->text();
|
||||
}
|
||||
|
||||
bool QgsNewSpatialiteLayerDialog::includePrimaryKey() const
|
||||
{
|
||||
return checkBoxPrimaryKey->isChecked();
|
||||
}
|
||||
|
||||
bool QgsNewSpatialiteLayerDialog::createDb()
|
||||
{
|
||||
QFile newDb( mDatabaseComboBox->currentText() );
|
||||
|
@ -49,6 +49,8 @@ class QgsNewSpatialiteLayerDialog: public QDialog, private Ui::QgsNewSpatialiteL
|
||||
QString geometryColumn() const;
|
||||
/**Returns the selected crs id*/
|
||||
QString selectedCrsId() const;
|
||||
/**Returns the state of the primary key checkbox*/
|
||||
bool includePrimaryKey() const;
|
||||
/** Create a new database */
|
||||
bool createDb();
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>411</width>
|
||||
<height>593</height>
|
||||
<width>431</width>
|
||||
<height>648</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -227,6 +227,16 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="checkBoxPrimaryKey">
|
||||
<property name="toolTip">
|
||||
<string>Add an integer id field as the primary key for the new layer</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Create an autoincrementing primary key</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>New attribute</string>
|
||||
@ -284,7 +294,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="7" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Attributes list</string>
|
||||
@ -397,7 +407,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="8" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
|
Loading…
x
Reference in New Issue
Block a user