emailuis/nmailui/src/nmeditortextdocument.cpp
changeset 43 99bcbff212ad
parent 23 2dc6caa42ec3
child 47 f83bd4ae1fe3
equal deleted inserted replaced
42:139d4b7b2938 43:99bcbff212ad
    29     Constructor. Caller needs to ensure manager is valid reference.
    29     Constructor. Caller needs to ensure manager is valid reference.
    30 */
    30 */
    31 NmEditorTextDocument::NmEditorTextDocument(QNetworkAccessManager &manager) :
    31 NmEditorTextDocument::NmEditorTextDocument(QNetworkAccessManager &manager) :
    32     mManager(manager)
    32     mManager(manager)
    33 {
    33 {
       
    34     NM_FUNCTION;
       
    35     
    34     connect(&mManager, SIGNAL(finished(QNetworkReply*)),
    36     connect(&mManager, SIGNAL(finished(QNetworkReply*)),
    35         this, SLOT(replyFinished(QNetworkReply*)));
    37         this, SLOT(replyFinished(QNetworkReply*)));
    36 }
    38 }
    37 
    39 
    38 /*!
    40 /*!
    39     Destructor
    41     Destructor
    40 */
    42 */
    41 NmEditorTextDocument::~NmEditorTextDocument()
    43 NmEditorTextDocument::~NmEditorTextDocument()
    42 {
    44 {
       
    45     NM_FUNCTION;
       
    46     
    43     foreach(QNetworkReply *reply, mReplyList) {
    47     foreach(QNetworkReply *reply, mReplyList) {
    44         if(reply) {
    48         if(reply) {
    45             reply->abort();
    49             reply->abort();
    46             reply->deleteLater();
    50             reply->deleteLater();
    47         }
    51         }
    51 /*!
    55 /*!
    52     replyFinished. Signaled when the image has been loaded from Internet.
    56     replyFinished. Signaled when the image has been loaded from Internet.
    53 */
    57 */
    54 void NmEditorTextDocument::replyFinished(QNetworkReply *reply)
    58 void NmEditorTextDocument::replyFinished(QNetworkReply *reply)
    55 {
    59 {
       
    60     NM_FUNCTION;
       
    61     
    56     if(reply) {
    62     if(reply) {
    57         if(reply->error() == QNetworkReply::NoError) {
    63         if(reply->error() == QNetworkReply::NoError) {
    58             QPixmap image;
    64             QPixmap image;
    59             if(image.loadFromData(reply->readAll())) { 
    65             if(image.loadFromData(reply->readAll())) { 
    60                 addResource(QTextDocument::ImageResource, reply->url(), QVariant(image));
    66                 addResource(QTextDocument::ImageResource, reply->url(), QVariant(image));
    69 /*!
    75 /*!
    70     loadResource. Starts fetching image from given URL.
    76     loadResource. Starts fetching image from given URL.
    71 */
    77 */
    72 QVariant NmEditorTextDocument::loadResource(int type, const QUrl &name)
    78 QVariant NmEditorTextDocument::loadResource(int type, const QUrl &name)
    73 {
    79 {
       
    80     NM_FUNCTION;
       
    81     
    74     QVariant retVal;
    82     QVariant retVal;
    75     
    83     
    76     if(type == QTextDocument::ImageResource) {    
    84     if(type == QTextDocument::ImageResource) {    
    77         // Load image data from the cache if it exists
    85         // Load image data from the cache if it exists
    78         if(mManager.cache()) {
    86         if(mManager.cache()) {