From e24ccb885a3fd4109b0b797296590fbcee0aeccb Mon Sep 17 00:00:00 2001 From: jef Date: Tue, 20 Apr 2010 19:17:41 +0000 Subject: [PATCH] allow creation of multiple layers in spatialite creation dialog git-svn-id: http://svn.osgeo.org/qgis/trunk@13337 c8812cc2-4d05-0410-92ff-de0c093fc19c --- .../QgsNewSpatialiteLayerDialog-de_DE | 29 ++ .../QgsNewSpatialiteLayerDialog-en_US | 4 +- src/app/qgisapp.cpp | 127 +------- src/app/qgsnewspatialitelayerdialog.cpp | 283 ++++++++++++------ src/app/qgsnewspatialitelayerdialog.h | 42 ++- src/ui/qgsnewspatialitelayerdialogbase.ui | 33 +- 6 files changed, 250 insertions(+), 268 deletions(-) create mode 100644 resources/context_help/QgsNewSpatialiteLayerDialog-de_DE diff --git a/resources/context_help/QgsNewSpatialiteLayerDialog-de_DE b/resources/context_help/QgsNewSpatialiteLayerDialog-de_DE new file mode 100644 index 00000000000..2d21ec5593d --- /dev/null +++ b/resources/context_help/QgsNewSpatialiteLayerDialog-de_DE @@ -0,0 +1,29 @@ +

Einen neuen SpatiaLite-Layer erzeugen

+In diesem Dialog können Sie eine neue SpatiaLite-Datenbank und/oder einen leeren SpatiaLite Layer zur Bearbeitung erzeugen. Unten werden die Eingabemöglichkeiten des Dialogs beschrieben. +

Datenbank

+Wählen Sie die Datenbank aus der Liste. Diese Liste wird aus den gespeicherten +SpatiaLite-Verbindungen erzeugt. Wenn sie keine gespeicherten Verbindungen +haben oder oder eine neue Datenbank erzeugen wollen Klicken Sie auf + rechts der Liste. +

Layername

+Geben Sie dem Layer, den Sie erzeugen wollen, einen Namen. Der Name sollte nur ein Wort sein. Wenn Sie wollen, können Sie auch Unterstriche verwenden +

Geometriespalte

+Geben Sie der Geometriespalte einen Namen oder übernehmen Sie die Voreinstellung. +

Typ

+Legen Sie den Layertyp fest, den Sie erzeugen wollen. +

EPSG-SRID

+Geben Sie einen EPSG-Code für die SRID (räumliche Bezugskennung) an. Für die SRID wird Ihnen WGS 84 vorgeschlagen. +Klicken Sie auf den Knopf um das Koordinatenbezugssystem ggf. zu ändern. +Die SRID muss in der Tabelle spatial_ref_sys in Ihre Datenbank existieren. Sie können SRIDs suchen indem Sie Suchbegriffe verwenden, die +ganz oder teilweise zu Namen oder SRIDs passen. +

Einen automatisch inkrementierenden Primärschlüssel erzeugen

+Das Anwählen dieses Kontrolkästchen fügt dem Layer einen Primärschlüssel hinzu. Diese Feld wird automatisch inkrementiert, sodaß Sie keinen +keinen Wert dafür beim Hinzufügen von Objekten zum Layer eingeben müssen. +

Neues Attribute

+Fügen Sie die gewünschten Attribute durch Klicken auf den Knopf nachdem Sie Namen und Type des Attributes festgelegt haben. Nur Fließkomma-, ganzzahlige und Zeichenkettenattribute werden unterstützt.
+Breite und Genauigkeit sind irrelevant in einer SpatiaLite-Datenbank, daher brauchen Sie sie nicht anzugeben. +

Attributliste

+In diesem Abschnitt sehen Sie die Attributliste. Um eins davon zu löschen, klicken Sie auf den Knopf . + +

+Klicken Sie auf um den Layer anzulegen und den Dialog zu schließen. Ein Klick auf erzeugt den Layer auch, aber hält den Dialog auf und erlaubt so mehr ähnliche Layer zu erzeugen. schließt den Dialog ohne weitere Änderung. diff --git a/resources/context_help/QgsNewSpatialiteLayerDialog-en_US b/resources/context_help/QgsNewSpatialiteLayerDialog-en_US index decb2e8ed74..cb9fc3d4a34 100644 --- a/resources/context_help/QgsNewSpatialiteLayerDialog-en_US +++ b/resources/context_help/QgsNewSpatialiteLayerDialog-en_US @@ -1,7 +1,7 @@

