display panel with number or warnings and lines in output window, button for jumping to next warning
This commit is contained in:
@ -17,17 +17,22 @@
|
||||
|
||||
#include <QColor>
|
||||
#include <QFont>
|
||||
#include <QLabel>
|
||||
#include <QTextDocument>
|
||||
|
||||
// workaround for Qt-5.12
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||
namespace QColorConstants {
|
||||
const QColor Red = QColor::fromRgb(0xff, 0x00, 0x00);
|
||||
const QColor Red = QColor::fromRgb(0xff, 0x00, 0x00);
|
||||
} // namespace QColorConstants
|
||||
#endif
|
||||
|
||||
FlagWarnings::FlagWarnings(QTextDocument *parent) :
|
||||
QSyntaxHighlighter(parent), isWarning(QStringLiteral("^(ERROR|WARNING).*$"))
|
||||
FlagWarnings::FlagWarnings(QLabel *label, QTextDocument *parent) :
|
||||
QSyntaxHighlighter(parent), isWarning(QStringLiteral("^(ERROR|WARNING).*$")), summary(label),
|
||||
document(parent)
|
||||
{
|
||||
nwarnings = nlines = 0;
|
||||
|
||||
formatWarning.setForeground(QColorConstants::Red);
|
||||
formatWarning.setFontWeight(QFont::Bold);
|
||||
}
|
||||
@ -39,6 +44,16 @@ void FlagWarnings::highlightBlock(const QString &text)
|
||||
|
||||
auto match = isWarning.match(text);
|
||||
if (match.hasMatch()) {
|
||||
++nwarnings;
|
||||
setFormat(match.capturedStart(0), match.capturedLength(0), formatWarning);
|
||||
}
|
||||
if (document && summary) {
|
||||
summary->setText(
|
||||
QString("%1 Warnings / Errors - %2 Lines").arg(nwarnings).arg(document->lineCount()));
|
||||
summary->repaint();
|
||||
}
|
||||
}
|
||||
|
||||
// Local Variables:
|
||||
// c-basic-offset: 4
|
||||
// End:
|
||||
|
||||
Reference in New Issue
Block a user