[FEATURE] move option to ignore GetMap and GetFeatureInfo URI from WMS GetCapabilities to connection

git-svn-id: http://svn.osgeo.org/qgis/trunk@15559 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
jef 2011-03-22 08:47:46 +00:00
parent 5770cefcf6
commit f3beea7942
5 changed files with 122 additions and 188 deletions

View File

@ -286,6 +286,8 @@ QDomDocument QgsManageConnectionsDialog::saveWMSConnections( const QStringList &
QDomElement el = doc.createElement( "wms" );
el.setAttribute( "name", connections[ i ] );
el.setAttribute( "url", settings.value( path + connections[ i ] + "/url", "" ).toString() );
el.setAttribute( "ignoreGetMapURI", settings.value( path + connections[i] + "/ignoreGetMapURI", false ).toBool() ? "true" : "false" );
el.setAttribute( "ignoreGetFeatureInfoURI", settings.value( path + connections[i] + "/ignoreGetFeatureInfoURI", false ).toBool() ? "true" : "false" );
path = "/Qgis/WMS/";
el.setAttribute( "username", settings.value( path + connections[ i ] + "/username", "" ).toString() );
@ -423,6 +425,8 @@ void QgsManageConnectionsDialog::loadWMSConnections( const QDomDocument &doc, co
// no dups detected or overwrite is allowed
settings.beginGroup( "/Qgis/connections-wms" );
settings.setValue( QString( "/" + connectionName + "/url" ) , child.attribute( "url" ) );
settings.setValue( QString( "/" + connectionName + "/ignoreGetMapURI" ), child.attribute( "ignoreGetMapURI" ) == "true" );
settings.setValue( QString( "/" + connectionName + "/ignoreGetFeatureInfoURI" ), child.attribute( "ignoreGetFeatureInfoURI" ) == "true" );
settings.endGroup();
if ( !child.attribute( "username" ).isEmpty() )

View File

@ -41,6 +41,18 @@ QgsNewHttpConnection::QgsNewHttpConnection(
QString credentialsKey = "/Qgis/WMS/" + connName;
txtName->setText( connName );
txtUrl->setText( settings.value( key + "/url" ).toString() );
if ( mBaseKey == "/Qgis/connections-wms/" )
{
cbxIgnoreGetMapURI->setChecked( settings.value( key + "/ignoreGetMapURI", false ).toBool() );
cbxIgnoreGetFeatureInfoURI->setChecked( settings.value( key + "/ignoreGetFeatureInfoURI", false ).toBool() );
}
else
{
cbxIgnoreGetMapURI->setVisible( false );
cbxIgnoreGetFeatureInfoURI->setVisible( false );
}
txtUserName->setText( settings.value( credentialsKey + "/username" ).toString() );
txtPassword->setText( settings.value( credentialsKey + "/password" ).toString() );
}
@ -96,6 +108,12 @@ void QgsNewHttpConnection::accept()
url.setEncodedQueryItems( params );
settings.setValue( key + "/url", url.toString() );
if ( mBaseKey == "/Qgis/connections-wms/" )
{
settings.setValue( key + "/ignoreGetMapURI", cbxIgnoreGetMapURI->isChecked() );
settings.setValue( key + "/ignoreGetFeatureInfoURI", cbxIgnoreGetFeatureInfoURI->isChecked() );
}
settings.setValue( credentialsKey + "/username", txtUserName->text() );
settings.setValue( credentialsKey + "/password", txtPassword->text() );

View File

@ -68,9 +68,6 @@ QgsWMSSourceSelect::QgsWMSSourceSelect( QWidget * parent, Qt::WFlags fl )
mAddButton->setEnabled( false );
populateConnectionList();
cbxIgnoreGetMap->setEnabled( false );
cbxIgnoreGetFeatureInfo->setEnabled( false );
QHBoxLayout *layout = new QHBoxLayout;
mImageFormatGroup = new QButtonGroup;
@ -411,57 +408,6 @@ bool QgsWMSSourceSelect::populateLayerList( QgsWmsProvider *wmsProvider )
lstLayers->expandItem( lstLayers->topLevelItem( 0 ) );
}
if ( wmsProvider->baseUrl() != wmsProvider->getMapUrl() )
{
QApplication::setOverrideCursor( Qt::ArrowCursor );
if ( QMessageBox::information( this,
tr( "WMS Provider" ),
tr( "Advertised GetMap URL\n\n %2\n\nis different from GetCapabilities URL\n\n %1\n\n"
"This might be an server configuration error. Should the URL be used?" )
.arg( wmsProvider->baseUrl() )
.arg( wmsProvider->getMapUrl() ),
QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes )
{
cbxIgnoreGetMap->setChecked( false );
}
else
{
cbxIgnoreGetMap->setChecked( true );
}
cbxIgnoreGetMap->setEnabled( true );
QApplication::restoreOverrideCursor();
}
else
{
cbxIgnoreGetMap->setEnabled( false );
cbxIgnoreGetMap->setChecked( false );
}
if ( wmsProvider->baseUrl() != wmsProvider->getFeatureInfoUrl() )
{
QApplication::setOverrideCursor( Qt::ArrowCursor );
if ( QMessageBox::information( this,
tr( "WMS Provider" ),
tr( "Advertised GetFeatureInfo URL\n\n %2\n\nis different from GetCapabilities URL\n\n %1\n\n"
"This might be an server configuration error. Should the URL be used?" )
.arg( wmsProvider->baseUrl() )
.arg( wmsProvider->getFeatureInfoUrl() ),
QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes )
{
cbxIgnoreGetFeatureInfo->setChecked( false );
}
else
{
cbxIgnoreGetFeatureInfo->setChecked( true );
}
cbxIgnoreGetFeatureInfo->setEnabled( true );
QApplication::restoreOverrideCursor();
}
return true;
}
@ -475,12 +421,9 @@ void QgsWMSSourceSelect::on_btnConnect_clicked()
QString credentialsKey = "/Qgis/WMS/" + cmbConnections->currentText();
QStringList connStringParts;
QString part;
connStringParts += settings.value( key + "/url" ).toString();
mConnName = cmbConnections->currentText();
mConnectionInfo = connStringParts.join( " " );
mConnectionInfo = settings.value( key + "/url" ).toString();
// Check for credentials and prepend to the connection info
QString username = settings.value( credentialsKey + "/username" ).toString();
@ -495,6 +438,29 @@ void QgsWMSSourceSelect::on_btnConnect_clicked()
mConnectionInfo = "username=" + username + ",password=" + password + ",url=" + mConnectionInfo;
}
bool ignoreGetMap = settings.value( key + "/ignoreGetMapURI", false ).toBool();
bool ignoreGetFeatureInfo = settings.value( key + "/ignoreGetFeatureInfoURI", false ).toBool();
if ( ignoreGetMap || ignoreGetFeatureInfo )
{
QString connArgs = "ignoreUrl=";
if ( ignoreGetMap )
{
connArgs += "GetMap";
if ( ignoreGetFeatureInfo )
connArgs += ";";
}
if ( ignoreGetFeatureInfo )
connArgs += "GetFeatureInfo";
if ( mConnectionInfo.startsWith( "username=" ) )
{
mConnectionInfo.prepend( connArgs + "," );
}
else
{
mConnectionInfo.prepend( connArgs + ",url=" );
}
}
QgsDebugMsg( QString( "Connection info: '%1'." ).arg( mConnectionInfo ) );
@ -572,31 +538,6 @@ void QgsWMSSourceSelect::addClicked()
}
}
if ( cbxIgnoreGetMap->isChecked() || cbxIgnoreGetFeatureInfo->isChecked() )
{
QString connArgs = "ignoreUrl=";
if ( cbxIgnoreGetMap->isChecked() )
{
connArgs += "GetMap";
if ( cbxIgnoreGetFeatureInfo->isChecked() )
connArgs += ";GetFeatureInfo";
}
else
{
connArgs += "GetFeatureInfo";
}
if ( connInfo.startsWith( "username=" ) || connInfo.startsWith( "tiled=" ) )
{
connInfo.prepend( connArgs + "," );
}
else
{
connInfo.prepend( connArgs + ",url=" );
}
}
QgisApp::instance()->addRasterLayer( connInfo,
leLayerName->text().isEmpty() ? layers.join( "/" ) : leLayerName->text(),
"wms", layers, styles, format, crs );
@ -823,7 +764,7 @@ void QgsWMSSourceSelect::on_lstLayers_itemSelectionChanged()
}
}
gbCRS->setTitle( tr( "Coordinate Reference System (%n available)", "crs count", mCRSs.count() ) );
gbCRS->setTitle( tr( "Options (%n coordinate reference systems available)", "crs count", mCRSs.count() ) );
btnChangeSpatialRefSys->setDisabled( mCRSs.isEmpty() );
if ( !layers.isEmpty() && !mCRSs.isEmpty() )

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>512</width>
<height>254</height>
<width>507</width>
<height>322</height>
</rect>
</property>
<property name="windowTitle">
@ -20,12 +20,65 @@
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="GroupBox1">
<property name="title">
<string>Connection details</string>
</property>
<layout class="QGridLayout">
<item row="1" column="0">
<widget class="QLabel" name="TextLabel1">
<property name="text">
<string>URL</string>
</property>
<property name="margin">
<number>5</number>
</property>
<property name="buddy">
<cstring>txtUrl</cstring>
</property>
</widget>
</item>
<item row="4" column="0" colspan="3">
<widget class="QLabel" name="label">
<property name="text">
<string>If the service requires basic authentication, enter a user name and optional password</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Password</string>
</property>
<property name="buddy">
<cstring>txtPassword</cstring>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;User name</string>
</property>
<property name="buddy">
<cstring>txtUserName</cstring>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="TextLabel1_2">
<property name="text">
@ -42,7 +95,7 @@
</property>
</widget>
</item>
<item row="0" column="1" colspan="4">
<item row="0" column="1">
<widget class="QLineEdit" name="txtName">
<property name="minimumSize">
<size>
@ -58,100 +111,44 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="TextLabel1">
<property name="text">
<string>URL</string>
</property>
<property name="margin">
<number>5</number>
</property>
<property name="buddy">
<cstring>txtUrl</cstring>
</property>
</widget>
</item>
<item row="1" column="1" colspan="4">
<item row="1" column="1">
<widget class="QLineEdit" name="txtUrl">
<property name="toolTip">
<string>HTTP address of the Web Map Server</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="5">
<widget class="QLabel" name="label">
<property name="text">
<string>If the service requires basic authentication, enter a user name and optional password</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<item row="5" column="1">
<widget class="QLineEdit" name="txtUserName"/>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;User name</string>
</property>
<property name="buddy">
<cstring>txtUserName</cstring>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLineEdit" name="txtUserName">
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Password</string>
</property>
<property name="buddy">
<cstring>txtPassword</cstring>
</property>
</widget>
</item>
<item row="3" column="4">
<item row="6" column="1">
<widget class="QLineEdit" name="txtPassword">
<property name="maximumSize">
<size>
<width>120</width>
<height>120</height>
</size>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="QCheckBox" name="cbxIgnoreGetFeatureInfoURI">
<property name="text">
<string>Ignore GetFeatureInfo URI reported in capabilities</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="cbxIgnoreGetMapURI">
<property name="text">
<string>Ignore GetMap URI reported in capabilities</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<tabstops>
<tabstop>txtName</tabstop>
<tabstop>txtUrl</tabstop>
<tabstop>txtUserName</tabstop>
<tabstop>txtPassword</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>767</width>
<width>773</width>
<height>539</height>
</rect>
</property>
@ -223,30 +223,6 @@
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<layout class="QHBoxLayout">
<item>
<widget class="QCheckBox" name="cbxIgnoreGetMap">
<property name="toolTip">
<string>Use base url instead of advertised GetFeatureInfo URL</string>
</property>
<property name="text">
<string>Ignore GetMap URL</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbxIgnoreGetFeatureInfo">
<property name="toolTip">
<string>Use base url instead of advertised GetFeatureInfo URL</string>
</property>
<property name="text">
<string>Ignore GetFeatureInfo URL</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
@ -445,8 +421,6 @@
<tabstop>lstLayers</tabstop>
<tabstop>leLayerName</tabstop>
<tabstop>btnChangeSpatialRefSys</tabstop>
<tabstop>cbxIgnoreGetMap</tabstop>
<tabstop>cbxIgnoreGetFeatureInfo</tabstop>
<tabstop>mLayerUpButton</tabstop>
<tabstop>mLayerDownButton</tabstop>
<tabstop>mLayerOrderTreeWidget</tabstop>