opt: reply remove unnecessary signal (#1866)
Some checks failed
SonarCloud / Build and analyze (push) Has been cancelled

* opt: remove unnecessary signal



---------

Co-authored-by: shenleban tongying <shenlebantongying@gmail.com>
This commit is contained in:
xiaoyifang 2024-10-26 19:35:27 +08:00 committed by GitHub
parent 7229faeec7
commit 15207cf400
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 51 deletions

View file

@ -22,9 +22,11 @@ AllowFrameReply::AllowFrameReply( QNetworkReply * _reply ):
setRequest( baseReply->request() ); setRequest( baseReply->request() );
setUrl( baseReply->url() ); setUrl( baseReply->url() );
// Signals to own slots QList< QByteArray > rawHeaders = baseReply->rawHeaderList();
for ( const auto & header : rawHeaders ) {
connect( baseReply, &QNetworkReply::metaDataChanged, this, &AllowFrameReply::applyMetaData ); if ( header.toLower() != "x-frame-options" )
setRawHeader( header, baseReply->rawHeader( header ) );
}
connect( baseReply, &QNetworkReply::errorOccurred, this, &AllowFrameReply::applyError ); connect( baseReply, &QNetworkReply::errorOccurred, this, &AllowFrameReply::applyError );
@ -32,45 +34,11 @@ AllowFrameReply::AllowFrameReply( QNetworkReply * _reply ):
// Redirect QNetworkReply signals // Redirect QNetworkReply signals
connect( baseReply, &QNetworkReply::downloadProgress, this, &QNetworkReply::downloadProgress );
connect( baseReply, &QNetworkReply::encrypted, this, &QNetworkReply::encrypted );
connect( baseReply, &QNetworkReply::finished, this, &QNetworkReply::finished ); connect( baseReply, &QNetworkReply::finished, this, &QNetworkReply::finished );
connect( baseReply,
&QNetworkReply::preSharedKeyAuthenticationRequired,
this,
&QNetworkReply::preSharedKeyAuthenticationRequired );
connect( baseReply, &QNetworkReply::redirected, this, &QNetworkReply::redirected );
connect( baseReply, &QNetworkReply::sslErrors, this, &QNetworkReply::sslErrors );
connect( baseReply, &QNetworkReply::uploadProgress, this, &QNetworkReply::uploadProgress );
// Redirect QIODevice signals
connect( baseReply, &QIODevice::aboutToClose, this, &QIODevice::aboutToClose );
connect( baseReply, &QIODevice::bytesWritten, this, &QIODevice::bytesWritten );
connect( baseReply, &QIODevice::readChannelFinished, this, &QIODevice::readChannelFinished );
setOpenMode( QIODevice::ReadOnly ); setOpenMode( QIODevice::ReadOnly );
} }
void AllowFrameReply::applyMetaData()
{
// The webengine does not support to customize the headers right now ,maybe until Qt6.7 there should be some api supports
}
void AllowFrameReply::setReadBufferSize( qint64 size )
{
QNetworkReply::setReadBufferSize( size );
baseReply->setReadBufferSize( size );
}
qint64 AllowFrameReply::bytesAvailable() const qint64 AllowFrameReply::bytesAvailable() const
{ {
return baseReply->bytesAvailable(); return baseReply->bytesAvailable();
@ -89,11 +57,6 @@ qint64 AllowFrameReply::readData( char * data, qint64 maxSize )
baseReply->read( data, size ); baseReply->read( data, size );
return size; return size;
} }
void AllowFrameReply::finishedSlot()
{
setFinished( true );
emit finished();
}
QNetworkReply * ArticleNetworkAccessManager::getArticleReply( QNetworkRequest const & req ) QNetworkReply * ArticleNetworkAccessManager::getArticleReply( QNetworkRequest const & req )
{ {

View file

@ -42,8 +42,6 @@ public:
delete baseReply; delete baseReply;
} }
// QNetworkReply virtual functions
void setReadBufferSize( qint64 size );
void close() void close()
{ {
baseReply->close(); baseReply->close();
@ -51,7 +49,7 @@ public:
// QIODevice virtual functions // QIODevice virtual functions
qint64 bytesAvailable() const; qint64 bytesAvailable() const;
bool atEnd() const bool atEnd() const override
{ {
return baseReply->atEnd(); return baseReply->atEnd();
} }
@ -81,11 +79,7 @@ public:
} }
public slots: public slots:
// Own AllowFrameReply slots
void applyMetaData();
void applyError( QNetworkReply::NetworkError code ); void applyError( QNetworkReply::NetworkError code );
// void readDataFromBase();
// Redirect QNetworkReply slots // Redirect QNetworkReply slots
virtual void abort() virtual void abort()
@ -96,7 +90,6 @@ public slots:
{ {
baseReply->ignoreSslErrors(); baseReply->ignoreSslErrors();
} }
void finishedSlot();
protected: protected:
// QNetworkReply virtual functions // QNetworkReply virtual functions
@ -186,7 +179,7 @@ public:
protected: protected:
virtual qint64 bytesAvailable() const; virtual qint64 bytesAvailable() const;
bool atEnd() const; bool atEnd() const override;
virtual void abort() {} virtual void abort() {}
virtual qint64 readData( char * data, qint64 maxSize ); virtual qint64 readData( char * data, qint64 maxSize );