[QGIS Commit] r10458 - in trunk/qgis/src: app app/attributetable app/ogr core plugins/georeferencer plugins/spit

svn_qgis at osgeo.org svn_qgis at osgeo.org
Fri Apr 3 02:54:21 EDT 2009


Author: jef
Date: 2009-04-03 02:54:21 -0400 (Fri, 03 Apr 2009)
New Revision: 10458

Modified:
   trunk/qgis/src/app/attributetable/BeataModel.cpp
   trunk/qgis/src/app/ogr/qgsogrhelperfunctions.cpp
   trunk/qgis/src/app/ogr/qgsogrhelperfunctions.h
   trunk/qgis/src/app/ogr/qgsopenvectorlayerdialog.cpp
   trunk/qgis/src/app/ogr/qgsopenvectorlayerdialog.h
   trunk/qgis/src/app/qgisapp.cpp
   trunk/qgis/src/app/qgisapp.h
   trunk/qgis/src/app/qgsdbsourceselect.cpp
   trunk/qgis/src/app/qgsnewconnection.cpp
   trunk/qgis/src/app/qgspluginmanager.cpp
   trunk/qgis/src/core/qgsdatasourceuri.cpp
   trunk/qgis/src/core/qgsdatasourceuri.h
   trunk/qgis/src/core/qgsgeometry.cpp
   trunk/qgis/src/core/qgsmaplayer.cpp
   trunk/qgis/src/plugins/georeferencer/qgspointdialog.cpp
   trunk/qgis/src/plugins/spit/qgsspit.cpp
Log:
automatic indentation update (r10429-r10457)

Modified: trunk/qgis/src/app/attributetable/BeataModel.cpp
===================================================================
--- trunk/qgis/src/app/attributetable/BeataModel.cpp	2009-04-03 04:01:19 UTC (rev 10457)
+++ trunk/qgis/src/app/attributetable/BeataModel.cpp	2009-04-03 06:54:21 UTC (rev 10458)
@@ -408,7 +408,7 @@
     mLastRow = ( QgsAttributeMap * ) & mFeat.attributeMap();
   }
 
-  if( !mLastRow )
+  if ( !mLastRow )
     return QVariant( "ERROR" );
 
   QVariant& val = ( *mLastRow )[ mAttributes[index.column()] ];
@@ -542,7 +542,7 @@
     mLastRow = ( QgsAttributeMap * ) & mFeat.attributeMap();
   }
 
-  if( !mLastRow )
+  if ( !mLastRow )
     return QVariant( "ERROR" );
 
   QVariant &val = ( *mLastRow )[ mAttributes[index.column()] ];
