3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
14 #include "QLogDialog.h"
15 #include "qt_helpers.h"
17 #include "frontends/Application.h"
19 #include "controllers/ControlLog.h"
23 #include <QTextBrowser>
24 #include <QPushButton>
29 typedef QController<ControlLog, QView<QLogDialog> > log_base_class;
31 QLog::QLog(Dialog & parent)
32 : log_base_class(parent, lyx::docstring())
36 logHighlighter::logHighlighter(QTextDocument * parent) :
37 QSyntaxHighlighter(parent)
39 infoFormat.setForeground(Qt::darkGray);
40 warningFormat.setForeground(Qt::darkBlue);
41 errorFormat.setForeground(Qt::red);
45 void logHighlighter::highlightBlock(QString const & text)
48 QRegExp exprInfo("^(Document Class:|LaTeX Font Info:|File:|Package:|Language:|Underfull|Overfull|\\(|\\\\).*$");
49 int index = text.indexOf(exprInfo);
51 int length = exprInfo.matchedLength();
52 setFormat(index, length, infoFormat);
53 index = text.indexOf(exprInfo, index + length);
56 QRegExp exprWarning("^LaTeX Warning.*$");
57 index = text.indexOf(exprWarning);
59 int length = exprWarning.matchedLength();
60 setFormat(index, length, warningFormat);
61 index = text.indexOf(exprWarning, index + length);
64 QRegExp exprError("^!.*$");
65 index = text.indexOf(exprError);
67 int length = exprError.matchedLength();
68 setFormat(index, length, errorFormat);
69 index = text.indexOf(exprError, index + length);
74 void QLog::build_dialog()
76 dialog_.reset(new QLogDialog(this));
77 // set syntax highlighting
78 highlighter = new logHighlighter(dialog_->logTB->document());
80 dialog_->logTB->setReadOnly(true);
81 QFont font(toqstr(theApp()->typewriterFontName()));
82 font.setKerning(false);
83 font.setFixedPitch(true);
84 font.setStyleHint(QFont::TypeWriter);
85 dialog_->logTB->setFont(font);
89 void QLog::update_contents()
91 setTitle(controller().title());
93 std::ostringstream ss;
94 controller().getContents(ss);
96 dialog_->logTB->setPlainText(toqstr(ss.str()));
99 } // namespace frontend
102 #include "QLog_moc.cpp"