Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix #3614
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15477 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Mar 14, 2011
1 parent 2f16afb commit d58c393
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 57 deletions.
21 changes: 3 additions & 18 deletions src/app/postgres/qgspgsourceselect.cpp
Expand Up @@ -928,25 +928,10 @@ void QgsPgSourceSelect::setConnectionListPosition()
QSettings settings;
// If possible, set the item currently displayed database
QString toSelect = settings.value( "/PostgreSQL/connections/selected" ).toString();
// Does toSelect exist in cmbConnections?
bool set = false;
for ( int i = 0; i < cmbConnections->count(); ++i )
if ( cmbConnections->itemText( i ) == toSelect )
{
cmbConnections->setCurrentIndex( i );
set = true;
break;
}
// If we couldn't find the stored item, but there are some,
// default to the last item (this makes some sense when deleting
// items as it allows the user to repeatidly click on delete to
// remove a whole lot of items).
if ( !set && cmbConnections->count() > 0 )
cmbConnections->setCurrentIndex( cmbConnections->findText( toSelect ) );

if ( cmbConnections->currentIndex() < 0 )
{
// If toSelect is null, then the selected connection wasn't found
// by QSettings, which probably means that this is the first time
// the user has used qgis with database connections, so default to
// the first in the list of connetions. Otherwise default to the last.
if ( toSelect.isNull() )
cmbConnections->setCurrentIndex( 0 );
else
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsnewhttpconnection.cpp
Expand Up @@ -92,5 +92,7 @@ void QgsNewHttpConnection::accept()
settings.setValue( credentialsKey + "/username", txtUserName->text() );
settings.setValue( credentialsKey + "/password", txtPassword->text() );

settings.setValue( mBaseKey + "/selected", txtName->text() );

QDialog::accept();
}
25 changes: 6 additions & 19 deletions src/app/qgswmssourceselect.cpp
Expand Up @@ -1008,31 +1008,18 @@ void QgsWMSSourceSelect::setConnectionListPosition()
{
QSettings settings;
QString toSelect = settings.value( "/Qgis/connections-wms/selected" ).toString();
// Does toSelect exist in cmbConnections?
bool set = false;
for ( int i = 0; i < cmbConnections->count(); ++i )
if ( cmbConnections->itemText( i ) == toSelect )
{
cmbConnections->setCurrentIndex( i );
set = true;
break;
}
// If we couldn't find the stored item, but there are some,
// default to the last item (this makes some sense when deleting
// items as it allows the user to repeatidly click on delete to
// remove a whole lot of items).
if ( !set && cmbConnections->count() > 0 )
{
// If toSelect is null, then the selected connection wasn't found
// by QSettings, which probably means that this is the first time
// the user has used qgis with database connections, so default to
// the first in the list of connetions. Otherwise default to the last.

cmbConnections->setCurrentIndex( cmbConnections->findText( toSelect ) );

if ( cmbConnections->currentIndex() < 0 )
{
if ( toSelect.isNull() )
cmbConnections->setCurrentIndex( 0 );
else
cmbConnections->setCurrentIndex( cmbConnections->count() - 1 );
}
}

void QgsWMSSourceSelect::showStatusMessage( QString const &theMessage )
{
labelStatus->setText( theMessage );
Expand Down
2 changes: 1 addition & 1 deletion src/app/spatialite/qgsnewspatialitelayerdialog.cpp
Expand Up @@ -295,7 +295,7 @@ bool QgsNewSpatialiteLayerDialog::createDb()

if ( !settings.contains( key ) )
{
settings.setValue( "/SpatiaLite/connections/selected", fi.fileName() );
settings.setValue( "/SpatiaLite/connections/selected", fi.fileName() + tr( "@" ) + fi.canonicalFilePath() );
settings.setValue( key, fi.canonicalFilePath() );

QMessageBox::information( 0, tr( "SpatiaLite Database" ), tr( "Registered new database!" ) );
Expand Down
24 changes: 5 additions & 19 deletions src/app/spatialite/qgsspatialitesourceselect.cpp
Expand Up @@ -887,25 +887,11 @@ void QgsSpatiaLiteSourceSelect::setConnectionListPosition()
QSettings settings;
// If possible, set the item currently displayed database
QString toSelect = settings.value( "/SpatiaLite/connections/selected" ).toString();
// Does toSelect exist in cmbConnections?
bool set = false;
for ( int i = 0; i < cmbConnections->count(); ++i )
if ( cmbConnections->itemText( i ) == toSelect )
{
cmbConnections->setCurrentIndex( i );
set = true;
break;
}
// If we couldn't find the stored item, but there are some,
// default to the last item (this makes some sense when deleting
// items as it allows the user to repeatidly click on delete to
// remove a whole lot of items).
if ( !set && cmbConnections->count() > 0 )
{
// If toSelect is null, then the selected connection wasn't found
// by QSettings, which probably means that this is the first time
// the user has used qgis with database connections, so default to
// the first in the list of connetions. Otherwise default to the last.

cmbConnections->setCurrentIndex( cmbConnections->findText( toSelect ) );

if ( cmbConnections->currentIndex() < 0 )
{
if ( toSelect.isNull() )
cmbConnections->setCurrentIndex( 0 );
else
Expand Down

0 comments on commit d58c393

Please sign in to comment.