@@ -582,7 +582,7 @@
   {
     mLastRowId = rowToId( index.row() );
     mFeat = mFeatureMap[rowToId( index.row() )];
-    mLastRow = ( QgsAttributeMap * ) &mFeat.attributeMap();
+    mLastRow = ( QgsAttributeMap * ) & mFeat.attributeMap();
 
 
 // QgsDebugMsg(mFeatureMap[rowToId(index.row())].id());

Modified: trunk/qgis/src/app/ogr/qgsogrhelperfunctions.cpp
===================================================================
--- trunk/qgis/src/app/ogr/qgsogrhelperfunctions.cpp	2009-04-03 04:01:19 UTC (rev 10457)
+++ trunk/qgis/src/app/ogr/qgsogrhelperfunctions.cpp	2009-04-03 06:54:21 UTC (rev 10458)
@@ -1,105 +1,105 @@
-/***************************************************************************
-                          qgsogrhelperfunctions.cpp
-    helper functions to create ogr uris for database and protocol drivers
-                             -------------------
-    begin                : Mon Jan 2 2009
-    copyright            : (C) 2009 by Godofredo Contreras Nava
-    email                : frdcn at hotmail.com
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- ***************************************************************************/
-/* $Id:$ */
-
-#include "qgsogrhelperfunctions.h"
-#include "qgslogger.h"
-#include <QRegExp>
-
-QString createDatabaseURI( QString connectionType, QString host, QString database, QString port, QString user, QString password )
-{
-  QString uri = "";
-    //todo:add default ports for all kind of databases
-	if (connectionType=="ESRI Personal GeoDatabase")
-	 {
-		 uri="PGeo:"+database;   
-	 }
-	else if (connectionType=="ESRI ArcSDE")
-	 {
-		 if (port.isNull()||port.isEmpty())
-            port="5151";
-		 uri="SDE:"+host+",PORT:"+port+","+database+","+user+","+password;		 		 
-	 }
-	else if (connectionType=="Informix DataBlade")
-	 {
-       //not tested
-       uri="IDB:dbname="+database+" server="+host
-			+" user="+user
-			+" pass="+password+" ";	   
-       
-	 }
-	else if (connectionType=="INGRES")
-	 {
-       //not tested
-       uri="@driver=ingres,dbname="+database+",userid="+user+", password="+password+" ";
-	 }
-	else if (connectionType=="MySQL")
-	 { 
-        uri="MySQL:"+database+",host="+host
-			+",port="+port+",user="+user
-			+", password="+password+" ";	    
-	 }
-	else if (connectionType=="Oracle Spatial")
-	 {
-		 uri="OCI:"+user+"/"+password
-			+"@"+host+"/"+database;	    
-	 }
-    else if (connectionType=="ODBC")
-	 { 
-		 if(!user.isEmpty())
-		   {
-             if(password.isEmpty())
-			  {
-                uri="ODBC:"+user+"@"+database;
-			  }
-			 else
-			  {
-                uri="ODBC:"+user+"/"+password+"@"+database;
-			  }
-		     
-		   }
-		 else
-		   {            
-			 uri="ODBC:"+database;
-		   }
-	 }
-	else if (connectionType=="OGDI Vectors")
-	 {
-	 }
-	else if (connectionType=="PostgreSQL")
-	 {
-		 uri="PG:dbname='"+database+"' host='"+host
-			+"' port='"+port+"' user='"+user
-			+"' password='"+password+"' ";	  
-		
-	 }
-	QgsDebugMsg("Connection type is="+connectionType+" and uri="+uri);
-	return uri;
-}
-
-
-QString createProtocolURI( QString type, QString url )
-{
-  QString uri = "";
-  if ( type == "GeoJSON" )
-  {
-    uri = url;
-  }
-  QgsDebugMsg( "Connection type is=" + type + " and uri=" + uri );
-  return uri;
-}
+/***************************************************************************
+                          qgsogrhelperfunctions.cpp
+    helper functions to create ogr uris for database and protocol drivers
+                             -------------------
+    begin                : Mon Jan 2 2009
+    copyright            : (C) 2009 by Godofredo Contreras Nava
+    email                : frdcn at hotmail.com
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+/* $Id:$ */
+
+#include "qgsogrhelperfunctions.h"
+#include "qgslogger.h"
+#include <QRegExp>
+
+QString createDatabaseURI( QString connectionType, QString host, QString database, QString port, QString user, QString password )
+{
+  QString uri = "";
+  //todo:add default ports for all kind of databases
+  if ( connectionType == "ESRI Personal GeoDatabase" )
+  {
+    uri = "PGeo:" + database;
+  }
+  else if ( connectionType == "ESRI ArcSDE" )
+  {
+    if ( port.isNull() || port.isEmpty() )
+      port = "5151";
+    uri = "SDE:" + host + ",PORT:" + port + "," + database + "," + user + "," + password;
+  }
+  else if ( connectionType == "Informix DataBlade" )
+  {
+    //not tested
+    uri = "IDB:dbname=" + database + " server=" + host
+          + " user=" + user
+          + " pass=" + password + " ";
+
+  }
+  else if ( connectionType == "INGRES" )
+  {
+    //not tested
+    uri = "@driver=ingres,dbname=" + database + ",userid=" + user + ", password=" + password + " ";
+  }
+  else if ( connectionType == "MySQL" )
+  {
+    uri = "MySQL:" + database + ",host=" + host
+          + ",port=" + port + ",user=" + user
+          + ", password=" + password + " ";
+  }
+  else if ( connectionType == "Oracle Spatial" )
+  {
+    uri = "OCI:" + user + "/" + password
+          + "@" + host + "/" + database;
+  }
+  else if ( connectionType == "ODBC" )
+  {
+    if ( !user.isEmpty() )
+    {
+      if ( password.isEmpty() )
+      {
+        uri = "ODBC:" + user + "@" + database;
+      }
+      else
+      {
+        uri = "ODBC:" + user + "/" + password + "@" + database;
+      }
+
+    }
+    else
+    {
+      uri = "ODBC:" + database;
+    }
+  }
+  else if ( connectionType == "OGDI Vectors" )
+  {
+  }
+  else if ( connectionType == "PostgreSQL" )
+  {
+    uri = "PG:dbname='" + database + "' host='" + host
+          + "' port='" + port + "' user='" + user
+          + "' password='" + password + "' ";
+
+  }
+  QgsDebugMsg( "Connection type is=" + connectionType + " and uri=" + uri );
+  return uri;
+}
+
+
+QString createProtocolURI( QString type, QString url )
+{
+  QString uri = "";
+  if ( type == "GeoJSON" )
+  {
+    uri = url;
+  }
+  QgsDebugMsg( "Connection type is=" + type + " and uri=" + uri );
+  return uri;
+}

Modified: trunk/qgis/src/app/ogr/qgsogrhelperfunctions.h
===================================================================
--- trunk/qgis/src/app/ogr/qgsogrhelperfunctions.h	2009-04-03 04:01:19 UTC (rev 10457)
+++ trunk/qgis/src/app/ogr/qgsogrhelperfunctions.h	2009-04-03 06:54:21 UTC (rev 10458)
@@ -1,26 +1,26 @@
-/***************************************************************************
-                          qgsogrhelperfunctions.h
-    helper functions to create ogr uris for database and protocol drivers
-                             -------------------
-    begin                : Mon Jan 2 2009
-    copyright            : (C) 2009 by Godofredo Contreras Nava
-    email                : frdcn at hotmail.com
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- ***************************************************************************/
-/* $Id:$ */
-
-#include <QString>
-
-/* Create database uri from connection parameters */
-QString createDatabaseURI(QString connectionType, QString host, QString database, QString port, QString user, QString password);
-
-/* Create protocol uri from connection parameters */
-QString createProtocolURI(QString type, QString url);
+/***************************************************************************
+                          qgsogrhelperfunctions.h
+    helper functions to create ogr uris for database and protocol drivers
+                             -------------------
+    begin                : Mon Jan 2 2009
+    copyright            : (C) 2009 by Godofredo Contreras Nava
+    email                : frdcn at hotmail.com
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+/* $Id:$ */
+
+#include <QString>
+
+/* Create database uri from connection parameters */
+QString createDatabaseURI( QString connectionType, QString host, QString database, QString port, QString user, QString password );
+
+/* Create protocol uri from connection parameters */
+QString createProtocolURI( QString type, QString url );

Modified: trunk/qgis/src/app/ogr/qgsopenvectorlayerdialog.cpp
===================================================================
--- trunk/qgis/src/app/ogr/qgsopenvectorlayerdialog.cpp	2009-04-03 04:01:19 UTC (rev 10457)
+++ trunk/qgis/src/app/ogr/qgsopenvectorlayerdialog.cpp	2009-04-03 06:54:21 UTC (rev 10458)
@@ -1,512 +1,512 @@
-/***************************************************************************
-                          qgsopenvectorlayerdialog.cpp
- Dialog to select the type and source for ogr vectors, supports
- file, database, directory and protocol sources.
-                             -------------------
-    begin                : Mon Jan 2 2009
-    copyright            : (C) 2009 by Godofredo Contreras Nava
-    email                : frdcn at hotmail.com
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- ***************************************************************************/
-/* $Id:$ */
-#include <QSettings>
-#include <QFileDialog>
-#include <QMessageBox>
-#include <QInputDialog>
-#include <QTextCodec>
-#include "qgslogger.h"
-#include "qgsencodingfiledialog.h"
-#include "qgsopenvectorlayerdialog.h"
-#include <ogr_api.h>
-#include "qgsproviderregistry.h"
-#include "qgsnewogrconnection.h"
-#include "qgsogrhelperfunctions.h"
-#include "qgscontexthelp.h"
-
-QgsOpenVectorLayerDialog::QgsOpenVectorLayerDialog( QWidget* parent, Qt::WFlags fl )
-    : QDialog( parent, fl )
-{
-  setupUi( this );
-  cmbDatabaseTypes->blockSignals( true );
-  cmbConnections->blockSignals( true );
-  radioSrcFile->setChecked( true );
-  mDataSourceType="file";
-  //set encoding
-  cmbEncodings->setItemText( cmbEncodings->currentIndex(), QString( QTextCodec::codecForLocale()->name() ) );
-
-  //add database drivers
-  mVectorFileFilter = QgsProviderRegistry::instance()->fileVectorFilters();
-  QgsDebugMsg( "Database drivers :" + QgsProviderRegistry::instance()->databaseDrivers() );
-  QStringList dbDrivers = QgsProviderRegistry::instance()->databaseDrivers().split( ";" );
-
-  for ( int i = 0;i < dbDrivers.count();i++ )
-  {
-    QString dbDriver = dbDrivers.at( i );
-    if (( !dbDriver.isEmpty() ) && ( !dbDriver.isNull() ) )
-      cmbDatabaseTypes->addItem( dbDriver.split( "," ).at( 0 ) );
-  }
-
-  //add directory drivers
-  QStringList dirDrivers = QgsProviderRegistry::instance()->directoryDrivers().split( ";" );
-  for ( int i = 0;i < dirDrivers.count();i++ )
-  {
-    QString dirDriver = dirDrivers.at( i );
-    if (( !dirDriver.isEmpty() ) && ( !dirDriver.isNull() ) )
-      cmbDirectoryTypes->addItem( dirDriver.split( "," ).at( 0 ) );
-  }
-
-  //add protocol drivers
-  QStringList proDrivers = QgsProviderRegistry::instance()->protocolDrivers().split( ";" );
-  for ( int i = 0;i < proDrivers.count();i++ )
-  {
-    QString proDriver = proDrivers.at( i );
-    if (( !proDriver.isEmpty() ) && ( !proDriver.isNull() ) )
-      cmbProtocolTypes->addItem( proDriver.split( "," ).at( 0 ) );
-  }
-  cmbDatabaseTypes->blockSignals( false );
-  cmbConnections->blockSignals( false );
-}
-
-QgsOpenVectorLayerDialog::~QgsOpenVectorLayerDialog()
-{
-}
-
-QStringList QgsOpenVectorLayerDialog::openFile()
-{
-
-  QStringList selectedFiles;
-  QgsDebugMsg( "Vector file filters: " + mVectorFileFilter );
-  QString enc;
-  QString title = tr( "Open an OGR Supported Vector Layer" );
-  openFilesRememberingFilter( "lastVectorFileFilter", mVectorFileFilter, selectedFiles,
-                              title );
-  mEnc = enc;
-  return selectedFiles;
-}
-
-QString QgsOpenVectorLayerDialog::openDirectory()
-{
-  QSettings settings;
-
-  bool haveLastUsedDir = settings.contains( "/UI/LastUsedDirectory" );
-  QString lastUsedDir = settings.value( "/UI/LastUsedDirectory",
-                                        QVariant( QString::null ) ).toString();
-  if ( !haveLastUsedDir )
-    lastUsedDir = "";
-
-  QString path = QFileDialog::getExistingDirectory( this,
-                 tr( "Open Directory" ), lastUsedDir,
-                 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks );
-
-  settings.setValue( "/UI/LastUsedDirectory", path );
-  //process path if it is grass
-  if ( cmbDirectoryTypes->currentText() == "Grass Vector" )
-  {
-#ifdef WIN32
-    //replace backslashes with forward slashes
-    path.replace( "\\", "/" );
-#endif
-    path = path + "/head";
-  }
-  return path;
-}
-
-QStringList QgsOpenVectorLayerDialog::dataSources()
-{
-  return mDataSources;
-}
-
-QString QgsOpenVectorLayerDialog::encoding()
-{
-  return cmbEncodings->currentText();
-}
-
-void QgsOpenVectorLayerDialog::helpInfo()
-{
-  QgsContextHelp::run( context_id );
-}
-
-QString QgsOpenVectorLayerDialog::dataSourceType()
-{
-  return mDataSourceType;
-}
-
-void QgsOpenVectorLayerDialog::addNewConnection()
-{
-  QgsNewOgrConnection *nc = new QgsNewOgrConnection( this );
-  if ( nc->exec() )
-  {
-    populateConnectionList();
-  }
-}
-
-void QgsOpenVectorLayerDialog::editConnection()
-{
-  QgsNewOgrConnection *nc = new QgsNewOgrConnection( this, cmbDatabaseTypes->currentText(), cmbConnections->currentText() );
-
-  if ( nc->exec() )
-  {
-    nc->saveConnection();
-  }
-}
-
-void QgsOpenVectorLayerDialog::deleteConnection()
-{
-  QSettings settings;
-  QString key = "/" + cmbDatabaseTypes->currentText() + "/connections/" + cmbConnections->currentText();
-  QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" )
-                .arg( cmbConnections->currentText() );
-  QMessageBox::StandardButton result = QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
-  if ( result == QMessageBox::Ok )
-  {
-    settings.remove( key + "/host" );
-    settings.remove( key + "/database" );
-    settings.remove( key + "/username" );
-    settings.remove( key + "/password" );
-    settings.remove( key + "/port" );
-    settings.remove( key + "/save" );
-    settings.remove( key );
-    cmbConnections->removeItem( cmbConnections->currentIndex() );  // populateConnectionList();
-    setConnectionListPosition();
-  }
-}
-
-void QgsOpenVectorLayerDialog::populateConnectionList()
-{
-  QSettings settings;
-  settings.beginGroup( "/" + cmbDatabaseTypes->currentText() + "/connections" );
-  QStringList keys = settings.childGroups();
-  QStringList::Iterator it = keys.begin();
-  cmbConnections->clear();
-  while ( it != keys.end() )
-  {
-    cmbConnections->addItem( *it );
-    ++it;
-  }
-  settings.endGroup();
-  setConnectionListPosition();
-}
-
-void QgsOpenVectorLayerDialog::setConnectionListPosition()
-{
-  QSettings settings;
-  // If possible, set the item currently displayed database
-
-  QString toSelect = settings.value( "/" + cmbDatabaseTypes->currentText() + "/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.
-    if ( toSelect.isNull() )
-      cmbConnections->setCurrentIndex( 0 );
-    else
-      cmbConnections->setCurrentIndex( cmbConnections->count() - 1 );
-  }
-}
-
-void QgsOpenVectorLayerDialog::setConnectionTypeListPosition()
-{
-  QSettings settings;
-
-  QString toSelect = settings.value( "/ogr/connections/selectedtype" ).toString();
-  bool set = false;
-  for ( int i = 0; i < cmbDatabaseTypes->count(); ++i )
-    if ( cmbDatabaseTypes->itemText( i ) == toSelect )
-    {
-      cmbDatabaseTypes->setCurrentIndex( i );
-      set = true;
-      break;
-    }
-}
-
-void QgsOpenVectorLayerDialog::setSelectedConnectionType()
-{
-  QSettings settings;
-  QString baseKey = "/ogr/connections/";
-  settings.setValue( baseKey + "selectedtype", cmbDatabaseTypes->currentText() );
-  QgsDebugMsg( "Setting selected type to" + cmbDatabaseTypes->currentText() );
-}
-
-void QgsOpenVectorLayerDialog::setSelectedConnection()
-{
-  QSettings settings;
-  settings.setValue( "/" + cmbDatabaseTypes->currentText() + "/connections/selected", cmbConnections->currentText() );
-  QgsDebugMsg( "Setting selected connection to " + cmbConnections->currentText() );
-}
-
-
-void QgsOpenVectorLayerDialog::on_buttonSelectSrc_clicked()
-{
-  QSettings settings;
-  QString filepath;
-
-  mDataSources.clear();
-
-  if ( radioSrcFile->isChecked() )
-  {
-    //file
-
-    //mType="file";
-    mDataSources = openFile();
-    filepath = "";
-    for ( int i = 0;i < mDataSources.count();i++ )
-      filepath += mDataSources.at( i ) + ";";
-    inputSrcDataset->setText( filepath );
-  }
-  else if ( radioSrcDirectory->isChecked() )
-  {
-
-    filepath = openDirectory();
-    mDataSources.append( filepath );
-    inputSrcDataset->setText( filepath );
-    //mType="directory";
-  }
-  else if ( radioSrcDatabase->isChecked() )
-  {
-    //mType="database";
-    //src = inputSrcDataset->text();
-  }
-  else
-  {
-    Q_ASSERT( !"SHOULD NEVER GET HERE" );
-  }
-
-
-
-}
-
-/**
-  Open files, preferring to have the default file selector be the
-  last one used, if any; also, prefer to start in the last directory
-  associated with filterName.
-
-  @param filterName the name of the filter; used for persistent store
-  key
-  @param filters    the file filters used for QFileDialog
-
-  @param selectedFiles string list of selected files; will be empty
-  if none selected
-  @param title      the title for the dialog
-  @note
-
-  Stores persistent settings under /UI/.  The sub-keys will be
-  filterName and filterName + "Dir".
-
-  Opens dialog on last directory associated with the filter name, or
-  the current working directory if this is the first time invoked
-  with the current filter name.
-
-*/
-void QgsOpenVectorLayerDialog::openFilesRememberingFilter( QString const &filterName,
-    QString const &filters, QStringList & selectedFiles, QString &title )
-{
-
-  bool haveLastUsedFilter = false; // by default, there is no last
-  // used filter
-
-  QSettings settings;         // where we keep last used filter in
-
-  // persistant state
-
-  haveLastUsedFilter = settings.contains( "/UI/" + filterName );
-  QString lastUsedFilter = settings.value( "/UI/" + filterName,
-                           QVariant( QString::null ) ).toString();
-
-  QString lastUsedDir = settings.value( "/UI/" + filterName + "Dir", "." ).toString();
-
-  //QString lastUsedEncoding = settings.value( "/UI/encoding" ).toString();
-
-  QgsDebugMsg( "Opening file dialog with filters: " + filters );
-
-  QFileDialog* openFileDialog = new QFileDialog( 0,
-      title, lastUsedDir, filters );
-
-  // allow for selection of more than one file
-  openFileDialog->setFileMode( QFileDialog::ExistingFiles );
-
-  if ( haveLastUsedFilter )     // set the filter to the last one used
-  {
-    openFileDialog->selectFilter( lastUsedFilter );
-  }
-
-  if ( openFileDialog->exec() == QDialog::Accepted )
-  {
-    selectedFiles = openFileDialog->selectedFiles();
-    //enc = openFileDialog->encoding();
-    // Fix by Tim - getting the dirPath from the dialog
-    // directly truncates the last node in the dir path.
-    // This is a workaround for that
-    QString myFirstFileName = selectedFiles.first();
-    QFileInfo myFI( myFirstFileName );
-    QString myPath = myFI.path();
-
-    QgsDebugMsg( "Writing last used dir: " + myPath );
-
-    settings.setValue( "/UI/" + filterName, openFileDialog->selectedFilter() );
-    settings.setValue( "/UI/" + filterName + "Dir", myPath );
-    //settings.setValue( "/UI/encoding", openFileDialog->encoding() );
-  }
-
-  delete openFileDialog;
-
-}   // openFilesRememberingFilter_
-
-
-
-//********************auto connected slots *****************/
-void QgsOpenVectorLayerDialog::on_buttonBox_accepted()
-{
-  QgsDebugMsg( "dialog button accepted" );
-  if ( radioSrcDatabase->isChecked() )
-  {
-    mDataSources.clear();
-    QSettings settings;
-    QString baseKey = "/" + cmbDatabaseTypes->currentText() + "/connections/";
-    baseKey += cmbConnections->currentText();
-    QString host = settings.value( baseKey + "/host" ).toString();
-    QString database = settings.value( baseKey + "/database" ).toString();
-    QString port = settings.value( baseKey + "/port" ).toString();
-    QString user = settings.value( baseKey + "/username" ).toString();
-    QString pass = settings.value( baseKey + "/password" ).toString();
-    bool makeConnection = false;
-    if ( pass.isEmpty() )
-      pass = QInputDialog::getText( this, tr( "Password for " ) + user,
-                                    tr( "Please enter your password:" ),
-                                    QLineEdit::Password, QString::null, &makeConnection );
-    if ( makeConnection || ( !pass.isEmpty() ) )
-      mDataSources.append( createDatabaseURI(
-                             cmbDatabaseTypes->currentText(),
-                             host,
-                             database,
-                             port,
-                             user,
-                             pass
-                           ) );
-  }
-  else if ( radioSrcProtocol->isChecked() )
-  {
-    mDataSources.clear();
-    mDataSources.append( createProtocolURI(
-                           cmbProtocolTypes->currentText(),
-                           protocolURI->text()
-                         ) );
-  }
-  accept();
-}
-
-void QgsOpenVectorLayerDialog::on_btnHelp_clicked()
-{
-  helpInfo();
-}
-
-void QgsOpenVectorLayerDialog::on_radioSrcFile_toggled( bool checked )
-{
-  if ( checked )
-  {
-    labelDirectoryType->hide();
-    cmbDirectoryTypes->hide();
-    fileGroupBox->show();
-    dbGroupBox->hide();
-    protocolGroupBox->hide();
-    layout()->setSizeConstraint( QLayout::SetFixedSize );
-	mDataSourceType="file";
-  }
-}
-
-void QgsOpenVectorLayerDialog::on_radioSrcDirectory_toggled( bool checked )
-{
-  if ( checked )
-  {
-    labelDirectoryType->show();
-    cmbDirectoryTypes->show();
-    fileGroupBox->show();
-    dbGroupBox->hide();
-    protocolGroupBox->hide();
-    layout()->setSizeConstraint( QLayout::SetFixedSize );
-	mDataSourceType="directory";
-  }
-}
-
-void QgsOpenVectorLayerDialog::on_radioSrcDatabase_toggled( bool checked )
-{
-  if ( checked )
-  {
-    layout()->blockSignals( true );
-    fileGroupBox->hide();
-    protocolGroupBox->hide();
-    dbGroupBox->show();
-    layout()->blockSignals( false );
-    layout()->setSizeConstraint( QLayout::SetFixedSize );
-    setConnectionTypeListPosition();
-    populateConnectionList();
-    setConnectionListPosition();
-	mDataSourceType="database";
-  }
-}
-
-void QgsOpenVectorLayerDialog::on_radioSrcProtocol_toggled( bool checked )
-{
-  if ( checked )
-  {
-    fileGroupBox->hide();
-    dbGroupBox->hide();
-    protocolGroupBox->show();
-    layout()->setSizeConstraint( QLayout::SetFixedSize );
-	mDataSourceType="protocol";
-  }
-}
-
-// Slot for adding a new connection
-void QgsOpenVectorLayerDialog::on_btnNew_clicked()
-{
-  addNewConnection();
-}
-// Slot for deleting an existing connection
-void QgsOpenVectorLayerDialog::on_btnDelete_clicked()
-{
-  deleteConnection();
-}
-
-
-// Slot for editing a connection
-void QgsOpenVectorLayerDialog::on_btnEdit_clicked()
-{
-  editConnection();
-}
-
-void QgsOpenVectorLayerDialog::on_cmbDatabaseTypes_currentIndexChanged( const QString & text )
-{
-  populateConnectionList();
-  setSelectedConnectionType();
-}
-
-void QgsOpenVectorLayerDialog::on_cmbConnections_currentIndexChanged( const QString & text )
-{
-  setSelectedConnection();
-}
-//********************end auto connected slots *****************/
-
-
+/***************************************************************************
+                          qgsopenvectorlayerdialog.cpp
+ Dialog to select the type and source for ogr vectors, supports
+ file, database, directory and protocol sources.
+                             -------------------
+    begin                : Mon Jan 2 2009
+    copyright            : (C) 2009 by Godofredo Contreras Nava
+    email                : frdcn at hotmail.com
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+/* $Id:$ */
+#include <QSettings>
+#include <QFileDialog>
+#include <QMessageBox>
+#include <QInputDialog>
+#include <QTextCodec>
+#include "qgslogger.h"
+#include "qgsencodingfiledialog.h"
+#include "qgsopenvectorlayerdialog.h"
+#include <ogr_api.h>
+#include "qgsproviderregistry.h"
+#include "qgsnewogrconnection.h"
+#include "qgsogrhelperfunctions.h"
+#include "qgscontexthelp.h"
+
+QgsOpenVectorLayerDialog::QgsOpenVectorLayerDialog( QWidget* parent, Qt::WFlags fl )
+    : QDialog( parent, fl )
+{
+  setupUi( this );
+  cmbDatabaseTypes->blockSignals( true );
+  cmbConnections->blockSignals( true );
+  radioSrcFile->setChecked( true );
+  mDataSourceType = "file";
+  //set encoding
+  cmbEncodings->setItemText( cmbEncodings->currentIndex(), QString( QTextCodec::codecForLocale()->name() ) );
+
+  //add database drivers
+  mVectorFileFilter = QgsProviderRegistry::instance()->fileVectorFilters();
+  QgsDebugMsg( "Database drivers :" + QgsProviderRegistry::instance()->databaseDrivers() );
+  QStringList dbDrivers = QgsProviderRegistry::instance()->databaseDrivers().split( ";" );
+
+  for ( int i = 0;i < dbDrivers.count();i++ )
+  {
+    QString dbDriver = dbDrivers.at( i );
+    if (( !dbDriver.isEmpty() ) && ( !dbDriver.isNull() ) )
+      cmbDatabaseTypes->addItem( dbDriver.split( "," ).at( 0 ) );
+  }
+
+  //add directory drivers
+  QStringList dirDrivers = QgsProviderRegistry::instance()->directoryDrivers().split( ";" );
+  for ( int i = 0;i < dirDrivers.count();i++ )
+  {
+    QString dirDriver = dirDrivers.at( i );
+    if (( !dirDriver.isEmpty() ) && ( !dirDriver.isNull() ) )
+      cmbDirectoryTypes->addItem( dirDriver.split( "," ).at( 0 ) );
+  }
+
+  //add protocol drivers
+  QStringList proDrivers = QgsProviderRegistry::instance()->protocolDrivers().split( ";" );
+  for ( int i = 0;i < proDrivers.count();i++ )
+  {
+    QString proDriver = proDrivers.at( i );
+    if (( !proDriver.isEmpty() ) && ( !proDriver.isNull() ) )
+      cmbProtocolTypes->addItem( proDriver.split( "," ).at( 0 ) );
+  }
+  cmbDatabaseTypes->blockSignals( false );
+  cmbConnections->blockSignals( false );
+}
+
+QgsOpenVectorLayerDialog::~QgsOpenVectorLayerDialog()
+{
+}
+
+QStringList QgsOpenVectorLayerDialog::openFile()
+{
+
+  QStringList selectedFiles;
+  QgsDebugMsg( "Vector file filters: " + mVectorFileFilter );
+  QString enc;
+  QString title = tr( "Open an OGR Supported Vector Layer" );
+  openFilesRememberingFilter( "lastVectorFileFilter", mVectorFileFilter, selectedFiles,
+                              title );
+  mEnc = enc;
+  return selectedFiles;
+}
+
+QString QgsOpenVectorLayerDialog::openDirectory()
+{
+  QSettings settings;
+
+  bool haveLastUsedDir = settings.contains( "/UI/LastUsedDirectory" );
+  QString lastUsedDir = settings.value( "/UI/LastUsedDirectory",
+                                        QVariant( QString::null ) ).toString();
+  if ( !haveLastUsedDir )
+    lastUsedDir = "";
+
+  QString path = QFileDialog::getExistingDirectory( this,
+                 tr( "Open Directory" ), lastUsedDir,
+                 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks );
+
+  settings.setValue( "/UI/LastUsedDirectory", path );
+  //process path if it is grass
+  if ( cmbDirectoryTypes->currentText() == "Grass Vector" )
+  {
+#ifdef WIN32
+    //replace backslashes with forward slashes
+    path.replace( "\\", "/" );
+#endif
+    path = path + "/head";
+  }
+  return path;
+}
+
+QStringList QgsOpenVectorLayerDialog::dataSources()
+{
+  return mDataSources;
+}
+
+QString QgsOpenVectorLayerDialog::encoding()
+{
+  return cmbEncodings->currentText();
+}
+
+void QgsOpenVectorLayerDialog::helpInfo()
+{
+  QgsContextHelp::run( context_id );
+}
+
+QString QgsOpenVectorLayerDialog::dataSourceType()
+{
+  return mDataSourceType;
+}
+
+void QgsOpenVectorLayerDialog::addNewConnection()
+{
+  QgsNewOgrConnection *nc = new QgsNewOgrConnection( this );
+  if ( nc->exec() )
+  {
+    populateConnectionList();
+  }
+}
+
+void QgsOpenVectorLayerDialog::editConnection()
+{
+  QgsNewOgrConnection *nc = new QgsNewOgrConnection( this, cmbDatabaseTypes->currentText(), cmbConnections->currentText() );
+
+  if ( nc->exec() )
+  {
+    nc->saveConnection();
+  }
+}
+
+void QgsOpenVectorLayerDialog::deleteConnection()
+{
+  QSettings settings;
+  QString key = "/" + cmbDatabaseTypes->currentText() + "/connections/" + cmbConnections->currentText();
+  QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" )
+                .arg( cmbConnections->currentText() );
+  QMessageBox::StandardButton result = QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
+  if ( result == QMessageBox::Ok )
+  {
+    settings.remove( key + "/host" );
+    settings.remove( key + "/database" );
+    settings.remove( key + "/username" );
+    settings.remove( key + "/password" );
+    settings.remove( key + "/port" );
+    settings.remove( key + "/save" );
+    settings.remove( key );
+    cmbConnections->removeItem( cmbConnections->currentIndex() );  // populateConnectionList();
+    setConnectionListPosition();
+  }
+}
+
+void QgsOpenVectorLayerDialog::populateConnectionList()
+{
+  QSettings settings;
+  settings.beginGroup( "/" + cmbDatabaseTypes->currentText() + "/connections" );
+  QStringList keys = settings.childGroups();
+  QStringList::Iterator it = keys.begin();
+  cmbConnections->clear();
+  while ( it != keys.end() )
+  {
+    cmbConnections->addItem( *it );
+    ++it;
+  }
+  settings.endGroup();
+  setConnectionListPosition();
+}
+
+void QgsOpenVectorLayerDialog::setConnectionListPosition()
+{
+  QSettings settings;
+  // If possible, set the item currently displayed database
+
+  QString toSelect = settings.value( "/" + cmbDatabaseTypes->currentText() + "/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.
+    if ( toSelect.isNull() )
+      cmbConnections->setCurrentIndex( 0 );
+    else
+      cmbConnections->setCurrentIndex( cmbConnections->count() - 1 );
+  }
+}
+
+void QgsOpenVectorLayerDialog::setConnectionTypeListPosition()
+{
+  QSettings settings;
+
+  QString toSelect = settings.value( "/ogr/connections/selectedtype" ).toString();
+  bool set = false;
+  for ( int i = 0; i < cmbDatabaseTypes->count(); ++i )
+    if ( cmbDatabaseTypes->itemText( i ) == toSelect )
+    {
+      cmbDatabaseTypes->setCurrentIndex( i );
+      set = true;
+      break;
+    }
+}
+
+void QgsOpenVectorLayerDialog::setSelectedConnectionType()
+{
+  QSettings settings;
+  QString baseKey = "/ogr/connections/";
+  settings.setValue( baseKey + "selectedtype", cmbDatabaseTypes->currentText() );
+  QgsDebugMsg( "Setting selected type to" + cmbDatabaseTypes->currentText() );
+}
+
+void QgsOpenVectorLayerDialog::setSelectedConnection()
+{
+  QSettings settings;
+  settings.setValue( "/" + cmbDatabaseTypes->currentText() + "/connections/selected", cmbConnections->currentText() );
+  QgsDebugMsg( "Setting selected connection to " + cmbConnections->currentText() );
+}
+
+
+void QgsOpenVectorLayerDialog::on_buttonSelectSrc_clicked()
+{
+  QSettings settings;
+  QString filepath;
+
+  mDataSources.clear();
+
+  if ( radioSrcFile->isChecked() )
+  {
+    //file
+
+    //mType="file";
+    mDataSources = openFile();
+    filepath = "";
+    for ( int i = 0;i < mDataSources.count();i++ )
+      filepath += mDataSources.at( i ) + ";";
+    inputSrcDataset->setText( filepath );
+  }
+  else if ( radioSrcDirectory->isChecked() )
+  {
+
+    filepath = openDirectory();
+    mDataSources.append( filepath );
+    inputSrcDataset->setText( filepath );
+    //mType="directory";
+  }
+  else if ( radioSrcDatabase->isChecked() )
+  {
+    //mType="database";
+    //src = inputSrcDataset->text();
+  }
+  else
+  {
+    Q_ASSERT( !"SHOULD NEVER GET HERE" );
+  }
+
+
+
+}
+
+/**
+  Open files, preferring to have the default file selector be the
+  last one used, if any; also, prefer to start in the last directory
+  associated with filterName.
+
+  @param filterName the name of the filter; used for persistent store
+  key
+  @param filters    the file filters used for QFileDialog
+
+  @param selectedFiles string list of selected files; will be empty
+  if none selected
+  @param title      the title for the dialog
+  @note
+
+  Stores persistent settings under /UI/.  The sub-keys will be
+  filterName and filterName + "Dir".
+
+  Opens dialog on last directory associated with the filter name, or
+  the current working directory if this is the first time invoked
+  with the current filter name.
+
+*/
+void QgsOpenVectorLayerDialog::openFilesRememberingFilter( QString const &filterName,
+    QString const &filters, QStringList & selectedFiles, QString &title )
+{
+
+  bool haveLastUsedFilter = false; // by default, there is no last
+  // used filter
+
+  QSettings settings;         // where we keep last used filter in
+
+  // persistant state
+
+  haveLastUsedFilter = settings.contains( "/UI/" + filterName );
+  QString lastUsedFilter = settings.value( "/UI/" + filterName,
+                           QVariant( QString::null ) ).toString();
+
+  QString lastUsedDir = settings.value( "/UI/" + filterName + "Dir", "." ).toString();
+
+  //QString lastUsedEncoding = settings.value( "/UI/encoding" ).toString();
+
+  QgsDebugMsg( "Opening file dialog with filters: " + filters );
+
+  QFileDialog* openFileDialog = new QFileDialog( 0,
+      title, lastUsedDir, filters );
+
+  // allow for selection of more than one file
+  openFileDialog->setFileMode( QFileDialog::ExistingFiles );
+
+  if ( haveLastUsedFilter )     // set the filter to the last one used
+  {
+    openFileDialog->selectFilter( lastUsedFilter );
+  }
+
+  if ( openFileDialog->exec() == QDialog::Accepted )
+  {
+    selectedFiles = openFileDialog->selectedFiles();
+    //enc = openFileDialog->encoding();
+    // Fix by Tim - getting the dirPath from the dialog
+    // directly truncates the last node in the dir path.
+    // This is a workaround for that
+    QString myFirstFileName = selectedFiles.first();
+    QFileInfo myFI( myFirstFileName );
+    QString myPath = myFI.path();
+
+    QgsDebugMsg( "Writing last used dir: " + myPath );
+
+    settings.setValue( "/UI/" + filterName, openFileDialog->selectedFilter() );
+    settings.setValue( "/UI/" + filterName + "Dir", myPath );
+    //settings.setValue( "/UI/encoding", openFileDialog->encoding() );
+  }
+
+  delete openFileDialog;
+
+}   // openFilesRememberingFilter_
+
+
+
+//********************auto connected slots *****************/
+void QgsOpenVectorLayerDialog::on_buttonBox_accepted()
+{
+  QgsDebugMsg( "dialog button accepted" );
+  if ( radioSrcDatabase->isChecked() )
+  {
+    mDataSources.clear();
+    QSettings settings;
+    QString baseKey = "/" + cmbDatabaseTypes->currentText() + "/connections/";
+    baseKey += cmbConnections->currentText();
+    QString host = settings.value( baseKey + "/host" ).toString();
+    QString database = settings.value( baseKey + "/database" ).toString();
+    QString port = settings.value( baseKey + "/port" ).toString();
+    QString user = settings.value( baseKey + "/username" ).toString();
+    QString pass = settings.value( baseKey + "/password" ).toString();
+    bool makeConnection = false;
+    if ( pass.isEmpty() )
+      pass = QInputDialog::getText( this, tr( "Password for " ) + user,
+                                    tr( "Please enter your password:" ),
+                                    QLineEdit::Password, QString::null, &makeConnection );
+    if ( makeConnection || ( !pass.isEmpty() ) )
+      mDataSources.append( createDatabaseURI(
+                             cmbDatabaseTypes->currentText(),
+                             host,
+                             database,
+                             port,
+                             user,
+                             pass
+                           ) );
+  }
+  else if ( radioSrcProtocol->isChecked() )
+  {
+    mDataSources.clear();
+    mDataSources.append( createProtocolURI(
+                           cmbProtocolTypes->currentText(),
+                           protocolURI->text()
+                         ) );
+  }
+  accept();
+}
+
+void QgsOpenVectorLayerDialog::on_btnHelp_clicked()
+{
+  helpInfo();
+}
+
+void QgsOpenVectorLayerDialog::on_radioSrcFile_toggled( bool checked )
+{
+  if ( checked )
+  {
+    labelDirectoryType->hide();
+    cmbDirectoryTypes->hide();
+    fileGroupBox->show();
+    dbGroupBox->hide();
+    protocolGroupBox->hide();
+    layout()->setSizeConstraint( QLayout::SetFixedSize );
+    mDataSourceType = "file";
+  }
+}
+
+void QgsOpenVectorLayerDialog::on_radioSrcDirectory_toggled( bool checked )
+{
+  if ( checked )
+  {
+    labelDirectoryType->show();
+    cmbDirectoryTypes->show();
+    fileGroupBox->show();
+    dbGroupBox->hide();
+    protocolGroupBox->hide();
+    layout()->setSizeConstraint( QLayout::SetFixedSize );
+    mDataSourceType = "directory";
+  }
+}
+
+void QgsOpenVectorLayerDialog::on_radioSrcDatabase_toggled( bool checked )
+{
+  if ( checked )
+  {
+    layout()->blockSignals( true );
+    fileGroupBox->hide();
+    protocolGroupBox->hide();
+    dbGroupBox->show();
+    layout()->blockSignals( false );
+    layout()->setSizeConstraint( QLayout::SetFixedSize );
+    setConnectionTypeListPosition();
+    populateConnectionList();
+    setConnectionListPosition();
+    mDataSourceType = "database";
+  }
+}
+
+void QgsOpenVectorLayerDialog::on_radioSrcProtocol_toggled( bool checked )
+{
+  if ( checked )
+  {
+    fileGroupBox->hide();
+    dbGroupBox->hide();
+    protocolGroupBox->show();
+    layout()->setSizeConstraint( QLayout::SetFixedSize );
+    mDataSourceType = "protocol";
+  }
+}
+
+// Slot for adding a new connection
+void QgsOpenVectorLayerDialog::on_btnNew_clicked()
+{
+  addNewConnection();
+}
+// Slot for deleting an existing connection
+void QgsOpenVectorLayerDialog::on_btnDelete_clicked()
+{
+  deleteConnection();
+}
+
+
+// Slot for editing a connection
+void QgsOpenVectorLayerDialog::on_btnEdit_clicked()
+{
+  editConnection();
+}
+
+void QgsOpenVectorLayerDialog::on_cmbDatabaseTypes_currentIndexChanged( const QString & text )
+{
+  populateConnectionList();
+  setSelectedConnectionType();
+}
+
+void QgsOpenVectorLayerDialog::on_cmbConnections_currentIndexChanged( const QString & text )
+{
+  setSelectedConnection();
+}
+//********************end auto connected slots *****************/
+
+

Modified: trunk/qgis/src/app/ogr/qgsopenvectorlayerdialog.h
===================================================================
--- trunk/qgis/src/app/ogr/qgsopenvectorlayerdialog.h	2009-04-03 04:01:19 UTC (rev 10457)
+++ trunk/qgis/src/app/ogr/qgsopenvectorlayerdialog.h	2009-04-03 06:54:21 UTC (rev 10458)
@@ -1,97 +1,97 @@
-/***************************************************************************
-                          qgsopenvectorlayerdialog.h
- Dialog to select the type and source for ogr vectors, supports
- file, database, directory and protocol sources.
-                             -------------------
-    begin                : Mon Jan 2 2009
-    copyright            : (C) 2009 by Godofredo Contreras Nava
-    email                : frdcn at hotmail.com
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- ***************************************************************************/
-/* $Id:$ */
-#ifndef QGSOPENVECTORLAYERDIALOG_H
-#define QGSOPENVECTORLAYERDIALOG_H
-
-
-#include <ui_qgsopenvectorlayerdialogbase.h>
-#include <QDialog>
-
-/**
- *  Class for a  dialog to select the type and source for ogr vectors, supports
- *  file, database, directory and protocol sources.
- */
-class QgsOpenVectorLayerDialog : public QDialog, private Ui::QgsOpenVectorLayerDialogBase
-{
-    Q_OBJECT
-
-  public:
-    QgsOpenVectorLayerDialog( QWidget* parent = 0,  Qt::WFlags fl = 0 );
-    ~QgsOpenVectorLayerDialog();
-    //! Opens a dialog to select a file datasource*/
-    QStringList openFile();
-    //! Opens a dialog to select a directory datasource*/
-    QString openDirectory();
-    //! Returns a list of selected datasources*/
-    QStringList dataSources();
-    //! Returns the encoding selected for user*/
-    QString encoding();
-    //! Display the context help
-    void helpInfo();
-	//! Returns the connection type
-	QString dataSourceType();
-  private:
-    //! Shows a dialog remembering the last directory and filter selected */
-    void openFilesRememberingFilter( QString const &filterName,
-                                     QString const &filters, QStringList & selectedFiles, QString &title );
-    //! Stores the file vector filters */
-    QString mVectorFileFilter;
-    //! Stores the selected datasources */
-    QStringList mDataSources;
-    //! Stores the user selected encoding
-    QString mEnc;
-    //! Stores the datasource type 
-	QString mDataSourceType; 
-    static const int context_id = 348772824;
-
-
-  private slots:
-    //! Opens the create connection dialog to build a new connection
-    void addNewConnection();
-    //! Opens a dialog to edit an existing connection
-    void editConnection();
-    //! Deletes the selected connection
-    void deleteConnection();
-    //! Populate the connection list combo box
-    void populateConnectionList();
-    //! Sets the actual position in connection list
-    void setConnectionListPosition();
-    //! Sets the actual position in types connection list
-    void setConnectionTypeListPosition();
-    //! Sets the selected connection type
-    void setSelectedConnectionType();
-    //! Sets the selected connection
-    void setSelectedConnection();
-
-    void on_buttonBox_accepted();
-    void on_btnHelp_clicked();
-    void on_buttonSelectSrc_clicked();
-    void on_radioSrcFile_toggled( bool checked );
-    void on_radioSrcDirectory_toggled( bool checked );
-    void on_radioSrcDatabase_toggled( bool checked );
-    void on_radioSrcProtocol_toggled( bool checked );
-    void on_btnNew_clicked();
-    void on_btnEdit_clicked();
-    void on_btnDelete_clicked();
-    void on_cmbDatabaseTypes_currentIndexChanged( const QString & text );
-    void on_cmbConnections_currentIndexChanged( const QString & text );
-};
-
-#endif // QGSOPENVECTORDIALOG_H
+/***************************************************************************
+                          qgsopenvectorlayerdialog.h
+ Dialog to select the type and source for ogr vectors, supports
+ file, database, directory and protocol sources.
+                             -------------------
+    begin                : Mon Jan 2 2009
+    copyright            : (C) 2009 by Godofredo Contreras Nava
+    email                : frdcn at hotmail.com
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+/* $Id:$ */
+#ifndef QGSOPENVECTORLAYERDIALOG_H
+#define QGSOPENVECTORLAYERDIALOG_H
+
+
+#include <ui_qgsopenvectorlayerdialogbase.h>
+#include <QDialog>
+
+/**
+ *  Class for a  dialog to select the type and source for ogr vectors, supports
+ *  file, database, directory and protocol sources.
+ */
+class QgsOpenVectorLayerDialog : public QDialog, private Ui::QgsOpenVectorLayerDialogBase
+{
+    Q_OBJECT
+
+  public:
+    QgsOpenVectorLayerDialog( QWidget* parent = 0,  Qt::WFlags fl = 0 );
+    ~QgsOpenVectorLayerDialog();
+    //! Opens a dialog to select a file datasource*/
+    QStringList openFile();
+    //! Opens a dialog to select a directory datasource*/
+    QString openDirectory();
+    //! Returns a list of selected datasources*/
+    QStringList dataSources();
+    //! Returns the encoding selected for user*/
+    QString encoding();
+    //! Display the context help
+    void helpInfo();
+    //! Returns the connection type
+    QString dataSourceType();
+  private:
+    //! Shows a dialog remembering the last directory and filter selected */
+    void openFilesRememberingFilter( QString const &filterName,
+                                     QString const &filters, QStringList & selectedFiles, QString &title );
+    //! Stores the file vector filters */
+    QString mVectorFileFilter;
+    //! Stores the selected datasources */
+    QStringList mDataSources;
+    //! Stores the user selected encoding
+    QString mEnc;
+    //! Stores the datasource type
+    QString mDataSourceType;
+    static const int context_id = 348772824;
+
+
+  private slots:
+    //! Opens the create connection dialog to build a new connection
+    void addNewConnection();
+    //! Opens a dialog to edit an existing connection
+    void editConnection();
+    //! Deletes the selected connection
+    void deleteConnection();
+    //! Populate the connection list combo box
+    void populateConnectionList();
+    //! Sets the actual position in connection list
+    void setConnectionListPosition();
+    //! Sets the actual position in types connection list
+    void setConnectionTypeListPosition();
+    //! Sets the selected connection type
+    void setSelectedConnectionType();
+    //! Sets the selected connection
+    void setSelectedConnection();
+
+    void on_buttonBox_accepted();
+    void on_btnHelp_clicked();
+    void on_buttonSelectSrc_clicked();
+    void on_radioSrcFile_toggled( bool checked );
+    void on_radioSrcDirectory_toggled( bool checked );
+    void on_radioSrcDatabase_toggled( bool checked );
+    void on_radioSrcProtocol_toggled( bool checked );
+    void on_btnNew_clicked();
+    void on_btnEdit_clicked();
+    void on_btnDelete_clicked();
+    void on_cmbDatabaseTypes_currentIndexChanged( const QString & text );
+    void on_cmbConnections_currentIndexChanged( const QString & text );
+};
+
+#endif // QGSOPENVECTORDIALOG_H

Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp	2009-04-03 04:01:19 UTC (rev 10457)
+++ trunk/qgis/src/app/qgisapp.cpp	2009-04-03 06:54:21 UTC (rev 10458)
@@ -2163,9 +2163,9 @@
       // no files were selected, so just bail
       mMapCanvas->freeze( false );
       return;
-     }
-	else
-     addVectorLayers( selectedSources, enc, ovl->dataSourceType() );
+    }
+    else
+      addVectorLayers( selectedSources, enc, ovl->dataSourceType() );
   }
 
   delete ovl;
