2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
* \file GuiErrorList.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 Alfredo Braunstein
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiErrorList.h"
|
2007-10-06 14:13:25 +00:00
|
|
|
|
2010-03-12 15:06:13 +00:00
|
|
|
#include "GuiView.h"
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
2007-10-06 14:13:25 +00:00
|
|
|
#include "Buffer.h"
|
|
|
|
#include "BufferView.h"
|
2009-11-14 15:52:54 +00:00
|
|
|
#include "FuncRequest.h"
|
2015-03-31 22:54:49 +00:00
|
|
|
#include "FuncStatus.h"
|
2010-03-12 15:06:13 +00:00
|
|
|
#include "BufferList.h"
|
2015-03-31 22:54:49 +00:00
|
|
|
#include "LyX.h"
|
2007-10-06 14:13:25 +00:00
|
|
|
#include "ParIterator.h"
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "Text.h"
|
2016-10-09 19:34:12 +00:00
|
|
|
#include "TexRow.h"
|
2007-09-05 20:33:29 +00:00
|
|
|
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "support/debug.h"
|
|
|
|
#include "support/gettext.h"
|
2007-10-06 14:13:25 +00:00
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
2006-05-03 19:51:15 +00:00
|
|
|
#include <QListWidget>
|
|
|
|
#include <QPushButton>
|
2008-02-18 09:55:14 +00:00
|
|
|
#include <QShowEvent>
|
|
|
|
#include <QTextBrowser>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2007-12-12 18:57:56 +00:00
|
|
|
using namespace lyx::support;
|
2007-09-05 20:33:29 +00:00
|
|
|
|
2010-03-12 13:47:28 +00:00
|
|
|
namespace {
|
|
|
|
|
2014-07-05 17:13:10 +00:00
|
|
|
string const guiErrorType(string const & s)
|
2010-03-12 13:47:28 +00:00
|
|
|
{
|
|
|
|
if (s == "docbook")
|
|
|
|
return N_("DocBook");
|
|
|
|
else if (s == "literate")
|
|
|
|
return N_("Literate");
|
2016-07-11 09:18:55 +00:00
|
|
|
else if (s == "latex")
|
|
|
|
// This covers all LaTeX variants
|
|
|
|
// (LaTeX, PDFLaTeX, XeTeX, LuaTeX, pLaTeX)
|
2010-03-12 13:47:28 +00:00
|
|
|
return N_("LaTeX");
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2017-07-23 11:11:54 +00:00
|
|
|
} // namespace
|
2010-03-12 13:47:28 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
GuiErrorList::GuiErrorList(GuiView & lv)
|
2017-03-08 15:41:42 +00:00
|
|
|
: GuiDialog(lv, "errorlist", qt_("Error List")), buf_(0), from_master_(false)
|
2007-04-25 10:25:37 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
2007-09-05 20:33:29 +00:00
|
|
|
|
2007-04-25 10:25:37 +00:00
|
|
|
connect(closePB, SIGNAL(clicked()),
|
2007-09-05 20:33:29 +00:00
|
|
|
this, SLOT(slotClose()));
|
2009-11-14 15:52:54 +00:00
|
|
|
connect(viewLogPB, SIGNAL(clicked()),
|
|
|
|
this, SLOT(viewLog()));
|
2015-03-31 22:54:49 +00:00
|
|
|
connect(showAnywayPB, SIGNAL(clicked()),
|
|
|
|
this, SLOT(showAnyway()));
|
2008-09-25 16:16:25 +00:00
|
|
|
connect(errorsLW, SIGNAL(currentRowChanged(int)),
|
2008-05-29 12:37:22 +00:00
|
|
|
this, SLOT(select()));
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
bc().setPolicy(ButtonPolicy::OkCancelPolicy);
|
|
|
|
bc().setCancel(closePB);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-06 14:13:25 +00:00
|
|
|
void GuiErrorList::showEvent(QShowEvent * e)
|
2007-04-25 10:25:37 +00:00
|
|
|
{
|
2008-05-29 12:37:22 +00:00
|
|
|
select();
|
2009-11-28 00:52:08 +00:00
|
|
|
paramsToDialog();
|
2007-04-25 10:25:37 +00:00
|
|
|
e->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-29 12:37:22 +00:00
|
|
|
void GuiErrorList::select()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2008-05-29 12:37:22 +00:00
|
|
|
int const item = errorsLW->row(errorsLW->currentItem());
|
2008-07-20 17:05:58 +00:00
|
|
|
if (item == -1)
|
|
|
|
return;
|
|
|
|
goTo(item);
|
|
|
|
descriptionTB->setPlainText(
|
|
|
|
toqstr(errorList()[item].description));
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-14 15:52:54 +00:00
|
|
|
void GuiErrorList::viewLog()
|
|
|
|
{
|
2010-03-12 15:06:13 +00:00
|
|
|
if (&buffer() != buf_) {
|
|
|
|
if (!theBufferList().isLoaded(buf_))
|
|
|
|
return;
|
|
|
|
FuncRequest fr(LFUN_BUFFER_SWITCH, buf_->absFileName());
|
|
|
|
dispatch(fr);
|
|
|
|
}
|
2009-11-14 15:52:54 +00:00
|
|
|
dispatch(FuncRequest(LFUN_DIALOG_SHOW, "latexlog"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-31 22:54:49 +00:00
|
|
|
void GuiErrorList::showAnyway()
|
|
|
|
{
|
|
|
|
dispatch(FuncRequest(LFUN_BUFFER_VIEW_CACHE));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-28 00:52:08 +00:00
|
|
|
void GuiErrorList::paramsToDialog()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2008-02-05 12:43:19 +00:00
|
|
|
setTitle(toqstr(name_));
|
2007-09-05 20:33:29 +00:00
|
|
|
errorsLW->clear();
|
|
|
|
descriptionTB->setPlainText(QString());
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2010-03-13 11:39:50 +00:00
|
|
|
ErrorList const & el = errorList();
|
|
|
|
ErrorList::const_iterator it = el.begin();
|
2010-03-13 16:55:59 +00:00
|
|
|
ErrorList::const_iterator const en = el.end();
|
|
|
|
for (; it != en; ++it)
|
2007-09-05 20:33:29 +00:00
|
|
|
errorsLW->addItem(toqstr(it->error));
|
2008-10-21 09:07:15 +00:00
|
|
|
errorsLW->setCurrentRow(0);
|
2015-04-05 08:50:30 +00:00
|
|
|
showAnywayPB->setEnabled(
|
|
|
|
lyx::getStatus(FuncRequest(LFUN_BUFFER_VIEW_CACHE)).enabled());
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
2007-10-06 14:13:25 +00:00
|
|
|
|
|
|
|
ErrorList const & GuiErrorList::errorList() const
|
|
|
|
{
|
2011-03-03 13:57:46 +00:00
|
|
|
Buffer const * buffer = from_master_
|
|
|
|
? bufferview()->buffer().masterBuffer()
|
|
|
|
: &bufferview()->buffer();
|
|
|
|
if (buffer == buf_)
|
|
|
|
error_list_ = buffer->errorList(error_type_);
|
|
|
|
|
2010-03-12 15:06:13 +00:00
|
|
|
return error_list_;
|
2007-10-06 14:13:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-24 06:01:34 +00:00
|
|
|
bool GuiErrorList::initialiseParams(string const & sdata)
|
2007-10-06 14:13:25 +00:00
|
|
|
{
|
2018-02-24 06:01:34 +00:00
|
|
|
from_master_ = prefixIs(sdata, "from_master|");
|
|
|
|
string error_type = sdata;
|
2009-06-21 12:26:41 +00:00
|
|
|
if (from_master_)
|
2018-02-24 06:01:34 +00:00
|
|
|
error_type = split(sdata, '|');
|
2007-10-06 14:13:25 +00:00
|
|
|
error_type_ = error_type;
|
2010-03-12 15:06:13 +00:00
|
|
|
buf_ = from_master_ ?
|
2009-06-21 12:26:41 +00:00
|
|
|
bufferview()->buffer().masterBuffer()
|
|
|
|
: &bufferview()->buffer();
|
2017-07-03 17:53:14 +00:00
|
|
|
name_ = bformat(_("%1$s Errors (%2$s)"),
|
2010-03-12 13:47:28 +00:00
|
|
|
_(guiErrorType(error_type)),
|
2010-03-12 15:06:13 +00:00
|
|
|
from_utf8(buf_->absFileName()));
|
2009-11-28 00:52:08 +00:00
|
|
|
paramsToDialog();
|
2007-10-06 14:13:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-06 10:55:47 +00:00
|
|
|
bool GuiErrorList::goTo(int item)
|
2007-10-06 14:13:25 +00:00
|
|
|
{
|
|
|
|
ErrorItem const & err = errorList()[item];
|
2016-10-09 19:34:12 +00:00
|
|
|
if (TexRow::isNone(err.start))
|
2008-07-06 10:55:47 +00:00
|
|
|
return false;
|
2007-10-06 14:13:25 +00:00
|
|
|
|
2011-03-04 13:37:14 +00:00
|
|
|
Buffer const * errbuf = err.buffer ? err.buffer : buf_;
|
|
|
|
|
|
|
|
if (&buffer() != errbuf) {
|
|
|
|
if (!theBufferList().isLoaded(errbuf))
|
|
|
|
return false;
|
|
|
|
FuncRequest fr(LFUN_BUFFER_SWITCH, errbuf->absFileName());
|
|
|
|
dispatch(fr);
|
|
|
|
}
|
2016-10-09 19:34:12 +00:00
|
|
|
dispatch(TexRow::goToFunc(err.start, err.end));
|
2008-07-06 10:56:47 +00:00
|
|
|
return true;
|
2007-10-06 14:13:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
Dialog * createGuiErrorList(GuiView & lv) { return new GuiErrorList(lv); }
|
2007-10-06 14:13:25 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2007-04-25 10:25:37 +00:00
|
|
|
|
|
|
|
|
2008-11-14 14:28:50 +00:00
|
|
|
#include "moc_GuiErrorList.cpp"
|