2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-04-26 03:53:02 +00:00
|
|
|
* \file QLog.cpp
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author John Levon
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "QLog.h"
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
2007-03-26 04:25:49 +00:00
|
|
|
#include "frontends/Application.h"
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "controllers/ControlLog.h"
|
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
|
2006-05-04 07:31:46 +00:00
|
|
|
#include <QTextBrowser>
|
|
|
|
#include <QPushButton>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-04-24 19:37:34 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// QLogDialog
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-04-24 19:37:34 +00:00
|
|
|
|
|
|
|
QLogDialog::QLogDialog(QLog * form)
|
|
|
|
: form_(form)
|
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
connect(closePB, SIGNAL(clicked()),
|
|
|
|
form, SLOT(slotClose()));
|
|
|
|
connect( updatePB, SIGNAL( clicked() ),
|
|
|
|
this, SLOT( updateClicked() ) );
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
2007-04-24 19:37:34 +00:00
|
|
|
void QLogDialog::closeEvent(QCloseEvent * e)
|
|
|
|
{
|
|
|
|
form_->slotWMHide();
|
|
|
|
e->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QLogDialog::updateClicked()
|
|
|
|
{
|
|
|
|
form_->update_contents();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// LogHighlighter
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
LogHighlighter::LogHighlighter(QTextDocument * parent)
|
|
|
|
: QSyntaxHighlighter(parent)
|
2007-03-26 04:25:49 +00:00
|
|
|
{
|
2007-03-28 00:26:04 +00:00
|
|
|
infoFormat.setForeground(Qt::darkGray);
|
2007-03-26 04:25:49 +00:00
|
|
|
warningFormat.setForeground(Qt::darkBlue);
|
|
|
|
errorFormat.setForeground(Qt::red);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-24 19:37:34 +00:00
|
|
|
void LogHighlighter::highlightBlock(QString const & text)
|
2007-03-26 04:25:49 +00:00
|
|
|
{
|
|
|
|
// Info
|
|
|
|
QRegExp exprInfo("^(Document Class:|LaTeX Font Info:|File:|Package:|Language:|Underfull|Overfull|\\(|\\\\).*$");
|
|
|
|
int index = text.indexOf(exprInfo);
|
|
|
|
while (index >= 0) {
|
|
|
|
int length = exprInfo.matchedLength();
|
|
|
|
setFormat(index, length, infoFormat);
|
|
|
|
index = text.indexOf(exprInfo, index + length);
|
|
|
|
}
|
|
|
|
// LaTeX Warning:
|
|
|
|
QRegExp exprWarning("^LaTeX Warning.*$");
|
|
|
|
index = text.indexOf(exprWarning);
|
|
|
|
while (index >= 0) {
|
|
|
|
int length = exprWarning.matchedLength();
|
|
|
|
setFormat(index, length, warningFormat);
|
|
|
|
index = text.indexOf(exprWarning, index + length);
|
|
|
|
}
|
|
|
|
// ! error
|
|
|
|
QRegExp exprError("^!.*$");
|
|
|
|
index = text.indexOf(exprError);
|
|
|
|
while (index >= 0) {
|
|
|
|
int length = exprError.matchedLength();
|
|
|
|
setFormat(index, length, errorFormat);
|
|
|
|
index = text.indexOf(exprError, index + length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-24 19:37:34 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// QLog
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
typedef QController<ControlLog, QView<QLogDialog> > LogBase;
|
|
|
|
|
|
|
|
QLog::QLog(Dialog & parent)
|
2007-04-25 16:39:21 +00:00
|
|
|
: LogBase(parent, docstring())
|
2007-04-24 19:37:34 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
void QLog::build_dialog()
|
|
|
|
{
|
|
|
|
dialog_.reset(new QLogDialog(this));
|
2007-03-26 04:25:49 +00:00
|
|
|
// set syntax highlighting
|
2007-04-24 19:37:34 +00:00
|
|
|
highlighter = new LogHighlighter(dialog_->logTB->document());
|
2007-03-26 04:25:49 +00:00
|
|
|
//
|
|
|
|
dialog_->logTB->setReadOnly(true);
|
|
|
|
QFont font(toqstr(theApp()->typewriterFontName()));
|
|
|
|
font.setKerning(false);
|
|
|
|
font.setFixedPitch(true);
|
|
|
|
font.setStyleHint(QFont::TypeWriter);
|
|
|
|
dialog_->logTB->setFont(font);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QLog::update_contents()
|
|
|
|
{
|
|
|
|
setTitle(controller().title());
|
|
|
|
|
|
|
|
std::ostringstream ss;
|
|
|
|
controller().getContents(ss);
|
|
|
|
|
2006-05-04 07:31:46 +00:00
|
|
|
dialog_->logTB->setPlainText(toqstr(ss.str()));
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2007-03-26 04:25:49 +00:00
|
|
|
|
|
|
|
#include "QLog_moc.cpp"
|