Skip to content

Commit 35eea22

Browse files
committed
Rework QgsNewHttpConnection layout so that both WFS and WMS settings
can be shown simultaneously
1 parent 6134950 commit 35eea22

4 files changed

+309
-233
lines changed

python/gui/qgsnewhttpconnection.sip

+14-2
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,40 @@ class QgsNewHttpConnection : QDialog
3232
typedef QFlags<QgsNewHttpConnection::ConnectionType> ConnectionTypes;
3333

3434

35+
enum Flag
36+
{
37+
FlagShowTestConnection,
38+
};
39+
typedef QFlags<QgsNewHttpConnection::Flag> Flags;
40+
41+
3542
QgsNewHttpConnection( QWidget *parent /TransferThis/ = 0,
3643
QgsNewHttpConnection::ConnectionTypes types = ConnectionWms,
3744
const QString &baseKey = "qgis/connections-wms/",
3845
const QString &connectionName = QString(),
46+
QgsNewHttpConnection::Flags flags = 0,
3947
Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );
4048
%Docstring
4149
Constructor for QgsNewHttpConnection.
4250

4351
The ``types`` argument dictates which connection type settings should be
4452
shown in the dialog.
53+
54+
The ``flags`` argument allows specifying flags which control the dialog behavior
55+
and appearance.
4556
%End
4657

4758
public slots:
59+
4860
virtual void accept();
4961

50-
void on_txtName_textChanged( const QString & );
51-
void on_txtUrl_textChanged( const QString & );
5262

5363
};
5464

5565
QFlags<QgsNewHttpConnection::ConnectionType> operator|(QgsNewHttpConnection::ConnectionType f1, QFlags<QgsNewHttpConnection::ConnectionType> f2);
5666

67+
QFlags<QgsNewHttpConnection::Flag> operator|(QgsNewHttpConnection::Flag f1, QFlags<QgsNewHttpConnection::Flag> f2);
68+
5769

