Geometrize  1.0
An application for geometrizing images into geometric primitives
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
Public Member Functions | Private Attributes | List of all members
geometrize::network::Downloader::DownloaderImpl Class Reference
Collaboration diagram for geometrize::network::Downloader::DownloaderImpl:
Collaboration graph
[legend]

Public Member Functions

 DownloaderImpl (Downloader *pQ, const QUrl &url, const std::function< void(Downloader *, QNetworkReply::NetworkError)> &onDownloaded)
 
DownloaderImploperator= (const DownloaderImpl &)=delete
 
 DownloaderImpl (const DownloaderImpl &)=delete
 
 ~DownloaderImpl ()=default
 
QByteArray getDownloadedData () const
 
QUrl getUrl () const
 

Private Attributes

Downloaderq
 
QNetworkAccessManager m_webCtrl
 
QByteArray m_downloadedData
 
QUrl m_url
 

Constructor & Destructor Documentation

geometrize::network::Downloader::DownloaderImpl::DownloaderImpl ( Downloader pQ,
const QUrl &  url,
const std::function< void(Downloader *, QNetworkReply::NetworkError)> &  onDownloaded 
)
inline
15  : q{pQ}, m_url{url}
16  {
17  q->connect(&m_webCtrl, &QNetworkAccessManager::finished, [this](QNetworkReply* pReply) {
18  m_downloadedData = pReply->readAll();
19  const QNetworkReply::NetworkError error{pReply->error()};
20  pReply->deleteLater();
21 
22  emit q->signal_downloaded(q, error); // Note caller may delete/deleteLater the Downloader instance at this point
23  });
24  q->connect(q, &Downloader::signal_downloaded, onDownloaded);
25 
26  QNetworkRequest request(m_url);
27  request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); // So that it can handle redirects e.g. Wikipedia random article links
28  m_webCtrl.get(request);
29  }
QByteArray m_downloadedData
Definition: downloader.cpp:47
QUrl m_url
Definition: downloader.cpp:48
QNetworkAccessManager m_webCtrl
Definition: downloader.cpp:46
Downloader * q
Definition: downloader.cpp:45
void signal_downloaded(Downloader *downloader, QNetworkReply::NetworkError error)
signal_downloaded Dispatched after a download completes.
geometrize::network::Downloader::DownloaderImpl::DownloaderImpl ( const DownloaderImpl )
delete
geometrize::network::Downloader::DownloaderImpl::~DownloaderImpl ( )
default

Member Function Documentation

QByteArray geometrize::network::Downloader::DownloaderImpl::getDownloadedData ( ) const
inline
35  {
36  return m_downloadedData;
37  }
QByteArray m_downloadedData
Definition: downloader.cpp:47
QUrl geometrize::network::Downloader::DownloaderImpl::getUrl ( ) const
inline
40  {
41  return m_url;
42  }
QUrl m_url
Definition: downloader.cpp:48
DownloaderImpl& geometrize::network::Downloader::DownloaderImpl::operator= ( const DownloaderImpl )
delete

Member Data Documentation

QByteArray geometrize::network::Downloader::DownloaderImpl::m_downloadedData
private
QUrl geometrize::network::Downloader::DownloaderImpl::m_url
private
QNetworkAccessManager geometrize::network::Downloader::DownloaderImpl::m_webCtrl
private
Downloader* geometrize::network::Downloader::DownloaderImpl::q
private

The documentation for this class was generated from the following file: