Skip to content

Commit

Permalink
fix headers reading in widget + deprecate method with settings
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Jan 16, 2023
1 parent a88ec8b commit 715f760
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
12 changes: 11 additions & 1 deletion python/gui/auto_generated/qgshttpheaderwidget.sip.in
Expand Up @@ -37,14 +37,24 @@ Default constructor
:return: build a new ``:py:class:`QgsHttpHeaders``` according to data in the UI
%End

void setFromSettings( const QgsSettings &settings, const QString &key );
void setHeaders( const QgsHttpHeaders &headers );
%Docstring
Sets the widget from the headers

.. versionadded:: 3.30
%End

void setFromSettings( const QgsSettings &settings, const QString &key ) /Deprecated/;
%Docstring
fill the inner header map from the settings defined at ``key``

.. seealso:: :py:func:`QgsHttpHeaders.setFromSettings`

:param settings:
:param key:

.. deprecated:: QGIS 3.30
use setFromHeaders instead
%End

void updateSettings( QgsSettings &settings, const QString &key ) const /Deprecated/;
Expand Down
4 changes: 4 additions & 0 deletions src/gui/qgshttpheaderwidget.cpp
Expand Up @@ -102,7 +102,11 @@ void QgsHttpHeaderWidget::setFromSettings( const QgsSettings &settings, const QS
// load headers from settings
QgsHttpHeaders headers;
headers.setFromSettings( settings, key );
setHeaders( headers );
}

void QgsHttpHeaderWidget::setHeaders( const QgsHttpHeaders &headers )
{
// clean table
for ( int i = tblwdgQueryPairs->rowCount(); i > 0; i-- )
tblwdgQueryPairs->removeRow( i - 1 );
Expand Down
9 changes: 8 additions & 1 deletion src/gui/qgshttpheaderwidget.h
Expand Up @@ -51,13 +51,20 @@ class GUI_EXPORT QgsHttpHeaderWidget : public QWidget, private Ui::QgsHttpHeader
*/
QgsHttpHeaders httpHeaders() const;

/**
* Sets the widget from the headers
* \since QGIS 3.30
*/
void setHeaders( const QgsHttpHeaders &headers );

/**
* \brief fill the inner header map from the settings defined at \a key
* \see QgsHttpHeaders::setFromSettings( const QgsSettings &settings, const QString &key )
* \param settings
* \param key
* \deprecated since QGIS 3.30 use setFromHeaders instead
*/
void setFromSettings( const QgsSettings &settings, const QString &key );
Q_DECL_DEPRECATED void setFromSettings( const QgsSettings &settings, const QString &key ) SIP_DEPRECATED;

/**
* \brief update the \a settings with the http headers present in the inner map.
Expand Down
6 changes: 2 additions & 4 deletions src/gui/qgsnewhttpconnection.cpp
Expand Up @@ -94,11 +94,9 @@ QgsNewHttpConnection::QgsNewHttpConnection( QWidget *parent, ConnectionTypes typ
// populate the dialog with the information stored for the connection
// populate the fields with the stored setting parameters

const QgsSettings settings;

txtName->setText( connectionName );
txtUrl->setText( QgsOwsConnection::settingsUrl->value( {mServiceName.toLower(), connectionName} ) );
mHttpHeaders->setFromSettings( settings, QStringLiteral( "qgis/connections-%1/%2" ).arg( mServiceName.toLower(), connectionName ) );
mHttpHeaders->setHeaders( QgsHttpHeaders( QgsOwsConnection::settingsHeaders->value( {mServiceName.toLower(), connectionName} ) ) );

updateServiceSpecificSettings();

Expand Down Expand Up @@ -327,7 +325,7 @@ void QgsNewHttpConnection::updateServiceSpecificSettings()
// Enable/disable these items per WFS versions
wfsVersionCurrentIndexChanged( versionIdx );

mHttpHeaders->setFromSettings( QgsSettings(), QStringLiteral( "qgis/connections-%1/%2" ).arg( mServiceName.toLower(), mOriginalConnName ) );
mHttpHeaders->setHeaders( QgsHttpHeaders( QgsOwsConnection::settingsHeaders->value( {mServiceName.toLower(), mOriginalConnName} ) ) );

txtMaxNumFeatures->setText( QgsOwsConnection::settingsMaxNumFeatures->value( detailsParameters ) );

Expand Down
2 changes: 2 additions & 0 deletions src/providers/arcgisrest/qgsnewarcgisrestconnection.cpp
Expand Up @@ -63,7 +63,9 @@ QgsNewArcGisRestConnectionDialog::QgsNewArcGisRestConnectionDialog( QWidget *par
const QString credentialsKey = "qgis/" + mCredentialsBaseKey + '/' + connectionName;
txtName->setText( connectionName );
txtUrl->setText( settings.value( key + "/url" ).toString() );
Q_NOWARN_DEPRECATED_PUSH
mHttpHeaders->setFromSettings( settings, key );
Q_NOWARN_DEPRECATED_POP

// portal
mContentEndPointLineEdit->setText( settings.value( key + "/content_endpoint" ).toString() );
Expand Down

0 comments on commit 715f760

Please sign in to comment.