Skip to content
Permalink
Browse files

Rework QgsNewHttpConnection layout so that both WFS and WMS settings

can be shown simultaneously
  • Loading branch information
nyalldawson committed Sep 11, 2017
1 parent 6134950 commit 35eea229aaa6adb904d04e7efd527d1be3e760bf
Showing with 309 additions and 233 deletions.
  1. +14 −2 python/gui/qgsnewhttpconnection.sip
  2. +69 −54 src/gui/qgsnewhttpconnection.cpp
  3. +20 −3 src/gui/qgsnewhttpconnection.h
  4. +206 −174 src/ui/qgsnewhttpconnectionbase.ui
@@ -32,28 +32,40 @@ class QgsNewHttpConnection : QDialog
typedef QFlags<QgsNewHttpConnection::ConnectionType> ConnectionTypes;


enum Flag
{
FlagShowTestConnection,
};
typedef QFlags<QgsNewHttpConnection::Flag> Flags;


QgsNewHttpConnection( QWidget *parent /TransferThis/ = 0,
QgsNewHttpConnection::ConnectionTypes types = ConnectionWms,
const QString &baseKey = "qgis/connections-wms/",
const QString &connectionName = QString(),
QgsNewHttpConnection::Flags flags = 0,
Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );
%Docstring
Constructor for QgsNewHttpConnection.

The ``types`` argument dictates which connection type settings should be
shown in the dialog.

The ``flags`` argument allows specifying flags which control the dialog behavior
and appearance.
%End

public slots:

virtual void accept();

void on_txtName_textChanged( const QString & );
void on_txtUrl_textChanged( const QString & );

};

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

QFlags<QgsNewHttpConnection::Flag> operator|(QgsNewHttpConnection::Flag f1, QFlags<QgsNewHttpConnection::Flag> f2);


