#include <QEventLoop>
#include <QNetworkReply>
#include <QScopedPointer>
#include <QSet>
#include <QThread>
#include <QTimer>


class CImageDecodingThreadSample : public QObject
{
    Q_OBJECT;
private:
    QScopedPointer<QNetworkAccessManager> m_manager;
    QString m_url;
    QTimer* m_timer;
    void LoadImage(QString newUrl);
    void run();

public:
   CImageDecodingThreadSample();
   ~CImageDecodingThreadSample();
    void loadFromNetwork(QUrl);

signals:
    void completed();

 public slots:
    void onReplyError(QNetworkReply::NetworkError);
    void onReplyFinished(QNetworkReply *);
    void startImageDownload();
    void onStarted();
};

class CImageResourceSample : public QObject
{
 Q_OBJECT;
public:
  CImageResourceSample();
 ~CImageResourceSample();
  static CImageResourceSample* getInstance(); 

public slots:
  void mainThreadcomplete();    
	
private:
    QScopedPointer<CImageDecodingThreadSample>  m_imageDecodingThread;
    QThread                                     m_decodingThread;
    static CImageResourceSample*                resource;
};
