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(itemClicked(QListWidgetItem *)),
71 this, SLOT(select()));
72 connect(errorsLW, SIGNAL(currentRowChanged(int)),
73 this, SLOT(select()));
75 bc().setPolicy(ButtonPolicy::OkCancelPolicy);
76 bc().setCancel(buttonBox->button(QDialogButtonBox::Cancel));
80 void GuiErrorList::showEvent(QShowEvent * e)
88 void GuiErrorList::select()
90 int const item = errorsLW->row(errorsLW->currentItem());
94 descriptionTB->setPlainText(
95 toqstr(errorList()[item].description));
99 void GuiErrorList::viewLog()
101 if (&buffer() != buf_) {
102 if (!theBufferList().isLoaded(buf_))
104 FuncRequest fr(LFUN_BUFFER_SWITCH, buf_->absFileName());
107 dispatch(FuncRequest(LFUN_DIALOG_SHOW, "latexlog"));
111 void GuiErrorList::showAnyway()
113 dispatch(FuncRequest(LFUN_BUFFER_VIEW_CACHE));
117 void GuiErrorList::paramsToDialog()
119 setTitle(toqstr(name_));
121 descriptionTB->setPlainText(QString());
123 ErrorList const & el = errorList();
124 ErrorList::const_iterator it = el.begin();
125 ErrorList::const_iterator const en = el.end();
126 for (; it != en; ++it)
127 errorsLW->addItem(toqstr(it->error));
128 errorsLW->setCurrentRow(0);
129 showAnywayPB->setEnabled(
130 lyx::getStatus(FuncRequest(LFUN_BUFFER_VIEW_CACHE)).enabled());
134 ErrorList const & GuiErrorList::errorList() const
136 Buffer const * buffer = from_master_
137 ? bufferview()->buffer().masterBuffer()
138 : &bufferview()->buffer();
140 error_list_ = buffer->errorList(error_type_);
146 bool GuiErrorList::initialiseParams(string const & sdata)
148 from_master_ = prefixIs(sdata, "from_master|");
149 string error_type = sdata;
151 error_type = split(sdata, '|');
152 error_type_ = error_type;
153 buf_ = from_master_ ?
154 bufferview()->buffer().masterBuffer()
155 : &bufferview()->buffer();
156 name_ = bformat(_("%1$s Errors (%2$s)"),
157 _(guiErrorType(error_type)),
158 from_utf8(buf_->absFileName()));
164 bool GuiErrorList::goTo(int item)
166 ErrorItem const & err = errorList()[item];
167 if (TexRow::isNone(err.start))
170 Buffer const * errbuf = err.buffer ? err.buffer : buf_;
172 if (&buffer() != errbuf) {
173 if (!theBufferList().isLoaded(errbuf))
175 FuncRequest fr(LFUN_BUFFER_SWITCH, errbuf->absFileName());
178 dispatch(TexRow::goToFunc(err.start, err.end));
183 } // namespace frontend
187 #include "moc_GuiErrorList.cpp"