[feature] enable import/export of ArcGIS connections (fix #27485)

This commit is contained in:
Alexander Bruy 2020-04-15 12:52:19 +03:00
parent 99a930ca51
commit 840d204636
4 changed files with 26 additions and 7 deletions

View File

@ -29,9 +29,6 @@
QgsAfsSourceSelect::QgsAfsSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode )
: QgsArcGisServiceSourceSelect( QStringLiteral( "ARCGISFEATURESERVER" ), QgsArcGisServiceSourceSelect::FeatureService, parent, fl, widgetMode )
{
// import/export of connections not supported yet
btnLoad->hide();
btnSave->hide();
}
bool QgsAfsSourceSelect::connectToService( const QgsOwsConnection &connection )

View File

@ -28,10 +28,6 @@
QgsAmsSourceSelect::QgsAmsSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode )
: QgsArcGisServiceSourceSelect( QStringLiteral( "ARCGISMAPSERVER" ), QgsArcGisServiceSourceSelect::MapService, parent, fl, widgetMode )
{
// import/export of connections not supported yet
btnLoad->hide();
btnSave->hide();
}
bool QgsAmsSourceSelect::connectToService( const QgsOwsConnection &connection )

View File

@ -63,6 +63,8 @@ QgsArcGisServiceSourceSelect::QgsArcGisServiceSourceSelect( const QString &servi
connect( btnEdit, &QAbstractButton::clicked, this, &QgsArcGisServiceSourceSelect::modifyEntryOfServerList );
connect( btnDelete, &QAbstractButton::clicked, this, &QgsArcGisServiceSourceSelect::deleteEntryOfServerList );
connect( btnConnect, &QAbstractButton::clicked, this, &QgsArcGisServiceSourceSelect::connectToServer );
connect( btnSave, &QPushButton::clicked, this, &QgsArcGisServiceSourceSelect::btnSave_clicked );
connect( btnLoad, &QPushButton::clicked, this, &QgsArcGisServiceSourceSelect::btnLoad_clicked );
connect( btnChangeSpatialRefSys, &QAbstractButton::clicked, this, &QgsArcGisServiceSourceSelect::changeCrs );
connect( lineFilter, &QLineEdit::textChanged, this, &QgsArcGisServiceSourceSelect::filterChanged );
populateConnectionList();
@ -460,3 +462,25 @@ void QgsArcGisServiceSourceSelect::showHelp()
{
QgsHelp::openHelp( QStringLiteral( "managing_data_source/index.html" ) );
}
void QgsArcGisServiceSourceSelect::btnSave_clicked()
{
QgsManageConnectionsDialog::Type serverType = mServiceType == FeatureService ? QgsManageConnectionsDialog::ArcgisFeatureServer : QgsManageConnectionsDialog::ArcgisMapServer;
QgsManageConnectionsDialog dlg( this, QgsManageConnectionsDialog::Export, serverType );
dlg.exec();
}
void QgsArcGisServiceSourceSelect::btnLoad_clicked()
{
QString fileName = QFileDialog::getOpenFileName( this, tr( "Load Connections" ), QDir::homePath(),
tr( "XML files (*.xml *.XML)" ) );
if ( fileName.isEmpty() )
{
return;
}
QgsManageConnectionsDialog::Type serverType = mServiceType == FeatureService ? QgsManageConnectionsDialog::ArcgisFeatureServer : QgsManageConnectionsDialog::ArcgisMapServer;
QgsManageConnectionsDialog dlg( this, QgsManageConnectionsDialog::Import, serverType, fileName );
dlg.exec();
populateConnectionList();
}

View File

@ -126,6 +126,8 @@ class QgsArcGisServiceSourceSelect : public QgsAbstractDataSourceWidget, protect
void showHelp();
void treeWidgetItemDoubleClicked( const QModelIndex &index );
void treeWidgetCurrentRowChanged( const QModelIndex &current, const QModelIndex &previous );
void btnSave_clicked();
void btnLoad_clicked();
};
/**