diff -r 64e38f08e49c -r 47d84de1c893 emailuis/nmailui/src/nmeditorcontent.cpp --- a/emailuis/nmailui/src/nmeditorcontent.cpp Fri Sep 17 08:27:21 2010 +0300 +++ b/emailuis/nmailui/src/nmeditorcontent.cpp Mon Oct 04 00:05:37 2010 +0300 @@ -125,10 +125,18 @@ } if (htmlPart) { - bodyContent.append(htmlPart->textContent()); + QString bodyText(htmlPart->textContent()); + if (editorStartMode==NmUiEditorReply || editorStartMode==NmUiEditorReplyAll || + editorStartMode==NmUiEditorForward) { + convertBodyStylesToDivision(bodyText); + } + if(editorStartMode==NmUiEditorReply || editorStartMode==NmUiEditorReplyAll ) { - removeEmbeddedImages(bodyContent); + removeEmbeddedImages(bodyText); } + + bodyContent.append(bodyText); + cursor.insertHtml(bodyContent); } else if (plainPart) { // Plain text part was present, set it to HbTextEdit as HTML @@ -273,43 +281,45 @@ void NmEditorContent::ensureCursorVisibility() { NM_FUNCTION; - - // check which of the editors has the focus and get the x/y coordinates for the cursor position - QGraphicsWidget *focused = mScrollAreaContents->focusWidget(); + + QGraphicsItem *focused = NULL; + QRectF localRect; // set to empty - if (focused) { - QRectF localRect(0, 0, 0, 0); - bool notFound = false; - - if (focused == mHeader->toEdit()) { - localRect = mHeader->toEdit()->rectForCursorPosition(); - } - else if (focused == mHeader->ccEdit()) { - localRect = mHeader->ccEdit()->rectForCursorPosition(); - } - else if (focused == mHeader->bccEdit()) { - localRect = mHeader->bccEdit()->rectForCursorPosition(); + // find out which widget has the input focus and get the cursor position ractangle + if (mHeader->toEdit() && mHeader->toEdit()->hasInputFocus()) { + focused = mHeader->toEdit(); + localRect = mHeader->toEdit()->rectForCursorPosition(); + } + else if (mHeader->ccEdit() && mHeader->ccEdit()->hasInputFocus()) { + focused = mHeader->ccEdit(); + localRect = mHeader->ccEdit()->rectForCursorPosition(); + } + else if (mHeader->bccEdit() && mHeader->bccEdit()->hasInputFocus()) { + focused = mHeader->bccEdit(); + localRect = mHeader->bccEdit()->rectForCursorPosition(); + } + else if (mHeader->subjectEdit() && mHeader->subjectEdit()->hasInputFocus()) { + focused = mHeader->subjectEdit(); + localRect = mHeader->subjectEdit()->rectForCursorPosition(); + } + else if (mEditorWidget->hasInputFocus()) { + focused = mEditorWidget; + localRect = mEditorWidget->rectForCursorPosition(); + } + + // ensure that the cursor position is visible + if (focused && !localRect.isEmpty()) { + QPointF topLeftPos = focused->mapToItem(mScrollAreaContents, localRect.topLeft()); + QPointF bottomRightPos = + focused->mapToItem(mScrollAreaContents, localRect.bottomRight()); + qreal marginRight = 0; + if (mScrollArea->style()) { + mScrollArea->style()->parameter("hb-param-margin-gene-right", marginRight); } - else if (focused == mHeader->subjectEdit()) { - localRect = mHeader->subjectEdit()->rectForCursorPosition(); - } - else if (focused == mEditorWidget) { - localRect = mEditorWidget->rectForCursorPosition(); - } - else { - notFound = true; - } + bottomRightPos.rx() += marginRight; - if (!notFound) { - QPointF topLeftPos = focused->mapToItem(mScrollAreaContents, localRect.topLeft()); - QPointF bottomRightPos = - focused->mapToItem(mScrollAreaContents, localRect.bottomRight()); - qreal marginRight = 0; - mScrollArea->style()->parameter("hb-param-margin-gene-right", marginRight); - bottomRightPos.rx() += marginRight; - mScrollArea->ensureVisible(topLeftPos); - mScrollArea->ensureVisible(bottomRightPos); - } + mScrollArea->ensureVisible(topLeftPos); + mScrollArea->ensureVisible(bottomRightPos); } } /*! @@ -359,3 +369,170 @@ mHeader->repositHeader(tr); } +/*! + Removes body bgcolor tag from content and creates DIV from it. + */ +void NmEditorContent::convertBodyStylesToDivision(QString &bodyContent) +{ + NM_FUNCTION; + convertBGColorToStyle(bodyContent); + + // Make division from the head style body tag + createDivisionFromHead(bodyContent); +} + +/*! + * Creates div.reply from the html header styles (if there is any) and applies this + * style to the message by surrounding the message with the div.reply element. + * + * Example: + * + * + * + *

This is bigger text.

+ * This is the body text. + * + * + * ----> + * + * + * + * + *
+ *

This is bigger text.

+ * This is the body text. + *
+ * + */ +void NmEditorContent::createDivisionFromHead(QString &bodyContent) +{ + NM_FUNCTION; + + // Regular expression string for searching part that contains