Create a New Spatialite Layer

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.

Database

-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 () 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 Add Spatialite Table(s) dialog. +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 () to the right of the drop-down.

Layer name

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.

Geometry column

@@ -19,4 +19,4 @@ Width and precision are irrelevant in a Spatialite database so you do not have t In this section you can see the list of attributes. To delete one of them, click on it and choose button.

-To create the layer, click on . The layer will be created and you will be returned to the dialog. From here you can click or change the parameters to create additional layers. +Click on to create the layer and close the dialog. Clicking also creates the layer, but keeps the dialog open, thereby allowing you to create more similar layers. will close the layer without further changes. diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 888003feac3..f47a79ab771 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -3098,18 +3098,6 @@ void QgisApp::newVectorLayer() addVectorLayers( fileNames, enc, "file" ); } -static QString quotedIdentifier( QString id ) -{ - id.replace( "\"", "\"\"" ); - return id.prepend( "\"" ).append( "\"" ); -} - -static QString quotedValue( QString value ) -{ - value.replace( "'", "''" ); - return value.prepend( "'" ).append( "'" ); -} - #ifdef HAVE_SPATIALITE void QgisApp::newSpatialiteLayer() { @@ -3118,120 +3106,7 @@ void QgisApp::newSpatialiteLayer() 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(); - QString newGeometryColumn = spatialiteDialog.geometryColumn(); - //QgsDebugMsg( QString( "New file format will be: %1" ).arg( fileformat ) ); - - // Get the list containing the name/type pairs for each attribute - QList * items = spatialiteDialog.attributes( ); - - // Build up the sql statement for creating the table - // - 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 ) - { - QStringList field = items->at( i ); - if ( i > 0 ) - sql += ","; - sql += QString( "%1 %2" ).arg( quotedIdentifier( field.at( 0 ) ) ).arg( field.at( 1 ) ); - } - // complete the create table statement - sql += ")"; - QgsDebugMsg( QString( "Creating table in database %1" ).arg( databaseName ) ); - QgsDebugMsg( sql ); // OK - - QString sqlAddGeom = QString( "select AddGeometryColumn(%1,%2,%3,%4,2)" ) - .arg( quotedValue( newLayerName ) ) - .arg( quotedValue( newGeometryColumn ) ) - .arg( crsId ) - .arg( quotedValue( geometrytype ) ); - QgsDebugMsg( sqlAddGeom ); // OK - - QString sqlCreateIndex = QString( "select CreateSpatialIndex(%1,%2)" ).arg( quotedValue( newLayerName ) ).arg( quotedValue( newGeometryColumn ) ); - QgsDebugMsg( sqlCreateIndex ); // OK - - spatialite_init( 0 ); - - sqlite3 *db; - int rc = sqlite3_open( databaseName.toUtf8(), &db ); - if ( rc != SQLITE_OK ) - { - QMessageBox::warning( this, - tr( "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 Creating SpatiaLite Table" ), - 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 ); - } - - QgsVectorLayer *layer = new QgsVectorLayer( QString( "dbname='%1' table='%2'(%3) sql=" ) - .arg( databaseName ) - .arg( newLayerName ) - .arg( newGeometryColumn ), newLayerName, "spatialite" ); - if ( layer->isValid() ) - { - // register this layer with the central layers registry - QgsMapLayerRegistry::instance()->addMapLayer( layer ); - } - else - { - QgsDebugMsg( newLayerName + " is an invalid layer - not loaded" ); - QMessageBox::critical( this, tr( "Invalid Layer" ), tr( "%1 is an invalid layer and cannot be loaded." ).arg( newLayerName ) ); - delete layer; - } - } - } - } + spatialiteDialog.exec(); } #endif diff --git a/src/app/qgsnewspatialitelayerdialog.cpp b/src/app/qgsnewspatialitelayerdialog.cpp index 75f92343d8a..debd469de38 100644 --- a/src/app/qgsnewspatialitelayerdialog.cpp +++ b/src/app/qgsnewspatialitelayerdialog.cpp @@ -24,6 +24,9 @@ #include "qgsspatialitesridsdialog.h" #include "qgsapplication.h" #include "qgisapp.h" // <- for theme icons +#include +#include + #include "qgslogger.h" #include @@ -32,7 +35,7 @@ #include #include - +#include QgsNewSpatialiteLayerDialog::QgsNewSpatialiteLayerDialog( QWidget *parent, Qt::WFlags fl ) : QDialog( parent, fl ) @@ -54,42 +57,28 @@ QgsNewSpatialiteLayerDialog::QgsNewSpatialiteLayerDialog( QWidget *parent, Qt::W 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(); - mOkButton = buttonBox->button( QDialogButtonBox::Ok ); - mOkButton->setEnabled( false ); - mOkButton->setDefault( true ); + + buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false ); + buttonBox->button( QDialogButtonBox::Apply )->setEnabled( false ); + + connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) ); + + buttonBox->button( QDialogButtonBox::Ok )->setDefault( true ); // 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; + pbnFindSRID->setEnabled( mDatabaseComboBox->count() ); } 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 ); - createDb(); - needNewDb = true; - } -} void QgsNewSpatialiteLayerDialog::on_mTypeBox_currentIndexChanged( int index ) { // This isn't used since widths are irrelevant in sqlite3 @@ -103,6 +92,20 @@ void QgsNewSpatialiteLayerDialog::on_mTypeBox_currentIndexChanged( int index ) } } +void QgsNewSpatialiteLayerDialog::on_toolButtonNewDatabase_clicked() +{ + QString fileName = QFileDialog::getSaveFileName( this, tr( "New SpatiaLite Database File" ), + ".", + tr( "SpatiaLite (*.sqlite *.db )" ) ); + + if ( fileName.isEmpty() ) + return; + + mDatabaseComboBox->insertItem( 0, fileName ); + mDatabaseComboBox->setCurrentIndex( 0 ); + createDb(); +} + QString QgsNewSpatialiteLayerDialog::selectedType() const { if ( mPointRadioButton->isChecked() ) @@ -134,17 +137,11 @@ QString QgsNewSpatialiteLayerDialog::selectedType() const return ""; } -QString QgsNewSpatialiteLayerDialog::selectedCrsId() const -{ - return leSRID->text(); -} - void QgsNewSpatialiteLayerDialog::on_leLayerName_textChanged( QString text ) { - if ( leLayerName->text().length() > 0 && mAttributeView->topLevelItemCount() > 0 ) - { - mOkButton->setEnabled( true ); - } + bool created = leLayerName->text().length() > 0 && mAttributeView->topLevelItemCount() > 0 && createDb(); + buttonBox->button( QDialogButtonBox::Ok )->setEnabled( created ); + buttonBox->button( QDialogButtonBox::Apply )->setEnabled( created ); } void QgsNewSpatialiteLayerDialog::on_mAddAttributeButton_clicked() @@ -157,7 +154,9 @@ void QgsNewSpatialiteLayerDialog::on_mAddAttributeButton_clicked() mAttributeView->addTopLevelItem( new QTreeWidgetItem( QStringList() << myName << myType ) ); if ( mAttributeView->topLevelItemCount() > 0 && leLayerName->text().length() > 0 ) { - mOkButton->setEnabled( true ); + bool created = createDb(); + buttonBox->button( QDialogButtonBox::Ok )->setEnabled( created ); + buttonBox->button( QDialogButtonBox::Apply )->setEnabled( created ); } mNameEdit->clear(); } @@ -168,19 +167,13 @@ void QgsNewSpatialiteLayerDialog::on_mRemoveAttributeButton_clicked() delete mAttributeView->currentItem(); if ( mAttributeView->topLevelItemCount() == 0 ) { - mOkButton->setEnabled( false ); + buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false ); + buttonBox->button( QDialogButtonBox::Apply )->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, tr( "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() ) ) @@ -195,78 +188,190 @@ void QgsNewSpatialiteLayerDialog::on_pbnFindSRID_clicked() } } -// Create a QList of QStringList objects that define the layer attributes. -// Each QStringList contains the field name and its type. -QList * QgsNewSpatialiteLayerDialog::attributes() const -{ - QTreeWidgetItemIterator it( mAttributeView ); - QList *list = new QList; - 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(); -} - -QString QgsNewSpatialiteLayerDialog::geometryColumn() const -{ - return leGeometryColumn->text(); -} - -bool QgsNewSpatialiteLayerDialog::includePrimaryKey() const -{ - return checkBoxPrimaryKey->isChecked(); -} - bool QgsNewSpatialiteLayerDialog::createDb() { + QSettings settings; + + if ( mDatabaseComboBox->currentText().isEmpty() ) + return false; + QFile newDb( mDatabaseComboBox->currentText() ); if ( !newDb.exists() ) { - qWarning( "creating a new db" ); + QgsDebugMsg( "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() ); + QgsDebugMsg( QString( "making this dir: %1" ).arg( path.absolutePath() ) ); // 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() ); + QgsDebugMsg( QString( "Copying %1 to %2" ).arg( spatialiteTemplate ).arg( newDb.fileName() ) ); //now copy the template db file into the chosen location if ( !spatialiteTemplateDb.copy( newDb.fileName() ) ) { QMessageBox::warning( 0, tr( "SpatiaLite Database" ), tr( "Could not copy the template database to new location" ) ); + pbnFindSRID->setEnabled( false ); return false; } + } + + QFileInfo fi( newDb ); + if ( !fi.exists() ) + { + pbnFindSRID->setEnabled( false ); + return false; + } + + QString key = "/SpatiaLite/connections/" + fi.fileName() + "/sqlitepath"; + + if ( !settings.contains( key ) ) + { + settings.setValue( "/SpatiaLite/connections/selected", fi.fileName() ); + settings.setValue( key, fi.canonicalFilePath() ); + + QMessageBox::information( 0, tr( "SpatiaLite Database" ), tr( "Registered new database!" ) ); + } + + pbnFindSRID->setEnabled( true ); + + return true; +} + +void QgsNewSpatialiteLayerDialog::on_buttonBox_accepted() +{ + if ( apply() ) + accept(); +} + +void QgsNewSpatialiteLayerDialog::on_buttonBox_rejected() +{ + reject(); +} + +bool QgsNewSpatialiteLayerDialog::apply() +{ + // Build up the sql statement for creating the table + QString sql = QString( "create table %1(" ).arg( quotedIdentifier( leLayerName->text() ) ); + QString delim = ""; + + if ( checkBoxPrimaryKey->isChecked() ) + { + sql += "pkuid integer primary key autoincrement,"; + } + + QTreeWidgetItemIterator it( mAttributeView ); + while ( *it ) + { + sql += delim + QString( "%1 %2" ).arg( quotedIdentifier(( *it )->text( 0 ) ) ).arg(( *it )->text( 1 ) ); + + delim = ","; + + ++it; + } + + // complete the create table statement + sql += ")"; + + QgsDebugMsg( QString( "Creating table in database %1" ).arg( mDatabaseComboBox->currentText() ) ); + + QgsDebugMsg( sql ); // OK + + QString sqlAddGeom = QString( "select AddGeometryColumn(%1,%2,%3,%4,2)" ) + .arg( quotedValue( leLayerName->text() ) ) + .arg( quotedValue( leGeometryColumn->text() ) ) + .arg( leSRID->text().toInt() ) + .arg( quotedValue( selectedType() ) ); + QgsDebugMsg( sqlAddGeom ); // OK + + QString sqlCreateIndex = QString( "select CreateSpatialIndex(%1,%2)" ) + .arg( quotedValue( leLayerName->text() ) ) + .arg( quotedValue( leGeometryColumn->text() ) ); + QgsDebugMsg( sqlCreateIndex ); // OK + + spatialite_init( 0 ); + + sqlite3 *db; + int rc = sqlite3_open( mDatabaseComboBox->currentText().toUtf8(), &db ); + if ( rc != SQLITE_OK ) + { + QMessageBox::warning( this, + tr( "SpatiaLite Database" ), + tr( "Unable to open the database: %1" ).arg( mDatabaseComboBox->currentText() ) ); + } + else + { + char * errmsg; + rc = sqlite3_exec( db, sql.toUtf8(), NULL, NULL, &errmsg ); + if ( rc != SQLITE_OK ) + { + QMessageBox::warning( this, + tr( "Error Creating SpatiaLite Table" ), + tr( "Failed to create the SpatiaLite table %1. The database returned:\n%2" ).arg( leLayerName->text() ).arg( errmsg ) ); + sqlite3_free( errmsg ); + } else { - QMessageBox::information( 0, tr( "SpatiaLite Database" ), tr( "Created new database!" ) ); + // 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 ); + } + + QgsVectorLayer *layer = new QgsVectorLayer( QString( "dbname='%1' table='%2'(%3) sql=" ) + .arg( mDatabaseComboBox->currentText() ) + .arg( leLayerName->text() ) + .arg( leGeometryColumn->text() ), leLayerName->text(), "spatialite" ); + if ( layer->isValid() ) + { + // register this layer with the central layers registry + if ( QgsMapLayerRegistry::instance()->addMapLayer( layer ) ) + return true; + } + else + { + QgsDebugMsg( leLayerName->text() + " is an invalid layer - not loaded" ); + QMessageBox::critical( this, tr( "Invalid Layer" ), tr( "%1 is an invalid layer and cannot be loaded." ).arg( leLayerName->text() ) ); + delete layer; + } + } } } - return true; + + return false; } + +QString QgsNewSpatialiteLayerDialog::quotedIdentifier( QString id ) +{ + id.replace( "\"", "\"\"" ); + return id.prepend( "\"" ).append( "\"" ); +} + +QString QgsNewSpatialiteLayerDialog::quotedValue( QString value ) +{ + value.replace( "'", "''" ); + return value.prepend( "'" ).append( "'" ); +} + + diff --git a/src/app/qgsnewspatialitelayerdialog.h b/src/app/qgsnewspatialitelayerdialog.h index dca55c99c18..7f22291bbc8 100644 --- a/src/app/qgsnewspatialitelayerdialog.h +++ b/src/app/qgsnewspatialitelayerdialog.h @@ -15,8 +15,8 @@ * * ***************************************************************************/ /* $Id$ */ -#ifndef qgsnewspatialitelayerdialog_H -#define qgsnewspatialitelayerdialog_H +#ifndef QGSNEWSPATIALITELAYERDIALOG_H +#define QGSNEWSPATIALITELAYERDIALOG_H #include "ui_qgsnewspatialitelayerdialogbase.h" #include "qgisgui.h" @@ -27,6 +27,7 @@ extern "C" { #include +#include } class QgsNewSpatialiteLayerDialog: public QDialog, private Ui::QgsNewSpatialiteLayerDialogBase @@ -36,23 +37,6 @@ class QgsNewSpatialiteLayerDialog: public QDialog, private Ui::QgsNewSpatialiteL 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 >& at ) const; - QList * attributes() const; - /**Returns the database name */ - QString databaseName() const; - /**Returns the layer name to be created */ - QString layerName() const; - /**Returns the geometry column name */ - 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(); protected slots: void on_mAddAttributeButton_clicked(); @@ -60,15 +44,23 @@ class QgsNewSpatialiteLayerDialog: public QDialog, private Ui::QgsNewSpatialiteL void on_mTypeBox_currentIndexChanged( int index ); void on_pbnFindSRID_clicked(); void on_leLayerName_textChanged( QString text ); - void createNewDb(); + void on_toolButtonNewDatabase_clicked(); void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); } + void on_buttonBox_accepted(); + void on_buttonBox_rejected(); + + bool apply(); private: - QPushButton *mOkButton; - int mCrsId; - sqlite3 *db; - bool needNewDb; + /**Returns the selected geometry type*/ + QString selectedType() const; + + /** Create a new database */ + bool createDb(); + + static QString quotedIdentifier( QString id ); + static QString quotedValue( QString value ); }; -#endif //qgsnewvectorlayerdialog_H +#endif // QGSNEWVECTORLAYERDIALOG_H diff --git a/src/ui/qgsnewspatialitelayerdialogbase.ui b/src/ui/qgsnewspatialitelayerdialogbase.ui index 7de1ce82be6..579cc695261 100644 --- a/src/ui/qgsnewspatialitelayerdialogbase.ui +++ b/src/ui/qgsnewspatialitelayerdialogbase.ui @@ -6,8 +6,8 @@ 0 0 - 431 - 648 + 477 + 596 @@ -413,7 +413,7 @@ Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok + QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok|QDialogButtonBox::Apply @@ -440,8 +440,8 @@ accept() - 355 - 568 + 364 + 585 387 @@ -456,8 +456,8 @@ reject() - 281 - 568 + 290 + 585 242 @@ -465,24 +465,5 @@ - - toolButtonNewDatabase - clicked() - QgsNewSpatialiteLayerDialogBase - createNewDb() - - - 403 - 28 - - - 52 - 39 - - - - - createNewDb() -