@@ -2176,26 +2176,26 @@
 
 bool QgisApp::addVectorLayers( QStringList const & theLayerQStringList, const QString& enc, const QString dataSourceType )
 {
-  
+
   for ( QStringList::ConstIterator it = theLayerQStringList.begin();
         it != theLayerQStringList.end();
         ++it )
   {
     QString base;
-    if(dataSourceType=="file")
-	  {
-        QFileInfo fi( *it );
-        base = fi.completeBaseName();
-	  }
-	else if(dataSourceType=="database")
-	  {
-        base=*it;  
-	  }
-	else //directory //protocol
-	  {
-		QFileInfo fi( *it );
-        base = fi.completeBaseName();
-	  }
+    if ( dataSourceType == "file" )
+    {
+      QFileInfo fi( *it );
+      base = fi.completeBaseName();
+    }
+    else if ( dataSourceType == "database" )
+    {
+      base = *it;
+    }
+    else //directory //protocol
+    {
+      QFileInfo fi( *it );
+      base = fi.completeBaseName();
+    }
 
 
     QgsDebugMsg( "completeBaseName: " + base );
@@ -2523,7 +2523,7 @@
   {
 
     addRasterLayer( wmss->connectionInfo(),
-                    /*wmss->connName()*/wmss->selectedLayers().join("/"),
+                    /*wmss->connName()*/wmss->selectedLayers().join( "/" ),
                     "wms",
                     wmss->selectedLayers(),
                     wmss->selectedStylesForSelectedLayers(),

Modified: trunk/qgis/src/app/qgisapp.h
===================================================================
--- trunk/qgis/src/app/qgisapp.h	2009-04-03 04:01:19 UTC (rev 10457)
+++ trunk/qgis/src/app/qgisapp.h	2009-04-03 06:54:21 UTC (rev 10458)
@@ -83,7 +83,7 @@
     /** \brief overloaded vesion of the privat addLayer method that takes a list of
      * file names instead of prompting user with a dialog.
      @param enc encoding type for the layer
-	 @param dataSourceType type of ogr datasource
+    @param dataSourceType type of ogr datasource
      @returns true if successfully added layer
      */
     bool addVectorLayers( QStringList const & theLayerQStringList, const QString& enc, const QString dataSourceType );

Modified: trunk/qgis/src/app/qgsdbsourceselect.cpp
===================================================================
--- trunk/qgis/src/app/qgsdbsourceselect.cpp	2009-04-03 04:01:19 UTC (rev 10457)
+++ trunk/qgis/src/app/qgsdbsourceselect.cpp	2009-04-03 06:54:21 UTC (rev 10458)
@@ -375,7 +375,7 @@
                      database,
                      settings.value( key + "/username" ).toString(),
                      password,
-                     (QgsDataSourceURI::SSLmode) settings.value( key + "/sslmode", QgsDataSourceURI::SSLprefer ).toInt() );
+                     ( QgsDataSourceURI::SSLmode ) settings.value( key + "/sslmode", QgsDataSourceURI::SSLprefer ).toInt() );
 
 
 
@@ -415,7 +415,7 @@
                          database,
                          settings.value( key + "/username" ).toString(),
                          password,
-                         (QgsDataSourceURI::SSLmode) settings.value( key + "/sslmode", QgsDataSourceURI::SSLprefer ).toInt() );
+                         ( QgsDataSourceURI::SSLmode ) settings.value( key + "/sslmode", QgsDataSourceURI::SSLprefer ).toInt() );
 
       m_connectionInfo = uri.connectionInfo();
       PQfinish( pd );

