m_outputParserChain = parser;
if (m_outputParserChain) {
- connect(parser, SIGNAL(addOutput(QString)),
- this, SLOT(outputAdded(QString)));
+ connect(parser, SIGNAL(addOutput(QString, QTextCharFormat)),
+ this, SLOT(outputAdded(QString, QTextCharFormat)));
connect(parser, SIGNAL(addTask(ProjectExplorer::Task)),
this, SLOT(taskAdded(ProjectExplorer::Task)));
}
void AbstractProcessStep::processStarted()
{
- emit addOutput(tr("<font color=\"#0000ff\">Starting: \"%1\" %2</font>\n").arg(m_command, Qt::escape(m_arguments.join(" "))));
+ QTextCharFormat textCharFormat;
+ textCharFormat.setForeground(Qt::blue);
+ emit addOutput(tr("Starting: \"%1\" %2\n").arg(m_command, m_arguments.join(" ")), textCharFormat);
}
void AbstractProcessStep::processFinished(int exitCode, QProcess::ExitStatus status)
{
- if (status == QProcess::NormalExit && exitCode == 0)
- emit addOutput(tr("<font color=\"#0000ff\">The process \"%1\" exited normally.</font>").arg(m_command));
- else if (status == QProcess::NormalExit)
- emit addOutput(tr("<font color=\"#ff0000\"><b>The process \"%1\" exited with code %2.</b></font>").arg(m_command, m_process->exitCode()));
- else
- emit addOutput(tr("<font color=\"#ff0000\"><b>The process \"%1\" crashed.</b></font>").arg(m_command));
+ QTextCharFormat textCharFormat;
+ if (status == QProcess::NormalExit && exitCode == 0) {
+ textCharFormat.setForeground(Qt::blue);
+ emit addOutput(tr("The process \"%1\" exited normally.").arg(m_command), textCharFormat);
+ } else if (status == QProcess::NormalExit) {
+ textCharFormat.setForeground(Qt::red);
+ textCharFormat.setFontWeight(QFont::Bold);
+ emit addOutput(tr("The process \"%1\" exited with code %2.").arg(m_command, m_process->exitCode()), textCharFormat);
+ } else {
+ textCharFormat.setForeground(Qt::red);
+ textCharFormat.setFontWeight(QFont::Bold);
+ emit addOutput(tr("The process \"%1\" crashed.").arg(m_command), textCharFormat);
+ }
}
void AbstractProcessStep::processStartupFailed()
{
- emit addOutput(tr("<font color=\"#ff0000\"><b>Could not start process \"%1\"</b></font>").arg(m_command));
+ QTextCharFormat textCharFormat;
+ textCharFormat.setForeground(Qt::red);
+ textCharFormat.setFontWeight(QFont::Bold);
+ emit addOutput(tr("Could not start process \"%1\"").arg(m_command), textCharFormat);
}
bool AbstractProcessStep::processSucceeded(int exitCode, QProcess::ExitStatus status)
{
if (m_outputParserChain)
m_outputParserChain->stdOutput(line);
- emit addOutput(Qt::escape(line));
+ QTextCharFormat textCharFormat;
+ emit addOutput(Qt::escape(line), textCharFormat);
}
void AbstractProcessStep::processReadyReadStdError()
{
if (m_outputParserChain)
m_outputParserChain->stdError(line);
- emit addOutput(QLatin1String("<font color=\"#ff0000\">") + Qt::escape(line) + QLatin1String("</font>"));
+ QTextCharFormat textCharFormat;
+ textCharFormat.setForeground(Qt::red);
+ emit addOutput(line, textCharFormat);
}
void AbstractProcessStep::checkForCancel()
emit addTask(editable);
}
-void AbstractProcessStep::outputAdded(const QString &string)
+void AbstractProcessStep::outputAdded(const QString &string, const QTextCharFormat &textCharFormat)
{
- emit addOutput(string);
+ emit addOutput(string, textCharFormat);
}
void AbstractProcessStep::slotProcessFinished(int, QProcess::ExitStatus)
void checkForCancel();
void taskAdded(const ProjectExplorer::Task &task);
- void outputAdded(const QString &string);
+ void outputAdded(const QString &string, const QTextCharFormat &format);
private:
QTimer *m_timer;
QFutureInterface<bool> *m_futureInterface;
void BuildManager::emitCancelMessage()
{
- emit addToOutputWindow(tr("<font color=\"#ff0000\">Canceled build.</font>"));
+ QTextCharFormat textCharFormat;
+ textCharFormat.setForeground(Qt::red);
+ emit addToOutputWindow(tr("Canceled build."), textCharFormat);
}
void BuildManager::clearBuildQueue()
m_taskWindow->addTask(task);
}
-void BuildManager::addToOutputWindow(const QString &string)
+void BuildManager::addToOutputWindow(const QString &string, const QTextCharFormat &format)
{
- m_outputWindow->appendText(string);
+ m_outputWindow->appendText(string, format);
}
void BuildManager::nextBuildQueue()
disconnect(m_currentBuildStep, SIGNAL(addTask(ProjectExplorer::Task)),
this, SLOT(addToTaskWindow(ProjectExplorer::Task)));
- disconnect(m_currentBuildStep, SIGNAL(addOutput(QString)),
- this, SLOT(addToOutputWindow(QString)));
+ disconnect(m_currentBuildStep, SIGNAL(addOutput(QString, QTextCharFormat)),
+ this, SLOT(addToOutputWindow(QString, QTextCharFormat)));
++m_progress;
m_progressFutureInterface->setProgressValueAndText(m_progress*100, msgProgress(m_progress, m_maxProgress));
// Build Failure
const QString projectName = m_currentBuildStep->buildConfiguration()->target()->project()->displayName();
const QString targetName = m_currentBuildStep->buildConfiguration()->target()->displayName();
- addToOutputWindow(tr("<font color=\"#ff0000\">Error while building project %1 (target: %2)</font>").arg(projectName, targetName));
- addToOutputWindow(tr("<font color=\"#ff0000\">When executing build step '%1'</font>").arg(m_currentBuildStep->displayName()));
+ QTextCharFormat textCharFormat;
+ textCharFormat.setForeground(Qt::red);
+ addToOutputWindow(tr("Error while building project %1 (target: %2)").arg(projectName, targetName), textCharFormat);
+ addToOutputWindow(tr("When executing build step '%1'").arg(m_currentBuildStep->displayName()), textCharFormat);
// NBS TODO fix in qtconcurrent
m_progressFutureInterface->setProgressValueAndText(m_progress*100, tr("Error while building project %1 (target: %2)").arg(projectName, targetName));
}
if (m_currentBuildStep->buildConfiguration()->target()->project() != m_previousBuildStepProject) {
const QString projectName = m_currentBuildStep->buildConfiguration()->target()->project()->displayName();
- addToOutputWindow(tr("<b>Running build steps for project %2...</b>")
- .arg(projectName));
+ QTextCharFormat textCharFormat;
+ textCharFormat.setFontWeight(QFont::Bold);
+ addToOutputWindow(tr("Running build steps for project %2...")
+ .arg(projectName), textCharFormat);
m_previousBuildStepProject = m_currentBuildStep->buildConfiguration()->target()->project();
}
m_watcher.setFuture(QtConcurrent::run(&BuildStep::run, m_currentBuildStep));
BuildStep *bs = steps.at(i);
connect(bs, SIGNAL(addTask(ProjectExplorer::Task)),
this, SLOT(addToTaskWindow(ProjectExplorer::Task)));
- connect(bs, SIGNAL(addOutput(QString)),
- this, SLOT(addToOutputWindow(QString)));
+ connect(bs, SIGNAL(addOutput(QString, QTextCharFormat)),
+ this, SLOT(addToOutputWindow(QString, QTextCharFormat)));
init = bs->init();
if (!init)
break;
// print something for the user
const QString projectName = bs->buildConfiguration()->target()->project()->displayName();
const QString targetName = bs->buildConfiguration()->target()->displayName();
- addToOutputWindow(tr("<font color=\"#ff0000\">Error while building project %1 (target: %2)</font>").arg(projectName, targetName));
- addToOutputWindow(tr("<font color=\"#ff0000\">When executing build step '%1'</font>").arg(bs->displayName()));
+ QTextCharFormat textCharFormat;
+ textCharFormat.setForeground(Qt::red);
+ addToOutputWindow(tr("Error while building project %1 (target: %2)").arg(projectName, targetName), textCharFormat);
+ addToOutputWindow(tr("When executing build step '%1'").arg(bs->displayName()), textCharFormat);
// disconnect the buildsteps again
for (int j = 0; j <= i; ++j) {
BuildStep *bs = steps.at(j);
disconnect(bs, SIGNAL(addTask(ProjectExplorer::Task)),
this, SLOT(addToTaskWindow(ProjectExplorer::Task)));
- disconnect(bs, SIGNAL(addOutput(QString)),
- this, SLOT(addToOutputWindow(QString)));
+ disconnect(bs, SIGNAL(addOutput(QString, QTextCharFormat)),
+ this, SLOT(addToOutputWindow(QString, QTextCharFormat)));
}
return false;
}
private slots:
void addToTaskWindow(const ProjectExplorer::Task &task);
- void addToOutputWindow(const QString &string);
+ void addToOutputWindow(const QString &string, const QTextCharFormat &textCharFormat);
void nextBuildQueue();
void progressChanged();
void addTask(const ProjectExplorer::Task &task);
// The string is added to the generated output, usually in the output
// window.
- // It should be in html format, that is properly escaped
- void addOutput(const QString &string);
+ // It should be in plain text, with the format in the parameter
+ void addOutput(const QString &string, const QTextCharFormat &textCharFormat);
private:
BuildConfiguration *m_buildConfiguration;
Aggregation::Aggregate *agg = new Aggregation::Aggregate;
agg->add(m_textEdit);
agg->add(new Find::BaseTextFind(m_textEdit));
+
+ qRegisterMetaType<QTextCharFormat>("QTextCharFormat");
}
bool CompileOutputWindow::hasFocus()
return m_textEdit;
}
-void CompileOutputWindow::appendText(const QString &text)
+void CompileOutputWindow::appendText(const QString &text, const QTextCharFormat &textCharFormat)
{
- m_textEdit->appendHtml(text);
+ QString textWithNewline = text;
+ if (!textWithNewline.endsWith("\n"))
+ textWithNewline.append("\n");
+ QTextCursor cursor = QTextCursor(m_textEdit->document());
+ cursor.movePosition(QTextCursor::End);
+ cursor.beginEditBlock();
+ cursor.insertText(textWithNewline, textCharFormat);
+ cursor.endEditBlock();
}
void CompileOutputWindow::clearContents()
#define COMPILEOUTPUTWINDOW_H
#include <coreplugin/ioutputpane.h>
+#include <QtGui/QColor>
+#include <QtGui/QTextCharFormat>
QT_BEGIN_NAMESPACE
class QPlainTextEdit;
int priorityInStatusBar() const;
void clearContents();
void visibilityChanged(bool visible);
- void appendText(const QString &text);
+ void appendText(const QString &text, const QTextCharFormat &textCharFormat);
bool canFocus();
bool hasFocus();
void setFocus();
}
m_parser = parser;
- connect(parser, SIGNAL(addOutput(QString)),
- this, SLOT(outputAdded(QString)), Qt::DirectConnection);
+ connect(parser, SIGNAL(addOutput(QString, QTextCharFormat)),
+ this, SLOT(outputAdded(QString, QTextCharFormat)), Qt::DirectConnection);
connect(parser, SIGNAL(addTask(ProjectExplorer::Task)),
this, SLOT(taskAdded(ProjectExplorer::Task)), Qt::DirectConnection);
}
IOutputParser *IOutputParser::takeOutputParserChain()
{
IOutputParser *parser = m_parser;
- disconnect(parser, SIGNAL(addOutput(QString)),
- this, SLOT(outputAdded(QString)));
+ disconnect(parser, SIGNAL(addOutput(QString, QTextCharFormat)),
+ this, SLOT(outputAdded(QString, QTextCharFormat)));
disconnect(parser, SIGNAL(addTask(ProjectExplorer::Task)),
this, SLOT(taskAdded(ProjectExplorer::Task)));
m_parser = 0;
m_parser->stdError(line);
}
-void IOutputParser::outputAdded(const QString &string)
+void IOutputParser::outputAdded(const QString &string, const QTextCharFormat &textCharFormat)
{
- emit addOutput(string);
+ emit addOutput(string, textCharFormat);
}
void IOutputParser::taskAdded(const ProjectExplorer::Task &task)
/// added to the output.
/// Note: This is additional information. There is no need to add each
/// line!
- void addOutput(const QString &string);
+ void addOutput(const QString &string, const QTextCharFormat &format);
/// Should be emitted for each task seen in the output.
void addTask(const ProjectExplorer::Task &task);
public slots:
/// Subparsers have their addOutput signal connected to this slot.
/// This method can be overwritten to change the string.
- virtual void outputAdded(const QString &string);
+ virtual void outputAdded(const QString &string, const QTextCharFormat &color);
/// Subparsers have their addTask signal connected to this slot.
/// This method can be overwritten to change the task.
virtual void taskAdded(const ProjectExplorer::Task &task);
{
reset();
- childParser()->outputAdded(input);
+ QTextCharFormat textCharFormat;
+ childParser()->outputAdded(input, textCharFormat);
QCOMPARE(m_receivedOutput, output);
QVERIFY(m_receivedStdErrChildLine.isNull());
parser->appendOutputParser(this);
}
-void OutputParserTester::outputAdded(const QString &line)
+void OutputParserTester::outputAdded(const QString &line, const QTextCharFormat &textCharFormat)
{
if (!m_receivedOutput.isEmpty())
m_receivedOutput.append(QChar('\n'));
void appendOutputParser(IOutputParser *parser);
private slots:
- void outputAdded(const QString &line);
+ void outputAdded(const QString &line, const QTextCharFormat &textCharFormat);
void taskAdded(const ProjectExplorer::Task &task);
private:
// Try to detect command in environment
const QString tmp = environment.searchInPath(makeCmd);
if (tmp.isEmpty()) {
- emit addOutput(tr("<font color=\"#ff0000\">Could not find make command: %1 "\
- "in the build environment</font>").arg(makeCmd));
+ QTextCharFormat textCharFormat;
+ textCharFormat.setForeground(Qt::red);
+ emit addOutput(tr("Could not find make command: %1 in the build environment").arg(makeCmd), textCharFormat);
return false;
}
makeCmd = tmp;
canContinue = false;
}
if (!canContinue) {
- emit addOutput(tr("<font color=\"#0000ff\">Configuration is faulty, please check the Build Issues view for details.</font>"));
+ QTextCharFormat textCharFormat;
+ textCharFormat.setForeground(Qt::blue);
+ emit addOutput(tr("Configuration is faulty, please check the Build Issues view for details."), textCharFormat);
fi.reportResult(false);
return;
}
if (!m_needToRunQMake) {
- emit addOutput(tr("<font color=\"#0000ff\">Configuration unchanged, skipping qmake step.</font>"));
+ QTextCharFormat textCharFormat;
+ textCharFormat.setForeground(Qt::blue);
+ emit addOutput(tr("Configuration unchanged, skipping qmake step."), textCharFormat);
fi.reportResult(true);
return;
}
if (!packagingNeeded())
return true;
- emit addOutput(tr("Creating package file ..."));
+ QTextCharFormat textCharFormat;
+ emit addOutput(tr("Creating package file ..."), textCharFormat);
QFile configFile(targetRoot() % QLatin1String("/config.sh"));
if (!configFile.open(QIODevice::ReadOnly)) {
raiseError(tr("Cannot open MADDE config file '%1'.")
return false;
}
- emit addOutput(tr("Package created."));
+ emit addOutput(tr("Package created."), textCharFormat);
m_packageContents->setUnModified();
return true;
}
bool MaemoPackageCreationStep::runCommand(QProcess &proc, const QString &command)
{
- emit addOutput(tr("Package Creation: Running command '%1'.").arg(command));
+ QTextCharFormat textCharFormat;
+ emit addOutput(tr("Package Creation: Running command '%1'.").arg(command), textCharFormat);
QString perl;
#ifdef Q_OS_WIN
perl = maddeRoot() + QLatin1String("/bin/perl.exe ");
void MaemoPackageCreationStep::raiseError(const QString &shortMsg,
const QString &detailedMsg)
{
- emit addOutput(detailedMsg.isNull() ? shortMsg : detailedMsg);
+ QTextCharFormat textCharFormat;
+ emit addOutput(detailedMsg.isNull() ? shortMsg : detailedMsg, textCharFormat);
emit addTask(Task(Task::Error, shortMsg, QString(), -1,
TASK_CATEGORY_BUILDSYSTEM));
}