Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
f48de4f5
Commit
f48de4f5
authored
Jan 07, 2011
by
hjk
Browse files
projectexplorer: refactor OutputFormatter interface
parent
01d4c5a3
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/plugins/projectexplorer/outputformatter.cpp
View file @
f48de4f5
...
...
@@ -53,8 +53,7 @@ OutputFormatter::OutputFormatter()
OutputFormatter
::~
OutputFormatter
()
{
if
(
m_formats
)
delete
[]
m_formats
;
delete
[]
m_formats
;
}
QPlainTextEdit
*
OutputFormatter
::
plainTextEdit
()
const
...
...
@@ -68,21 +67,14 @@ void OutputFormatter::setPlainTextEdit(QPlainTextEdit *plainText)
initFormats
();
}
void
OutputFormatter
::
append
ApplicationOutput
(
const
QString
&
text
,
bool
onStdErr
)
void
OutputFormatter
::
append
Message
(
const
QString
&
text
,
OutputFormat
format
)
{
QTextCursor
cursor
(
m_plainTextEdit
->
document
());
cursor
.
movePosition
(
QTextCursor
::
End
);
cursor
.
insertText
(
text
,
format
(
onStdErr
?
StdErrFormat
:
StdOutFormat
)
);
cursor
.
insertText
(
text
,
m_
format
s
[
format
]
);
}
void
OutputFormatter
::
appendMessage
(
const
QString
&
text
,
bool
isError
)
{
QTextCursor
cursor
(
m_plainTextEdit
->
document
());
cursor
.
movePosition
(
QTextCursor
::
End
);
cursor
.
insertText
(
text
,
format
(
isError
?
ErrorMessageFormat
:
NormalMessageFormat
));
}
QTextCharFormat
OutputFormatter
::
format
(
Format
format
)
QTextCharFormat
OutputFormatter
::
format
(
OutputFormat
format
)
const
{
return
m_formats
[
format
];
}
...
...
src/plugins/projectexplorer/outputformatter.h
View file @
f48de4f5
...
...
@@ -45,6 +45,15 @@ QT_FORWARD_DECLARE_CLASS(QColor)
namespace
ProjectExplorer
{
enum
OutputFormat
{
NormalMessageFormat
,
ErrorMessageFormat
,
StdOutFormat
,
StdErrFormat
,
NumberOfFormats
// Keep this entry last.
};
class
PROJECTEXPLORER_EXPORT
OutputFormatter
:
public
QObject
{
Q_OBJECT
...
...
@@ -56,24 +65,13 @@ public:
QPlainTextEdit
*
plainTextEdit
()
const
;
void
setPlainTextEdit
(
QPlainTextEdit
*
plainText
);
virtual
void
appendApplicationOutput
(
const
QString
&
text
,
bool
onStdErr
);
virtual
void
appendMessage
(
const
QString
&
text
,
bool
isError
);
virtual
void
appendMessage
(
const
QString
&
text
,
OutputFormat
format
);
virtual
void
handleLink
(
const
QString
&
href
);
protected:
enum
Format
{
NormalMessageFormat
=
0
,
ErrorMessageFormat
=
1
,
StdOutFormat
=
2
,
StdErrFormat
=
3
,
NumberOfFormats
=
4
};
void
initFormats
();
void
clearLastLine
();
QTextCharFormat
format
(
Format
format
);
QTextCharFormat
format
(
Output
Format
format
)
const
;
static
QColor
mixColors
(
const
QColor
&
a
,
const
QColor
&
b
);
...
...
src/plugins/projectexplorer/outputwindow.cpp
View file @
f48de4f5
...
...
@@ -631,7 +631,7 @@ void OutputWindow::appendApplicationOutput(const QString &output, bool onStdErr)
out
.
remove
(
QLatin1Char
(
'\r'
));
setMaximumBlockCount
(
MaxBlockCount
);
const
bool
atBottom
=
isScrollbarAtBottom
();
m_formatter
->
append
ApplicationOutput
(
doNewlineEnfocement
(
out
),
onStdErr
);
m_formatter
->
append
Message
(
doNewlineEnfocement
(
out
),
onStdErr
?
StdErrFormat
:
StdOutFormat
);
if
(
atBottom
)
scrollToBottom
();
enableUndoRedo
();
...
...
@@ -653,7 +653,7 @@ void OutputWindow::appendApplicationOutputInline(const QString &output, bool onS
newline
=
out
.
indexOf
(
QLatin1Char
(
'\n'
));
moveCursor
(
QTextCursor
::
End
);
if
(
newline
!=
-
1
)
m_formatter
->
append
ApplicationOutput
(
out
.
left
(
newline
),
onStdErr
);
// doesn't enforce new paragraph like appendPlainText
m_formatter
->
append
Message
(
out
.
left
(
newline
),
onStdErr
?
StdErrFormat
:
StdOutFormat
);
// doesn't enforce new paragraph like appendPlainText
}
QString
s
=
out
.
mid
(
newline
+
1
);
...
...
@@ -664,7 +664,7 @@ void OutputWindow::appendApplicationOutputInline(const QString &output, bool onS
m_enforceNewline
=
true
;
s
.
chop
(
1
);
}
m_formatter
->
append
ApplicationOutput
(
QLatin1Char
(
'\n'
)
+
s
,
onStdErr
);
m_formatter
->
append
Message
(
QLatin1Char
(
'\n'
)
+
s
,
onStdErr
?
StdErrFormat
:
StdOutFormat
);
}
if
(
atBottom
)
...
...
@@ -678,7 +678,7 @@ void OutputWindow::appendMessage(const QString &output, bool isError)
out
.
remove
(
QLatin1Char
(
'\r'
));
setMaximumBlockCount
(
MaxBlockCount
);
const
bool
atBottom
=
isScrollbarAtBottom
();
m_formatter
->
appendMessage
(
doNewlineEnfocement
(
out
),
isError
);
m_formatter
->
appendMessage
(
doNewlineEnfocement
(
out
),
isError
?
ErrorMessageFormat
:
NormalMessageFormat
);
if
(
atBottom
)
scrollToBottom
();
enableUndoRedo
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment