Skip to content

Commit 118482b

Browse files
author
jef
committedDec 11, 2009

File tree

1 file changed

+47
-56
lines changed

1 file changed

+47
-56
lines changed
 

‎src/app/ogr/qgsopenvectorlayerdialog.cpp

Lines changed: 47 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ QString QgsOpenVectorLayerDialog::openDirectory()
110110
QSettings settings;
111111

112112
bool haveLastUsedDir = settings.contains( "/UI/LastUsedDirectory" );
113-
QString lastUsedDir = settings.value( "/UI/LastUsedDirectory",
114-
QVariant( QString::null ) ).toString();
113+
QString lastUsedDir = settings.value( "/UI/LastUsedDirectory", QVariant() ).toString();
115114
if ( !haveLastUsedDir )
116115
lastUsedDir = "";
117116

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

268267
void QgsOpenVectorLayerDialog::on_buttonSelectSrc_clicked()
269268
{
270-
QSettings settings;
271-
QString filepath;
272-
273-
mDataSources.clear();
274-
275269
if ( radioSrcFile->isChecked() )
276270
{
277-
//file
278-
279-
//mType="file";
280-
mDataSources = openFile();
281-
filepath = "";
282-
for ( int i = 0; i < mDataSources.count(); i++ )
283-
filepath += mDataSources.at( i ) + ";";
284-
inputSrcDataset->setText( filepath );
271+
inputSrcDataset->setText( openFile().join( ";" ) );
285272
}
286273
else if ( radioSrcDirectory->isChecked() )
287274
{
288-
289-
filepath = openDirectory();
290-
mDataSources.append( filepath );
291-
inputSrcDataset->setText( filepath );
292-
//mType="directory";
293-
}
294-
else if ( radioSrcDatabase->isChecked() )
295-
{
296-
//mType="database";
297-
//src = inputSrcDataset->text();
275+
inputSrcDataset->setText( openDirectory() );
298276
}
299-
else
277+
else if ( !radioSrcDatabase->isChecked() )
300278
{
301279
Q_ASSERT( !"SHOULD NEVER GET HERE" );
302280
}
303-
304-
305-
306281
}
307282

308283

@@ -312,6 +287,9 @@ void QgsOpenVectorLayerDialog::accept()
312287
{
313288
QSettings settings;
314289
QgsDebugMsg( "dialog button accepted" );
290+
291+
mDataSources.clear();
292+
315293
if ( radioSrcDatabase->isChecked() )
316294
{
317295
if ( !settings.contains( "/" + cmbDatabaseTypes->currentText()
@@ -324,28 +302,35 @@ void QgsOpenVectorLayerDialog::accept()
324302
return;
325303
}
326304

327-
mDataSources.clear();
328305
QString baseKey = "/" + cmbDatabaseTypes->currentText() + "/connections/";
329306
baseKey += cmbConnections->currentText();
330307
QString host = settings.value( baseKey + "/host" ).toString();
331308
QString database = settings.value( baseKey + "/database" ).toString();
332309
QString port = settings.value( baseKey + "/port" ).toString();
333310
QString user = settings.value( baseKey + "/username" ).toString();
334311
QString pass = settings.value( baseKey + "/password" ).toString();
312+
335313
bool makeConnection = false;
336314
if ( pass.isEmpty() )
337-
pass = QInputDialog::getText( this, tr( "Password for " ) + user,
315+
{
316+
pass = QInputDialog::getText( this,
317+
tr( "Password for " ) + user,
338318
tr( "Please enter your password:" ),
339-
QLineEdit::Password, QString::null, &makeConnection );
340-
if ( makeConnection || ( !pass.isEmpty() ) )
341-
mDataSources.append( createDatabaseURI(
342-
cmbDatabaseTypes->currentText(),
343-
host,
344-
database,
345-
port,
346-
user,
347-
pass
348-
) );
319+
QLineEdit::Password, QString::null,
320+
&makeConnection );
321+
}
322+
323+
if ( makeConnection || !pass.isEmpty() )
324+
{
325+
mDataSources << createDatabaseURI(
326+
cmbDatabaseTypes->currentText(),
327+
host,
328+
database,
329+
port,
330+
user,
331+
pass
332+
);
333+
}
349334
}
350335
else if ( radioSrcProtocol->isChecked() )
351336
{
@@ -357,25 +342,31 @@ void QgsOpenVectorLayerDialog::accept()
357342
return;
358343
}
359344

360-
mDataSources.clear();
361-
mDataSources.append( createProtocolURI(
362-
cmbProtocolTypes->currentText(),
363-
protocolURI->text()
364-
) );
345+
mDataSources << createProtocolURI( cmbProtocolTypes->currentText(), protocolURI->text() );
365346
}
366-
else if ( radioSrcFile->isChecked() && inputSrcDataset->text().isEmpty() )
347+
else if ( radioSrcFile->isChecked() )
367348
{
368-
QMessageBox::information( this,
369-
tr( "Add vector layer" ),
370-
tr( "No layers selected." ) );
371-
return;
349+
if ( inputSrcDataset->text().isEmpty() )
350+
{
351+
QMessageBox::information( this,
352+
tr( "Add vector layer" ),
353+
tr( "No layers selected." ) );
354+
return;
355+
}
356+
357+
mDataSources << inputSrcDataset->text().split( ";" );
372358
}
373-
else if ( radioSrcDirectory->isChecked() && inputSrcDataset->text().isEmpty() )
359+
else if ( radioSrcDirectory->isChecked() )
374360
{
375-
QMessageBox::information( this,
376-
tr( "Add vector layer" ),
377-
tr( "No directory selected." ) );
378-
return;
361+
if ( inputSrcDataset->text().isEmpty() )
362+
{
363+
QMessageBox::information( this,
364+
tr( "Add vector layer" ),
365+
tr( "No directory selected." ) );
366+
return;
367+
}
368+
369+
mDataSources << inputSrcDataset->text();
379370
}
380371

381372
// Save the used encoding

0 commit comments

Comments
 (0)
Please sign in to comment.