Implementation of the "Add New Spatialite Layer/Database" feature.

Squashed commit of the following:

commit e6e01ec0b3955d1cf9cb2756dfcf1aac27a0725e
Author: Gary Sherman <gsherman@geoapt.com>
Date:   Sun Apr 4 17:45:05 2010 -0800

    Implementation of the add new spatialite layer dialog with ability to search for epsg srid

commit c1d46e35715e4f8baa137800c88483f612ebcb89
Author: Gary Sherman <gsherman@geoapt.com>
Date:   Sun Apr 4 17:44:23 2010 -0800

    Spatialite database template used when creating a new database

commit 6d4fd8d80e610d6f0f6d22ed49815134292924c5
Author: Gary Sherman <gsherman@geoapt.com>
Date:   Sun Apr 4 17:43:31 2010 -0800

    Context help for the Add New Spatialite Layer dialog

commit 1a6398be174d62df1bf74428bcf898b8d1ea8455
Author: Gary Sherman <gsherman@geoapt.com>
Date:   Sun Apr 4 17:42:51 2010 -0800

    Dialog for finding an SRID from the spatialite spatial_ref_sys table

commit 197a65c134ed06b12fd6c8d96900dcf8197f802d
Author: Gary Sherman <gsherman@geoapt.com>
Date:   Sat Apr 3 11:32:58 2010 -0800

    Renamed the spatialite srids dialog selector to the proper form

commit 66c7cafa78f71b7f06504fe3b7bd4577614bfe67
Author: Gary Sherman <gsherman@geoapt.com>
Date:   Fri Apr 2 22:25:09 2010 -0800

    Implemented create new db. Can now create a new db and an empty layer in
    one pass.

commit 088730293ad4722e7d6045e8661e6c28488b8cae
Author: Gary Sherman <gsherman@geoapt.com>
Date:   Fri Apr 2 20:43:12 2010 -0800

    Adjust new spatialite layer dialog. Add field for geometry column name

commit d7c60012ddce6a70d0512bc9195524e6d672b372
Author: Gary Sherman <gsherman@geoapt.com>
Date:   Fri Apr 2 12:46:49 2010 -0800

    New spatialite layer menu item does not show up if qgis is built with internal spatialite

commit 1343dfe7ac7868c38e8b7bd17ef1dd5a4a04ebad
Author: Gary Sherman <gsherman@geoapt.com>
Date:   Fri Apr 2 11:35:26 2010 -0800

    Test of geometry column creation in the dialog

commit c8785f4aaee9d5b08fe0c0dd6f6bbfcd9cf6c7a5
Author: Gary Sherman <gsherman@geoapt.com>
Date:   Wed Mar 31 21:39:03 2010 -0800

    Added multi geometry types to the radio button group

commit 06350192b9dfa6d6cc5c6ac9c4d0b1a65f260476
Author: Gary Sherman <gsherman@geoapt.com>
Date:   Wed Mar 31 21:13:20 2010 -0800

    SQL for creating the new spatialite table complete---still needs the code to actually push it to the database

commit 0e05d6ab9904d003d9c7c7704f53392fc478cee1
Author: Gary Sherman <gsherman@geoapt.com>
Date:   Wed Mar 31 21:12:25 2010 -0800

    Added field for the layer name to be created

commit 3c372b4da3097981d824c2dbb7a661c916d9cf7b
Author: Gary Sherman <gsherman@Macintosh.local>
Date:   Tue Mar 30 21:39:10 2010 -0800

    Removed unneeded fields from the spatialite dialog (width and precision). Added methods for getting the attributes

commit 1871db18a5d87f22caf9a34001c879eaf7f58342
Author: Gary Sherman <gsherman@Macintosh.local>
Date:   Fri Mar 19 20:51:34 2010 -0800

    Renamed ui file

commit a42e578afac13d2a9e984faedc79d0d206b48c66
Author: Gary Sherman <gsherman@Macintosh.local>
Date:   Fri Mar 19 20:51:00 2010 -0800

    Added dialog for displaying and selecting a spatialite srid

commit d0c48bc2317d175fa13c4e52fb6d4f0b10a58518
Author: Gary Sherman <gsherman@Macintosh.local>
Date:   Fri Mar 19 19:41:07 2010 -0800

    More work on the dialog to create a new spatialite layer

commit cc6d8a4e48e42c865eec9da3d2ad1e900fbbe295
Author: Gary Sherman <gsherman@Macintosh.local>
Date:   Thu Mar 18 20:51:08 2010 -0800

    Wire the new spatialite layer dialog into qgisapp

commit c5a54601fd9b76e46aeb534f92a605cd744ae768
Author: Gary Sherman <gsherman@Macintosh.local>
Date:   Thu Mar 18 20:50:18 2010 -0800

    Dialog implementation for creating a new spatialite layer

git-svn-id: http://svn.osgeo.org/qgis/trunk@13240 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
gsherman 2010-04-05 02:32:06 +00:00
parent 868a157629
commit f36bfa5e39
14 changed files with 1449 additions and 8 deletions

View File

@ -1,5 +1,5 @@
INSTALL(FILES srs.db qgis.db qgis_help.db symbology-ng-style.xml
DESTINATION ${QGIS_DATA_DIR}/resources)
SUBDIRS(context_help)
INSTALL(FILES srs.db qgis.db qgis_help.db symbology-ng-style.xml spatialite.db
DESTINATION ${QGIS_DATA_DIR}/resources)
SUBDIRS(context_help)

View File

