Skip to content

Commit

Permalink
fix #2179
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12312 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Dec 2, 2009
1 parent b10bb58 commit 5823e97
Showing 1 changed file with 20 additions and 26 deletions.
46 changes: 20 additions & 26 deletions src/app/qgsspatialitesourceselect.cpp
Expand Up @@ -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();
}
Expand Down

0 comments on commit 5823e97

Please sign in to comment.