Utils: Remove unneeded double indirection in OutputFormatter

Change-Id: I1af77688172d139cca105ac20086a3b7c5f32df6
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
hjk
2015-02-25 13:31:40 +01:00
committed by Orgad Shaneh
parent 4413096cae
commit 1b71e8a53d

View File

@@ -43,24 +43,14 @@ class OutputFormatterPrivate
{ {
public: public:
OutputFormatterPrivate() OutputFormatterPrivate()
: plainTextEdit(0) : plainTextEdit(0), overwriteOutput(false)
, formats(0) {}
, escapeCodeHandler(new AnsiEscapeCodeHandler)
, overwriteOutput(false)
{
}
~OutputFormatterPrivate()
{
delete[] formats;
delete escapeCodeHandler;
}
QPlainTextEdit *plainTextEdit; QPlainTextEdit *plainTextEdit;
QTextCharFormat *formats; QTextCharFormat formats[NumberOfFormats];
QFont font; QFont font;
QTextCursor cursor; QTextCursor cursor;
AnsiEscapeCodeHandler *escapeCodeHandler; AnsiEscapeCodeHandler escapeCodeHandler;
bool overwriteOutput; bool overwriteOutput;
}; };
@@ -118,7 +108,7 @@ QTextCharFormat OutputFormatter::charFormat(OutputFormat format) const
QList<FormattedText> OutputFormatter::parseAnsi(const QString &text, const QTextCharFormat &format) QList<FormattedText> OutputFormatter::parseAnsi(const QString &text, const QTextCharFormat &format)
{ {
return d->escapeCodeHandler->parseText(FormattedText(text, format)); return d->escapeCodeHandler.parseText(FormattedText(text, format));
} }
void OutputFormatter::append(QTextCursor &cursor, const QString &text, void OutputFormatter::append(QTextCursor &cursor, const QString &text,
@@ -148,8 +138,6 @@ void OutputFormatter::initFormats()
QFont boldFont = d->font; QFont boldFont = d->font;
boldFont.setBold(true); boldFont.setBold(true);
d->formats = new QTextCharFormat[NumberOfFormats];
Theme *theme = creatorTheme(); Theme *theme = creatorTheme();
// NormalMessageFormat // NormalMessageFormat
@@ -192,7 +180,7 @@ void OutputFormatter::setFont(const QFont &font)
void OutputFormatter::flush() void OutputFormatter::flush()
{ {
d->escapeCodeHandler->endFormatScope(); d->escapeCodeHandler.endFormatScope();
} }
} // namespace Utils } // namespace Utils