Skip to content
Permalink
Browse files

fix #2269

git-svn-id: http://svn.osgeo.org/qgis/trunk@12413 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Dec 11, 2009
1 parent 8b38700 commit 7222e3ce037191b797aa32d03873183c1ce325d5
Showing with 47 additions and 56 deletions.
  1. +47 −56 src/app/ogr/qgsopenvectorlayerdialog.cpp
@@ -110,8 +110,7 @@ QString QgsOpenVectorLayerDialog::openDirectory()
QSettings settings;

bool haveLastUsedDir = settings.contains( "/UI/LastUsedDirectory" );
QString lastUsedDir = settings.value( "/UI/LastUsedDirectory",
QVariant( QString::null ) ).toString();
QString lastUsedDir = settings.value( "/UI/LastUsedDirectory", QVariant() ).toString();
if ( !haveLastUsedDir )
lastUsedDir = "";

@@ -267,42 +266,18 @@ void QgsOpenVectorLayerDialog::setSelectedConnection()

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 );
inputSrcDataset->setText( openFile().join( ";" ) );
}
else if ( radioSrcDirectory->isChecked() )
{

filepath = openDirectory();
mDataSources.append( filepath );
inputSrcDataset->setText( filepath );
//mType="directory";
}
else if ( radioSrcDatabase->isChecked() )
{
//mType="database";
//src = inputSrcDataset->text();
inputSrcDataset->setText( openDirectory() );
}
else
else if ( !radioSrcDatabase->isChecked() )
{
Q_ASSERT( !"SHOULD NEVER GET HERE" );
}



}


@@ -312,6 +287,9 @@ void QgsOpenVectorLayerDialog::accept()
{
QSettings settings;
QgsDebugMsg( "dialog button accepted" );

mDataSources.clear();

if ( radioSrcDatabase->isChecked() )
{
if ( !settings.contains( "/" + cmbDatabaseTypes->currentText()
@@ -324,28 +302,35 @@ void QgsOpenVectorLayerDialog::accept()
return;
}

mDataSources.clear();
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,
{
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
) );
QLineEdit::Password, QString::null,
&makeConnection );
}

if ( makeConnection || !pass.isEmpty() )
{
mDataSources << createDatabaseURI(
cmbDatabaseTypes->currentText(),
host,
database,
port,
user,
pass
);
}
}
else if ( radioSrcProtocol->isChecked() )
{
@@ -357,25 +342,31 @@ void QgsOpenVectorLayerDialog::accept()
return;
}

mDataSources.clear();
mDataSources.append( createProtocolURI(
cmbProtocolTypes->currentText(),
protocolURI->text()
) );
mDataSources << createProtocolURI( cmbProtocolTypes->currentText(), protocolURI->text() );
}
else if ( radioSrcFile->isChecked() && inputSrcDataset->text().isEmpty() )
else if ( radioSrcFile->isChecked() )
{
QMessageBox::information( this,
tr( "Add vector layer" ),
tr( "No layers selected." ) );
return;
if ( inputSrcDataset->text().isEmpty() )
{
QMessageBox::information( this,
tr( "Add vector layer" ),
tr( "No layers selected." ) );
return;
}

mDataSources << inputSrcDataset->text().split( ";" );
}
else if ( radioSrcDirectory->isChecked() && inputSrcDataset->text().isEmpty() )
else if ( radioSrcDirectory->isChecked() )
{
QMessageBox::information( this,
tr( "Add vector layer" ),
tr( "No directory selected." ) );
return;
if ( inputSrcDataset->text().isEmpty() )
{
QMessageBox::information( this,
tr( "Add vector layer" ),
tr( "No directory selected." ) );
return;
}

mDataSources << inputSrcDataset->text();
}

// Save the used encoding

0 comments on commit 7222e3c

Please sign in to comment.
You can’t perform that action at this time.