22#include "ui_qgshttpheaderwidget.h"
32 grpbxAdvanced->setCollapsed(
true );
35 connect( btnAddQueryPair, &QToolButton::clicked,
this, &QgsHttpHeaderWidget::addQueryPair );
36 connect( btnRemoveQueryPair, &QToolButton::clicked,
this, &QgsHttpHeaderWidget::removeQueryPair );
41void QgsHttpHeaderWidget::addQueryPairRow(
const QString &key,
const QString &val )
43 const int rowCnt = tblwdgQueryPairs->rowCount();
44 tblwdgQueryPairs->insertRow( rowCnt );
46 const Qt::ItemFlags itemFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable
47 | Qt::ItemIsEditable | Qt::ItemIsDropEnabled;
49 QTableWidgetItem *keyItem =
new QTableWidgetItem( key );
50 keyItem->setFlags( itemFlags );
51 tblwdgQueryPairs->setItem( rowCnt, 0, keyItem );
53 QTableWidgetItem *valueItem =
new QTableWidgetItem( val );
54 valueItem->setFlags( itemFlags );
55 tblwdgQueryPairs->setItem( rowCnt, 1, valueItem );
61 for (
int i = 0; i < tblwdgQueryPairs->rowCount(); ++i )
63 if ( tblwdgQueryPairs->item( i, 0 )->text().isEmpty() )
67 querypairs [ tblwdgQueryPairs->item( i, 0 )->text() ] = QVariant( tblwdgQueryPairs->item( i, 1 )->text() ) ;
70 if ( !mRefererLineEdit->text().isEmpty() )
72 querypairs [
"referer" ] = QVariant( mRefererLineEdit->text() ) ;
76 for (
auto k : querypairs.
keys() )
78 QgsLogger::debug( QString(
"httpHeaders called: %1=%2" ).arg( k, querypairs[k].toString() ) );
86void QgsHttpHeaderWidget::addQueryPair()
88 addQueryPairRow( QString(), QString() );
89 tblwdgQueryPairs->setFocus();
90 tblwdgQueryPairs->setCurrentCell( tblwdgQueryPairs->rowCount() - 1, 0 );
94void QgsHttpHeaderWidget::removeQueryPair()
96 tblwdgQueryPairs->removeRow( tblwdgQueryPairs->currentRow() );
107 for (
int i = tblwdgQueryPairs->rowCount(); i > 0; i-- )
108 tblwdgQueryPairs->removeRow( i - 1 );
111 QList<QString> lst = headers.
keys();
112 for (
auto ite = lst.constBegin(); ite != lst.constEnd(); ++ite )
114 if ( ite->compare(
"referer" ) != 0 )
116 addQueryPairRow( *ite, headers[ *ite ].toString() );
120 mRefererLineEdit->setText( headers[ *ite ].toString() );
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static void debug(const QString &msg, int debuglevel=1, const char *file=nullptr, const char *function=nullptr, int line=-1)
Goes to qDebug.
This class is a composition of two QSettings instances: