display panel with number or warnings and lines in output window, button for jumping to next warning

This commit is contained in:
Axel Kohlmeyer
2024-12-28 18:44:27 -05:00
parent f50b5d63f3
commit 73eeda3b1d
10 changed files with 82 additions and 7 deletions

View File

@ -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: