#include <HttpImageDownloader.h>
Public Slots | |
void | downloadImage (const QString &imageUrl) |
Signals | |
void | downloading (int) |
void | downloadComplete (QByteArray downloadedImageData, QString mainURL) |
Public Member Functions | |
CHttpImageDownloader (const QString &imageUrl, const QString &imageMainUrl, QObject *parent=0) | |
virtual | ~CHttpImageDownloader () |
void | setDownloadImageUrl (const QString &imageUrl) |
Protected Member Functions | |
virtual void | run () |
Private Slots | |
void | httpRequestFinished (int requestId, bool error) |
void | readResponseHeader (const QHttpResponseHeader &responseHeader) |
void | updateDataReadProgress (int bytesRead, int totalBytes) |
Private Attributes | |
QHttp * | http |
QBuffer | buffer |
int | httpGetId |
QString | m_ImageUrl |
QString | m_ImageMainUrl |
CHttpImageDownloader class also stores the thumbnail view URL and original view URL of the image, when download complete it emits original view URL with the downaloded image byte array.
CHttpImageDownloader::CHttpImageDownloader | ( | const QString & | imageUrl, | |
const QString & | imageMainUrl, | |||
QObject * | parent = 0 | |||
) |
imageUrl | image URL that need to be downloaded | |
imageMainUrl | image URL that need to be emitted with downloadComplete() signal | |
parent |
References http, httpRequestFinished(), m_ImageMainUrl, m_ImageUrl, readResponseHeader(), and updateDataReadProgress().
CHttpImageDownloader::~CHttpImageDownloader | ( | ) | [virtual] |
void CHttpImageDownloader::setDownloadImageUrl | ( | const QString & | imageUrl | ) |
This function set the URL from which image needs to be downloaded.
imageUrl | URL for the image loacation |
References m_ImageUrl.
Referenced by CImageHolder::setOriginalPixmap().
void CHttpImageDownloader::downloadImage | ( | const QString & | imageUrl | ) | [slot] |
void CHttpImageDownloader::run | ( | ) | [protected, virtual] |
References downloadImage(), and m_ImageUrl.
void CHttpImageDownloader::httpRequestFinished | ( | int | requestId, | |
bool | error | |||
) | [private, slot] |
References buffer, downloadComplete(), httpGetId, and m_ImageMainUrl.
Referenced by CHttpImageDownloader().
void CHttpImageDownloader::readResponseHeader | ( | const QHttpResponseHeader & | responseHeader | ) | [private, slot] |
void CHttpImageDownloader::updateDataReadProgress | ( | int | bytesRead, | |
int | totalBytes | |||
) | [private, slot] |
void CHttpImageDownloader::downloading | ( | int | ) | [signal] |
This signal is emitted when image download from the web server is started. This signal emits progress in percent for the downloaded image. Progress emitted byt his signal range from 0-100
Referenced by updateDataReadProgress().
void CHttpImageDownloader::downloadComplete | ( | QByteArray | downloadedImageData, | |
QString | mainURL | |||
) | [signal] |
This signal is called when image is downloaded web server. This signal emits bytearray of the downloaded image and also original image URL.
downloadedImageData | downloaded image data from the web server | |
mainURL | URL for the original image |
Referenced by httpRequestFinished().
QHttp* CHttpImageDownloader::http [private] |
Referenced by CHttpImageDownloader(), downloadImage(), and readResponseHeader().
QBuffer CHttpImageDownloader::buffer [private] |
Referenced by downloadImage(), and httpRequestFinished().
int CHttpImageDownloader::httpGetId [private] |
Referenced by downloadImage(), and httpRequestFinished().
QString CHttpImageDownloader::m_ImageUrl [private] |
Referenced by CHttpImageDownloader(), run(), and setDownloadImageUrl().
QString CHttpImageDownloader::m_ImageMainUrl [private] |
Referenced by CHttpImageDownloader(), and httpRequestFinished().