Modified: trunk/qgis/src/app/qgsnewconnection.cpp
===================================================================
--- trunk/qgis/src/app/qgsnewconnection.cpp	2009-04-03 04:01:19 UTC (rev 10457)
+++ trunk/qgis/src/app/qgsnewconnection.cpp	2009-04-03 06:54:21 UTC (rev 10458)
@@ -61,10 +61,10 @@
     // Ensure that cb_plublicSchemaOnly is set correctly
     on_cb_geometryColumnsOnly_clicked();
 
-    cbxSSLmode->insertItem( QgsDataSourceURI::SSLprefer, tr("prefer") );
-    cbxSSLmode->insertItem( QgsDataSourceURI::SSLrequire, tr("require") );
-    cbxSSLmode->insertItem( QgsDataSourceURI::SSLallow, tr("allow") );
-    cbxSSLmode->insertItem( QgsDataSourceURI::SSLdisable, tr("disable") );
+    cbxSSLmode->insertItem( QgsDataSourceURI::SSLprefer, tr( "prefer" ) );
+    cbxSSLmode->insertItem( QgsDataSourceURI::SSLrequire, tr( "require" ) );
+    cbxSSLmode->insertItem( QgsDataSourceURI::SSLallow, tr( "allow" ) );
+    cbxSSLmode->insertItem( QgsDataSourceURI::SSLdisable, tr( "disable" ) );
     cbxSSLmode->setCurrentIndex( settings.value( key + "/sslmode", QgsDataSourceURI::SSLprefer ).toInt() );
 
     if ( settings.value( key + "/save" ).toString() == "true" )
