mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
fix: indent, doc, typo
This commit is contained in:
parent
345dd4dd87
commit
c1582ce1c3
@ -26,38 +26,58 @@ This class implements simple http header management.
|
||||
|
||||
QgsHttpHeaders( const QMap<QString, QVariant> &headers );
|
||||
%Docstring
|
||||
Copy constructor
|
||||
@param headers
|
||||
constructor from map
|
||||
|
||||
:param headers:
|
||||
%End
|
||||
|
||||
QgsHttpHeaders();
|
||||
%Docstring
|
||||
default constructor
|
||||
%End
|
||||
|
||||
QgsHttpHeaders( const QgsSettings &settings, const QString &key = QString() );
|
||||
%Docstring
|
||||
constructor from ``:py:class:`QgsSettings```
|
||||
|
||||
:param settings:
|
||||
:param key:
|
||||
%End
|
||||
|
||||
virtual ~QgsHttpHeaders();
|
||||
|
||||
bool updateNetworkRequest( QNetworkRequest &request ) const;
|
||||
%Docstring
|
||||
update the ``request`` by adding all the http headers
|
||||
@param request
|
||||
@return true if the update succeed
|
||||
|
||||
:param request:
|
||||
|
||||
:return: true if the update succeed
|
||||
%End
|
||||
|
||||
void updateSettings( QgsSettings &settings, const QString &key = QString() ) const;
|
||||
%Docstring
|
||||
update the ``settings`` by adding all the http headers in the path "key/KEY_PREFIX/"
|
||||
@param settings
|
||||
@param key sub group path
|
||||
|
||||
:param settings:
|
||||
:param key: sub group path
|
||||
%End
|
||||
|
||||
void setFromSettings( const QgsSettings &settings, const QString &key = QString() );
|
||||
%Docstring
|
||||
loads headers from the ``settings``
|
||||
@param settings
|
||||
@param key sub group path
|
||||
|
||||
:param settings:
|
||||
:param key: sub group path
|
||||
%End
|
||||
|
||||
QVariant &operator[]( const QString &key );
|
||||
|
||||
QList<QString> keys() const;
|
||||
%Docstring
|
||||
|
||||
:return: the list of all http header key
|
||||
%End
|
||||
|
||||
|
||||
};
|
||||
|
||||
@ -8,26 +8,53 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class QgsHttpHeaderWidget : QWidget
|
||||
{
|
||||
%Docstring(signature="appended")
|
||||
Display referer http header field and collapsible table of key/value pairs
|
||||
|
||||
.. versionadded:: 3.22
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgshttpheaderwidget.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
explicit QgsHttpHeaderWidget( QWidget *parent = 0 );
|
||||
%Docstring
|
||||
Default constructor
|
||||
|
||||
:param parent: parent widget
|
||||
%End
|
||||
~QgsHttpHeaderWidget();
|
||||
|
||||
QgsHttpHeaders httpHeaders() const;
|
||||
%Docstring
|
||||
|
||||
:return: build a new ``:py:class:`QgsHttpHeaders``` according to data in the UI
|
||||
%End
|
||||
|
||||
void setFromSettings( const QgsSettings &settings, const QString &key );
|
||||
%Docstring
|
||||
mRefererLineEdit->setText( settings.value( key + "/referer" ).toString() ); */
|
||||
fill the inner header map from the settings defined at ``key``
|
||||
|
||||
.. seealso:: :py:func:`QgsHttpHeaders.setFromSettings`
|
||||
|
||||
:param settings:
|
||||
:param key:
|
||||
%End
|
||||
|
||||
void updateSettings( QgsSettings &settings, const QString &key ) const;
|
||||
%Docstring
|
||||
settings.setValue( key + "/referer", mRefererLineEdit->:py:func:`~QgsHttpHeaderWidget.text` ); */
|
||||
update the ``settings`` with the http headers present in the inner map.
|
||||
|
||||
.. seealso:: :py:func:`QgsHttpHeaders.updateSettings`
|
||||
|
||||
:param settings:
|
||||
:param key:
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
-------------------
|
||||
begin : 2021-09-09
|
||||
copyright : (C) 2021 B. De Mezzo
|
||||
email : benoit.de.mezzo@oslandia.com
|
||||
email : benoit dot de dot mezzo at oslandia dot com
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
-------------------
|
||||
begin : 2021-09-09
|
||||
copyright : (C) 2021 B. De Mezzo
|
||||
email : benoit.de.mezzo@oslandia.com
|
||||
email : benoit dot de dot mezzo at oslandia dot com
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
@ -42,41 +42,63 @@ class CORE_EXPORT QgsHttpHeaders
|
||||
static const QString KEY_PREFIX;
|
||||
|
||||
/**
|
||||
* @brief Copy constructor
|
||||
* @param headers
|
||||
* \brief constructor from map
|
||||
* \param headers
|
||||
*/
|
||||
QgsHttpHeaders( const QMap<QString, QVariant> &headers );
|
||||
|
||||
/**
|
||||
* \brief default constructor
|
||||
*/
|
||||
QgsHttpHeaders();
|
||||
|
||||
/**
|
||||
* \brief constructor from \a QgsSettings
|
||||
* \param settings
|
||||
* \param key
|
||||
*/
|
||||
QgsHttpHeaders( const QgsSettings &settings, const QString &key = QString() );
|
||||
|
||||
virtual ~QgsHttpHeaders();
|
||||
|
||||
/**
|
||||
* @brief update the \a request by adding all the http headers
|
||||
* @param request
|
||||
* @return true if the update succeed
|
||||
* \brief update the \a request by adding all the http headers
|
||||
* \param request
|
||||
* \return true if the update succeed
|
||||
*/
|
||||
bool updateNetworkRequest( QNetworkRequest &request ) const;
|
||||
|
||||
/**
|
||||
* @brief update the \a settings by adding all the http headers in the path "key/KEY_PREFIX/"
|
||||
* @param settings
|
||||
* @param key sub group path
|
||||
* \brief update the \a settings by adding all the http headers in the path "key/KEY_PREFIX/"
|
||||
* \param settings
|
||||
* \param key sub group path
|
||||
*/
|
||||
void updateSettings( QgsSettings &settings, const QString &key = QString() ) const;
|
||||
|
||||
/**
|
||||
* @brief loads headers from the \a settings
|
||||
* @param settings
|
||||
* @param key sub group path
|
||||
* \brief loads headers from the \a settings
|
||||
* \param settings
|
||||
* \param key sub group path
|
||||
*/
|
||||
void setFromSettings( const QgsSettings &settings, const QString &key = QString() );
|
||||
|
||||
/**
|
||||
* \param key http header key name
|
||||
* \return http header value
|
||||
*/
|
||||
QVariant &operator[]( const QString &key );
|
||||
|
||||
/**
|
||||
* \return the list of all http header key
|
||||
*/
|
||||
QList<QString> keys() const;
|
||||
|
||||
#ifndef SIP_RUN
|
||||
|
||||
/**
|
||||
* \param key http header key name
|
||||
* \return http header value
|
||||
*/
|
||||
const QVariant operator[]( const QString &key ) const;
|
||||
#endif
|
||||
|
||||
|
||||
@ -1,3 +1,23 @@
|
||||
/***************************************************************************
|
||||
qgshttpheaderswidget.cpp
|
||||
This class implements simple UI for http header.
|
||||
|
||||
-------------------
|
||||
begin : 2021-09-09
|
||||
copyright : (C) 2021 B. De Mezzo
|
||||
email : benoit dot de dot mezzo at oslandia dot com
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgshttpheaderwidget.h"
|
||||
#include "ui_qgshttpheaderwidget.h"
|
||||
|
||||
@ -77,8 +97,6 @@ void QgsHttpHeaderWidget::setFromSettings( const QgsSettings &settings, const QS
|
||||
// load headers from settings
|
||||
QgsHttpHeaders headers;
|
||||
headers.setFromSettings( settings, key );
|
||||
printf("In QgsHttpHeaderWidget::setFromSettings: headers[referer]:'%s'\n",
|
||||
headers["referer"].toString().toStdString().c_str());
|
||||
|
||||
// push headers to table
|
||||
tblwdgQueryPairs->clearContents();
|
||||
@ -104,7 +122,4 @@ void QgsHttpHeaderWidget::updateSettings( QgsSettings &settings, const QString &
|
||||
{
|
||||
QgsHttpHeaders h = httpHeaders();
|
||||
h.updateSettings( settings, key );
|
||||
printf("In QgsHttpHeaderWidget::updateSettings: h[referer]:'%s', settings:'%s'\n",
|
||||
h["referer"].toString().toStdString().c_str(),
|
||||
settings.value( key + "referer" ).toString().toStdString().c_str());
|
||||
}
|
||||
|
||||
@ -1,3 +1,23 @@
|
||||
/***************************************************************************
|
||||
qgshttpheaderswidget.h
|
||||
This class implements simple UI for http header.
|
||||
|
||||
-------------------
|
||||
begin : 2021-09-09
|
||||
copyright : (C) 2021 B. De Mezzo
|
||||
email : benoit dot de dot mezzo at oslandia dot com
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef QGSHTTPHEADERWIDGET_H
|
||||
#define QGSHTTPHEADERWIDGET_H
|
||||
|
||||
@ -6,25 +26,62 @@
|
||||
#include "qgshttpheaders.h"
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup gui
|
||||
* \class QgsHttpHeaderWidget
|
||||
* \brief Display referer http header field and collapsible table of key/value pairs
|
||||
*
|
||||
* \since QGIS 3.22
|
||||
*/
|
||||
class GUI_EXPORT QgsHttpHeaderWidget : public QWidget, private Ui::QgsHttpHeaderWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
* \param parent parent widget
|
||||
*/
|
||||
explicit QgsHttpHeaderWidget( QWidget *parent = nullptr );
|
||||
~QgsHttpHeaderWidget();
|
||||
|
||||
/**
|
||||
* \return build a new \a QgsHttpHeaders according to data in the UI
|
||||
*/
|
||||
QgsHttpHeaders httpHeaders() const;
|
||||
|
||||
/* mRefererLineEdit->setText( settings.value( key + "/referer" ).toString() ); */
|
||||
/**
|
||||
* \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
|
||||
*/
|
||||
void setFromSettings( const QgsSettings &settings, const QString &key );
|
||||
|
||||
/* settings.setValue( key + "/referer", mRefererLineEdit->text() ); */
|
||||
/**
|
||||
* \brief update the \a settings with the http headers present in the inner map.
|
||||
* \see QgsHttpHeaders::updateSettings( QgsSettings &settings, const QString &key ) const
|
||||
* \param settings
|
||||
* \param key
|
||||
*/
|
||||
void updateSettings( QgsSettings &settings, const QString &key ) const;
|
||||
|
||||
private slots:
|
||||
|
||||
/**
|
||||
* create qt signal/slot connections
|
||||
*/
|
||||
void setupConnections();
|
||||
|
||||
/**
|
||||
* add a new key/value http header pair in the table
|
||||
*/
|
||||
void addQueryPair();
|
||||
|
||||
/**
|
||||
* remove a key/value http header pair from the table
|
||||
*/
|
||||
void removeQueryPair();
|
||||
|
||||
private:
|
||||
|
||||
@ -83,8 +83,8 @@ void TestQgsHttpheaders::updateSettings()
|
||||
QCOMPARE( settings.value( keyBase + QgsHttpHeaders::KEY_PREFIX + "referer" ).toString(), "http://gg.com" );
|
||||
QVERIFY( ! settings.contains( keyBase + "referer" ) );
|
||||
|
||||
// test backward compability
|
||||
settings.setValue( keyBase + "referer", "paf" ) ; // legacy referer, should be overriden
|
||||
// test backward compatibility
|
||||
settings.setValue( keyBase + "referer", "paf" ) ; // legacy referer, should be overridden
|
||||
h.updateSettings( settings, keyBase );
|
||||
QVERIFY( settings.contains( keyBase + QgsHttpHeaders::KEY_PREFIX + "referer" ) );
|
||||
QCOMPARE( settings.value( keyBase + QgsHttpHeaders::KEY_PREFIX + "referer" ).toString(), "http://gg.com" );
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user