20 #include <QMessageBox>
22 #include <QPushButton>
25 QWidget *parent,
const QString& baseKey,
const QString& connName, Qt::WFlags fl ):
26 QDialog( parent, fl ),
28 mOriginalConnName( connName )
32 QString service = baseKey.mid( 18, 3 ).toUpper();
33 setWindowTitle(
tr(
"Create a new %1 connection" ).arg( service ) );
42 if ( !connName.isEmpty() )
51 txtName->setText( connName );
52 txtUrl->setText( settings.value( key +
"/url" ).toString() );
54 cbxIgnoreGetMapURI->setChecked( settings.value( key +
"/ignoreGetMapURI",
false ).toBool() );
55 cbxIgnoreAxisOrientation->setChecked( settings.value( key +
"/ignoreAxisOrientation",
false ).toBool() );
56 cbxInvertAxisOrientation->setChecked( settings.value( key +
"/invertAxisOrientation",
false ).toBool() );
57 cbxIgnoreGetFeatureInfoURI->setChecked( settings.value( key +
"/ignoreGetFeatureInfoURI",
false ).toBool() );
58 cbxSmoothPixmapTransform->setChecked( settings.value( key +
"/smoothPixmapTransform",
false ).toBool() );
60 txtReferer->setText( settings.value( key +
"/referer" ).toString() );
62 txtUserName->setText( settings.value( credentialsKey +
"/username" ).toString() );
63 txtPassword->setText( settings.value( credentialsKey +
"/password" ).toString() );
66 if (
mBaseKey !=
"/Qgis/connections-wms/" )
68 if (
mBaseKey ==
"/Qgis/connections-wcs/" )
70 cbxIgnoreGetMapURI->setText(
tr(
"Ignore GetCoverage URI reported in capabilities" ) );
71 cbxIgnoreAxisOrientation->setText(
tr(
"Ignore axis orientation" ) );
75 cbxIgnoreGetMapURI->setVisible(
false );
76 cbxIgnoreAxisOrientation->setVisible(
false );
77 cbxInvertAxisOrientation->setVisible(
false );
78 cbxSmoothPixmapTransform->setVisible(
false );
79 mGroupBox->layout()->removeWidget( cbxIgnoreGetMapURI );
80 mGroupBox->layout()->removeWidget( cbxIgnoreAxisOrientation );
81 mGroupBox->layout()->removeWidget( cbxInvertAxisOrientation );
82 mGroupBox->layout()->removeWidget( cbxSmoothPixmapTransform );
85 cbxIgnoreGetFeatureInfoURI->setVisible(
false );
86 mGroupBox->layout()->removeWidget( cbxIgnoreGetFeatureInfoURI );
88 txtReferer->setVisible(
false );
89 mGroupBox->layout()->removeWidget( txtReferer );
90 lblReferer->setVisible(
false );
91 mGroupBox->layout()->removeWidget( lblReferer );
96 resize( w, height() );
108 buttonBox->button( QDialogButtonBox::Ok )->setDisabled( text.isEmpty() );
114 QString key =
mBaseKey + txtName->text();
119 settings.contains( key +
"/url" ) &&
120 QMessageBox::question(
this,
121 tr(
"Save connection" ),
122 tr(
"Should the existing connection %1 be overwritten?" ).arg( txtName->text() ),
123 QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel )
128 if ( !txtPassword->text().isEmpty() &&
129 QMessageBox::question(
this,
130 tr(
"Saving passwords" ),
131 tr(
"WARNING: You have entered a password. It will be stored in plain text in your project files and in your home directory on Unix-like systems, or in your user profile on Windows. If you do not want this to happen, please press the Cancel button.\nNote: giving the password is optional. It will be requested interactivly, when needed." ),
132 QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel )
144 QUrl url( txtUrl->text().trimmed() );
145 const QList< QPair<QByteArray, QByteArray> > &items = url.encodedQueryItems();
146 QHash< QString, QPair<QByteArray, QByteArray> > params;
147 for ( QList< QPair<QByteArray, QByteArray> >::const_iterator it = items.constBegin(); it != items.constEnd(); ++it )
149 params.insert( QString( it->first ).toUpper(), *it );
152 if ( params[
"SERVICE"].second.toUpper() ==
"WMS" ||
153 params[
"SERVICE"].second.toUpper() ==
"WFS" ||
154 params[
"SERVICE"].second.toUpper() ==
"WCS" )
156 url.removeEncodedQueryItem( params[
"SERVICE"].first );
157 url.removeEncodedQueryItem( params[
"REQUEST"].first );
158 url.removeEncodedQueryItem( params[
"FORMAT"].first );
161 if ( url.encodedPath().isEmpty() )
163 url.setEncodedPath(
"/" );
166 settings.setValue( key +
"/url", url.toString() );
167 if (
mBaseKey ==
"/Qgis/connections-wms/" ||
mBaseKey ==
"/Qgis/connections-wcs/" )
169 settings.setValue( key +
"/ignoreGetMapURI", cbxIgnoreGetMapURI->isChecked() );
170 settings.setValue( key +
"/ignoreAxisOrientation", cbxIgnoreAxisOrientation->isChecked() );
171 settings.setValue( key +
"/invertAxisOrientation", cbxInvertAxisOrientation->isChecked() );
172 settings.setValue( key +
"/smoothPixmapTransform", cbxSmoothPixmapTransform->isChecked() );
174 if (
mBaseKey ==
"/Qgis/connections-wms/" )
176 settings.setValue( key +
"/ignoreGetFeatureInfoURI", cbxIgnoreGetFeatureInfoURI->isChecked() );
179 settings.setValue( key +
"/referer", txtReferer->text() );
181 settings.setValue( credentialsKey +
"/username", txtUserName->text() );
182 settings.setValue( credentialsKey +
"/password", txtPassword->text() );
184 settings.setValue(
mBaseKey +
"/selected", txtName->text() );