@ -0,0 +1,20 @@
<h3>Create a New Spatialite Layer</h3>
You can use this dialog to create a new Spatialite database and/or an empty Spatialite layer for editing. See below for an explanation of the dialog inputs.
<h4>Database</h4>
Choose the database from the drop-down list. This list is created from your saved Spatialite connections. If you don't have a saved connection or want to create a new database, click on the button (<label>...</label>) to the right of the drop-down. If you create a new database you will have to add it to your Spatialite connections in the <i>Add Spatialite Table(s)</i> dialog.
<h4>Layer name</h4>
Enter a name for the layer you want to create. The name should be one word. You can use underscores in the name if you like.
<h4>Geometry column</h4>
Enter a name for the geometry column or accept the default.
<h4>Type</h4>
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>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.
<h4>Attributes list</h4>
In this section you can see the list of attributes. To delete one of them, click on it and choose <label>Remove selected attribute</label> button.
<p>
To create the layer, click on <label>Apply</label>. The layer will be created and you will be returned to the dialog. From here you can click <label>Close</label> or change the parameters to create additional layers.

BIN
resources/spatialite.db Normal file

Binary file not shown.

View File

@ -24,6 +24,7 @@ SET(QGIS_APP_SRCS
qgsdelattrdialog.cpp
qgsdisplayangle.cpp
qgsfieldcalculator.cpp
qgsnewspatialitelayerdialog.cpp
qgsnewvectorlayerdialog.cpp
qgsgraduatedsymboldialog.cpp
qgshelpviewer.cpp
@ -58,6 +59,7 @@ SET(QGIS_APP_SRCS
qgsnewhttpconnection.cpp
qgsnumericsortlistviewitem.cpp
qgsoptions.cpp
qgsspatialitesridsdialog.cpp
qgspastetransformations.cpp
qgspointrotationitem.cpp
qgspluginitem.cpp
@ -143,6 +145,7 @@ SET (QGIS_APP_MOC_HDRS
qgsfieldcalculator.h
qgsformannotationdialog.h
qgsmaptoolmeasureangle.h
qgsnewspatialitelayerdialog.h
qgsnewvectorlayerdialog.h
qgsgraduatedsymboldialog.h
qgshelpviewer.h
@ -178,6 +181,7 @@ SET (QGIS_APP_MOC_HDRS
qgswmssourceselect.h
qgssinglesymboldialog.h
qgssnappingdialog.h
qgsspatialitesridsdialog.h
qgsuniquevaluedialog.h
qgsvectorlayerproperties.h
qgsdbtablemodel.h
@ -330,6 +334,7 @@ IF (WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(../core/spatialite/headers/spatialite)
ELSE (WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(${SQLITE3_INCLUDE_DIR})
ADD_DEFINITIONS(-DEXTERNAL_SPATIALITE)
ENDIF (WITH_INTERNAL_SPATIALITE)
IF (POSTGRES_FOUND)

View File

@ -214,6 +214,7 @@
#endif
#ifdef HAVE_SPATIALITE
#include "qgsspatialitesourceselect.h"
#include "qgsnewspatialitelayerdialog.h"
#endif
#include "qgspythonutils.h"
@ -936,11 +937,18 @@ void QgisApp::createActions()
// Layer Menu Items
mActionNewVectorLayer = new QAction( getThemeIcon( "mActionNewVectorLayer.png" ), tr( "New Vector Layer..." ), this );
shortcuts->registerAction( mActionNewVectorLayer, tr( "Ctrl+Shift+N", "Create a New Vector Layer" ) );
mActionNewVectorLayer->setStatusTip( tr( "Create a New Vector Layer" ) );
mActionNewVectorLayer = new QAction( getThemeIcon( "mActionNewVectorLayer.png" ), tr( "New Vector Layer (shapefile)..." ), this );
shortcuts->registerAction( mActionNewVectorLayer, tr( "Ctrl+Shift+N", "Create a New Vector Layer (shapefile)" ) );
mActionNewVectorLayer->setStatusTip( tr( "Create a New Vector Layer (shapefile)" ) );
connect( mActionNewVectorLayer, SIGNAL( triggered() ), this, SLOT( newVectorLayer() ) );
#ifdef HAVE_SPATIALITE
mActionNewSpatialiteLayer = new QAction( getThemeIcon( "mActionNewVectorLayer.png" ), tr( "New Spatialite Layer ..." ), this );
shortcuts->registerAction( mActionNewSpatialiteLayer, tr( "Ctrl+Shift+S", "Create a New Spatialite Layer " ) );
mActionNewSpatialiteLayer->setStatusTip( tr( "Create a New Spatialite Layer " ) );
connect( mActionNewSpatialiteLayer, SIGNAL( triggered() ), this, SLOT( newSpatialiteLayer() ) );
#endif
mActionAddOgrLayer = new QAction( getThemeIcon( "mActionAddOgrLayer.png" ), tr( "Add Vector Layer..." ), this );
shortcuts->registerAction( mActionAddOgrLayer, tr( "Ctrl+Shift+V", "Add a Vector Layer" ) );
mActionAddOgrLayer->setStatusTip( tr( "Add a Vector Layer" ) );
@ -1411,7 +1419,14 @@ void QgisApp::createMenus()
mLayerMenu = menuBar()->addMenu( tr( "&Layer" ) );
#ifdef HAVE_SPATIALITE
QMenu *newLayerMenu = mLayerMenu->addMenu( tr( "New ") );
newLayerMenu->addAction( mActionNewVectorLayer );
newLayerMenu->addAction( mActionNewSpatialiteLayer );
#else
mLayerMenu->addAction( mActionNewVectorLayer );
#endif
mLayerMenu->addAction( mActionAddOgrLayer );
mLayerMenu->addAction( mActionAddRasterLayer );
#ifdef HAVE_POSTGRESQL
@ -3082,6 +3097,213 @@ void QgisApp::newVectorLayer()
addVectorLayers( fileNames, enc, "file" );
}
void QgisApp::newSpatialiteLayer()
{
if ( mMapCanvas && mMapCanvas->isDrawing() )
{
return;
}
QgsNewSpatialiteLayerDialog spatialiteDialog( this );
if ( spatialiteDialog.exec() == QDialog::Rejected )
{
return;
}
QString geometrytype = spatialiteDialog.selectedType();
//QString fileformat = geomDialog.selectedFileFormat();
QString crsId = spatialiteDialog.selectedCrsId();
QString databaseName = spatialiteDialog.databaseName();
QString newLayerName = spatialiteDialog.layerName();
//QgsDebugMsg( QString( "New file format will be: %1" ).arg( fileformat ) );
// Get the list containing the name/type pairs for each attribute
QList<QStringList> * items = spatialiteDialog.attributes( );
// Build up the sql statement for creating the table
//
QString sql = QString("create table %1 (id integer primary key autoincrement").arg(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 )
{
QStringList field = items->at(i);
sql += QString(", %1 %2").arg(field.at(0)).arg(field.at(1));
}
// complete the create table statement
sql += ")";
std::cout << "Creating table in database " << databaseName.toUtf8().data() << std::endl;
std::cout << sql.toUtf8().data() << std::endl; // OK
QString sqlAddGeom = QString("select AddGeometryColumn('%1', 'geom', %2, '%3', 2)").arg(newLayerName).arg(crsId).arg(geometrytype);
std::cout << sqlAddGeom.toUtf8().data() << std::endl; // OK
QString sqlCreateIndex = QString("select CreateSpatialIndex('%1', 'geom')").arg(newLayerName);
std::cout << sqlCreateIndex.toUtf8().data() << std::endl; // OK
sqlite3 *db;
int rc = sqlite3_open( databaseName.toUtf8(), &db );
if ( rc != SQLITE_OK )
{
QMessageBox::warning( this, "Spatialite Database", tr( "Unable to open the database: %1").arg(databaseName ) );
}
else
{
char * errmsg;
rc = sqlite3_exec( db, sql.toUtf8(), NULL, NULL, &errmsg);
if ( rc != SQLITE_OK )
{
QMessageBox::warning( this, tr( "Error deleting bookmark" ),
tr( "Failed to create the Spatialite table %1. The database returned:\n%2" ).arg( newLayerName ).arg( errmsg ) );
sqlite3_free( errmsg );
}
else
{
// create the geometry column and the spatial index
rc = sqlite3_exec( db, sqlAddGeom.toUtf8(), NULL, NULL, &errmsg);
if ( rc != SQLITE_OK )
{
QMessageBox::warning( this, tr( "Error Creating Geometry Column" ),
tr( "Failed to create the geometry column. The database returned:\n%1" ).arg( errmsg ) );
sqlite3_free( errmsg );
}
else
{
// create the spatial index
rc = sqlite3_exec( db, sqlCreateIndex.toUtf8(), NULL, NULL, &errmsg);
if ( rc != SQLITE_OK )
{
QMessageBox::warning( this, tr( "Error Creating Spatial Index" ),
tr( "Failed to create the spatial index. The database returned:\n%1" ).arg( errmsg ) );
sqlite3_free( errmsg );
}
}
}
}
/*
bool haveLastUsedFilter = false; // by default, there is no last
// used filter
QString enc;
QString fileName;
QSettings settings; // where we keep last used filter in
// persistent state
haveLastUsedFilter = settings.contains( "/UI/lastVectorFileFilter" );
QString lastUsedFilter = settings.value( "/UI/lastVectorFileFilter",
QVariant( QString::null ) ).toString();
QString lastUsedDir = settings.value( "/UI/lastVectorFileFilterDir",
"." ).toString();
QgsDebugMsg( "Saving vector file dialog without filters: " );
QgsEncodingFileDialog* openFileDialog = new QgsEncodingFileDialog( this,
tr( "Save As" ), lastUsedDir, "", QString( "" ) );
// allow for selection of more than one file
openFileDialog->setFileMode( QFileDialog::AnyFile );
openFileDialog->setAcceptMode( QFileDialog::AcceptSave );
openFileDialog->setConfirmOverwrite( true );
if ( haveLastUsedFilter ) // set the filter to the last one used
{
openFileDialog->selectFilter( lastUsedFilter );
}
int res;
while (( res = openFileDialog->exec() ) == QDialog::Accepted )
{
fileName = openFileDialog->selectedFiles().first();
if ( fileformat == "ESRI Shapefile" )
{
if ( !isValidShapeFileName( fileName ) )
{
fileName += ".shp";
}
if ( !isValidShapeFileName( fileName ) )
{
QMessageBox::information( this,
tr( "New Shapefile" ),
tr( "Shapefiles must end on .shp" ) );
continue;
}
}
break;
}
if ( res == QDialog::Rejected )
{
delete openFileDialog;
return;
}
enc = openFileDialog->encoding();
// If the file exists, delete it otherwise we'll end up loading that
// file, which can cause problems (e.g., if the file contains
// linestrings, but we're wanting to create points, we'll end up
// with a linestring file).
if ( fileformat == "ESRI Shapefile" )
{
QgsVectorFileWriter::deleteShapeFile( fileName );
}
else
{
QFile::remove( fileName );
}
settings.setValue( "/UI/lastVectorFileFilter", openFileDialog->selectedFilter() );
settings.setValue( "/UI/lastVectorFileFilterDir", openFileDialog->directory().absolutePath() );
delete openFileDialog;
//try to create the new layer with OGRProvider instead of QgsVectorFileWriter
QgsProviderRegistry * pReg = QgsProviderRegistry::instance();
QString ogrlib = pReg->library( "ogr" );
// load the data provider
QLibrary* myLib = new QLibrary( ogrlib );
bool loaded = myLib->load();
if ( loaded )
{
QgsDebugMsg( "ogr provider loaded" );
typedef bool ( *createEmptyDataSourceProc )( const QString&, const QString&, const QString&, QGis::WkbType,
const std::list<std::pair<QString, QString> >&, const QgsCoordinateReferenceSystem * );
createEmptyDataSourceProc createEmptyDataSource = ( createEmptyDataSourceProc ) cast_to_fptr( myLib->resolve( "createEmptyDataSource" ) );
if ( createEmptyDataSource )
{
if ( geometrytype != QGis::WKBUnknown )
{
QgsCoordinateReferenceSystem srs( crsId, QgsCoordinateReferenceSystem::InternalCrsId );
createEmptyDataSource( fileName, fileformat, enc, geometrytype, attributes, &srs );
}
else
{
QgsDebugMsg( "geometry type not recognised" );
return;
}
}
else
{
QgsDebugMsg( "Resolving newEmptyDataSource(...) failed" );
}
}
//then add the layer to the view
QStringList fileNames;
fileNames.append( fileName );
//todo: the last parameter will change accordingly to layer type
addVectorLayers( fileNames, enc, "file" );
*/
}
void QgisApp::fileOpen()
{
if ( mMapCanvas && mMapCanvas->isDrawing() )

View File

@ -265,6 +265,7 @@ class QgisApp : public QMainWindow
QAction *actionViewSeparator3() { return mActionViewSeparator3; }
QAction *actionNewVectorLayer() { return mActionNewVectorLayer; }
QAction *actionNewSpatialLiteLayer() { return mActionNewSpatialiteLayer; }
QAction *actionAddOgrLayer() { return mActionAddOgrLayer; }
QAction *actionAddRasterLayer() { return mActionAddRasterLayer; }
QAction *actionAddPgLayer() { return mActionAddPgLayer; }
@ -488,6 +489,8 @@ class QgisApp : public QMainWindow
void fileNew( bool thePromptToSaveFlag );
//! Create a new empty vector layer
void newVectorLayer();
//! Create a new empty spatialite layer
void newSpatialiteLayer();
//! Print the current map view frame
void newPrintComposer();
void showComposerManager();
@ -859,6 +862,7 @@ class QgisApp : public QMainWindow
QAction *mActionAnnotation;
QAction *mActionNewVectorLayer;
QAction *mActionNewSpatialiteLayer;
QAction *mActionAddOgrLayer;
QAction *mActionAddRasterLayer;
QAction *mActionAddPgLayer;

View File

@ -0,0 +1,320 @@
/***************************************************************************
qgsnewspatialitelayerdialog.cpp
Creates a new Spatialite layer. This dialog borrows heavily from
qgsnewvectorlayerdialog.cpp
-------------------
begin : 2010-03-18
copyright : (C) 2010 by Gary Sherman
email : gsherman@mrcc.com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */
/*
extern "C"
{
#include <spatialite/sqlite3.h>
#include <spatialite/gaiageo.h>
#include <spatialite.h>
}
*/
#include "qgsnewspatialitelayerdialog.h"
#include "qgsspatialitesridsdialog.h"
#include "qgsapplication.h"
#include "qgisapp.h" // <- for theme icons
#include "qgslogger.h"
//#include <sqlite3.h>
#include <QPushButton>
#include <QSettings>
#include <QLineEdit>
#include <QMessageBox>
#include <QFileDialog>
QgsNewSpatialiteLayerDialog::QgsNewSpatialiteLayerDialog( QWidget *parent, Qt::WFlags fl )
: QDialog( parent, fl )
{
setupUi( this );
mAddAttributeButton->setIcon( QgisApp::getThemeIcon( "/mActionNewAttribute.png" ) );
mRemoveAttributeButton->setIcon( QgisApp::getThemeIcon( "/mActionDeleteAttribute.png" ) );
mTypeBox->addItem( tr( "Text data" ), "text" );
mTypeBox->addItem( tr( "Whole number" ), "integer" );
mTypeBox->addItem( tr( "Decimal number" ), "real" );
mPointRadioButton->setChecked( true );
// Populate the database list from the stored connections
QSettings settings;
settings.beginGroup( "/SpatiaLite/connections" );
QStringList keys = settings.childGroups();
QStringList::Iterator it = keys.begin();
mDatabaseComboBox->clear();
while ( it != keys.end() )
{
// retrieving the SQLite DB name and full path
//QString text = *it + tr( "@" );
QString text = settings.value( *it + "/sqlitepath", "###unknown###" ).toString();
mDatabaseComboBox->addItem( text );
++it;
}
settings.endGroup();
mApplyButton = buttonBox->button( QDialogButtonBox::Apply );
mApplyButton->setEnabled( false );
mApplyButton->setDefault( true );
connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) );
// Set the SRID box to a default of WGS84
leSRID->setText( "4326" );
// flag to indicate if we need to create a new db before adding a layer
needNewDb = false;
}
QgsNewSpatialiteLayerDialog::~QgsNewSpatialiteLayerDialog()
{
}
void QgsNewSpatialiteLayerDialog::createNewDb()
{
// QMessageBox::information( 0, tr( "Spatialite Layer" ), tr( "Create new db clicked" ) );
QString fileName = QFileDialog::getSaveFileName(this, tr("New Spatialite Database File"),
".",
tr("Spatialite (*.sqlite *.db )"));
if ( !fileName.isEmpty() )
{
mDatabaseComboBox->insertItem( 0, fileName );
mDatabaseComboBox->setCurrentIndex(0);
needNewDb = true;
}
}
void QgsNewSpatialiteLayerDialog::on_mTypeBox_currentIndexChanged( int index )
{
// This isn't used since widths are irrelevant in sqlite3
switch ( index )
{
case 0: // Text data
case 1: // Whole number
case 2: // Decimal number
default:
break;
}
}
QString QgsNewSpatialiteLayerDialog::selectedType() const
{
if ( mPointRadioButton->isChecked() )
{
return "POINT";
}
else if ( mLineRadioButton->isChecked() )
{
return "LINESTRING";
}
else if ( mPolygonRadioButton->isChecked() )
{
return "POLYGON";
}
else if ( mMultipointRadioButton->isChecked() )
{
return "MULTIPOINT";
}
else if ( mMultilineRadioButton->isChecked() )
{
return "MULTILINESTRING";
}
else if ( mMultipolygonRadioButton->isChecked() )
{
return "MULTIPOLYGON";
}
}
QString QgsNewSpatialiteLayerDialog::selectedCrsId() const
{
return leSRID->text();
}
void QgsNewSpatialiteLayerDialog::apply()
{
// Check to see if the db exists and if not create it
createDb();
// Init spatialite
spatialite_init( 0 );
QString newLayerName = leLayerName->text();
int rc = sqlite3_open_v2( mDatabaseComboBox->currentText().toUtf8(), &db, SQLITE_OPEN_READWRITE, NULL );
if ( rc != SQLITE_OK )
{
QMessageBox::warning( this, "Spatialite Database", tr( "Unable to open the database"));
}
else
{
char * errmsg;
QString sql = QString("CREATE TABLE %1 (id integer primary key autoincrement, name text)").arg( newLayerName );
rc = sqlite3_exec( db, sql.toUtf8(), NULL, NULL, &errmsg);
if ( rc != SQLITE_OK )
{
QMessageBox::warning( this, tr( "Error Creating Table" ),
tr( "Failed to create the Spatialite table. The database returned:\n%1" ).arg( errmsg ) );
sqlite3_free( errmsg );
}
else
{
// get the geometry type
QString geomType = selectedType();
// create the geometry column and the spatial index
sql = QString("select AddGeometryColumn('%1', 'geom', %2, '%3', 2)").arg( newLayerName ).arg( leSRID->text() ).arg( geomType );
rc = sqlite3_exec( db, sql.toUtf8(), NULL, NULL, &errmsg);
if ( rc != SQLITE_OK )
{
QMessageBox::warning( this, tr( "Error Creating Geometry Column" ),
tr( "Failed to create the geometry column. The database returned:\n%1" ).arg( errmsg ) );
sqlite3_free( errmsg );
}
else
{
// create the spatial index
sql = QString("select CreateSpatialIndex('%1', 'geom')").arg( newLayerName );
rc = sqlite3_exec( db, sql.toUtf8(), NULL, NULL, &errmsg);
if ( rc != SQLITE_OK )
{
QMessageBox::warning( this, tr( "Error Creating Spatial Index" ),
tr( "Failed to create the spatial index. The database returned:\n%1" ).arg( errmsg ) );
sqlite3_free( errmsg );
}
else
{
QMessageBox::information( 0, tr( "Spatialite Layer" ), tr( "Layer created" ) );
}
}
}
}
}
void QgsNewSpatialiteLayerDialog::on_leLayerName_textChanged( QString text )
{
if ( leLayerName->text().length() > 0 && mAttributeView->topLevelItemCount() > 0)
{
mApplyButton->setEnabled( true );
}
}
void QgsNewSpatialiteLayerDialog::on_mAddAttributeButton_clicked()
{
if ( mNameEdit->text().length() > 0 )
{
QString myName = mNameEdit->text();
//use userrole to avoid translated type string
QString myType = mTypeBox->itemData( mTypeBox->currentIndex(), Qt::UserRole ).toString();
mAttributeView->addTopLevelItem( new QTreeWidgetItem( QStringList() << myName << myType ) );
if ( mAttributeView->topLevelItemCount() > 0 && leLayerName->text().length() > 0 )
{
mApplyButton->setEnabled( true );
}
mNameEdit->clear();
}
}
void QgsNewSpatialiteLayerDialog::on_mRemoveAttributeButton_clicked()
{
delete mAttributeView->currentItem();
if ( mAttributeView->topLevelItemCount() == 0 )
{
mApplyButton->setEnabled( false );
}
}
void QgsNewSpatialiteLayerDialog::on_pbnFindSRID_clicked()
{
/* hold on to this for a bit
int rc = sqlite3_open( mDatabaseComboBox->currentText().toUtf8().data(), &db );
if ( rc != SQLITE_OK )
{
QMessageBox::warning( this, "Spatialite Database", tr( "Unable to open the database: %1").arg(mDatabaseComboBox->currentText() ) );
}
*/
// set the SRID from a list returned from the selected Spatialite database
QgsSpatialiteSridsDialog *sridDlg = new QgsSpatialiteSridsDialog(this);
if ( sridDlg->load( mDatabaseComboBox->currentText() ) )
{
if ( sridDlg->exec() )
{
// set the srid field to the selection
sridDlg->selectedSrid();
leSRID->setText( sridDlg->selectedSrid() );
sridDlg->accept();
}
}
}
// Create a QList of QStringList objects that define the layer attributes.
// Each QStringList contains the field name and its type.
QList<QStringList> * QgsNewSpatialiteLayerDialog::attributes() const
{
QTreeWidgetItemIterator it( mAttributeView );
QList<QStringList> *list = new QList<QStringList>;
while ( *it )
{
QTreeWidgetItem *item = *it;
QStringList items;
items << item->text( 0 );
items << item->text( 1 );
list->append(items);
//QString type = QString( "%1;%2;%3" ).arg( item->text( 1 ) ).arg( item->text( 2 ) ).arg( item->text( 3 ) );
//at.push_back( std::make_pair( item->text( 0 ), type ) );
//QgsDebugMsg( QString( "appending %1//%2" ).arg( item->text( 0 ) ).arg( type ) );
++it;
}
return list;
}
QString QgsNewSpatialiteLayerDialog::databaseName() const
{
return mDatabaseComboBox->currentText();
}
QString QgsNewSpatialiteLayerDialog::layerName() const
{
return leLayerName->text();
}
bool QgsNewSpatialiteLayerDialog::createDb()
{
QFile newDb( mDatabaseComboBox->currentText() );
if ( !newDb.exists() )
{
qWarning( "creating a new db" );
// copy the spatilite template to the user specified path
QString spatialiteTemplate = QgsApplication::qgisSpatialiteDbTemplatePath();
QFile spatialiteTemplateDb( spatialiteTemplate );
QFileInfo fullPath = QFileInfo( mDatabaseComboBox->currentText() );
QDir path = fullPath.dir();
qWarning("making this dir: %s", path.absolutePath().toUtf8().data());
// Must be sure there is destination directory ~/.qgis
QDir().mkpath( path.absolutePath( ) );
qWarning("Copying %s ", spatialiteTemplate.toUtf8().data());
qWarning("to %s", newDb.fileName().toUtf8().data());
//now copy the template db file into the chosen location
bool isDbFileCopied = spatialiteTemplateDb.copy( newDb.fileName() );
if ( !isDbFileCopied )
{
// QMessageBox::warning( this, "Spatialite Database", tr( "Unable to copy the template database to your new location" ));
return false;
}
}
return true;
}

View File

@ -0,0 +1,70 @@
/***************************************************************************
QgsNewSpatialiteLayerDialog.h - description
-------------------
begin : 2010-03-19
copyright : (C) 2010 by Gary Sherman
email : gsherman@mrcc.com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */
#ifndef qgsnewspatialitelayerdialog_H
#define qgsnewspatialitelayerdialog_H
#include <sqlite3.h>
extern "C"
{
#include <spatialite/headers/spatialite.h>
}
//#include <sqlite3.h>
#include "ui_qgsnewspatialitelayerdialogbase.h"
#include "qgisgui.h"
#include "qgscontexthelp.h"
#include "qgis.h"
class QgsNewSpatialiteLayerDialog: public QDialog, private Ui::QgsNewSpatialiteLayerDialogBase
{
Q_OBJECT
public:
QgsNewSpatialiteLayerDialog( QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags );
~QgsNewSpatialiteLayerDialog();
/**Returns the selected geometry type*/
QString selectedType() const;
/**Appends the chosen attribute names and types to at*/
//void attributes( std::list<std::pair<QString, QString> >& at ) const;
QList<QStringList> * attributes() const;
/**Returns the database name */
QString databaseName() const;
/**Returns the layer name to be created */
QString layerName() const;
/**Returns the selected crs id*/
QString selectedCrsId() const;
/** Create a new database */
bool createDb();
protected slots:
void on_mAddAttributeButton_clicked();
void on_mRemoveAttributeButton_clicked();
void on_mTypeBox_currentIndexChanged( int index );
void on_pbnFindSRID_clicked();
void on_leLayerName_textChanged( QString text );
void createNewDb();
void apply();
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
private:
QPushButton *mApplyButton;
int mCrsId;
sqlite3 *db;
bool needNewDb;
};
#endif //qgsnewvectorlayerdialog_H

View File

@ -0,0 +1,119 @@
#include <QMessageBox>
#include "qgsspatialitesridsdialog.h"
QgsSpatialiteSridsDialog::QgsSpatialiteSridsDialog( QWidget *parent, Qt::WFlags fl )
: QDialog( parent, fl )
{
setupUi( this );
db = 0;
pbnFilter->setDefault( true );
leSearch->setFocus();
}
QgsSpatialiteSridsDialog::~QgsSpatialiteSridsDialog()
{
sqlite3_close( db );
}
QString QgsSpatialiteSridsDialog::selectedSrid()
{
return twSrids->currentItem()->text(0);
}
bool QgsSpatialiteSridsDialog::load(QString dbName)
{
mDbName = dbName;
bool status = true;
if ( !db )
{
int rc = sqlite3_open_v2( dbName.toUtf8(), &db, SQLITE_OPEN_READONLY, NULL );
if ( rc != SQLITE_OK )
{
QMessageBox::warning( this, "Spatialite Database", tr( "Unable to open the database"));
return false;
}
}
// load up the srid table
// prepare the sql statement
const char *pzTail;
sqlite3_stmt *ppStmt;
QString sql = "select auth_srid, auth_name, ref_sys_name from spatial_ref_sys order by srid asc";
int rc = sqlite3_prepare( db, sql.toUtf8(), sql.toUtf8().length(), &ppStmt, &pzTail );
// XXX Need to free memory from the error msg if one is set
if ( rc == SQLITE_OK )
{
// get the first row of the result set
while ( sqlite3_step( ppStmt ) == SQLITE_ROW )
{
QTreeWidgetItem *item = new QTreeWidgetItem( twSrids );
// srid
item->setText (0, QString::fromUtf8(( const char * )sqlite3_column_text( ppStmt, 0 ) ) );
item->setText (1, QString::fromUtf8(( const char * )sqlite3_column_text( ppStmt, 1 ) ) );
// name
item->setText( 2, QString::fromUtf8(( const char * )sqlite3_column_text( ppStmt, 2 ) ) );
// proj4 text
item->setText( 3, QString::fromUtf8(( const char * )sqlite3_column_text( ppStmt, 3 ) ) );
}
twSrids->sortByColumn( 0, Qt::AscendingOrder );
}
else
{
// XXX query failed -- warn the user some how
QMessageBox::warning(0, "Error", QString( "Failed to load SRIDS: %1" ).arg( sqlite3_errmsg( db ) ) );
status = false;
}
// close the statement
sqlite3_finalize( ppStmt );
return status;
}
void QgsSpatialiteSridsDialog::on_pbnFilter_clicked()
{
if ( leSearch->text().length() == 0 )
{
load( mDbName );
}
else
{
const char *pzTail;
sqlite3_stmt *ppStmt;
QString search;
if ( radioButtonSrid->isChecked() )
{
search = "srid";
}
else
{
search = "ref_sys_name";
}
QString sql = QString("select auth_srid, auth_name, ref_sys_name from spatial_ref_sys where %1 like '%").arg(search) + leSearch->text() + QString("%' order by srid asc");
//QMessageBox::information(0, "Sql", sql);
int rc = sqlite3_prepare( db, sql.toUtf8(), sql.toUtf8().length(), &ppStmt, &pzTail );
// XXX Need to free memory from the error msg if one is set
if ( rc == SQLITE_OK )
{
// clear the display
twSrids->clear();
// get the first row of the result set
while ( sqlite3_step( ppStmt ) == SQLITE_ROW )
{
QTreeWidgetItem *item = new QTreeWidgetItem( twSrids );
// srid
item->setText (0, QString::fromUtf8(( const char * )sqlite3_column_text( ppStmt, 0 ) ) );
item->setText (1, QString::fromUtf8(( const char * )sqlite3_column_text( ppStmt, 1 ) ) );
// name
item->setText( 2, QString::fromUtf8(( const char * )sqlite3_column_text( ppStmt, 2 ) ) );
// proj4 text
item->setText( 3, QString::fromUtf8(( const char * )sqlite3_column_text( ppStmt, 3 ) ) );
}
twSrids->sortByColumn( 0, Qt::AscendingOrder );
}
else
{
// XXX query failed -- warn the user some how
QMessageBox::warning(0, "Error", QString( "Failed to load SRIDS: %1" ).arg( sqlite3_errmsg( db ) ) );
}
// close the statement
sqlite3_finalize( ppStmt );
}
}

View File

@ -0,0 +1,42 @@
/***************************************************************************
QgsSpatialiteSridsDialog.h - Dialog for selecting an
SRID from a Spatialite spatial_ref_sys table
-------------------
begin : 2010-04-03
copyright : (C) 2010 by Gary Sherman
email : gsherman@geoapt.com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */
#ifndef QgsSpatialiteSridsDialog_H
#define QgsSpatialiteSridsDialog_H
#include "ui_qgsspatialitesridsdialogbase.h"
#include "qgisgui.h"
#include "qgscontexthelp.h"
#include "qgis.h"
#include <sqlite3.h>
class QgsSpatialiteSridsDialog: public QDialog, private Ui::QgsSpatialiteSridsDialogBase
{
Q_OBJECT
public:
QgsSpatialiteSridsDialog( QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags);
~QgsSpatialiteSridsDialog();
bool load(QString dbName);
QString selectedSrid();
public slots:
void on_pbnFilter_clicked();
private:
sqlite3 *db;
QString mDbName;
};
#endif //QgsSpatialiteSridsDialog_H

View File

@ -269,6 +269,14 @@ const QString QgsApplication::qgisMasterDbFilePath()
return mPkgDataPath + QString( "/resources/qgis.db" );
}
/*!
Returns the path to the spatialite template db file.
*/
const QString QgsApplication::qgisSpatialiteDbTemplatePath()
{
return mPkgDataPath + QString( "/resources/spatialite.db" );
}
/*!
Returns the path to the settings directory in user's home dir
*/

View File

@ -89,6 +89,9 @@ class CORE_EXPORT QgsApplication: public QApplication
//! Returns the path to the master qgis.db file.
static const QString qgisMasterDbFilePath();
//! Returns the path to the spatialite template db file.
static const QString qgisSpatialiteDbTemplatePath();
//! Returns the path to the settings directory in user's home dir
static const QString qgisSettingsDirPath();

View File

@ -0,0 +1,478 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QgsNewSpatialiteLayerDialogBase</class>
<widget class="QDialog" name="QgsNewSpatialiteLayerDialogBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>411</width>
<height>593</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>351</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>New Spatialite Layer</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="mFileFormatLabel">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Database</string>
</property>
<property name="buddy">
<cstring>mDatabaseComboBox</cstring>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="mDatabaseComboBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonNewDatabase">
<property name="toolTip">
<string>Create a new Spatialite database</string>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Layer name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leLayerName">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Name for the new layer</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Geometry column</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leGeometryColumn">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Name for the new layer</string>
</property>
<property name="text">
<string>geometry</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="buttonGroup1">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Type</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QRadioButton" name="mPointRadioButton">
<property name="text">
<string>Point</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="mLineRadioButton">
<property name="text">
<string>Line</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QRadioButton" name="mPolygonRadioButton">
<property name="text">
<string>Polygon</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="mMultipointRadioButton">
<property name="text">
<string>MultiPoint</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="mMultilineRadioButton">
<property name="text">
<string>Multiline</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QRadioButton" name="mMultipolygonRadioButton">
<property name="text">
<string>Multipolygon</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>EPSG SRID</string>
</property>
<property name="buddy">
<cstring>leSRID</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leSRID">
<property name="toolTip">
<string>Spatial Reference Id</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbnFindSRID">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Specify the coordinate reference system of the layer's geometry.</string>
</property>
<property name="whatsThis">
<string>Specify the coordinate reference system of the layer's geometry.</string>
</property>
<property name="text">
<string>Find SRID</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>New attribute</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="textLabel1">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Name</string>
</property>
<property name="buddy">
<cstring>mNameEdit</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="mNameEdit">
<property name="toolTip">
<string>An attribute name</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="textLabel2">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Type</string>
</property>
<property name="buddy">
<cstring>mTypeBox</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="mTypeBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="6" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Attributes list</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0" colspan="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="mAddAttributeButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Add attribute to list</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Add to attributes list</string>
</property>
<property name="icon">
<iconset>
<normaloff>../../images/themes/default/mActionNewAttribute.png</normaloff>../../images/themes/default/mActionNewAttribute.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QTreeWidget" name="mAttributeView">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="columnCount">
<number>2</number>
</property>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Type</string>
</property>
</column>
</widget>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1" colspan="2">
<widget class="QToolButton" name="mRemoveAttributeButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Delete selected attribute</string>
</property>
<property name="text">
<string>Remove selected attribute</string>
</property>
<property name="icon">
<iconset>
<normaloff>../../images/themes/default/mActionDeleteAttribute.png</normaloff>../../images/themes/default/mActionDeleteAttribute.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="7" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Close|QDialogButtonBox::Help</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<tabstops>
<tabstop>mDatabaseComboBox</tabstop>
<tabstop>mPointRadioButton</tabstop>
<tabstop>mLineRadioButton</tabstop>
<tabstop>mPolygonRadioButton</tabstop>
<tabstop>mNameEdit</tabstop>
<tabstop>mTypeBox</tabstop>
<tabstop>mAttributeView</tabstop>
<tabstop>mRemoveAttributeButton</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QgsNewSpatialiteLayerDialogBase</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>355</x>
<y>568</y>
</hint>
<hint type="destinationlabel">
<x>387</x>
<y>304</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QgsNewSpatialiteLayerDialogBase</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>281</x>
<y>568</y>
</hint>
<hint type="destinationlabel">
<x>242</x>
<y>308</y>
</hint>
</hints>
</connection>
<connection>
<sender>toolButtonNewDatabase</sender>
<signal>clicked()</signal>
<receiver>QgsNewSpatialiteLayerDialogBase</receiver>
<slot>createNewDb()</slot>
<hints>
<hint type="sourcelabel">
<x>403</x>
<y>28</y>
</hint>
<hint type="destinationlabel">
<x>52</x>
<y>39</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>createNewDb()</slot>
</slots>
</ui>

View File

@ -0,0 +1,150 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QgsSpatialiteSridsDialogBase</class>
<widget class="QDialog" name="QgsSpatialiteSridsDialogBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>601</width>
<height>332</height>
</rect>
</property>
<property name="windowTitle">
<string>Select a Spatialite Spatial Reference System</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" colspan="2">
<widget class="QTreeWidget" name="twSrids">
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="columnCount">
<number>3</number>
</property>
<column>
<property name="text">
<string>SRID</string>
</property>
</column>
<column>
<property name="text">
<string>Authority</string>
</property>
</column>
<column>
<property name="text">
<string>Reference Name</string>
</property>
</column>
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Search</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leSearch"/>
</item>
<item>
<widget class="QPushButton" name="pbnFilter">
<property name="text">
<string>Filter</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="1">
<widget class="QGroupBox" name="groupBox">
<property name="minimumSize">
<size>
<width>160</width>
<height>26</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QRadioButton" name="radioButtonSrid">
<property name="text">
<string>SRID</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radioButtonName">
<property name="text">
<string>Name</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Close|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<tabstops>
<tabstop>twSrids</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QgsSpatialiteSridsDialogBase</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>217</x>
<y>327</y>
</hint>
<hint type="destinationlabel">
<x>274</x>
<y>256</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>clicked(QAbstractButton*)</signal>
<receiver>QgsSpatialiteSridsDialogBase</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>378</x>
<y>308</y>
</hint>
<hint type="destinationlabel">
<x>452</x>
<y>295</y>
</hint>
</hints>
</connection>
</connections>
</ui>