18 #include <QCloseEvent>
19 #include <QFileDialog>
20 #include <QMessageBox>
21 #include <QPushButton>
23 #include <QTextStream>
29 , mFileName( fileName )
31 , mConnectionType( type )
37 pb =
new QPushButton(
tr(
"Select all" ) );
38 buttonBox->addButton( pb, QDialogButtonBox::ActionRole );
39 connect( pb, SIGNAL( clicked() ),
this, SLOT(
selectAll() ) );
41 pb =
new QPushButton(
tr(
"Clear selection" ) );
42 buttonBox->addButton( pb, QDialogButtonBox::ActionRole );
43 connect( pb, SIGNAL( clicked() ),
this, SLOT(
clearSelection() ) );
45 if ( mDialogMode ==
Import )
47 label->setText(
tr(
"Select connections to import" ) );
48 buttonBox->button( QDialogButtonBox::Ok )->setText(
tr(
"Import" ) );
49 buttonBox->button( QDialogButtonBox::Ok )->setEnabled(
false );
54 buttonBox->button( QDialogButtonBox::Ok )->setText(
tr(
"Export" ) );
55 buttonBox->button( QDialogButtonBox::Ok )->setEnabled(
false );
58 if ( !populateConnections() )
60 QApplication::postEvent(
this,
new QCloseEvent() );
64 disconnect( buttonBox, SIGNAL( accepted() ),
this, SLOT( accept() ) );
65 connect( buttonBox, SIGNAL( accepted() ),
this, SLOT(
doExportImport() ) );
67 connect( listConnections, SIGNAL( itemSelectionChanged() ),
this, SLOT(
selectionChanged() ) );
72 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( !listConnections->selectedItems().isEmpty() );
77 QList<QListWidgetItem *> selection = listConnections->selectedItems();
78 if ( selection.isEmpty() )
80 QMessageBox::warning(
this,
tr(
"Export/import error" ),
81 tr(
"You should select at least one connection from list." ) );
86 for (
int i = 0; i < selection.size(); ++i )
88 items.append( selection.at( i )->text() );
91 if ( mDialogMode ==
Export )
93 QString fileName = QFileDialog::getSaveFileName(
this,
tr(
"Save connections" ),
".",
94 tr(
"XML files (*.xml *.XML)" ) );
95 if ( fileName.isEmpty() )
101 if ( !fileName.toLower().endsWith(
".xml" ) )
106 mFileName = fileName;
109 switch ( mConnectionType )
112 doc = saveOWSConnections( items,
"WMS" );
115 doc = saveWFSConnections( items );
118 doc = savePgConnections( items );
121 doc = saveMssqlConnections( items );
124 doc = saveOWSConnections( items,
"WCS" );
127 doc = saveOracleConnections( items );
131 QFile
file( mFileName );
132 if ( !file.open( QIODevice::WriteOnly | QIODevice::Text ) )
134 QMessageBox::warning(
this,
tr(
"Saving connections" ),
135 tr(
"Cannot write file %1:\n%2." )
137 .arg( file.errorString() ) );
141 QTextStream out( &file );
146 QFile
file( mFileName );
147 if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
149 QMessageBox::warning(
this,
tr(
"Loading connections" ),
150 tr(
"Cannot read file %1:\n%2." )
152 .arg( file.errorString() ) );
161 if ( !doc.setContent( &file,
true, &errorStr, &errorLine, &errorColumn ) )
163 QMessageBox::warning(
this,
tr(
"Loading connections" ),
164 tr(
"Parse error at line %1, column %2:\n%3" )
171 switch ( mConnectionType )
174 loadOWSConnections( doc, items,
"WMS" );
177 loadWFSConnections( doc, items );
180 loadPgConnections( doc, items );
183 loadMssqlConnections( doc, items );
186 loadOWSConnections( doc, items,
"WCS" );
189 loadOracleConnections( doc, items );
193 listConnections->clear();
200 bool QgsManageConnectionsDialog::populateConnections()
203 if ( mDialogMode ==
Export )
206 switch ( mConnectionType )
209 settings.beginGroup(
"/Qgis/connections-wms" );
212 settings.beginGroup(
"/Qgis/connections-wfs" );
215 settings.beginGroup(
"/Qgis/connections-wcs" );
218 settings.beginGroup(
"/PostgreSQL/connections" );
221 settings.beginGroup(
"/MSSQL/connections" );
224 settings.beginGroup(
"/Oracle/connections" );
227 QStringList keys = settings.childGroups();
228 QStringList::Iterator it = keys.begin();
229 while ( it != keys.end() )
231 QListWidgetItem *item =
new QListWidgetItem();
232 item->setText( *it );
233 listConnections->addItem( item );
241 QFile
file( mFileName );
242 if ( !
file.open( QIODevice::ReadOnly | QIODevice::Text ) )
244 QMessageBox::warning(
this,
tr(
"Loading connections" ),
245 tr(
"Cannot read file %1:\n%2." )
247 .arg(
file.errorString() ) );
256 if ( !doc.setContent( &
file,
true, &errorStr, &errorLine, &errorColumn ) )
258 QMessageBox::warning(
this,
tr(
"Loading connections" ),
259 tr(
"Parse error at line %1, column %2:\n%3" )
266 QDomElement root = doc.documentElement();
267 switch ( mConnectionType )
270 if ( root.tagName() !=
"qgsWMSConnections" )
272 QMessageBox::information(
this,
tr(
"Loading connections" ),
273 tr(
"The file is not an WMS connections exchange file." ) );
279 if ( root.tagName() !=
"qgsWFSConnections" )
281 QMessageBox::information(
this,
tr(
"Loading connections" ),
282 tr(
"The file is not an WFS connections exchange file." ) );
288 if ( root.tagName() !=
"qgsWCSConnections" )
290 QMessageBox::information(
this,
tr(
"Loading connections" ),
291 tr(
"The file is not an WCS connections exchange file." ) );
297 if ( root.tagName() !=
"qgsPgConnections" )
299 QMessageBox::information(
this,
tr(
"Loading connections" ),
300 tr(
"The file is not an PostGIS connections exchange file." ) );
306 if ( root.tagName() !=
"qgsMssqlConnections" )
308 QMessageBox::information(
this,
tr(
"Loading connections" ),
309 tr(
"The file is not an MSSQL connections exchange file." ) );
314 if ( root.tagName() !=
"qgsOracleConnections" )
316 QMessageBox::information(
this,
tr(
"Loading connections" ),
317 tr(
"The file is not an Oracle connections exchange file." ) );
323 QDomElement child = root.firstChildElement();
324 while ( !child.isNull() )
326 QListWidgetItem *item =
new QListWidgetItem();
327 item->setText( child.attribute(
"name" ) );
328 listConnections->addItem( item );
329 child = child.nextSiblingElement();
335 QDomDocument QgsManageConnectionsDialog::saveOWSConnections(
const QStringList &connections,
const QString & service )
337 QDomDocument doc(
"connections" );
338 QDomElement root = doc.createElement(
"qgs" + service.toUpper() +
"Connections" );
339 root.setAttribute(
"version",
"1.0" );
340 doc.appendChild( root );
344 for (
int i = 0; i < connections.count(); ++i )
346 path =
"/Qgis/connections-" + service.toLower() +
"/";
347 QDomElement el = doc.createElement( service.toLower() );
348 el.setAttribute(
"name", connections[ i ] );
349 el.setAttribute(
"url", settings.value( path + connections[ i ] +
"/url",
"" ).toString() );
351 if ( service ==
"WMS" )
353 el.setAttribute(
"ignoreGetMapURI", settings.value( path + connections[i] +
"/ignoreGetMapURI",
false ).toBool() ?
"true" :
"false" );
354 el.setAttribute(
"ignoreGetFeatureInfoURI", settings.value( path + connections[i] +
"/ignoreGetFeatureInfoURI",
false ).toBool() ?
"true" :
"false" );
355 el.setAttribute(
"ignoreAxisOrientation", settings.value( path + connections[i] +
"/ignoreAxisOrientation",
false ).toBool() ?
"true" :
"false" );
356 el.setAttribute(
"invertAxisOrientation", settings.value( path + connections[i] +
"/invertAxisOrientation",
false ).toBool() ?
"true" :
"false" );
357 el.setAttribute(
"referer", settings.value( path + connections[ i ] +
"/referer",
"" ).toString() );
358 el.setAttribute(
"smoothPixmapTransform", settings.value( path + connections[i] +
"/smoothPixmapTransform",
false ).toBool() ?
"true" :
"false" );
359 el.setAttribute(
"dpiMode", settings.value( path + connections[i] +
"/dpiMode",
"7" ).toInt() );
362 path =
"/Qgis/" + service.toUpper() +
"/";
363 el.setAttribute(
"username", settings.value( path + connections[ i ] +
"/username",
"" ).toString() );
364 el.setAttribute(
"password", settings.value( path + connections[ i ] +
"/password",
"" ).toString() );
365 root.appendChild( el );
371 QDomDocument QgsManageConnectionsDialog::saveWFSConnections(
const QStringList &connections )
373 QDomDocument doc(
"connections" );
374 QDomElement root = doc.createElement(
"qgsWFSConnections" );
375 root.setAttribute(
"version",
"1.0" );
376 doc.appendChild( root );
380 for (
int i = 0; i < connections.count(); ++i )
382 path =
"/Qgis/connections-wfs/";
383 QDomElement el = doc.createElement(
"wfs" );
384 el.setAttribute(
"name", connections[ i ] );
385 el.setAttribute(
"url", settings.value( path + connections[ i ] +
"/url",
"" ).toString() );
387 el.setAttribute(
"referer", settings.value( path + connections[ i ] +
"/referer",
"" ).toString() );
390 el.setAttribute(
"username", settings.value( path + connections[ i ] +
"/username",
"" ).toString() );
391 el.setAttribute(
"password", settings.value( path + connections[ i ] +
"/password",
"" ).toString() );
392 root.appendChild( el );
398 QDomDocument QgsManageConnectionsDialog::savePgConnections(
const QStringList &connections )
400 QDomDocument doc(
"connections" );
401 QDomElement root = doc.createElement(
"qgsPgConnections" );
402 root.setAttribute(
"version",
"1.0" );
403 doc.appendChild( root );
407 for (
int i = 0; i < connections.count(); ++i )
409 path =
"/PostgreSQL/connections/" + connections[ i ];
410 QDomElement el = doc.createElement(
"postgis" );
411 el.setAttribute(
"name", connections[ i ] );
412 el.setAttribute(
"host", settings.value( path +
"/host",
"" ).toString() );
413 el.setAttribute(
"port", settings.value( path +
"/port",
"" ).toString() );
414 el.setAttribute(
"database", settings.value( path +
"/database",
"" ).toString() );
415 el.setAttribute(
"service", settings.value( path +
"/service",
"" ).toString() );
416 el.setAttribute(
"sslmode", settings.value( path +
"/sslmode",
"1" ).toString() );
417 el.setAttribute(
"estimatedMetadata", settings.value( path +
"/estimatedMetadata",
"0" ).toString() );
419 el.setAttribute(
"saveUsername", settings.value( path +
"/saveUsername",
"false" ).toString() );
421 if ( settings.value( path +
"/saveUsername",
"false" ).toString() ==
"true" )
423 el.setAttribute(
"username", settings.value( path +
"/username",
"" ).toString() );
426 el.setAttribute(
"savePassword", settings.value( path +
"/savePassword",
"false" ).toString() );
428 if ( settings.value( path +
"/savePassword",
"false" ).toString() ==
"true" )
430 el.setAttribute(
"password", settings.value( path +
"/password",
"" ).toString() );
433 root.appendChild( el );
439 QDomDocument QgsManageConnectionsDialog::saveMssqlConnections(
const QStringList &connections )
441 QDomDocument doc(
"connections" );
442 QDomElement root = doc.createElement(
"qgsMssqlConnections" );
443 root.setAttribute(
"version",
"1.0" );
444 doc.appendChild( root );
448 for (
int i = 0; i < connections.count(); ++i )
450 path =
"/MSSQL/connections/" + connections[ i ];
451 QDomElement el = doc.createElement(
"mssql" );
452 el.setAttribute(
"name", connections[ i ] );
453 el.setAttribute(
"host", settings.value( path +
"/host",
"" ).toString() );
454 el.setAttribute(
"port", settings.value( path +
"/port",
"" ).toString() );
455 el.setAttribute(
"database", settings.value( path +
"/database",
"" ).toString() );
456 el.setAttribute(
"service", settings.value( path +
"/service",
"" ).toString() );
457 el.setAttribute(
"sslmode", settings.value( path +
"/sslmode",
"1" ).toString() );
458 el.setAttribute(
"estimatedMetadata", settings.value( path +
"/estimatedMetadata",
"0" ).toString() );
460 el.setAttribute(
"saveUsername", settings.value( path +
"/saveUsername",
"false" ).toString() );
462 if ( settings.value( path +
"/saveUsername",
"false" ).toString() ==
"true" )
464 el.setAttribute(
"username", settings.value( path +
"/username",
"" ).toString() );
467 el.setAttribute(
"savePassword", settings.value( path +
"/savePassword",
"false" ).toString() );
469 if ( settings.value( path +
"/savePassword",
"false" ).toString() ==
"true" )
471 el.setAttribute(
"password", settings.value( path +
"/password",
"" ).toString() );
474 root.appendChild( el );
480 QDomDocument QgsManageConnectionsDialog::saveOracleConnections(
const QStringList &connections )
482 QDomDocument doc(
"connections" );
483 QDomElement root = doc.createElement(
"qgsOracleConnections" );
484 root.setAttribute(
"version",
"1.0" );
485 doc.appendChild( root );
489 for (
int i = 0; i < connections.count(); ++i )
491 path =
"/Oracle/connections/" + connections[ i ];
492 QDomElement el = doc.createElement(
"oracle" );
493 el.setAttribute(
"name", connections[ i ] );
494 el.setAttribute(
"host", settings.value( path +
"/host",
"" ).toString() );
495 el.setAttribute(
"port", settings.value( path +
"/port",
"" ).toString() );
496 el.setAttribute(
"database", settings.value( path +
"/database",
"" ).toString() );
497 el.setAttribute(
"dboptions", settings.value( path +
"/dboptions",
"" ).toString() );
498 el.setAttribute(
"estimatedMetadata", settings.value( path +
"/estimatedMetadata",
"0" ).toString() );
499 el.setAttribute(
"userTablesOnly", settings.value( path +
"/userTablesOnly",
"0" ).toString() );
500 el.setAttribute(
"geometryColumnsOnly", settings.value( path +
"/geometryColumnsOnly",
"0" ).toString() );
501 el.setAttribute(
"allowGeometrylessTables", settings.value( path +
"/allowGeometrylessTables",
"0" ).toString() );
503 el.setAttribute(
"saveUsername", settings.value( path +
"/saveUsername",
"false" ).toString() );
505 if ( settings.value( path +
"/saveUsername",
"false" ).toString() ==
"true" )
507 el.setAttribute(
"username", settings.value( path +
"/username",
"" ).toString() );
510 el.setAttribute(
"savePassword", settings.value( path +
"/savePassword",
"false" ).toString() );
512 if ( settings.value( path +
"/savePassword",
"false" ).toString() ==
"true" )
514 el.setAttribute(
"password", settings.value( path +
"/password",
"" ).toString() );
517 root.appendChild( el );
523 void QgsManageConnectionsDialog::loadOWSConnections(
const QDomDocument &doc,
const QStringList &items,
const QString &service )
525 QDomElement root = doc.documentElement();
526 if ( root.tagName() !=
"qgs" + service.toUpper() +
"Connections" )
528 QMessageBox::information(
this,
tr(
"Loading connections" ),
529 tr(
"The file is not an %1 connections exchange file." ).arg( service ) );
533 QString connectionName;
535 settings.beginGroup(
"/Qgis/connections-" + service.toLower() );
536 QStringList keys = settings.childGroups();
538 QDomElement child = root.firstChildElement();
540 bool overwrite =
true;
542 while ( !child.isNull() )
544 connectionName = child.attribute(
"name" );
545 if ( !items.contains( connectionName ) )
547 child = child.nextSiblingElement();
552 if ( keys.contains( connectionName ) && prompt )
554 int res = QMessageBox::warning(
this,
555 tr(
"Loading connections" ),
556 tr(
"Connection with name '%1' already exists. Overwrite?" )
557 .arg( connectionName ),
558 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
562 case QMessageBox::Cancel:
564 case QMessageBox::No:
565 child = child.nextSiblingElement();
567 case QMessageBox::Yes:
570 case QMessageBox::YesToAll:
574 case QMessageBox::NoToAll:
581 if ( keys.contains( connectionName ) && !overwrite )
583 child = child.nextSiblingElement();
588 settings.beginGroup(
"/Qgis/connections-" + service.toLower() );
589 settings.setValue( QString(
"/" + connectionName +
"/url" ), child.attribute(
"url" ) );
590 settings.setValue( QString(
"/" + connectionName +
"/ignoreGetMapURI" ), child.attribute(
"ignoreGetMapURI" ) ==
"true" );
591 settings.setValue( QString(
"/" + connectionName +
"/ignoreGetFeatureInfoURI" ), child.attribute(
"ignoreGetFeatureInfoURI" ) ==
"true" );
592 settings.setValue( QString(
"/" + connectionName +
"/ignoreAxisOrientation" ), child.attribute(
"ignoreAxisOrientation" ) ==
"true" );
593 settings.setValue( QString(
"/" + connectionName +
"/invertAxisOrientation" ), child.attribute(
"invertAxisOrientation" ) ==
"true" );
594 settings.setValue( QString(
"/" + connectionName +
"/referer" ), child.attribute(
"referer" ) );
595 settings.setValue( QString(
"/" + connectionName +
"/smoothPixmapTransform" ), child.attribute(
"smoothPixmapTransform" ) ==
"true" );
596 settings.setValue( QString(
"/" + connectionName +
"/dpiMode" ), child.attribute(
"dpiMode",
"7" ).toInt() );
599 if ( !child.attribute(
"username" ).isEmpty() )
601 settings.beginGroup(
"/Qgis/" + service.toUpper() +
"/" + connectionName );
602 settings.setValue(
"/username", child.attribute(
"username" ) );
603 settings.setValue(
"/password", child.attribute(
"password" ) );
606 child = child.nextSiblingElement();
610 void QgsManageConnectionsDialog::loadWFSConnections(
const QDomDocument &doc,
const QStringList &items )
612 QDomElement root = doc.documentElement();
613 if ( root.tagName() !=
"qgsWFSConnections" )
615 QMessageBox::information(
this,
tr(
"Loading connections" ),
616 tr(
"The file is not an WFS connections exchange file." ) );
620 QString connectionName;
622 settings.beginGroup(
"/Qgis/connections-wfs" );
623 QStringList keys = settings.childGroups();
625 QDomElement child = root.firstChildElement();
627 bool overwrite =
true;
629 while ( !child.isNull() )
631 connectionName = child.attribute(
"name" );
632 if ( !items.contains( connectionName ) )
634 child = child.nextSiblingElement();
639 if ( keys.contains( connectionName ) && prompt )
641 int res = QMessageBox::warning(
this,
642 tr(
"Loading connections" ),
643 tr(
"Connection with name '%1' already exists. Overwrite?" )
644 .arg( connectionName ),
645 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
649 case QMessageBox::Cancel:
651 case QMessageBox::No:
652 child = child.nextSiblingElement();
654 case QMessageBox::Yes:
657 case QMessageBox::YesToAll:
661 case QMessageBox::NoToAll:
668 if ( keys.contains( connectionName ) && !overwrite )
670 child = child.nextSiblingElement();
675 settings.beginGroup(
"/Qgis/connections-wfs" );
676 settings.setValue( QString(
"/" + connectionName +
"/url" ), child.attribute(
"url" ) );
679 if ( !child.attribute(
"username" ).isEmpty() )
681 settings.beginGroup(
"/Qgis/WFS/" + connectionName );
682 settings.setValue(
"/username", child.attribute(
"username" ) );
683 settings.setValue(
"/password", child.attribute(
"password" ) );
686 child = child.nextSiblingElement();
691 void QgsManageConnectionsDialog::loadPgConnections(
const QDomDocument &doc,
const QStringList &items )
693 QDomElement root = doc.documentElement();
694 if ( root.tagName() !=
"qgsPgConnections" )
696 QMessageBox::information(
this,
697 tr(
"Loading connections" ),
698 tr(
"The file is not an PostGIS connections exchange file." ) );
702 QString connectionName;
704 settings.beginGroup(
"/PostgreSQL/connections" );
705 QStringList keys = settings.childGroups();
707 QDomElement child = root.firstChildElement();
709 bool overwrite =
true;
711 while ( !child.isNull() )
713 connectionName = child.attribute(
"name" );
714 if ( !items.contains( connectionName ) )
716 child = child.nextSiblingElement();
721 if ( keys.contains( connectionName ) && prompt )
723 int res = QMessageBox::warning(
this,
724 tr(
"Loading connections" ),
725 tr(
"Connection with name '%1' already exists. Overwrite?" )
726 .arg( connectionName ),
727 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
730 case QMessageBox::Cancel:
732 case QMessageBox::No:
733 child = child.nextSiblingElement();
735 case QMessageBox::Yes:
738 case QMessageBox::YesToAll:
742 case QMessageBox::NoToAll:
749 if ( keys.contains( connectionName ) && !overwrite )
751 child = child.nextSiblingElement();
756 settings.beginGroup(
"/PostgreSQL/connections/" + connectionName );
758 settings.setValue(
"/host", child.attribute(
"host" ) );
759 settings.setValue(
"/port", child.attribute(
"port" ) );
760 settings.setValue(
"/database", child.attribute(
"database" ) );
761 if ( child.hasAttribute(
"service" ) )
763 settings.setValue(
"/service", child.attribute(
"service" ) );
767 settings.setValue(
"/service",
"" );
769 settings.setValue(
"/sslmode", child.attribute(
"sslmode" ) );
770 settings.setValue(
"/estimatedMetadata", child.attribute(
"estimatedMetadata" ) );
771 settings.setValue(
"/saveUsername", child.attribute(
"saveUsername" ) );
772 settings.setValue(
"/username", child.attribute(
"username" ) );
773 settings.setValue(
"/savePassword", child.attribute(
"savePassword" ) );
774 settings.setValue(
"/password", child.attribute(
"password" ) );
777 child = child.nextSiblingElement();
781 void QgsManageConnectionsDialog::loadMssqlConnections(
const QDomDocument &doc,
const QStringList &items )
783 QDomElement root = doc.documentElement();
784 if ( root.tagName() !=
"qgsMssqlConnections" )
786 QMessageBox::information(
this,
787 tr(
"Loading connections" ),
788 tr(
"The file is not an MSSQL connections exchange file." ) );
792 QString connectionName;
794 settings.beginGroup(
"/MSSQL/connections" );
795 QStringList keys = settings.childGroups();
797 QDomElement child = root.firstChildElement();
799 bool overwrite =
true;
801 while ( !child.isNull() )
803 connectionName = child.attribute(
"name" );
804 if ( !items.contains( connectionName ) )
806 child = child.nextSiblingElement();
811 if ( keys.contains( connectionName ) && prompt )
813 int res = QMessageBox::warning(
this,
814 tr(
"Loading connections" ),
815 tr(
"Connection with name '%1' already exists. Overwrite?" )
816 .arg( connectionName ),
817 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
820 case QMessageBox::Cancel:
822 case QMessageBox::No:
823 child = child.nextSiblingElement();
825 case QMessageBox::Yes:
828 case QMessageBox::YesToAll:
832 case QMessageBox::NoToAll:
839 if ( keys.contains( connectionName ) && !overwrite )
841 child = child.nextSiblingElement();
846 settings.beginGroup(
"/MSSQL/connections/" + connectionName );
848 settings.setValue(
"/host", child.attribute(
"host" ) );
849 settings.setValue(
"/port", child.attribute(
"port" ) );
850 settings.setValue(
"/database", child.attribute(
"database" ) );
851 if ( child.hasAttribute(
"service" ) )
853 settings.setValue(
"/service", child.attribute(
"service" ) );
857 settings.setValue(
"/service",
"" );
859 settings.setValue(
"/sslmode", child.attribute(
"sslmode" ) );
860 settings.setValue(
"/estimatedMetadata", child.attribute(
"estimatedMetadata" ) );
861 settings.setValue(
"/saveUsername", child.attribute(
"saveUsername" ) );
862 settings.setValue(
"/username", child.attribute(
"username" ) );
863 settings.setValue(
"/savePassword", child.attribute(
"savePassword" ) );
864 settings.setValue(
"/password", child.attribute(
"password" ) );
867 child = child.nextSiblingElement();
871 void QgsManageConnectionsDialog::loadOracleConnections(
const QDomDocument &doc,
const QStringList &items )
873 QDomElement root = doc.documentElement();
874 if ( root.tagName() !=
"qgsOracleConnections" )
876 QMessageBox::information(
this,
877 tr(
"Loading connections" ),
878 tr(
"The file is not an Oracle connections exchange file." ) );
882 QString connectionName;
884 settings.beginGroup(
"/Oracle/connections" );
885 QStringList keys = settings.childGroups();
887 QDomElement child = root.firstChildElement();
889 bool overwrite =
true;
891 while ( !child.isNull() )
893 connectionName = child.attribute(
"name" );
894 if ( !items.contains( connectionName ) )
896 child = child.nextSiblingElement();
901 if ( keys.contains( connectionName ) && prompt )
903 int res = QMessageBox::warning(
this,
904 tr(
"Loading connections" ),
905 tr(
"Connection with name '%1' already exists. Overwrite?" )
906 .arg( connectionName ),
907 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
910 case QMessageBox::Cancel:
912 case QMessageBox::No:
913 child = child.nextSiblingElement();
915 case QMessageBox::Yes:
918 case QMessageBox::YesToAll:
922 case QMessageBox::NoToAll:
929 if ( keys.contains( connectionName ) && !overwrite )
931 child = child.nextSiblingElement();
936 settings.beginGroup(
"/Oracle/connections/" + connectionName );
938 settings.setValue(
"/host", child.attribute(
"host" ) );
939 settings.setValue(
"/port", child.attribute(
"port" ) );
940 settings.setValue(
"/database", child.attribute(
"database" ) );
941 settings.setValue(
"/dboptions", child.attribute(
"dboptions" ) );
942 settings.setValue(
"/estimatedMetadata", child.attribute(
"estimatedMetadata" ) );
943 settings.setValue(
"/userTablesOnly", child.attribute(
"userTablesOnly" ) );
944 settings.setValue(
"/geometryColumnsOnly", child.attribute(
"geometryColumnsOnly" ) );
945 settings.setValue(
"/allowGeometrylessTables", child.attribute(
"allowGeometrylessTables" ) );
946 settings.setValue(
"/saveUsername", child.attribute(
"saveUsername" ) );
947 settings.setValue(
"/username", child.attribute(
"username" ) );
948 settings.setValue(
"/savePassword", child.attribute(
"savePassword" ) );
949 settings.setValue(
"/password", child.attribute(
"password" ) );
952 child = child.nextSiblingElement();
958 listConnections->selectAll();
959 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( !listConnections->selectedItems().isEmpty() );
964 listConnections->clearSelection();
965 buttonBox->button( QDialogButtonBox::Ok )->setEnabled(
false );