Skip to content
Permalink
Browse files
fix #2179
git-svn-id: http://svn.osgeo.org/qgis/trunk@12312 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Dec 2, 2009
1 parent 74b924a commit a1b0f200a4eb819295870f4ba227ee286f2f2ef5
Showing with 20 additions and 26 deletions.
  1. +20 −26 src/app/qgsspatialitesourceselect.cpp
@@ -304,39 +304,33 @@ void QgsSpatiaLiteSourceSelect::addNewConnection()
// Retrieve last used project dir from persistent settings
sqlite3 *handle;
QSettings settings;
QString fullPath;
QString lastUsedDir = settings.value( "/UI/lastSpatiaLiteDir", "." ).toString();

QString myFile = QFileDialog::getOpenFileName( this,
tr( "Choose a SpatiaLite/SQLite DB to open" ),
lastUsedDir, QObject::tr( "SQLite DB (*.sqlite);;All files (*.*)" ) );
tr( "Choose a SpatiaLite/SQLite DB to open" ),
lastUsedDir, QObject::tr( "SQLite DB (*.sqlite);;All files (*.*)" ) );

if ( myFile.isEmpty() )
{
QFileInfo myFI( myFile );
QString myPath = myFI.path();
QString myName = myFI.fileName();
return;

handle = openSpatiaLiteDb( myFI.canonicalFilePath() );
if ( handle )
{
// OK, this one is a valid SpatiaLite DB
closeSpatiaLiteDb( handle );

// Persist last used SpatiaLite dir
settings.setValue( "/UI/lastSpatiaLiteDir", myPath );
// inserting this SQLite DB path
QString baseKey = "/SpatiaLite/connections/";
settings.setValue( baseKey + "selected", myName );
baseKey += myName;
settings.setValue( baseKey + "/sqlitepath", fullPath );
}
}
else
{
// if they didn't select anything, just return
QFileInfo myFI( myFile );
QString myPath = myFI.path();
QString myName = myFI.fileName();

handle = openSpatiaLiteDb( myFI.canonicalFilePath() );
if ( !handle )
return;
}

// OK, this one is a valid SpatiaLite DB
closeSpatiaLiteDb( handle );

// Persist last used SpatiaLite dir
settings.setValue( "/UI/lastSpatiaLiteDir", myPath );
// inserting this SQLite DB path
QString baseKey = "/SpatiaLite/connections/";
settings.setValue( baseKey + "selected", myName );
baseKey += myName;
settings.setValue( baseKey + "/sqlitepath", myFI.canonicalFilePath() );

populateConnectionList();
}

0 comments on commit a1b0f20

Please sign in to comment.