@@ -114,7 +114,7 @@
 void QgsNewConnection::testConnection()
 {
   QgsDataSourceURI uri;
-  uri.setConnection( txtHost->text(), txtPort->text(), txtDatabase->text(), txtUsername->text(), txtPassword->text(), (QgsDataSourceURI::SSLmode) cbxSSLmode->currentIndex() );
+  uri.setConnection( txtHost->text(), txtPort->text(), txtDatabase->text(), txtUsername->text(), txtPassword->text(), ( QgsDataSourceURI::SSLmode ) cbxSSLmode->currentIndex() );
 
   QgsLogger::debug( "PQconnectdb(" + uri.connectionInfo() + ");" );
 

Modified: trunk/qgis/src/app/qgspluginmanager.cpp
===================================================================
--- trunk/qgis/src/app/qgspluginmanager.cpp	2009-04-03 04:01:19 UTC (rev 10457)
+++ trunk/qgis/src/app/qgspluginmanager.cpp	2009-04-03 06:54:21 UTC (rev 10458)
@@ -94,7 +94,7 @@
   connect( btnClearAll, SIGNAL( clicked() ), this, SLOT( clearAll() ) );
 
   qRegisterMetaType<QgsDetailedItemData>();
-  
+
   // add installer's icon
   QString myCurThemePath = QgsApplication::activeThemePath() + "/plugins/plugin_installer.png";
   QString myDefThemePath = QgsApplication::defaultThemePath() + "/plugins/plugin_installer.png";
@@ -106,15 +106,15 @@
   {
     btnPluginInstaller->setIcon( QIcon( myDefThemePath ) );
   }
-  
+
   // check for plugin installer
-  if (checkForPluginInstaller())
+  if ( checkForPluginInstaller() )
   {
-    connect( btnPluginInstaller, SIGNAL( clicked() ), this, SLOT( showPluginInstaller() ));
+    connect( btnPluginInstaller, SIGNAL( clicked() ), this, SLOT( showPluginInstaller() ) );
   }
   else
   {
-    btnPluginInstaller->setEnabled(false);
+    btnPluginInstaller->setEnabled( false );
   }
 }
 
