diff --git a/src/plugins/projectexplorer/linuxiccparser.cpp b/src/plugins/projectexplorer/linuxiccparser.cpp index cb45e8a844aadfaeb381282f7acb8d87df57a16d..1957b2ffb7d389545edb7d2f2ff8f0bb486d35df 100644 --- a/src/plugins/projectexplorer/linuxiccparser.cpp +++ b/src/plugins/projectexplorer/linuxiccparser.cpp @@ -36,7 +36,7 @@ using namespace ProjectExplorer; LinuxIccParser::LinuxIccParser() - : m_expectFirstLine(true) + : m_expectFirstLine(true), m_indent(0) { // main.cpp(53): error #308: function \"AClass::privatefunc\" (declared at line 4 of \"main.h\") is inaccessible @@ -78,12 +78,26 @@ void LinuxIccParser::stdError(const QString &line) m_expectFirstLine = false; } else if (!m_expectFirstLine && m_caretLine.indexIn(line) != -1) { - // TODO do something + // Format the last line as code + QTextLayout::FormatRange fr; + fr.start = m_temporary.description.lastIndexOf('\n') + 1; + fr.length = m_temporary.description.length() - fr.start; + fr.format.setFontItalic(true); + m_temporary.formats.append(fr); + + QTextLayout::FormatRange fr2; + fr2.start = fr.start + line.indexOf('^') - m_indent; + fr2.length = 1; + fr2.format.setFontWeight(QFont::Bold); + m_temporary.formats.append(fr2); } else if (!m_expectFirstLine && line.trimmed().isEmpty()) { // last Line m_expectFirstLine = true; emit addTask(m_temporary); } else if (!m_expectFirstLine && m_continuationLines.indexIn(line) != -1) { m_temporary.description.append("\n"); + m_indent = 0; + while (m_indent < line.length() && line.at(m_indent).isSpace()) + m_indent++; m_temporary.description.append(m_continuationLines.cap(1).trimmed()); } else { IOutputParser::stdError(line); diff --git a/src/plugins/projectexplorer/linuxiccparser.h b/src/plugins/projectexplorer/linuxiccparser.h index 0c4b472ff4dbe72b08650c623cdeedd680b44b6c..b557a4ae12c3acfd805ff238aab985378e1592b3 100644 --- a/src/plugins/projectexplorer/linuxiccparser.h +++ b/src/plugins/projectexplorer/linuxiccparser.h @@ -50,6 +50,7 @@ private: QRegExp m_caretLine; bool m_expectFirstLine; + int m_indent; ProjectExplorer::Task m_temporary; }; diff --git a/src/plugins/projectexplorer/taskwindow.cpp b/src/plugins/projectexplorer/taskwindow.cpp index 5b7d700e6278a8292442e3485af73fda296ae167..a26b27376f2e287e9e1657f5b7cb8c49415ab6cf 100644 --- a/src/plugins/projectexplorer/taskwindow.cpp +++ b/src/plugins/projectexplorer/taskwindow.cpp @@ -122,7 +122,7 @@ public: int sizeOfLineNumber(); void setFileNotFound(const QModelIndex &index, bool b); - enum Roles { File = Qt::UserRole, Line, Description, FileNotFound, Type, Category }; + enum Roles { File = Qt::UserRole, Line, Description, FileNotFound, Type, Category, Task_t }; QIcon iconFor(Task::TaskType type); @@ -337,6 +337,8 @@ QVariant TaskModel::data(const QModelIndex &index, int role) const return (int)m_tasks.at(index.row()).type; } else if (role == TaskModel::Category) { return m_tasks.at(index.row()).category; + } else if (role == TaskModel::Task_t) { + return QVariant::fromValue(m_tasks.at(index.row())); } return QVariant(); } @@ -879,6 +881,7 @@ void TaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, int height = 0; description.replace('\n', QChar::LineSeparator); QTextLayout tl(description); + tl.setAdditionalFormats(index.data(TaskModel::Task_t).value<ProjectExplorer::Task>().formats); tl.beginLayout(); while (true) { QTextLine line = tl.createLine(); diff --git a/src/plugins/projectexplorer/taskwindow.h b/src/plugins/projectexplorer/taskwindow.h index 6ad39204b0255490c42c76c42f303983131a923b..2eca65e3cf7892bd4afb03b241ee1ace7bda54d3 100644 --- a/src/plugins/projectexplorer/taskwindow.h +++ b/src/plugins/projectexplorer/taskwindow.h @@ -38,6 +38,7 @@ #include <QtCore/QModelIndex> #include <QtGui/QAction> #include <QtGui/QToolButton> +#include <QtGui/QTextLayout> namespace ProjectExplorer { @@ -65,7 +66,7 @@ struct PROJECTEXPLORER_EXPORT Task { { } Task(const Task &source) : type(source.type), description(source.description), file(source.file), - line(source.line), category(source.category) + line(source.line), category(source.category), formats(source.formats) { } ~Task() { } @@ -75,6 +76,16 @@ struct PROJECTEXPLORER_EXPORT Task { QString file; int line; QString category; + // Having a QList<QTextLayout> in Task + // isn't that great + // It would be cleaner to split up the text into + // the logical hunks and then assemble them again + // (That is diffrent consumers of tasks could show them in + // different ways!) + // But then again, the wording of the text most likely + // doesn't work if you split it up, nor are our parsers + // anywhere near being that good + QList<QTextLayout::FormatRange> formats; }; class PROJECTEXPLORER_EXPORT TaskWindow : public Core::IOutputPane