2 * \file GuiErrorList.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Alfredo Braunstein
8 * Full author contact details are available in file CREDITS.
13 #include "GuiErrorList.h"
16 #include "qt_helpers.h"
19 #include "BufferView.h"
20 #include "FuncRequest.h"
21 #include "FuncStatus.h"
22 #include "BufferList.h"
27 #include "support/debug.h"
28 #include "support/gettext.h"
29 #include "support/lstrings.h"
31 #include <QListWidget>
32 #include <QPushButton>
34 #include <QTextBrowser>
37 using namespace lyx::support;
41 string const guiErrorType(string const & s)
45 else if (s == "literate")
46 return N_("Literate");
47 else if (s == "latex")
48 // This covers all LaTeX variants
49 // (LaTeX, PDFLaTeX, XeTeX, LuaTeX, pLaTeX)
59 GuiErrorList::GuiErrorList(GuiView & lv)
60 : GuiDialog(lv, "errorlist", qt_("Error List")), buf_(nullptr), from_master_(false)
64 connect(buttonBox, SIGNAL(clicked(QAbstractButton *)),
65 this, SLOT(slotButtonBox(QAbstractButton *)));
66 connect(viewLogPB, SIGNAL(clicked()),
67 this, SLOT(viewLog()));
68 connect(showAnywayPB, SIGNAL(clicked()),
69 this, SLOT(showAnyway()));
70 connect(errorsLW, SIGNAL(currentRowChanged(int)),
71 this, SLOT(select()));
73 bc().setPolicy(ButtonPolicy::OkCancelPolicy);
74 bc().setCancel(buttonBox->button(QDialogButtonBox::Cancel));
78 void GuiErrorList::showEvent(QShowEvent * e)
86 void GuiErrorList::select()
88 int const item = errorsLW->row(errorsLW->currentItem());
92 descriptionTB->setPlainText(
93 toqstr(errorList()[item].description));
97 void GuiErrorList::viewLog()
99 if (&buffer() != buf_) {
100 if (!theBufferList().isLoaded(buf_))
102 FuncRequest fr(LFUN_BUFFER_SWITCH, buf_->absFileName());
105 dispatch(FuncRequest(LFUN_DIALOG_SHOW, "latexlog"));
109 void GuiErrorList::showAnyway()
111 dispatch(FuncRequest(LFUN_BUFFER_VIEW_CACHE));
115 void GuiErrorList::paramsToDialog()
117 setTitle(toqstr(name_));
119 descriptionTB->setPlainText(QString());
121 ErrorList const & el = errorList();
122 ErrorList::const_iterator it = el.begin();
123 ErrorList::const_iterator const en = el.end();
124 for (; it != en; ++it)
125 errorsLW->addItem(toqstr(it->error));
126 errorsLW->setCurrentRow(0);
127 showAnywayPB->setEnabled(
128 lyx::getStatus(FuncRequest(LFUN_BUFFER_VIEW_CACHE)).enabled());
132 ErrorList const & GuiErrorList::errorList() const
134 Buffer const * buffer = from_master_
135 ? bufferview()->buffer().masterBuffer()
136 : &bufferview()->buffer();
138 error_list_ = buffer->errorList(error_type_);
144 bool GuiErrorList::initialiseParams(string const & sdata)
146 from_master_ = prefixIs(sdata, "from_master|");
147 string error_type = sdata;
149 error_type = split(sdata, '|');
150 error_type_ = error_type;
151 buf_ = from_master_ ?
152 bufferview()->buffer().masterBuffer()
153 : &bufferview()->buffer();
154 name_ = bformat(_("%1$s Errors (%2$s)"),
155 _(guiErrorType(error_type)),
156 from_utf8(buf_->absFileName()));
162 bool GuiErrorList::goTo(int item)
164 ErrorItem const & err = errorList()[item];
165 if (TexRow::isNone(err.start))
168 Buffer const * errbuf = err.buffer ? err.buffer : buf_;
170 if (&buffer() != errbuf) {
171 if (!theBufferList().isLoaded(errbuf))
173 FuncRequest fr(LFUN_BUFFER_SWITCH, errbuf->absFileName());
176 dispatch(TexRow::goToFunc(err.start, err.end));
181 } // namespace frontend
185 #include "moc_GuiErrorList.cpp"