@@ -110,8 +110,7 @@ QString QgsOpenVectorLayerDialog::openDirectory()
110
110
QSettings settings;
111
111
112
112
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 ();
115
114
if ( !haveLastUsedDir )
116
115
lastUsedDir = " " ;
117
116
@@ -267,42 +266,18 @@ void QgsOpenVectorLayerDialog::setSelectedConnection()
267
266
268
267
void QgsOpenVectorLayerDialog::on_buttonSelectSrc_clicked ()
269
268
{
270
- QSettings settings;
271
- QString filepath;
272
-
273
- mDataSources .clear ();
274
-
275
269
if ( radioSrcFile->isChecked () )
276
270
{
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 ( " ;" ) );
285
272
}
286
273
else if ( radioSrcDirectory->isChecked () )
287
274
{
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 () );
298
276
}
299
- else
277
+ else if ( !radioSrcDatabase-> isChecked () )
300
278
{
301
279
Q_ASSERT ( !" SHOULD NEVER GET HERE" );
302
280
}
303
-
304
-
305
-
306
281
}
307
282
308
283
@@ -312,6 +287,9 @@ void QgsOpenVectorLayerDialog::accept()
312
287
{
313
288
QSettings settings;
314
289
QgsDebugMsg ( " dialog button accepted" );
290
+
291
+ mDataSources .clear ();
292
+
315
293
if ( radioSrcDatabase->isChecked () )
316
294
{
317
295
if ( !settings.contains ( " /" + cmbDatabaseTypes->currentText ()
@@ -324,28 +302,35 @@ void QgsOpenVectorLayerDialog::accept()
324
302
return ;
325
303
}
326
304
327
- mDataSources .clear ();
328
305
QString baseKey = " /" + cmbDatabaseTypes->currentText () + " /connections/" ;
329
306
baseKey += cmbConnections->currentText ();
330
307
QString host = settings.value ( baseKey + " /host" ).toString ();
331
308
QString database = settings.value ( baseKey + " /database" ).toString ();
332
309
QString port = settings.value ( baseKey + " /port" ).toString ();
333
310
QString user = settings.value ( baseKey + " /username" ).toString ();
334
311
QString pass = settings.value ( baseKey + " /password" ).toString ();
312
+
335
313
bool makeConnection = false ;
336
314
if ( pass.isEmpty () )
337
- pass = QInputDialog::getText ( this , tr ( " Password for " ) + user,
315
+ {
316
+ pass = QInputDialog::getText ( this ,
317
+ tr ( " Password for " ) + user,
338
318
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
+ }
349
334
}
350
335
else if ( radioSrcProtocol->isChecked () )
351
336
{
@@ -357,25 +342,31 @@ void QgsOpenVectorLayerDialog::accept()
357
342
return ;
358
343
}
359
344
360
- mDataSources .clear ();
361
- mDataSources .append ( createProtocolURI (
362
- cmbProtocolTypes->currentText (),
363
- protocolURI->text ()
364
- ) );
345
+ mDataSources << createProtocolURI ( cmbProtocolTypes->currentText (), protocolURI->text () );
365
346
}
366
- else if ( radioSrcFile->isChecked () && inputSrcDataset-> text (). isEmpty () )
347
+ else if ( radioSrcFile->isChecked () )
367
348
{
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 ( " ;" );
372
358
}
373
- else if ( radioSrcDirectory->isChecked () && inputSrcDataset-> text (). isEmpty () )
359
+ else if ( radioSrcDirectory->isChecked () )
374
360
{
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 ();
379
370
}
380
371
381
372
// Save the used encoding
0 commit comments