@@ -527,22 +527,22 @@
 bool QgsPluginManager::checkForPluginInstaller()
 {
   // check whether python's enabled
-  if (!mPythonUtils)
+  if ( !mPythonUtils )
     return false;
-  
+
   // check whether python installer is present
-  if (!mPythonUtils->pluginList().contains("plugin_installer"))
+  if ( !mPythonUtils->pluginList().contains( "plugin_installer" ) )
     return false;
-  
+
   QString res;
   // check it's loaded and started
-  bool retval = mPythonUtils->evalString("plugins.has_key('plugin_installer')", res);
-  if (!retval || res != "True")
+  bool retval = mPythonUtils->evalString( "plugins.has_key('plugin_installer')", res );
+  if ( !retval || res != "True" )
   {
     // TODO: try to load the plugin installer!
     return false;
   }
-  
+
   return true;
 }
 
@@ -550,16 +550,16 @@
 {
   bool res;
   QString cls, msg;
-  res = mPythonUtils->runStringUnsafe("_qgis_plugin_manager = wrapinstance( " + QString::number((unsigned long)this) + ", QtGui.QWidget )");
-  if (!res)
+  res = mPythonUtils->runStringUnsafe( "_qgis_plugin_manager = wrapinstance( " + QString::number(( unsigned long )this ) + ", QtGui.QWidget )" );
+  if ( !res )
   {
-    QgsDebugMsg("wrapinstance error: " + cls + " :: " + msg);
+    QgsDebugMsg( "wrapinstance error: " + cls + " :: " + msg );
   }
-  res = mPythonUtils->runStringUnsafe("plugins['plugin_installer'].run( _qgis_plugin_manager )");
-  if (!res)
+  res = mPythonUtils->runStringUnsafe( "plugins['plugin_installer'].run( _qgis_plugin_manager )" );
+  if ( !res )
   {
-    mPythonUtils->getError(cls, msg);
-    QMessageBox::warning(this, tr("Error"), tr("Failed to open plugin installer!"));
-    mPythonUtils->runStringUnsafe("del _qgis_plugin_manager");
+    mPythonUtils->getError( cls, msg );
+    QMessageBox::warning( this, tr( "Error" ), tr( "Failed to open plugin installer!" ) );
+    mPythonUtils->runStringUnsafe( "del _qgis_plugin_manager" );
   }
 }

