@@ -187,7 +187,7 @@ void QgsNewSpatialiteLayerDialog::on_pbnFindSRID_clicked()
187
187
}
188
188
}
189
189
190
- void QgsNewSpatialiteLayerDialog::initializeSpatialMetadata (sqlite3 *sqlite_handle)
190
+ void QgsNewSpatialiteLayerDialog::initializeSpatialMetadata ( sqlite3 *sqlite_handle )
191
191
{
192
192
// attempting to perform self-initialization for a newly created DB
193
193
int ret;
@@ -199,37 +199,37 @@ void QgsNewSpatialiteLayerDialog::initializeSpatialMetadata(sqlite3 *sqlite_hand
199
199
int rows;
200
200
int columns;
201
201
202
- if (sqlite_handle == NULL )
202
+ if ( sqlite_handle == NULL )
203
203
return ;
204
- // checking if this DB is really empty
205
- strcpy (sql, " SELECT Count(*) from sqlite_master" );
206
- ret = sqlite3_get_table (sqlite_handle, sql, &results, &rows, &columns, NULL );
207
- if (ret != SQLITE_OK)
204
+ // checking if this DB is really empty
205
+ strcpy ( sql, " SELECT Count(*) from sqlite_master" );
206
+ ret = sqlite3_get_table ( sqlite_handle, sql, &results, &rows, &columns, NULL );
207
+ if ( ret != SQLITE_OK )
208
208
return ;
209
- if (rows < 1 )
209
+ if ( rows < 1 )
210
210
;
211
211
else
212
212
{
213
- for (i = 1 ; i <= rows; i++)
214
- count = atoi (results[(i * columns) + 0 ]);
213
+ for ( i = 1 ; i <= rows; i++ )
214
+ count = atoi ( results[( i * columns ) + 0 ] );
215
215
}
216
- sqlite3_free_table (results);
216
+ sqlite3_free_table ( results );
217
217
218
- if (count > 0 )
218
+ if ( count > 0 )
219
219
return ;
220
220
221
221
// all right, it's empty: proceding to initialize
222
- strcpy (sql, " SELECT InitSpatialMetadata()" );
223
- ret = sqlite3_exec (sqlite_handle, sql, NULL , NULL , &errMsg);
224
- if (ret != SQLITE_OK)
222
+ strcpy ( sql, " SELECT InitSpatialMetadata()" );
223
+ ret = sqlite3_exec ( sqlite_handle, sql, NULL , NULL , &errMsg );
224
+ if ( ret != SQLITE_OK )
225
225
{
226
226
QString errCause = tr ( " Unable to initialize SpatialMetedata:\n " );
227
- errCause += QString::fromUtf8 (errMsg);
227
+ errCause += QString::fromUtf8 ( errMsg );
228
228
QMessageBox::warning ( 0 , tr ( " SpatiaLite Database" ), errCause );
229
- sqlite3_free (errMsg);
229
+ sqlite3_free ( errMsg );
230
230
return ;
231
231
}
232
- spatial_ref_sys_init (sqlite_handle, 0 );
232
+ spatial_ref_sys_init ( sqlite_handle, 0 );
233
233
}
234
234
235
235
bool QgsNewSpatialiteLayerDialog::createDb ()
@@ -256,32 +256,32 @@ bool QgsNewSpatialiteLayerDialog::createDb()
256
256
257
257
// creating/opening the new database
258
258
QString dbPath = newDb.fileName ();
259
- spatialite_init (0 );
260
- ret = sqlite3_open_v2 (dbPath.toUtf8 ().constData (), &sqlite_handle, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL );
261
- if (ret)
259
+ spatialite_init ( 0 );
260
+ ret = sqlite3_open_v2 ( dbPath.toUtf8 ().constData (), &sqlite_handle, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL );
261
+ if ( ret )
262
262
{
263
- // an error occurred
263
+ // an error occurred
264
264
QString errCause = tr ( " Could not create a new database\n " );
265
- errCause += QString::fromUtf8 (sqlite3_errmsg (sqlite_handle) );
266
- sqlite3_close (sqlite_handle);
267
- QMessageBox::warning ( 0 , tr ( " SpatiaLite Database" ), errCause );
265
+ errCause += QString::fromUtf8 ( sqlite3_errmsg ( sqlite_handle ) );
266
+ sqlite3_close ( sqlite_handle );
267
+ QMessageBox::warning ( 0 , tr ( " SpatiaLite Database" ), errCause );
268
268
pbnFindSRID->setEnabled ( false );
269
269
return false ;
270
270
}
271
271
// activating Foreign Key constraints
272
- ret = sqlite3_exec (sqlite_handle, " PRAGMA foreign_keys = 1" , NULL , 0 , &errMsg);
273
- if (ret != SQLITE_OK)
272
+ ret = sqlite3_exec ( sqlite_handle, " PRAGMA foreign_keys = 1" , NULL , 0 , &errMsg );
273
+ if ( ret != SQLITE_OK )
274
274
{
275
275
QMessageBox::warning ( 0 , tr ( " SpatiaLite Database" ), tr ( " Unable to activate FOREIGN_KEY constraints" ) );
276
- sqlite3_free (errMsg);
277
- sqlite3_close (sqlite_handle);
276
+ sqlite3_free ( errMsg );
277
+ sqlite3_close ( sqlite_handle );
278
278
pbnFindSRID->setEnabled ( false );
279
279
return false ;
280
280
}
281
- initializeSpatialMetadata (sqlite_handle);
282
-
281
+ initializeSpatialMetadata ( sqlite_handle );
282
+
283
283
// all done: closing the DB connection
284
- sqlite3_close (sqlite_handle);
284
+ sqlite3_close ( sqlite_handle );
285
285
}
286
286
287
287
QFileInfo fi ( newDb );
0 commit comments