Skip to content

Commit

Permalink
[feature] enable import/export of ArcGIS connections (fix #27485)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Apr 15, 2020
1 parent 99a930c commit 840d204
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
3 changes: 0 additions & 3 deletions src/providers/arcgisrest/qgsafssourceselect.cpp
Expand Up @@ -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 )
Expand Down
4 changes: 0 additions & 4 deletions src/providers/arcgisrest/qgsamssourceselect.cpp
Expand Up @@ -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 )
Expand Down
24 changes: 24 additions & 0 deletions src/providers/arcgisrest/qgsarcgisservicesourceselect.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}
2 changes: 2 additions & 0 deletions src/providers/arcgisrest/qgsarcgisservicesourceselect.h
Expand Up @@ -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();
};

/**
Expand Down

0 comments on commit 840d204

Please sign in to comment.