Skip to content

Commit 17d6890

Browse files
author
jef
committed
[FEATURE] move option to ignore GetMap and GetFeatureInfo URI from WMS GetCapabilities to connection
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15559 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 6dd72db commit 17d6890

5 files changed

+118
-184
lines changed

src/app/qgsmanageconnectionsdialog.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ QDomDocument QgsManageConnectionsDialog::saveWMSConnections( const QStringList &
286286
QDomElement el = doc.createElement( "wms" );
287287
el.setAttribute( "name", connections[ i ] );
288288
el.setAttribute( "url", settings.value( path + connections[ i ] + "/url", "" ).toString() );
289+
el.setAttribute( "ignoreGetMapURI", settings.value( path + connections[i] + "/ignoreGetMapURI", false ).toBool() ? "true" : "false" );
290+
el.setAttribute( "ignoreGetFeatureInfoURI", settings.value( path + connections[i] + "/ignoreGetFeatureInfoURI", false ).toBool() ? "true" : "false" );
289291

290292
path = "/Qgis/WMS/";
291293
el.setAttribute( "username", settings.value( path + connections[ i ] + "/username", "" ).toString() );
@@ -423,6 +425,8 @@ void QgsManageConnectionsDialog::loadWMSConnections( const QDomDocument &doc, co
423425
// no dups detected or overwrite is allowed
424426
settings.beginGroup( "/Qgis/connections-wms" );
425427
settings.setValue( QString( "/" + connectionName + "/url" ) , child.attribute( "url" ) );
428+
settings.setValue( QString( "/" + connectionName + "/ignoreGetMapURI" ), child.attribute( "ignoreGetMapURI" ) == "true" );
429+
settings.setValue( QString( "/" + connectionName + "/ignoreGetFeatureInfoURI" ), child.attribute( "ignoreGetFeatureInfoURI" ) == "true" );
426430
settings.endGroup();
427431

428432
if ( !child.attribute( "username" ).isEmpty() )

src/app/qgsnewhttpconnection.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ QgsNewHttpConnection::QgsNewHttpConnection(
4141
QString credentialsKey = "/Qgis/WMS/" + connName;
4242
txtName->setText( connName );
4343
txtUrl->setText( settings.value( key + "/url" ).toString() );
44+
45+
if ( mBaseKey == "/Qgis/connections-wms/" )
46+
{
47+
cbxIgnoreGetMapURI->setChecked( settings.value( key + "/ignoreGetMapURI", false ).toBool() );
48+
cbxIgnoreGetFeatureInfoURI->setChecked( settings.value( key + "/ignoreGetFeatureInfoURI", false ).toBool() );
49+
}
50+
else
51+
{
52+
cbxIgnoreGetMapURI->setVisible( false );
53+
cbxIgnoreGetFeatureInfoURI->setVisible( false );
54+
}
55+
4456
txtUserName->setText( settings.value( credentialsKey + "/username" ).toString() );
4557
txtPassword->setText( settings.value( credentialsKey + "/password" ).toString() );
4658
}
@@ -96,6 +108,12 @@ void QgsNewHttpConnection::accept()
96108
url.setEncodedQueryItems( params );
97109

98110
settings.setValue( key + "/url", url.toString() );
111+
if ( mBaseKey == "/Qgis/connections-wms/" )
112+
{
113+
settings.setValue( key + "/ignoreGetMapURI", cbxIgnoreGetMapURI->isChecked() );
114+
settings.setValue( key + "/ignoreGetFeatureInfoURI", cbxIgnoreGetFeatureInfoURI->isChecked() );
115+
}
116+
99117
settings.setValue( credentialsKey + "/username", txtUserName->text() );
100118
settings.setValue( credentialsKey + "/password", txtPassword->text() );
101119

src/app/qgswmssourceselect.cpp

+25-84
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ QgsWMSSourceSelect::QgsWMSSourceSelect( QWidget * parent, Qt::WFlags fl )
6868
mAddButton->setEnabled( false );
6969
populateConnectionList();
7070

71-
cbxIgnoreGetMap->setEnabled( false );
72-
cbxIgnoreGetFeatureInfo->setEnabled( false );
73-
7471
QHBoxLayout *layout = new QHBoxLayout;
7572
mImageFormatGroup = new QButtonGroup;
7673

@@ -411,57 +408,6 @@ bool QgsWMSSourceSelect::populateLayerList( QgsWmsProvider *wmsProvider )
411408
lstLayers->expandItem( lstLayers->topLevelItem( 0 ) );
412409
}
413410

414-
if ( wmsProvider->baseUrl() != wmsProvider->getMapUrl() )
415-
{
416-
QApplication::setOverrideCursor( Qt::ArrowCursor );
417-
418-
if ( QMessageBox::information( this,
419-
tr( "WMS Provider" ),
420-
tr( "Advertised GetMap URL\n\n %2\n\nis different from GetCapabilities URL\n\n %1\n\n"
421-
"This might be an server configuration error. Should the URL be used?" )
422-
.arg( wmsProvider->baseUrl() )
423-
.arg( wmsProvider->getMapUrl() ),
424-
QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes )
425-
{
426-
cbxIgnoreGetMap->setChecked( false );
427-
}
428-
else
429-
{
430-
cbxIgnoreGetMap->setChecked( true );
431-
}
432-
cbxIgnoreGetMap->setEnabled( true );
433-
434-
QApplication::restoreOverrideCursor();
435-
}
436-
else
437-
{
438-
cbxIgnoreGetMap->setEnabled( false );
439-
cbxIgnoreGetMap->setChecked( false );
440-
}
441-
442-
if ( wmsProvider->baseUrl() != wmsProvider->getFeatureInfoUrl() )
443-
{
444-
QApplication::setOverrideCursor( Qt::ArrowCursor );
445-
446-
if ( QMessageBox::information( this,
447-
tr( "WMS Provider" ),
448-
tr( "Advertised GetFeatureInfo URL\n\n %2\n\nis different from GetCapabilities URL\n\n %1\n\n"
449-
"This might be an server configuration error. Should the URL be used?" )
450-
.arg( wmsProvider->baseUrl() )
451-
.arg( wmsProvider->getFeatureInfoUrl() ),
452-
QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes )
453-
{
454-
cbxIgnoreGetFeatureInfo->setChecked( false );
455-
}
456-
else
457-
{
458-
cbxIgnoreGetFeatureInfo->setChecked( true );
459-
}
460-
cbxIgnoreGetFeatureInfo->setEnabled( true );
461-
462-
QApplication::restoreOverrideCursor();
463-
}
464-
465411
return true;
466412
}
467413

@@ -475,12 +421,9 @@ void QgsWMSSourceSelect::on_btnConnect_clicked()
475421
QString credentialsKey = "/Qgis/WMS/" + cmbConnections->currentText();
476422

477423
QStringList connStringParts;
478-
QString part;
479-
480-
connStringParts += settings.value( key + "/url" ).toString();
481424

482425
mConnName = cmbConnections->currentText();
483-
mConnectionInfo = connStringParts.join( " " );
426+
mConnectionInfo = settings.value( key + "/url" ).toString();
484427

485428
// Check for credentials and prepend to the connection info
486429
QString username = settings.value( credentialsKey + "/username" ).toString();
@@ -495,6 +438,29 @@ void QgsWMSSourceSelect::on_btnConnect_clicked()
495438
mConnectionInfo = "username=" + username + ",password=" + password + ",url=" + mConnectionInfo;
496439
}
497440

441+
bool ignoreGetMap = settings.value( key + "/ignoreGetMapURI", false ).toBool();
442+
bool ignoreGetFeatureInfo = settings.value( key + "/ignoreGetFeatureInfoURI", false ).toBool();
443+
if ( ignoreGetMap || ignoreGetFeatureInfo )
444+
{
445+
QString connArgs = "ignoreUrl=";
446+
if ( ignoreGetMap )
447+
{
448+
connArgs += "GetMap";
449+
if ( ignoreGetFeatureInfo )
450+
connArgs += ";";
451+
}
452+
if ( ignoreGetFeatureInfo )
453+
connArgs += "GetFeatureInfo";
454+
455+
if ( mConnectionInfo.startsWith( "username=" ) )
456+
{
457+
mConnectionInfo.prepend( connArgs + "," );
458+
}
459+
else
460+
{
461+
mConnectionInfo.prepend( connArgs + ",url=" );
462+
}
463+
}
498464

499465
QgsDebugMsg( QString( "Connection info: '%1'." ).arg( mConnectionInfo ) );
500466

@@ -572,31 +538,6 @@ void QgsWMSSourceSelect::addClicked()
572538
}
573539
}
574540

