Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #35764 from alexbruy/ds-manager
Add XYZ tiles to Datasource manager dialog and Layers menu
- Loading branch information
Showing
18 changed files
with
415 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
/*************************************************************************** | ||
qgsxyzsourceselect.cpp | ||
--------------------------------- | ||
begin : April 2020 | ||
copyright : (C) 2020 by Alexander Bruy | ||
email : alexander dot bruy at gmail dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgshelp.h" | ||
#include "qgsgui.h" | ||
#include "qgsmanageconnectionsdialog.h" | ||
#include "qgsxyzsourceselect.h" | ||
#include "qgsxyzconnection.h" | ||
#include "qgsxyzconnectiondialog.h" | ||
|
||
#include <QFileDialog> | ||
#include <QMessageBox> | ||
|
||
QgsXyzSourceSelect::QgsXyzSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode theWidgetMode ) | ||
: QgsAbstractDataSourceWidget( parent, fl, theWidgetMode ) | ||
{ | ||
setupUi( this ); | ||
QgsGui::enableAutoGeometryRestore( this ); | ||
|
||
connect( btnNew, &QPushButton::clicked, this, &QgsXyzSourceSelect::btnNew_clicked ); | ||
connect( btnEdit, &QPushButton::clicked, this, &QgsXyzSourceSelect::btnEdit_clicked ); | ||
connect( btnDelete, &QPushButton::clicked, this, &QgsXyzSourceSelect::btnDelete_clicked ); | ||
connect( btnSave, &QPushButton::clicked, this, &QgsXyzSourceSelect::btnSave_clicked ); | ||
connect( btnLoad, &QPushButton::clicked, this, &QgsXyzSourceSelect::btnLoad_clicked ); | ||
connect( cmbConnections, &QComboBox::currentTextChanged, this, &QgsXyzSourceSelect::cmbConnections_currentTextChanged ); | ||
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsXyzSourceSelect::showHelp ); | ||
setupButtons( buttonBox ); | ||
populateConnectionList(); | ||
} | ||
|
||
void QgsXyzSourceSelect::btnNew_clicked() | ||
{ | ||
QgsXyzConnectionDialog nc( this ); | ||
if ( nc.exec() ) | ||
{ | ||
QgsXyzConnectionUtils::addConnection( nc.connection() ); | ||
populateConnectionList(); | ||
emit connectionsChanged(); | ||
} | ||
} | ||
|
||
void QgsXyzSourceSelect::btnEdit_clicked() | ||
{ | ||
QgsXyzConnectionDialog nc( this ); | ||
nc.setConnection( QgsXyzConnectionUtils::connection( cmbConnections->currentText() ) ); | ||
if ( nc.exec() ) | ||
{ | ||
QgsXyzConnectionUtils::addConnection( nc.connection() ); | ||
populateConnectionList(); | ||
emit connectionsChanged(); | ||
} | ||
} | ||
|
||
void QgsXyzSourceSelect::btnDelete_clicked() | ||
{ | ||
QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" ) | ||
.arg( cmbConnections->currentText() ); | ||
if ( QMessageBox::Yes != QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No ) ) | ||
return; | ||
|
||
QgsXyzConnectionUtils::deleteConnection( cmbConnections->currentText() ); | ||
|
||
populateConnectionList(); | ||
emit connectionsChanged(); | ||
} | ||
|
||
void QgsXyzSourceSelect::btnSave_clicked() | ||
{ | ||
QgsManageConnectionsDialog dlg( this, QgsManageConnectionsDialog::Export, QgsManageConnectionsDialog::XyzTiles ); | ||
dlg.exec(); | ||
} | ||
|
||
void QgsXyzSourceSelect::btnLoad_clicked() | ||
{ | ||
QString fileName = QFileDialog::getOpenFileName( this, tr( "Load Connections" ), QDir::homePath(), | ||
tr( "XML files (*.xml *.XML)" ) ); | ||
if ( fileName.isEmpty() ) | ||
{ | ||
return; | ||
} | ||
|
||
QgsManageConnectionsDialog dlg( this, QgsManageConnectionsDialog::Import, QgsManageConnectionsDialog::XyzTiles, fileName ); | ||
dlg.exec(); | ||
populateConnectionList(); | ||
} | ||
|
||
void QgsXyzSourceSelect::addButtonClicked() | ||
{ | ||
emit addRasterLayer( QgsXyzConnectionUtils::connection( cmbConnections->currentText() ).encodedUri(), cmbConnections->currentText(), QStringLiteral( "wms" ) ); | ||
} | ||
|
||
void QgsXyzSourceSelect::populateConnectionList() | ||
{ | ||
cmbConnections->blockSignals( true ); | ||
cmbConnections->clear(); | ||
cmbConnections->addItems( QgsXyzConnectionUtils::connectionList() ); | ||
cmbConnections->blockSignals( false ); | ||
|
||
setConnectionListPosition(); | ||
|
||
btnEdit->setDisabled( cmbConnections->count() == 0 ); | ||
btnDelete->setDisabled( cmbConnections->count() == 0 ); | ||
cmbConnections->setDisabled( cmbConnections->count() == 0 ); | ||
} | ||
|
||
void QgsXyzSourceSelect::setConnectionListPosition() | ||
{ | ||
QString toSelect = QgsXyzConnectionUtils::selectedConnection(); | ||
|
||
cmbConnections->setCurrentIndex( cmbConnections->findText( toSelect ) ); | ||
|
||
if ( cmbConnections->currentIndex() < 0 ) | ||
{ | ||
if ( toSelect.isNull() ) | ||
cmbConnections->setCurrentIndex( 0 ); | ||
else | ||
cmbConnections->setCurrentIndex( cmbConnections->count() - 1 ); | ||
} | ||
emit enableButtons( !cmbConnections->currentText().isEmpty() ); | ||
} | ||
|
||
void QgsXyzSourceSelect::cmbConnections_currentTextChanged( const QString &text ) | ||
{ | ||
QgsXyzConnectionUtils::setSelectedConnection( text ); | ||
emit enableButtons( !text.isEmpty() ); | ||
} | ||
|
||
void QgsXyzSourceSelect::showHelp() | ||
{ | ||
QgsHelp::openHelp( QStringLiteral( "managing_data_source/opening_data.html#using-xyz-tile-services" ) ); | ||
} |
Oops, something went wrong.