emailuis/nmailui/src/nmeditorcontent.cpp
changeset 44 c2d07d913565
parent 43 99bcbff212ad
child 47 f83bd4ae1fe3
child 54 997a02608b3a
equal deleted inserted replaced
43:99bcbff212ad 44:c2d07d913565
    73 /*!
    73 /*!
    74     Fill message data into header and body fileds. If reply envelopw is
    74     Fill message data into header and body fileds. If reply envelopw is
    75     present, reply header is generated and set to editor. Reply
    75     present, reply header is generated and set to editor. Reply
    76     envelope ownership is not transferred here.
    76     envelope ownership is not transferred here.
    77  */
    77  */
    78 void NmEditorContent::setMessageData(const NmMessage &originalMessage)
    78 void NmEditorContent::setMessageData(const NmMessage &originalMessage,
       
    79                                      bool createReplyHeader)
    79 {
    80 {
    80     NM_FUNCTION;
    81     NM_FUNCTION;
       
    82     
       
    83     QString bodyContent;
       
    84     
       
    85     // We create the "reply" header (also for forward message), but not to draft message.
       
    86     if (mEditorWidget && createReplyHeader) {          
       
    87         QTextCursor cursor = mEditorWidget->textCursor();
       
    88         cursor.setPosition(0);
       
    89         cursor.insertHtml(NmUtilities::createReplyHeader(originalMessage.envelope()));
       
    90     }
       
    91     // Take reply header as html format.
       
    92     bodyContent.append(mEditorWidget->toHtml());
       
    93     
    81     // Check which part is present. Html or plain text part. We use the original message parts.
    94     // Check which part is present. Html or plain text part. We use the original message parts.
    82     const NmMessagePart *htmlPart = originalMessage.htmlBodyPart();
    95     const NmMessagePart *htmlPart = originalMessage.htmlBodyPart();
    83 
       
    84     const NmMessagePart *plainPart = originalMessage.plainTextBodyPart();
    96     const NmMessagePart *plainPart = originalMessage.plainTextBodyPart();
    85 
    97  
    86     if (htmlPart) {
    98     if (htmlPart && mEditorWidget) {
    87         emit setHtml(htmlPart->textContent());    
    99         bodyContent.append(htmlPart->textContent());
       
   100         emit setHtml(bodyContent);
    88         mMessageBodyType = HTMLText;
   101         mMessageBodyType = HTMLText;
    89     }
   102     }
    90     else if (plainPart) {
   103     else if (plainPart) {
    91         // Plain text part was present, set it to HbTextEdit
   104         // Plain text part was present, set it to HbTextEdit
    92         emit setPlainText(plainPart->textContent());
   105         bodyContent.append(plainPart->textContent());
       
   106         emit setPlainText(bodyContent);
    93         mMessageBodyType = PlainText;
   107         mMessageBodyType = PlainText;
    94     }
       
    95     
       
    96     // We create the "reply" header (also for forward message)
       
    97     if (mEditorWidget) {          
       
    98         QTextCursor cursor = mEditorWidget->textCursor();
       
    99         cursor.setPosition(0);
       
   100         cursor.insertHtml(NmUtilities::createReplyHeader(originalMessage.envelope()));
       
   101     }
   108     }
   102 }  
   109 }  
   103 
   110 
   104 /*!
   111 /*!
   105    This method set new height for the editor content when header or body field
   112    This method set new height for the editor content when header or body field
   135     // Body edit widget is also interested about bg scroll position change
   142     // Body edit widget is also interested about bg scroll position change
   136     connect(mBackgroundScrollArea, SIGNAL(scrollPositionChanged(QPointF)),
   143     connect(mBackgroundScrollArea, SIGNAL(scrollPositionChanged(QPointF)),
   137             mEditorWidget, SLOT(updateScrollPosition(QPointF)));
   144             mEditorWidget, SLOT(updateScrollPosition(QPointF)));
   138     // Signal for setting HbTextEdit widgets html content
   145     // Signal for setting HbTextEdit widgets html content
   139     connect(this, SIGNAL(setHtml(QString)),
   146     connect(this, SIGNAL(setHtml(QString)),
   140             mEditorWidget, SLOT(setHtml(QString)));
   147             mEditorWidget, SLOT(setHtml(QString)), Qt::QueuedConnection);
   141     // Signal for setting HbTextEdit widgets plain text content
   148     // Signal for setting HbTextEdit widgets plain text content
   142     connect(this, SIGNAL(setPlainText(QString)),
   149     connect(this, SIGNAL(setPlainText(QString)),
   143             mEditorWidget, SLOT(setPlainText(QString)));
   150             mEditorWidget, SLOT(setPlainText(QString)), Qt::QueuedConnection);
   144     // Inform text edit widget that header height has been changed
   151     // Inform text edit widget that header height has been changed
   145     connect(mHeaderWidget, SIGNAL(headerHeightChanged(int)),
   152     connect(mHeaderWidget, SIGNAL(headerHeightChanged(int)),
   146             mEditorWidget, SLOT(setHeaderHeight(int)));
   153             mEditorWidget, SLOT(setHeaderHeight(int)));
   147 }
   154 }
   148 
   155