20 #include <QMessageBox>
22 #include <QPushButton>
23 #include <QRegExpValidator>
29 mOriginalConnName( connName )
41 mCredentialsBaseKey = mBaseKey.
split(
'-' ).
last().toUpper();
46 cmbDpiMode->addItem(
tr(
"all" ) );
47 cmbDpiMode->addItem(
tr(
"off" ) );
48 cmbDpiMode->addItem(
tr(
"QGIS" ) );
49 cmbDpiMode->addItem(
tr(
"UMN" ) );
50 cmbDpiMode->addItem(
tr(
"GeoServer" ) );
59 QString key = mBaseKey + connName;
60 QString credentialsKey =
"/Qgis/" + mCredentialsBaseKey +
"/" + connName;
61 txtName->setText( connName );
64 cbxIgnoreGetMapURI->setChecked( settings.
value( key +
"/ignoreGetMapURI",
false ).
toBool() );
65 cbxIgnoreAxisOrientation->setChecked( settings.
value( key +
"/ignoreAxisOrientation",
false ).
toBool() );
66 cbxInvertAxisOrientation->setChecked( settings.
value( key +
"/invertAxisOrientation",
false ).
toBool() );
67 cbxIgnoreGetFeatureInfoURI->setChecked( settings.
value( key +
"/ignoreGetFeatureInfoURI",
false ).
toBool() );
68 cbxSmoothPixmapTransform->setChecked( settings.
value( key +
"/smoothPixmapTransform",
false ).
toBool() );
71 switch ( settings.
value( key +
"/dpiMode", 7 ).
toInt() )
89 cmbDpiMode->setCurrentIndex( dpiIdx );
91 txtReferer->setText( settings.
value( key +
"/referer" ).
toString() );
93 txtUserName->setText( settings.
value( credentialsKey +
"/username" ).
toString() );
94 txtPassword->setText( settings.
value( credentialsKey +
"/password" ).
toString() );
97 if ( mBaseKey !=
"/Qgis/connections-wms/" )
99 if ( mBaseKey ==
"/Qgis/connections-wcs/" )
101 cbxIgnoreGetMapURI->setText(
tr(
"Ignore GetCoverage URI reported in capabilities" ) );
102 cbxIgnoreAxisOrientation->setText(
tr(
"Ignore axis orientation" ) );
106 cbxIgnoreGetMapURI->setVisible(
false );
107 cbxIgnoreAxisOrientation->setVisible(
false );
108 cbxInvertAxisOrientation->setVisible(
false );
109 cbxSmoothPixmapTransform->setVisible(
false );
110 mGroupBox->layout()->removeWidget( cbxIgnoreGetMapURI );
111 mGroupBox->layout()->removeWidget( cbxIgnoreAxisOrientation );
112 mGroupBox->layout()->removeWidget( cbxInvertAxisOrientation );
113 mGroupBox->layout()->removeWidget( cbxSmoothPixmapTransform );
116 cbxIgnoreGetFeatureInfoURI->setVisible(
false );
117 mGroupBox->layout()->removeWidget( cbxIgnoreGetFeatureInfoURI );
119 cmbDpiMode->setVisible(
false );
120 mGroupBox->layout()->removeWidget( cmbDpiMode );
121 lblDpiMode->setVisible(
false );
122 mGroupBox->layout()->removeWidget( lblDpiMode );
124 txtReferer->setVisible(
false );
125 mGroupBox->layout()->removeWidget( txtReferer );
126 lblReferer->setVisible(
false );
127 mGroupBox->layout()->removeWidget( lblReferer );
145 buttonBox->button( QDialogButtonBox::Ok )->setDisabled( txtName->text().isEmpty() || txtUrl->text().isEmpty() );
151 buttonBox->button( QDialogButtonBox::Ok )->setDisabled( txtName->text().isEmpty() || txtUrl->text().isEmpty() );
157 QString key = mBaseKey + txtName->text();
158 QString credentialsKey =
"/Qgis/" + mCredentialsBaseKey +
"/" + txtName->text();
161 if (( mOriginalConnName.
isNull() || mOriginalConnName.
compare( txtName->text(), Qt::CaseInsensitive ) != 0 ) &&
162 settings.
contains( key +
"/url" ) &&
164 tr(
"Save connection" ),
165 tr(
"Should the existing connection %1 be overwritten?" ).arg( txtName->text() ),
166 QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel )
171 if ( !txtPassword->text().isEmpty() &&
173 tr(
"Saving passwords" ),
174 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." ),
175 QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel )
181 if ( !mOriginalConnName.
isNull() && mOriginalConnName != key )
183 settings.
remove( mBaseKey + mOriginalConnName );
184 settings.
remove(
"/Qgis/" + mCredentialsBaseKey +
"/" + mOriginalConnName );
188 QUrl url( txtUrl->text().trimmed() );
196 if ( params[
"SERVICE"].second.toUpper() ==
"WMS" ||
197 params[
"SERVICE"].second.toUpper() ==
"WFS" ||
198 params[
"SERVICE"].second.toUpper() ==
"WCS" )
200 url.removeEncodedQueryItem( params[
"SERVICE"].first );
201 url.removeEncodedQueryItem( params[
"REQUEST"].first );
202 url.removeEncodedQueryItem( params[
"FORMAT"].first );
205 if ( url.encodedPath().isEmpty() )
207 url.setEncodedPath(
"/" );
210 settings.
setValue( key +
"/url", url.toString() );
211 if ( mBaseKey ==
"/Qgis/connections-wms/" || mBaseKey ==
"/Qgis/connections-wcs/" )
213 settings.
setValue( key +
"/ignoreGetMapURI", cbxIgnoreGetMapURI->isChecked() );
214 settings.
setValue( key +
"/ignoreAxisOrientation", cbxIgnoreAxisOrientation->isChecked() );
215 settings.
setValue( key +
"/invertAxisOrientation", cbxInvertAxisOrientation->isChecked() );
216 settings.
setValue( key +
"/smoothPixmapTransform", cbxSmoothPixmapTransform->isChecked() );
219 switch ( cmbDpiMode->currentIndex() )
238 settings.
setValue( key +
"/dpiMode", dpiMode );
240 if ( mBaseKey ==
"/Qgis/connections-wms/" )
242 settings.
setValue( key +
"/ignoreGetFeatureInfoURI", cbxIgnoreGetFeatureInfoURI->isChecked() );
245 settings.
setValue( key +
"/referer", txtReferer->text() );
247 settings.
setValue( credentialsKey +
"/username", txtUserName->text() );
248 settings.
setValue( credentialsKey +
"/password", txtPassword->text() );
250 settings.
setValue( mBaseKey +
"/selected", txtName->text() );
~QgsNewHttpConnection()
Destructor.
iterator insert(const Key &key, const T &value)
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
QString tr(const char *sourceText, const char *disambiguation, int n)
void on_txtName_textChanged(const QString &)
void setValue(const QString &key, const QVariant &value)
int toInt(bool *ok) const
StandardButton question(QWidget *parent, const QString &title, const QString &text, QFlags< QMessageBox::StandardButton > buttons, StandardButton defaultButton)
void accept() override
Saves the connection to ~/.qt/qgisrc.
bool contains(const QString &key) const
void remove(const QString &key)
QVariant value(const QString &key, const QVariant &defaultValue) const
QString mid(int position, int n) const
QgsNewHttpConnection(QWidget *parent=0, const QString &baseKey="/Qgis/connections-wms/", const QString &connName=QString::null, Qt::WindowFlags fl=QgisGui::ModalDialogFlags)
Constructor.
void on_txtUrl_textChanged(const QString &)
int compare(const QString &other) const