/************************************************************************
* This file has been generated automatically from *
@@ -25,7 +25,7 @@
#include <QRegExp>
#include <QRegExpValidator>

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

cbxIgnoreGetMapURI->setChecked( settings.value( key + "/ignoreGetMapURI", false ).toBool() );
cbxIgnoreAxisOrientation->setChecked( settings.value( key + "/ignoreAxisOrientation", false ).toBool() );
cbxInvertAxisOrientation->setChecked( settings.value( key + "/invertAxisOrientation", false ).toBool() );
if ( mTypes & ConnectionWfs && mTypes & ConnectionWms )
{
cbxWfsIgnoreAxisOrientation->setChecked( settings.value( key + "/wfs/ignoreAxisOrientation", false ).toBool() );
cbxWfsInvertAxisOrientation->setChecked( settings.value( key + "/wfs/invertAxisOrientation", false ).toBool() );
cbxWmsIgnoreAxisOrientation->setChecked( settings.value( key + "/wms/ignoreAxisOrientation", false ).toBool() );
cbxWmsInvertAxisOrientation->setChecked( settings.value( key + "/wms/invertAxisOrientation", false ).toBool() );
}
else if ( mTypes & ConnectionWfs )
{
cbxWfsIgnoreAxisOrientation->setChecked( settings.value( key + "/ignoreAxisOrientation", false ).toBool() );
cbxWfsInvertAxisOrientation->setChecked( settings.value( key + "/invertAxisOrientation", false ).toBool() );
}
else
{
cbxWmsIgnoreAxisOrientation->setChecked( settings.value( key + "/ignoreAxisOrientation", false ).toBool() );
cbxWmsInvertAxisOrientation->setChecked( settings.value( key + "/invertAxisOrientation", false ).toBool() );
}
cbxIgnoreGetFeatureInfoURI->setChecked( settings.value( key + "/ignoreGetFeatureInfoURI", false ).toBool() );
cbxSmoothPixmapTransform->setChecked( settings.value( key + "/smoothPixmapTransform", false ).toBool() );

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

if ( !( mTypes & ConnectionWms ) )
if ( !( mTypes & ConnectionWms ) && !( mTypes & ConnectionWcs ) )
{
if ( !( mTypes & ConnectionWcs ) &&
!( mTypes & ConnectionWfs ) )
{
cbxIgnoreAxisOrientation->setVisible( false );
cbxInvertAxisOrientation->setVisible( false );
mGroupBox->layout()->removeWidget( cbxIgnoreAxisOrientation );
mGroupBox->layout()->removeWidget( cbxInvertAxisOrientation );
}

if ( mTypes & ConnectionWfs )
{
cbxIgnoreAxisOrientation->setText( tr( "Ignore axis orientation (WFS 1.1/WFS 2.0)" ) );
}
mWmsOptionsGroupBox->setVisible( false );
mGroupBox->layout()->removeWidget( mWmsOptionsGroupBox );
}
if ( !( mTypes & ConnectionWfs ) )
{
mWfsOptionsGroupBox->setVisible( false );
mGroupBox->layout()->removeWidget( mWfsOptionsGroupBox );
}

if ( mTypes & ConnectionWcs )
{
cbxIgnoreGetMapURI->setText( tr( "Ignore GetCoverage URI reported in capabilities" ) );
cbxIgnoreAxisOrientation->setText( tr( "Ignore axis orientation" ) );
}
else
if ( mTypes & ConnectionWcs )
{
cbxIgnoreGetMapURI->setText( tr( "Ignore GetCoverage URI reported in capabilities" ) );
cbxWmsIgnoreAxisOrientation->setText( tr( "Ignore axis orientation" ) );
if ( !( mTypes & ConnectionWms ) )
{
cbxIgnoreGetMapURI->setVisible( false );
cbxSmoothPixmapTransform->setVisible( false );
mGroupBox->layout()->removeWidget( cbxIgnoreGetMapURI );
mGroupBox->layout()->removeWidget( cbxSmoothPixmapTransform );
}
mWmsOptionsGroupBox->setTitle( tr( "WCS Options" ) );

cbxIgnoreGetFeatureInfoURI->setVisible( false );
mGroupBox->layout()->removeWidget( cbxIgnoreGetFeatureInfoURI );
cbxIgnoreGetFeatureInfoURI->setVisible( false );
mGroupBox->layout()->removeWidget( cbxIgnoreGetFeatureInfoURI );

cmbDpiMode->setVisible( false );
mGroupBox->layout()->removeWidget( cmbDpiMode );
lblDpiMode->setVisible( false );
mGroupBox->layout()->removeWidget( lblDpiMode );
cmbDpiMode->setVisible( false );
mGroupBox->layout()->removeWidget( cmbDpiMode );
lblDpiMode->setVisible( false );
mGroupBox->layout()->removeWidget( lblDpiMode );

txtReferer->setVisible( false );
mGroupBox->layout()->removeWidget( txtReferer );
lblReferer->setVisible( false );
mGroupBox->layout()->removeWidget( lblReferer );
txtReferer->setVisible( false );
mGroupBox->layout()->removeWidget( txtReferer );
lblReferer->setVisible( false );
mGroupBox->layout()->removeWidget( lblReferer );
}
}

if ( !( mTypes & ConnectionWfs ) )

if ( !( flags & FlagShowTestConnection ) )
{
lblVersion->setVisible( false );
cmbVersion->setVisible( false );
mGroupBox->layout()->removeWidget( cmbVersion );
lblMaxNumFeatures->setVisible( false );
mGroupBox->layout()->removeWidget( lblMaxNumFeatures );
txtMaxNumFeatures->setVisible( false );
mGroupBox->layout()->removeWidget( txtMaxNumFeatures );
mTestConnectionButton->hide();
mGroupBox->layout()->removeWidget( mTestConnectionButton );
}

// Adjust height
int w = width();
adjustSize();
resize( w, height() );

on_txtName_textChanged( connectionName );
connect( txtName, &QLineEdit::textChanged, this, &QgsNewHttpConnection::nameChanged );
connect( txtUrl, &QLineEdit::textChanged, this, &QgsNewHttpConnection::urlChanged );

nameChanged( connectionName );
}

void QgsNewHttpConnection::on_txtName_textChanged( const QString &text )
void QgsNewHttpConnection::nameChanged( const QString &text )
{
Q_UNUSED( text );
buttonBox->button( QDialogButtonBox::Ok )->setDisabled( txtName->text().isEmpty() || txtUrl->text().isEmpty() );
}

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

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

if ( mBaseKey == QLatin1String( "qgis/connections-wms/" ) ||
mBaseKey == QLatin1String( "qgis/connections-wcs/" ) ||
mBaseKey == QLatin1String( "qgis/connections-wfs/" ) )
if ( mTypes & ConnectionWfs && mTypes & ConnectionWms )
{
settings.setValue( key + "/wfs/ignoreAxisOrientation", cbxWfsIgnoreAxisOrientation->isChecked() );
settings.setValue( key + "/wms/ignoreAxisOrientation", cbxWmsIgnoreAxisOrientation->isChecked() );
settings.setValue( key + "/wfs/invertAxisOrientation", cbxWfsInvertAxisOrientation->isChecked() );
settings.setValue( key + "/wms/invertAxisOrientation", cbxWmsInvertAxisOrientation->isChecked() );
}
else if ( mTypes & ConnectionWfs )
{
settings.setValue( key + "/ignoreAxisOrientation", cbxWfsIgnoreAxisOrientation->isChecked() );
settings.setValue( key + "/invertAxisOrientation", cbxWfsInvertAxisOrientation->isChecked() );
}
else
{
settings.setValue( key + "/ignoreAxisOrientation", cbxIgnoreAxisOrientation->isChecked() );
settings.setValue( key + "/invertAxisOrientation", cbxInvertAxisOrientation->isChecked() );
settings.setValue( key + "/ignoreAxisOrientation", cbxWmsIgnoreAxisOrientation->isChecked() );
settings.setValue( key + "/invertAxisOrientation", cbxWmsInvertAxisOrientation->isChecked() );
}

if ( mBaseKey == QLatin1String( "qgis/connections-wms/" ) || mBaseKey == QLatin1String( "qgis/connections-wcs/" ) )
@@ -48,24 +48,40 @@ class GUI_EXPORT QgsNewHttpConnection : public QDialog, private Ui::QgsNewHttpCo
};
Q_DECLARE_FLAGS( ConnectionTypes, ConnectionType )

/**
* Flags controlling dialog behavior.
* \since QGIS 3.0
*/
enum Flag
{
FlagShowTestConnection = 1 << 1, //!< Display the 'test connection' button
};
Q_DECLARE_FLAGS( Flags, Flag )

/**
* Constructor for QgsNewHttpConnection.
*
* The \a types argument dictates which connection type settings should be
* shown in the dialog.
*
* The \a flags argument allows specifying flags which control the dialog behavior
* and appearance.
*/
QgsNewHttpConnection( QWidget *parent SIP_TRANSFERTHIS = nullptr,
QgsNewHttpConnection::ConnectionTypes types = ConnectionWms,
const QString &baseKey = "qgis/connections-wms/",
const QString &connectionName = QString(),
QgsNewHttpConnection::Flags flags = 0,
Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );

public slots:
// Saves the connection to ~/.qt/qgisrc

void accept() override;
void on_txtName_textChanged( const QString & );
void on_txtUrl_textChanged( const QString & );

private slots:

void nameChanged( const QString & );
void urlChanged( const QString & );

private:

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

Q_DECLARE_OPERATORS_FOR_FLAGS( QgsNewHttpConnection::ConnectionTypes )
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsNewHttpConnection::Flags )

#endif // QGSNEWHTTPCONNECTION_H

0 comments on commit 35eea22

Please sign in to comment.
You can’t perform that action at this time.