Modified: trunk/qgis/src/core/qgsdatasourceuri.cpp
===================================================================
--- trunk/qgis/src/core/qgsdatasourceuri.cpp	2009-04-03 04:01:19 UTC (rev 10457)
+++ trunk/qgis/src/core/qgsdatasourceuri.cpp	2009-04-03 06:54:21 UTC (rev 10458)
@@ -1,395 +1,395 @@
-/***************************************************************************
-      qgsdatasourceuri.h  -  Structure to contain the component parts
-                             of a data source URI
-                             -------------------
-    begin                : Dec 5, 2004
-    copyright            : (C) 2004 by Gary E.Sherman
-    email                : sherman at mrcc.com
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- ***************************************************************************/
-/* $Id: qgsdatasourceuri.h 5839 2006-09-19 18:04:21Z wonder $ */
-
-#include "qgsdatasourceuri.h"
-#include "qgslogger.h"
-
-#include <QStringList>
-#include <QRegExp>
-
-QgsDataSourceURI::QgsDataSourceURI() : mSSLmode(SSLprefer)
-{
-  // do nothing
-}
-
-QgsDataSourceURI::QgsDataSourceURI( QString uri ) : mSSLmode(SSLprefer)
-{
-  int i = 0;
-  while ( i < uri.length() )
-  {
-    skipBlanks( uri, i );
-
-    if ( uri[i] == '=' )
-    {
-      QgsDebugMsg( "parameter name expected before =" );
-      i++;
-      continue;
-    }
-
-    int start = i;
-
-    while ( i < uri.length() && uri[i] != '=' && !uri[i].isSpace() )
-      i++;
-
-    QString pname = uri.mid( start, i - start );
-
-    skipBlanks( uri, i );
-
-    if ( uri[i] != '=' )
-    {
-      QgsDebugMsg( "= expected after parameter name" );
-      return;
-    }
-
-    i++;
-
-    if ( pname == "sql" )
-    {
-      // rest of line is a sql where clause
-      skipBlanks( uri, i );
-      mSql = uri.mid( i );
-      break;
-    }
-    else
-    {
-      QString pval = getValue( uri, i );
-
-      if ( pname == "table" )
-      {
-        if ( uri[i] == '.' )
-        {
-          i++;
-
-          mSchema = pval;
-          mTable = getValue( uri, i );
-        }
-        else
-        {
-          mSchema = "";
-          mTable = pval;
-        }
-
-        if ( uri[i] == '(' )
-        {
-          i++;
-
-          int start = i;
-          QString col;
-          while ( i < uri.length() && uri[i] != ')' )
-            i++;
-
-          if ( i == uri.length() )
-          {
-            QgsDebugMsg( "closing parenthesis missing" );
-          }
-
-          mGeometryColumn = uri.mid( start, i - start );
-
-          i++;
-        }
-      }
-      else if ( pname == "service" )
-      {
-        QgsDebugMsg( "service keyword ignored" );
-      }
-      else if ( pname == "user" )
-      {
-        mUsername = pval;
-      }
-      else if ( pname == "password" )
-      {
-        mPassword = pval;
-      }
-      else if ( pname == "connect_timeout" )
-      {
-        QgsDebugMsg( "connection timeout ignored" );
-      }
-      else if ( pname == "dbname" )
-      {
-        mDatabase = pval;
-      }
-      else if ( pname == "host" )
-      {
-        mHost = pval;
-      }
-      else if ( pname == "hostaddr" )
-      {
-        QgsDebugMsg( "database host ip address ignored" );
-      }
-      else if ( pname == "port" )
-      {
-        mPort = pval;
-      }
-      else if ( pname == "tty" )
-      {
-        QgsDebugMsg( "backend debug tty ignored" );
-      }
-      else if ( pname == "options" )
-      {
-        QgsDebugMsg( "backend debug options ignored" );
-      }
-      else if ( pname == "sslmode" )
-      {
-        if( pval == "disable" )
-          mSSLmode = SSLdisable;
-        else if( pval == "allow" )
-          mSSLmode = SSLallow;
-        else if( pval == "prefer" )
-          mSSLmode = SSLprefer;
-        else if( pval == "require" )
-          mSSLmode = SSLrequire;
-      }
-      else if ( pname == "requiressl" )
-      {
-        if( pval == "0" )
-          mSSLmode = SSLdisable;         
-        else
-          mSSLmode = SSLprefer;
-      }
-      else if ( pname == "krbsrvname" )
-      {
-        QgsDebugMsg( "kerberos server name ignored" );
-      }
-      else if ( pname == "gsslib" )
-      {
-        QgsDebugMsg( "gsslib ignored" );
-      }
-      else
-      {
-        QgsDebugMsg( "invalid connection option \"" + pname + "\" ignored" );
-      }
-    }
-  }
-}
-
-QString QgsDataSourceURI::removePassword( const QString& aUri)
-{
-  QRegExp regexp;
-  regexp.setMinimal( true );
-  QString safeName( aUri );
-  //this works for postgres, ingres, mysql, 
-  if((aUri.contains("PG:"))
-     ||(aUri.contains("driver=ingres")) 
-	 ||(aUri.contains("MySQL:"))) 
-    {
-       regexp.setPattern( " password=.* " );
-	   safeName.replace( regexp, " " );
-    }
-  else if (aUri.contains("IDB:"))
-    {
-       regexp.setPattern( " pass=.* " );
-	   safeName.replace( regexp, " " );
-    }
-  else if  ((aUri.contains("OCI:"))
-	   ||(aUri.contains("ODBC:")))
-    {
-       regexp.setPattern( "/.*@" );
-	   safeName.replace( regexp, "/@" );
-    }
-  else if  (aUri.contains("SDE:"))
-    {
-       QStringList strlist=aUri.split(",");
-	   safeName=strlist[0]+","+strlist[1]+","+strlist[2]+","+strlist[3];
-    } 
-  return safeName;
-}
-
-QString QgsDataSourceURI::username() const
-{
-  return mUsername;
-}
-
-QString QgsDataSourceURI::schema() const
-{
-  return mSchema;
-}
-
-QString QgsDataSourceURI::table() const
-{
-  return mTable;
-}
-
-QString QgsDataSourceURI::sql() const
-{
-  return mSql;
-}
-
-QString QgsDataSourceURI::geometryColumn() const
-{
-  return mGeometryColumn;
-}
-
-void QgsDataSourceURI::setSql( QString sql )
-{
-  mSql = sql;
-}
-
-void QgsDataSourceURI::clearSchema()
-{
-  mSchema = "";
-}
-
-void QgsDataSourceURI::skipBlanks( const QString &uri, int &i )
-{
-  // skip space before value
-  while ( i < uri.length() && uri[i].isSpace() )
-    i++;
-}
-
-QString QgsDataSourceURI::getValue( const QString &uri, int &i )
-{
-  skipBlanks( uri, i );
-
-  // Get the parameter value
-  QString pval;
-  if ( uri[i] == '\'' || uri[i] == '"' )
-  {
-    QChar delim = uri[i];
-
-    i++;
-
-    // value is quoted
-    for ( ;; )
-    {
-      if ( i == uri.length() )
-      {
-        QgsDebugMsg( "unterminated quoted string in connection info string" );
-        return pval;
-      }
-
-      if ( uri[i] == '\\' )
-      {
-        i++;
-        if ( i == uri.length() )
-          continue;
-      }
-      else if ( uri[i] == delim )
-      {
-        i++;
-        break;
-      }
-
-      pval += uri[i++];
-    }
-  }
-  else
-  {
-    // value is not quoted
-    while ( i < uri.length() )
-    {
-      if ( uri[i].isSpace() )
-      {
-        // end of value
-        break;
-      }
-
-      if ( uri[i] == '\\' )
-      {
-        i++;
-        if ( i == uri.length() )
-          break;
-      }
-
-      pval += uri[i++];
-    }
-  }
-
-  skipBlanks( uri, i );
-
-  return pval;
-}
-
-QString QgsDataSourceURI::connectionInfo() const
-{
-  QString connectionInfo = "dbname='" + mDatabase + "'";
-
-  if ( mHost != "" )
-  {
-    connectionInfo += " host=" + mHost;
-    if ( mPort != "" )
-      connectionInfo += " port=" + mPort;
-  }
-
-  if ( mUsername != "" )
-  {
-    connectionInfo += " user='" + mUsername + "'"; //needs to be escaped
-
-    if ( mPassword != "" )
-    {
-      QString p = mPassword;
-      p.replace( '\\', "\\\\" );
-      p.replace( '\'', "\\'" );
-      connectionInfo += " password='" + p + "'";
-    }
-  }
-
-  if ( mSSLmode == SSLdisable )
-    connectionInfo += " sslmode=disable";
-  else if ( mSSLmode == SSLallow )
-    connectionInfo += " sslmode=allow";
-  else if ( mSSLmode == SSLrequire )
-    connectionInfo += " sslmode=require";
-  else if ( mSSLmode == SSLprefer )
-    connectionInfo += " sslmode=prefer";
-
-  return connectionInfo;
-}
-
-QString QgsDataSourceURI::uri() const
-{
-  return connectionInfo()
-         + QString( " table=%1 (%2) sql=%3" )
-         .arg( quotedTablename() )
-         .arg( mGeometryColumn )
-         .arg( mSql );
-}
-
-QString QgsDataSourceURI::quotedTablename() const
-{
-  if ( mSchema != "" )
-    return QString( "\"%1\".\"%2\"" ).arg( mSchema ).arg( mTable );
-  else
-    return QString( "\"%1\"" ).arg( mTable );
-}
-
-void QgsDataSourceURI::setConnection( const QString &host,
-                                      const QString &port,
-                                      const QString &database,
-                                      const QString &username,
-                                      const QString &password,
-                                      SSLmode sslmode )
-{
-  mHost = host;
-  mDatabase = database;
-  mPort = port;
-  mUsername = username;
-  mPassword = password;
-  mSSLmode = sslmode;
-}
-
-void QgsDataSourceURI::setDataSource( const QString &schema,
-                                      const QString &table,
-                                      const QString &geometryColumn,
-                                      const QString &sql )
-{
-  mSchema = schema;
-  mTable = table;
-  mGeometryColumn = geometryColumn;
-  mSql = sql;
-}
+/***************************************************************************
+      qgsdatasourceuri.h  -  Structure to contain the component parts
+                             of a data source URI
+                             -------------------
+    begin                : Dec 5, 2004
+    copyright            : (C) 2004 by Gary E.Sherman
+    email                : sherman at mrcc.com
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+/* $Id: qgsdatasourceuri.h 5839 2006-09-19 18:04:21Z wonder $ */
+
+#include "qgsdatasourceuri.h"
+#include "qgslogger.h"
+
+#include <QStringList>
+#include <QRegExp>
+
+QgsDataSourceURI::QgsDataSourceURI() : mSSLmode( SSLprefer )
+{
+  // do nothing
+}
+
+QgsDataSourceURI::QgsDataSourceURI( QString uri ) : mSSLmode( SSLprefer )
+{
+  int i = 0;
+  while ( i < uri.length() )
+  {
+    skipBlanks( uri, i );
+
+    if ( uri[i] == '=' )
+    {
+      QgsDebugMsg( "parameter name expected before =" );
+      i++;
+      continue;
+    }
+
+    int start = i;
+
+    while ( i < uri.length() && uri[i] != '=' && !uri[i].isSpace() )
+      i++;
+
+    QString pname = uri.mid( start, i - start );
+
+    skipBlanks( uri, i );
+
+    if ( uri[i] != '=' )
+    {
+      QgsDebugMsg( "= expected after parameter name" );
+      return;
+    }
+
+    i++;
+
+    if ( pname == "sql" )
+    {
+      // rest of line is a sql where clause
+      skipBlanks( uri, i );
+      mSql = uri.mid( i );
+      break;
+    }
+    else
+    {
+      QString pval = getValue( uri, i );
+
+      if ( pname == "table" )
+      {
+        if ( uri[i] == '.' )
+        {
+          i++;
+
+          mSchema = pval;
+          mTable = getValue( uri, i );
+        }
+        else
+        {
+          mSchema = "";
+          mTable = pval;
+        }
+
+        if ( uri[i] == '(' )
+        {
+          i++;
+
+          int start = i;
+          QString col;
+          while ( i < uri.length() && uri[i] != ')' )
+            i++;
+
+          if ( i == uri.length() )
+          {
+            QgsDebugMsg( "closing parenthesis missing" );
+          }
+
+          mGeometryColumn = uri.mid( start, i - start );
+
+          i++;
+        }
+      }
+      else if ( pname == "service" )
+      {
+        QgsDebugMsg( "service keyword ignored" );
+      }
+      else if ( pname == "user" )
+      {
+        mUsername = pval;
+      }
+      else if ( pname == "password" )
+      {
+        mPassword = pval;
+      }
+      else if ( pname == "connect_timeout" )
+      {
+        QgsDebugMsg( "connection timeout ignored" );
+      }
+      else if ( pname == "dbname" )
+      {
+        mDatabase = pval;
+      }
+      else if ( pname == "host" )
+      {
+        mHost = pval;
+      }
+      else if ( pname == "hostaddr" )
+      {
+        QgsDebugMsg( "database host ip address ignored" );
+      }
+      else if ( pname == "port" )
+      {
+        mPort = pval;
+      }
+      else if ( pname == "tty" )
+      {
+        QgsDebugMsg( "backend debug tty ignored" );
+      }
+      else if ( pname == "options" )
+      {
+        QgsDebugMsg( "backend debug options ignored" );
+      }
+      else if ( pname == "sslmode" )
+      {
+        if ( pval == "disable" )
+          mSSLmode = SSLdisable;
+        else if ( pval == "allow" )
+          mSSLmode = SSLallow;
+        else if ( pval == "prefer" )
+          mSSLmode = SSLprefer;
+        else if ( pval == "require" )
+          mSSLmode = SSLrequire;
+      }
+      else if ( pname == "requiressl" )
+      {
+        if ( pval == "0" )
+          mSSLmode = SSLdisable;
+        else
+          mSSLmode = SSLprefer;
+      }
+      else if ( pname == "krbsrvname" )
+      {
+        QgsDebugMsg( "kerberos server name ignored" );
+      }
+      else if ( pname == "gsslib" )
+      {
+        QgsDebugMsg( "gsslib ignored" );
+      }
+      else
+      {
+        QgsDebugMsg( "invalid connection option \"" + pname + "\" ignored" );
+      }
+    }
+  }
+}
+
+QString QgsDataSourceURI::removePassword( const QString& aUri )
+{
+  QRegExp regexp;
+  regexp.setMinimal( true );
+  QString safeName( aUri );
+  //this works for postgres, ingres, mysql,
+  if (( aUri.contains( "PG:" ) )
+      || ( aUri.contains( "driver=ingres" ) )
+      || ( aUri.contains( "MySQL:" ) ) )
+  {
+    regexp.setPattern( " password=.* " );
+    safeName.replace( regexp, " " );
+  }
+  else if ( aUri.contains( "IDB:" ) )
+  {
+    regexp.setPattern( " pass=.* " );
+    safeName.replace( regexp, " " );
+  }
+  else if (( aUri.contains( "OCI:" ) )
+           || ( aUri.contains( "ODBC:" ) ) )
+  {
+    regexp.setPattern( "/.*@" );
+    safeName.replace( regexp, "/@" );
+  }
+  else if ( aUri.contains( "SDE:" ) )
+  {
+    QStringList strlist = aUri.split( "," );
+    safeName = strlist[0] + "," + strlist[1] + "," + strlist[2] + "," + strlist[3];
+  }
+  return safeName;
+}
+
+QString QgsDataSourceURI::username() const
+{
+  return mUsername;
+}
+
+QString QgsDataSourceURI::schema() const
+{
+  return mSchema;
+}
+
+QString QgsDataSourceURI::table() const
+{
+  return mTable;
+}
+
+QString QgsDataSourceURI::sql() const
+{
+  return mSql;
+}
+
+QString QgsDataSourceURI::geometryColumn() const
+{
+  return mGeometryColumn;
+}
+
+void QgsDataSourceURI::setSql( QString sql )
+{
+  mSql = sql;
+}
+
+void QgsDataSourceURI::clearSchema()
+{
+  mSchema = "";
+}
+
+void QgsDataSourceURI::skipBlanks( const QString &uri, int &i )
+{
+  // skip space before value
+  while ( i < uri.length() && uri[i].isSpace() )
+    i++;
+}
+
+QString QgsDataSourceURI::getValue( const QString &uri, int &i )
+{
+  skipBlanks( uri, i );
+
+  // Get the parameter value
+  QString pval;
+  if ( uri[i] == '\'' || uri[i] == '"' )
+  {
+    QChar delim = uri[i];
+
+    i++;
+
+    // value is quoted
+    for ( ;; )
+    {
+      if ( i == uri.length() )
+      {
+        QgsDebugMsg( "unterminated quoted string in connection info string" );
+        return pval;
+      }
+
+      if ( uri[i] == '\\' )
+      {
+        i++;
+        if ( i == uri.length() )
+          continue;
+      }
+      else if ( uri[i] == delim )
+      {
+        i++;
+        break;
+      }
+
+      pval += uri[i++];
+    }
+  }
+  else
+  {
+    // value is not quoted
+    while ( i < uri.length() )
+    {
+      if ( uri[i].isSpace() )
+      {
+        // end of value
+        break;
+      }
+
+      if ( uri[i] == '\\' )
+      {
+        i++;
+        if ( i == uri.length() )
+          break;
+      }
+
+      pval += uri[i++];
+    }
+  }
+
+  skipBlanks( uri, i );
+
+  return pval;
+}
+
+QString QgsDataSourceURI::connectionInfo() const
+{
+  QString connectionInfo = "dbname='" + mDatabase + "'";
+
+  if ( mHost != "" )
+  {
+    connectionInfo += " host=" + mHost;
+    if ( mPort != "" )
+      connectionInfo += " port=" + mPort;
+  }
+
+  if ( mUsername != "" )
+  {
+    connectionInfo += " user='" + mUsername + "'"; //needs to be escaped
+
+    if ( mPassword != "" )
+    {
+      QString p = mPassword;
+      p.replace( '\\', "\\\\" );
+      p.replace( '\'', "\\'" );
+      connectionInfo += " password='" + p + "'";
+    }
+  }
+
+  if ( mSSLmode == SSLdisable )
+    connectionInfo += " sslmode=disable";
+  else if ( mSSLmode == SSLallow )
+    connectionInfo += " sslmode=allow";
+  else if ( mSSLmode == SSLrequire )
+    connectionInfo += " sslmode=require";
+  else if ( mSSLmode == SSLprefer )
+    connectionInfo += " sslmode=prefer";
+
+  return connectionInfo;
+}
+
+QString QgsDataSourceURI::uri() const
+{
+  return connectionInfo()
+         + QString( " table=%1 (%2) sql=%3" )
+         .arg( quotedTablename() )
+         .arg( mGeometryColumn )
+         .arg( mSql );
+}
+
+QString QgsDataSourceURI::quotedTablename() const
+{
+  if ( mSchema != "" )
+    return QString( "\"%1\".\"%2\"" ).arg( mSchema ).arg( mTable );
+  else
+    return QString( "\"%1\"" ).arg( mTable );
+}
+
+void QgsDataSourceURI::setConnection( const QString &host,
+                                      const QString &port,
+                                      const QString &database,
+                                      const QString &username,
+                                      const QString &password,
+                                      SSLmode sslmode )
+{
+  mHost = host;
+  mDatabase = database;
+  mPort = port;
+  mUsername = username;
+  mPassword = password;
+  mSSLmode = sslmode;
+}
+
+void QgsDataSourceURI::setDataSource( const QString &schema,
+                                      const QString &table,
+                                      const QString &geometryColumn,
+                                      const QString &sql )
+{
+  mSchema = schema;
+  mTable = table;
+  mGeometryColumn = geometryColumn;
+  mSql = sql;
+}