575-
if ( cbxIgnoreGetMap->isChecked() || cbxIgnoreGetFeatureInfo->isChecked() )
576-
{
577-
QString connArgs = "ignoreUrl=";
578-
579-
if ( cbxIgnoreGetMap->isChecked() )
580-
{
581-
connArgs += "GetMap";
582-
if ( cbxIgnoreGetFeatureInfo->isChecked() )
583-
connArgs += ";GetFeatureInfo";
584-
}
585-
else
586-
{
587-
connArgs += "GetFeatureInfo";
588-
}
589-
590-
if ( connInfo.startsWith( "username=" ) || connInfo.startsWith( "tiled=" ) )
591-
{
592-
connInfo.prepend( connArgs + "," );
593-
}
594-
else
595-
{
596-
connInfo.prepend( connArgs + ",url=" );
597-
}
598-
}
599-
600541
QgisApp::instance()->addRasterLayer( connInfo,
601542
leLayerName->text().isEmpty() ? layers.join( "/" ) : leLayerName->text(),
602543
"wms", layers, styles, format, crs );
@@ -823,7 +764,7 @@ void QgsWMSSourceSelect::on_lstLayers_itemSelectionChanged()
823764
}
824765
}
825766

826-
gbCRS->setTitle( tr( "Coordinate Reference System (%n available)", "crs count", mCRSs.count() ) );
767+
gbCRS->setTitle( tr( "Options (%n coordinate reference systems available)", "crs count", mCRSs.count() ) );
827768
btnChangeSpatialRefSys->setDisabled( mCRSs.isEmpty() );
828769

829770
if ( !layers.isEmpty() && !mCRSs.isEmpty() )

0 commit comments

Comments
 (0)