[QGIS Commit] r15477 - in trunk/qgis/src/app: . postgres spatialite

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Mar 14 15:35:23 EDT 2011


Author: jef
Date: 2011-03-14 12:35:23 -0700 (Mon, 14 Mar 2011)
New Revision: 15477

Modified:
   trunk/qgis/src/app/postgres/qgspgsourceselect.cpp
   trunk/qgis/src/app/qgsnewhttpconnection.cpp
   trunk/qgis/src/app/qgswmssourceselect.cpp
   trunk/qgis/src/app/spatialite/qgsnewspatialitelayerdialog.cpp
   trunk/qgis/src/app/spatialite/qgsspatialitesourceselect.cpp
Log:
fix #3614

Modified: trunk/qgis/src/app/postgres/qgspgsourceselect.cpp
===================================================================
--- trunk/qgis/src/app/postgres/qgspgsourceselect.cpp	2011-03-14 17:17:37 UTC (rev 15476)
+++ trunk/qgis/src/app/postgres/qgspgsourceselect.cpp	2011-03-14 19:35:23 UTC (rev 15477)
@@ -928,25 +928,10 @@
   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

Modified: trunk/qgis/src/app/qgsnewhttpconnection.cpp
===================================================================
--- trunk/qgis/src/app/qgsnewhttpconnection.cpp	2011-03-14 17:17:37 UTC (rev 15476)
+++ trunk/qgis/src/app/qgsnewhttpconnection.cpp	2011-03-14 19:35:23 UTC (rev 15477)
@@ -92,5 +92,7 @@
   settings.setValue( credentialsKey + "/username", txtUserName->text() );
   settings.setValue( credentialsKey + "/password", txtPassword->text() );
 
+  settings.setValue( mBaseKey + "/selected", txtName->text() );
+
   QDialog::accept();
 }

Modified: trunk/qgis/src/app/qgswmssourceselect.cpp
===================================================================
--- trunk/qgis/src/app/qgswmssourceselect.cpp	2011-03-14 17:17:37 UTC (rev 15476)
+++ trunk/qgis/src/app/qgswmssourceselect.cpp	2011-03-14 19:35:23 UTC (rev 15477)
@@ -1008,31 +1008,18 @@
 {
   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 )
+
+  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
       cmbConnections->setCurrentIndex( cmbConnections->count() - 1 );
   }
 }
+
 void QgsWMSSourceSelect::showStatusMessage( QString const &theMessage )
 {
   labelStatus->setText( theMessage );

Modified: trunk/qgis/src/app/spatialite/qgsnewspatialitelayerdialog.cpp
===================================================================
--- trunk/qgis/src/app/spatialite/qgsnewspatialitelayerdialog.cpp	2011-03-14 17:17:37 UTC (rev 15476)
+++ trunk/qgis/src/app/spatialite/qgsnewspatialitelayerdialog.cpp	2011-03-14 19:35:23 UTC (rev 15477)
@@ -295,7 +295,7 @@
 
   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!" ) );

Modified: trunk/qgis/src/app/spatialite/qgsspatialitesourceselect.cpp
===================================================================
--- trunk/qgis/src/app/spatialite/qgsspatialitesourceselect.cpp	2011-03-14 17:17:37 UTC (rev 15476)
+++ trunk/qgis/src/app/spatialite/qgsspatialitesourceselect.cpp	2011-03-14 19:35:23 UTC (rev 15477)
@@ -887,25 +887,11 @@
   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 )
+
+  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



More information about the QGIS-commit mailing list