Skip to content

Commit

Permalink
Rework QgsNewHttpConnection layout so that both WFS and WMS settings
Browse files Browse the repository at this point in the history
can be shown simultaneously
  • Loading branch information
nyalldawson committed Sep 12, 2017
1 parent 6134950 commit 35eea22
Show file tree
Hide file tree
Showing 4 changed files with 309 additions and 233 deletions.
16 changes: 14 additions & 2 deletions python/gui/qgsnewhttpconnection.sip
Expand Up @@ -32,28 +32,40 @@ class QgsNewHttpConnection : QDialog
typedef QFlags<QgsNewHttpConnection::ConnectionType> ConnectionTypes; typedef QFlags<QgsNewHttpConnection::ConnectionType> ConnectionTypes;




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


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


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

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


public slots: public slots:

virtual void accept(); 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::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 * * This file has been generated automatically from *
Expand Down
123 changes: 69 additions & 54 deletions src/gui/qgsnewhttpconnection.cpp
Expand Up @@ -25,7 +25,7 @@
#include <QRegExp> #include <QRegExp>
#include <QRegExpValidator> #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 ) : QDialog( parent, fl )
, mTypes( types ) , mTypes( types )
, mBaseKey( baseKey ) , mBaseKey( baseKey )
Expand Down Expand Up @@ -76,8 +76,23 @@ QgsNewHttpConnection::QgsNewHttpConnection( QWidget *parent, ConnectionTypes typ
txtUrl->setText( settings.value( key + "/url" ).toString() ); txtUrl->setText( settings.value( key + "/url" ).toString() );


cbxIgnoreGetMapURI->setChecked( settings.value( key + "/ignoreGetMapURI", false ).toBool() ); cbxIgnoreGetMapURI->setChecked( settings.value( key + "/ignoreGetMapURI", false ).toBool() );
cbxIgnoreAxisOrientation->setChecked( settings.value( key + "/ignoreAxisOrientation", false ).toBool() ); if ( mTypes & ConnectionWfs && mTypes & ConnectionWms )
cbxInvertAxisOrientation->setChecked( settings.value( key + "/invertAxisOrientation", false ).toBool() ); {
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() ); cbxIgnoreGetFeatureInfoURI->setChecked( settings.value( key + "/ignoreGetFeatureInfoURI", false ).toBool() );
cbxSmoothPixmapTransform->setChecked( settings.value( key + "/smoothPixmapTransform", false ).toBool() ); cbxSmoothPixmapTransform->setChecked( settings.value( key + "/smoothPixmapTransform", false ).toBool() );


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


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

if ( mTypes & ConnectionWfs )
{
cbxIgnoreAxisOrientation->setText( tr( "Ignore axis orientation (WFS 1.1/WFS 2.0)" ) );
}


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


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


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


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


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


// Adjust height // Adjust height
int w = width(); int w = width();
adjustSize(); adjustSize();
resize( w, height() ); 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 ); Q_UNUSED( text );
buttonBox->button( QDialogButtonBox::Ok )->setDisabled( txtName->text().isEmpty() || txtUrl->text().isEmpty() ); 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 ); Q_UNUSED( text );
buttonBox->button( QDialogButtonBox::Ok )->setDisabled( txtName->text().isEmpty() || txtUrl->text().isEmpty() ); buttonBox->button( QDialogButtonBox::Ok )->setDisabled( txtName->text().isEmpty() || txtUrl->text().isEmpty() );
Expand Down Expand Up @@ -258,12 +263,22 @@ void QgsNewHttpConnection::accept()


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


if ( mBaseKey == QLatin1String( "qgis/connections-wms/" ) || if ( mTypes & ConnectionWfs && mTypes & ConnectionWms )
mBaseKey == QLatin1String( "qgis/connections-wcs/" ) || {
mBaseKey == QLatin1String( "qgis/connections-wfs/" ) ) 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 + "/ignoreAxisOrientation", cbxWmsIgnoreAxisOrientation->isChecked() );
settings.setValue( key + "/invertAxisOrientation", cbxInvertAxisOrientation->isChecked() ); settings.setValue( key + "/invertAxisOrientation", cbxWmsInvertAxisOrientation->isChecked() );
} }


if ( mBaseKey == QLatin1String( "qgis/connections-wms/" ) || mBaseKey == QLatin1String( "qgis/connections-wcs/" ) ) if ( mBaseKey == QLatin1String( "qgis/connections-wms/" ) || mBaseKey == QLatin1String( "qgis/connections-wcs/" ) )
Expand Down
23 changes: 20 additions & 3 deletions src/gui/qgsnewhttpconnection.h
Expand Up @@ -48,24 +48,40 @@ class GUI_EXPORT QgsNewHttpConnection : public QDialog, private Ui::QgsNewHttpCo
}; };
Q_DECLARE_FLAGS( ConnectionTypes, ConnectionType ) 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. * Constructor for QgsNewHttpConnection.
* *
* The \a types argument dictates which connection type settings should be * The \a types argument dictates which connection type settings should be
* shown in the dialog. * 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( QWidget *parent SIP_TRANSFERTHIS = nullptr,
QgsNewHttpConnection::ConnectionTypes types = ConnectionWms, QgsNewHttpConnection::ConnectionTypes types = ConnectionWms,
const QString &baseKey = "qgis/connections-wms/", const QString &baseKey = "qgis/connections-wms/",
const QString &connectionName = QString(), const QString &connectionName = QString(),
QgsNewHttpConnection::Flags flags = 0,
Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags ); Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );


public slots: public slots:
// Saves the connection to ~/.qt/qgisrc
void accept() override; 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: private:


Expand All @@ -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::ConnectionTypes )
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsNewHttpConnection::Flags )


#endif // QGSNEWHTTPCONNECTION_H #endif // QGSNEWHTTPCONNECTION_H

0 comments on commit 35eea22

Please sign in to comment.