Skip to content

Commit d58c393

Browse files
author
jef
committedMar 14, 2011
fix #3614
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15477 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

5 files changed

+17
-57
lines changed

5 files changed

+17
-57
lines changed
 

‎src/app/postgres/qgspgsourceselect.cpp

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -928,25 +928,10 @@ void QgsPgSourceSelect::setConnectionListPosition()
928928
QSettings settings;
929929
// If possible, set the item currently displayed database
930930
QString toSelect = settings.value( "/PostgreSQL/connections/selected" ).toString();
931-
// Does toSelect exist in cmbConnections?
932-
bool set = false;
933-
for ( int i = 0; i < cmbConnections->count(); ++i )
934-
if ( cmbConnections->itemText( i ) == toSelect )
935-
{
936-
cmbConnections->setCurrentIndex( i );
937-
set = true;
938-
break;
939-
}
940-
// If we couldn't find the stored item, but there are some,
941-
// default to the last item (this makes some sense when deleting
942-
// items as it allows the user to repeatidly click on delete to
943-
// remove a whole lot of items).
944-
if ( !set && cmbConnections->count() > 0 )
931+
cmbConnections->setCurrentIndex( cmbConnections->findText( toSelect ) );
932+
933+
if ( cmbConnections->currentIndex() < 0 )
945934
{
946-
// If toSelect is null, then the selected connection wasn't found
947-
// by QSettings, which probably means that this is the first time
948-
// the user has used qgis with database connections, so default to
949-
// the first in the list of connetions. Otherwise default to the last.
950935
if ( toSelect.isNull() )
951936
cmbConnections->setCurrentIndex( 0 );
952937
else

‎src/app/qgsnewhttpconnection.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,7 @@ void QgsNewHttpConnection::accept()
9292
settings.setValue( credentialsKey + "/username", txtUserName->text() );
9393
settings.setValue( credentialsKey + "/password", txtPassword->text() );
9494

95+
settings.setValue( mBaseKey + "/selected", txtName->text() );
96+
9597
QDialog::accept();
9698
}

‎src/app/qgswmssourceselect.cpp

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,31 +1008,18 @@ void QgsWMSSourceSelect::setConnectionListPosition()
10081008
{
10091009
QSettings settings;
10101010
QString toSelect = settings.value( "/Qgis/connections-wms/selected" ).toString();
1011-
// Does toSelect exist in cmbConnections?
1012-
bool set = false;
1013-
for ( int i = 0; i < cmbConnections->count(); ++i )
1014-
if ( cmbConnections->itemText( i ) == toSelect )
1015-
{
1016-
cmbConnections->setCurrentIndex( i );
1017-
set = true;
1018-
break;
1019-
}
1020-
// If we couldn't find the stored item, but there are some,
1021-
// default to the last item (this makes some sense when deleting
1022-
// items as it allows the user to repeatidly click on delete to
1023-
// remove a whole lot of items).
1024-
if ( !set && cmbConnections->count() > 0 )
1025-
{
1026-
// If toSelect is null, then the selected connection wasn't found
1027-
// by QSettings, which probably means that this is the first time
1028-
// the user has used qgis with database connections, so default to
1029-
// the first in the list of connetions. Otherwise default to the last.
1011+
1012+
cmbConnections->setCurrentIndex( cmbConnections->findText( toSelect ) );
1013+
1014+
if ( cmbConnections->currentIndex() < 0 )
1015+
{
10301016
if ( toSelect.isNull() )
10311017
cmbConnections->setCurrentIndex( 0 );
10321018
else
10331019
cmbConnections->setCurrentIndex( cmbConnections->count() - 1 );
10341020
}
10351021
}
1022+
10361023
void QgsWMSSourceSelect::showStatusMessage( QString const &theMessage )
10371024
{
10381025
labelStatus->setText( theMessage );

‎src/app/spatialite/qgsnewspatialitelayerdialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ bool QgsNewSpatialiteLayerDialog::createDb()
295295

296296
if ( !settings.contains( key ) )
297297
{
298-
settings.setValue( "/SpatiaLite/connections/selected", fi.fileName() );
298+
settings.setValue( "/SpatiaLite/connections/selected", fi.fileName() + tr( "@" ) + fi.canonicalFilePath() );
299299
settings.setValue( key, fi.canonicalFilePath() );
300300

301301
QMessageBox::information( 0, tr( "SpatiaLite Database" ), tr( "Registered new database!" ) );

‎src/app/spatialite/qgsspatialitesourceselect.cpp

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -887,25 +887,11 @@ void QgsSpatiaLiteSourceSelect::setConnectionListPosition()
887887
QSettings settings;
888888
// If possible, set the item currently displayed database
889889
QString toSelect = settings.value( "/SpatiaLite/connections/selected" ).toString();
890-
// Does toSelect exist in cmbConnections?
891-
bool set = false;
892-
for ( int i = 0; i < cmbConnections->count(); ++i )
893-
if ( cmbConnections->itemText( i ) == toSelect )
894-
{
895-
cmbConnections->setCurrentIndex( i );
896-
set = true;
897-
break;
898-
}
899-
// If we couldn't find the stored item, but there are some,
900-
// default to the last item (this makes some sense when deleting
901-
// items as it allows the user to repeatidly click on delete to
902-
// remove a whole lot of items).
903-
if ( !set && cmbConnections->count() > 0 )
904-
{
905-
// If toSelect is null, then the selected connection wasn't found
906-
// by QSettings, which probably means that this is the first time
907-
// the user has used qgis with database connections, so default to
908-
// the first in the list of connetions. Otherwise default to the last.
890+
891+
cmbConnections->setCurrentIndex( cmbConnections->findText( toSelect ) );
892+
893+
if ( cmbConnections->currentIndex() < 0 )
894+
{
909895
if ( toSelect.isNull() )
910896
cmbConnections->setCurrentIndex( 0 );
911897
else

0 commit comments

Comments
 (0)
Please sign in to comment.