Skip to content

Commit

Permalink
One less conversion in the mail editor window #327
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulEU committed Mar 28, 2014
1 parent 6745ea3 commit 3a493e8
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Mail/maileditorwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <QMenu>
#include <QMessageBox>
#include <QMimeData>
#include <QTextDocumentFragment>
#include <QToolBar>
#include <QToolButton>

Expand Down Expand Up @@ -49,9 +48,11 @@ class TDocumentTransform
const TPhysicalMailMessage& srcMsg, QTextDocument* doc);

private:
/// Replace from plain text
QTextCursor replace(const char* textToFind, const QString& replacement,
const QTextCursor& startPos = QTextCursor());
QTextCursor replace(const char* textToFind, const QTextDocumentFragment& replacement,
/// Replace from html text
QTextCursor replaceHtml(const char* textToFind, const QString& replacementHtml,
const QTextCursor& startPos = QTextCursor());
/// Allows to remove whole line containing given text.
void removeContainingLine(const char* textToFind, const QTextCursor& startPos = QTextCursor());
Expand Down Expand Up @@ -122,8 +123,7 @@ TDocumentTransform::Do(TLoadForm loadForm, const TStoredMailMessage& msgHeader,

replace("$$SUBJECT$$", newSubject);

QTextDocumentFragment tf(QTextDocumentFragment::fromHtml(QString(srcMsg.body.c_str())));
replace("$$SOURCE_BODY$$", tf);
replaceHtml("$$SOURCE_BODY$$", srcMsg.body.c_str());

return newSubject;
}
Expand Down Expand Up @@ -152,8 +152,7 @@ QTextCursor TDocumentTransform::replace(const char* textToFind, const QString& r
}

inline
QTextCursor
TDocumentTransform::replace(const char* textToFind, const QTextDocumentFragment& replacement,
QTextCursor TDocumentTransform::replaceHtml(const char* textToFind, const QString& replacementHtml,
const QTextCursor& startPos /*= QTextCursor()*/)
{
QTextCursor foundPos = find(textToFind, startPos);
Expand All @@ -162,7 +161,7 @@ TDocumentTransform::replace(const char* textToFind, const QTextDocumentFragment&
{
foundPos.beginEditBlock();
foundPos.removeSelectedText();
foundPos.insertFragment(replacement);
foundPos.insertHtml(replacementHtml);
foundPos.endEditBlock();
}

Expand Down

0 comments on commit 3a493e8

Please sign in to comment.