5870
/************************************************************************
5971
* This file has been generated automatically from *

src/gui/qgsnewhttpconnection.cpp

+69-54
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <QRegExp>
2626
#include <QRegExpValidator>
2727

28-
QgsNewHttpConnection::QgsNewHttpConnection( QWidget *parent, ConnectionTypes types, const QString &baseKey, const QString &connectionName, Qt::WindowFlags fl )
28+
QgsNewHttpConnection::QgsNewHttpConnection( QWidget *parent, ConnectionTypes types, const QString &baseKey, const QString &connectionName, QgsNewHttpConnection::Flags flags, Qt::WindowFlags fl )
2929
: QDialog( parent, fl )
3030
, mTypes( types )
3131
, mBaseKey( baseKey )
@@ -76,8 +76,23 @@ QgsNewHttpConnection::QgsNewHttpConnection( QWidget *parent, ConnectionTypes typ
7676
txtUrl->setText( settings.value( key + "/url" ).toString() );
7777

7878
cbxIgnoreGetMapURI->setChecked( settings.value( key + "/ignoreGetMapURI", false ).toBool() );
79-
cbxIgnoreAxisOrientation->setChecked( settings.value( key + "/ignoreAxisOrientation", false ).toBool() );
80-
cbxInvertAxisOrientation->setChecked( settings.value( key + "/invertAxisOrientation", false ).toBool() );
79+
if ( mTypes & ConnectionWfs && mTypes & ConnectionWms )
80+
{
81+
cbxWfsIgnoreAxisOrientation->setChecked( settings.value( key + "/wfs/ignoreAxisOrientation", false ).toBool() );
82+
cbxWfsInvertAxisOrientation->setChecked( settings.value( key + "/wfs/invertAxisOrientation", false ).toBool() );
83+
cbxWmsIgnoreAxisOrientation->setChecked( settings.value( key + "/wms/ignoreAxisOrientation", false ).toBool() );
84+
cbxWmsInvertAxisOrientation->setChecked( settings.value( key + "/wms/invertAxisOrientation", false ).toBool() );
85+
}
86+
else if ( mTypes & ConnectionWfs )
87+
{
88+
cbxWfsIgnoreAxisOrientation->setChecked( settings.value( key + "/ignoreAxisOrientation", false ).toBool() );
89+
cbxWfsInvertAxisOrientation->setChecked( settings.value( key + "/invertAxisOrientation", false ).toBool() );
90+
}
91+
else
92+
{
93+
cbxWmsIgnoreAxisOrientation->setChecked( settings.value( key + "/ignoreAxisOrientation", false ).toBool() );
94+
cbxWmsInvertAxisOrientation->setChecked( settings.value( key + "/invertAxisOrientation", false ).toBool() );
95+
}
8196
cbxIgnoreGetFeatureInfoURI->setChecked( settings.value( key + "/ignoreGetFeatureInfoURI", false ).toBool() );
8297
cbxSmoothPixmapTransform->setChecked( settings.value( key + "/smoothPixmapTransform", false ).toBool() );
8398

@@ -126,75 +141,65 @@ QgsNewHttpConnection::QgsNewHttpConnection( QWidget *parent, ConnectionTypes typ
126141
}
127142
}
128143

129-
if ( !( mTypes & ConnectionWms ) )
144+
if ( !( mTypes & ConnectionWms ) && !( mTypes & ConnectionWcs ) )
130145
{
131-
if ( !( mTypes & ConnectionWcs ) &&
132-
!( mTypes & ConnectionWfs ) )
133-
{
134-
cbxIgnoreAxisOrientation->setVisible( false );
135-
cbxInvertAxisOrientation->setVisible( false );
136-
mGroupBox->layout()->removeWidget( cbxIgnoreAxisOrientation );
137-
mGroupBox->layout()->removeWidget( cbxInvertAxisOrientation );
138-
}
139-
140-
if ( mTypes & ConnectionWfs )
141-
{
142-
cbxIgnoreAxisOrientation->setText( tr( "Ignore axis orientation (WFS 1.1/WFS 2.0)" ) );
143-
}
146+
mWmsOptionsGroupBox->setVisible( false );
147+
mGroupBox->layout()->removeWidget( mWmsOptionsGroupBox );
148+
}
149+
if ( !( mTypes & ConnectionWfs ) )
150+
{
151+
mWfsOptionsGroupBox->setVisible( false );
152+
mGroupBox->layout()->removeWidget( mWfsOptionsGroupBox );
153+
}
144154

145-
if ( mTypes & ConnectionWcs )
146-
{
147-
cbxIgnoreGetMapURI->setText( tr( "Ignore GetCoverage URI reported in capabilities" ) );
148-
cbxIgnoreAxisOrientation->setText( tr( "Ignore axis orientation" ) );
149-
}
150-
else
155+
if ( mTypes & ConnectionWcs )
156+
{
157+
cbxIgnoreGetMapURI->setText( tr( "Ignore GetCoverage URI reported in capabilities" ) );
158+
cbxWmsIgnoreAxisOrientation->setText( tr( "Ignore axis orientation" ) );
159+
if ( !( mTypes & ConnectionWms ) )
151160
{
152-
cbxIgnoreGetMapURI->setVisible( false );
153-
cbxSmoothPixmapTransform->setVisible( false );
154-
mGroupBox->layout()->removeWidget( cbxIgnoreGetMapURI );
155-
mGroupBox->layout()->removeWidget( cbxSmoothPixmapTransform );
156-
}
161+
mWmsOptionsGroupBox->setTitle( tr( "WCS Options" ) );
157162

158-
cbxIgnoreGetFeatureInfoURI->setVisible( false );
159-
mGroupBox->layout()->removeWidget( cbxIgnoreGetFeatureInfoURI );
163+
cbxIgnoreGetFeatureInfoURI->setVisible( false );
164+
mGroupBox->layout()->removeWidget( cbxIgnoreGetFeatureInfoURI );
160165

161-
cmbDpiMode->setVisible( false );
162-
mGroupBox->layout()->removeWidget( cmbDpiMode );
163-
lblDpiMode->setVisible( false );
164-
mGroupBox->layout()->removeWidget( lblDpiMode );
166+
cmbDpiMode->setVisible( false );
167+
mGroupBox->layout()->removeWidget( cmbDpiMode );
168+
lblDpiMode->setVisible( false );
169+
mGroupBox->layout()->removeWidget( lblDpiMode );
165170

166-
txtReferer->setVisible( false );
167-
mGroupBox->layout()->removeWidget( txtReferer );
168-
lblReferer->setVisible( false );
169-
mGroupBox->layout()->removeWidget( lblReferer );
171+
txtReferer->setVisible( false );
172+
mGroupBox->layout()->removeWidget( txtReferer );
173+
lblReferer->setVisible( false );
174+
mGroupBox->layout()->removeWidget( lblReferer );
175+
}
170176
}
171177

172-
if ( !( mTypes & ConnectionWfs ) )
178+
179+
if ( !( flags & FlagShowTestConnection ) )
173180
{
174-
lblVersion->setVisible( false );
175-
cmbVersion->setVisible( false );
176-
mGroupBox->layout()->removeWidget( cmbVersion );
177-
lblMaxNumFeatures->setVisible( false );
178-
mGroupBox->layout()->removeWidget( lblMaxNumFeatures );
179-
txtMaxNumFeatures->setVisible( false );
180-
mGroupBox->layout()->removeWidget( txtMaxNumFeatures );
181+
mTestConnectionButton->hide();
182+
mGroupBox->layout()->removeWidget( mTestConnectionButton );
181183
}
182184

183185
// Adjust height
184186
int w = width();
185187
adjustSize();
186188
resize( w, height() );
187189

188-
on_txtName_textChanged( connectionName );
190+
connect( txtName, &QLineEdit::textChanged, this, &QgsNewHttpConnection::nameChanged );
191+
connect( txtUrl, &QLineEdit::textChanged, this, &QgsNewHttpConnection::urlChanged );
192+
193+
nameChanged( connectionName );
189194
}
190195

191-
void QgsNewHttpConnection::on_txtName_textChanged( const QString &text )
196+
void QgsNewHttpConnection::nameChanged( const QString &text )
192197
{
193198
Q_UNUSED( text );
194199
buttonBox->button( QDialogButtonBox::Ok )->setDisabled( txtName->text().isEmpty() || txtUrl->text().isEmpty() );
195200
}
196201

197-
void QgsNewHttpConnection::on_txtUrl_textChanged( const QString &text )
202+
void QgsNewHttpConnection::urlChanged( const QString &text )
198203
{
199204
Q_UNUSED( text );
200205
buttonBox->button( QDialogButtonBox::Ok )->setDisabled( txtName->text().isEmpty() || txtUrl->text().isEmpty() );
@@ -258,12 +263,22 @@ void QgsNewHttpConnection::accept()
258263

259264
settings.setValue( key + "/url", url.toString() );
260265

261-
if ( mBaseKey == QLatin1String( "qgis/connections-wms/" ) ||
262-
mBaseKey == QLatin1String( "qgis/connections-wcs/" ) ||
263-
mBaseKey == QLatin1String( "qgis/connections-wfs/" ) )
266+
if ( mTypes & ConnectionWfs && mTypes & ConnectionWms )
267+
{
268+
settings.setValue( key + "/wfs/ignoreAxisOrientation", cbxWfsIgnoreAxisOrientation->isChecked() );
269+
settings.setValue( key + "/wms/ignoreAxisOrientation", cbxWmsIgnoreAxisOrientation->isChecked() );
270+
settings.setValue( key + "/wfs/invertAxisOrientation", cbxWfsInvertAxisOrientation->isChecked() );
271+
settings.setValue( key + "/wms/invertAxisOrientation", cbxWmsInvertAxisOrientation->isChecked() );
272+
}
273+
else if ( mTypes & ConnectionWfs )
274+
{
275+
settings.setValue( key + "/ignoreAxisOrientation", cbxWfsIgnoreAxisOrientation->isChecked() );
276+
settings.setValue( key + "/invertAxisOrientation", cbxWfsInvertAxisOrientation->isChecked() );
277+
}
278+
else
264279
{
265-
settings.setValue( key + "/ignoreAxisOrientation", cbxIgnoreAxisOrientation->isChecked() );
266-
settings.setValue( key + "/invertAxisOrientation", cbxInvertAxisOrientation->isChecked() );
280+
settings.setValue( key + "/ignoreAxisOrientation", cbxWmsIgnoreAxisOrientation->isChecked() );
281+
settings.setValue( key + "/invertAxisOrientation", cbxWmsInvertAxisOrientation->isChecked() );
267282
}
268283

269284
if ( mBaseKey == QLatin1String( "qgis/connections-wms/" ) || mBaseKey == QLatin1String( "qgis/connections-wcs/" ) )

src/gui/qgsnewhttpconnection.h

+20-3
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,40 @@ class GUI_EXPORT QgsNewHttpConnection : public QDialog, private Ui::QgsNewHttpCo
4848
};
4949
Q_DECLARE_FLAGS( ConnectionTypes, ConnectionType )
5050

51+
/**
52+
* Flags controlling dialog behavior.
53+
* \since QGIS 3.0
54+
*/
55+
enum Flag
56+
{
57+
FlagShowTestConnection = 1 << 1, //!< Display the 'test connection' button
58+
};
59+
Q_DECLARE_FLAGS( Flags, Flag )
60+
5161
/**
5262
* Constructor for QgsNewHttpConnection.
5363
*
5464
* The \a types argument dictates which connection type settings should be
5565
* shown in the dialog.
5666
*
67+
* The \a flags argument allows specifying flags which control the dialog behavior
68+
* and appearance.
5769
*/
5870
QgsNewHttpConnection( QWidget *parent SIP_TRANSFERTHIS = nullptr,
5971
QgsNewHttpConnection::ConnectionTypes types = ConnectionWms,
6072
const QString &baseKey = "qgis/connections-wms/",
6173
const QString &connectionName = QString(),
74+
QgsNewHttpConnection::Flags flags = 0,
6275
Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );
6376

6477
public slots:
65-
// Saves the connection to ~/.qt/qgisrc
78+
6679
void accept() override;
67-
void on_txtName_textChanged( const QString & );
68-
void on_txtUrl_textChanged( const QString & );
80+
81+
private slots:
82+
83+
void nameChanged( const QString & );
84+
void urlChanged( const QString & );
6985

7086
private:
7187

@@ -80,5 +96,6 @@ class GUI_EXPORT QgsNewHttpConnection : public QDialog, private Ui::QgsNewHttpCo
8096
};
8197

8298
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsNewHttpConnection::ConnectionTypes )
99+
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsNewHttpConnection::Flags )
83100

84101
#endif // QGSNEWHTTPCONNECTION_H

0 commit comments

Comments
 (0)