Modified: trunk/qgis/src/core/qgsdatasourceuri.h
===================================================================
--- trunk/qgis/src/core/qgsdatasourceuri.h	2009-04-03 04:01:19 UTC (rev 10457)
+++ trunk/qgis/src/core/qgsdatasourceuri.h	2009-04-03 06:54:21 UTC (rev 10458)
@@ -61,8 +61,8 @@
                         const QString& aGeometryColumn,
                         const QString& aSql = QString() );
 
-	 //! Removes password element from uris
-    static QString removePassword( const QString& aUri);
+    //! Removes password element from uris
+    static QString removePassword( const QString& aUri );
 
     QString username() const;
     QString schema() const;

Modified: trunk/qgis/src/core/qgsgeometry.cpp
===================================================================
--- trunk/qgis/src/core/qgsgeometry.cpp	2009-04-03 04:01:19 UTC (rev 10457)
+++ trunk/qgis/src/core/qgsgeometry.cpp	2009-04-03 06:54:21 UTC (rev 10458)
@@ -312,8 +312,8 @@
 static GEOSGeometry *createGeosLinearRing( const QgsPolyline& polyline )
 {
   GEOSCoordSequence *coord = 0;
-  
-  if (polyline.count() == 0)
+
+  if ( polyline.count() == 0 )
     return 0;
 
   try

Modified: trunk/qgis/src/core/qgsmaplayer.cpp
===================================================================
--- trunk/qgis/src/core/qgsmaplayer.cpp	2009-04-03 04:01:19 UTC (rev 10457)
+++ trunk/qgis/src/core/qgsmaplayer.cpp	2009-04-03 06:54:21 UTC (rev 10458)
@@ -113,8 +113,8 @@
 {
   // Redo this every time we're asked for it, as we don't know if
   // dataSource has changed.
-	QString safeName=QgsDataSourceURI::removePassword(mDataSource);  
-  return safeName; 
+  QString safeName = QgsDataSourceURI::removePassword( mDataSource );
+  return safeName;
 }
 
 QString const & QgsMapLayer::source() const

Modified: trunk/qgis/src/plugins/georeferencer/qgspointdialog.cpp
===================================================================
--- trunk/qgis/src/plugins/georeferencer/qgspointdialog.cpp	2009-04-03 04:01:19 UTC (rev 10457)
+++ trunk/qgis/src/plugins/georeferencer/qgspointdialog.cpp	2009-04-03 06:54:21 UTC (rev 10458)
@@ -516,23 +516,23 @@
       return false;
     }
   }
-      else //MH: don't forget the linear transformation ;-)
-      {
-        double xOffset = 0;
-        double yOffset = 0;
-        QFile file( worldFileName );
-        if(!file.open(QIODevice::WriteOnly))
-        {
-          return false;
-        }
-        QTextStream stream(&file);
-        stream<<QString::number(pixelXSize, 'f', 15)<<endl
-        <<0<<endl
-        <<0<<endl
-        <<QString::number(-pixelYSize, 'f', 15)<<endl
-        <<QString::number((origin.x() - xOffset * pixelXSize), 'f', 15)<<endl
-        <<QString::number((origin.y() + yOffset * pixelYSize), 'f', 15)<<endl;
-      }
+  else //MH: don't forget the linear transformation ;-)
+  {
+    double xOffset = 0;
+    double yOffset = 0;
+    QFile file( worldFileName );
+    if ( !file.open( QIODevice::WriteOnly ) )
+    {
+      return false;
+    }
+    QTextStream stream( &file );
+    stream << QString::number( pixelXSize, 'f', 15 ) << endl
+    << 0 << endl
+    << 0 << endl
+    << QString::number( -pixelYSize, 'f', 15 ) << endl
+    << QString::number(( origin.x() - xOffset * pixelXSize ), 'f', 15 ) << endl
+    << QString::number(( origin.y() + yOffset * pixelYSize ), 'f', 15 ) << endl;
+  }
 
   // write the data points in case we need them later
 //  saveGCPs( mapCoords, pixelCoords );

Modified: trunk/qgis/src/plugins/spit/qgsspit.cpp
===================================================================
--- trunk/qgis/src/plugins/spit/qgsspit.cpp	2009-04-03 04:01:19 UTC (rev 10457)
+++ trunk/qgis/src/plugins/spit/qgsspit.cpp	2009-04-03 06:54:21 UTC (rev 10458)
@@ -414,7 +414,7 @@
                        database,
                        settings.value( key + "/username" ).toString(),
                        password,
-                       (QgsDataSourceURI::SSLmode) settings.value( key + "/sslmode", QgsDataSourceURI::SSLprefer ).toInt() );
+                       ( QgsDataSourceURI::SSLmode ) settings.value( key + "/sslmode", QgsDataSourceURI::SSLprefer ).toInt() );
 
     conn = PQconnectdb( uri.connectionInfo().toUtf8() );
   }



More information about the QGIS-commit mailing list