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"
24 #include "ParIterator.h"
28 #include "support/debug.h"
29 #include "support/gettext.h"
30 #include "support/lstrings.h"
32 #include <QListWidget>
33 #include <QPushButton>
35 #include <QTextBrowser>
38 using namespace lyx::support;
42 string const guiErrorType(string const & s)
46 else if (s == "literate")
47 return N_("Literate");
48 else if (s == "latex")
49 // This covers all LaTeX variants
50 // (LaTeX, PDFLaTeX, XeTeX, LuaTeX, pLaTeX)
60 GuiErrorList::GuiErrorList(GuiView & lv)
61 : GuiDialog(lv, "errorlist", qt_("Error List")), buf_(0), from_master_(false)
65 connect(buttonBox, SIGNAL(clicked(QAbstractButton *)),
66 this, SLOT(slotButtonBox(QAbstractButton *)));
67 connect(viewLogPB, SIGNAL(clicked()),
68 this, SLOT(viewLog()));
69 connect(showAnywayPB, SIGNAL(clicked()),
70 this, SLOT(showAnyway()));
71 connect(errorsLW, SIGNAL(currentRowChanged(int)),
72 this, SLOT(select()));
74 bc().setPolicy(ButtonPolicy::OkCancelPolicy);
75 bc().setCancel(buttonBox->button(QDialogButtonBox::Cancel));
79 void GuiErrorList::showEvent(QShowEvent * e)
87 void GuiErrorList::select()
89 int const item = errorsLW->row(errorsLW->currentItem());
93 descriptionTB->setPlainText(
94 toqstr(errorList()[item].description));
98 void GuiErrorList::viewLog()
100 if (&buffer() != buf_) {
101 if (!theBufferList().isLoaded(buf_))
103 FuncRequest fr(LFUN_BUFFER_SWITCH, buf_->absFileName());
106 dispatch(FuncRequest(LFUN_DIALOG_SHOW, "latexlog"));
110 void GuiErrorList::showAnyway()
112 dispatch(FuncRequest(LFUN_BUFFER_VIEW_CACHE));
116 void GuiErrorList::paramsToDialog()
118 setTitle(toqstr(name_));
120 descriptionTB->setPlainText(QString());
122 ErrorList const & el = errorList();
123 ErrorList::const_iterator it = el.begin();
124 ErrorList::const_iterator const en = el.end();
125 for (; it != en; ++it)
126 errorsLW->addItem(toqstr(it->error));
127 errorsLW->setCurrentRow(0);
128 showAnywayPB->setEnabled(
129 lyx::getStatus(FuncRequest(LFUN_BUFFER_VIEW_CACHE)).enabled());
133 ErrorList const & GuiErrorList::errorList() const
135 Buffer const * buffer = from_master_
136 ? bufferview()->buffer().masterBuffer()
137 : &bufferview()->buffer();
139 error_list_ = buffer->errorList(error_type_);
145 bool GuiErrorList::initialiseParams(string const & sdata)
147 from_master_ = prefixIs(sdata, "from_master|");
148 string error_type = sdata;
150 error_type = split(sdata, '|');
151 error_type_ = error_type;
152 buf_ = from_master_ ?
153 bufferview()->buffer().masterBuffer()
154 : &bufferview()->buffer();
155 name_ = bformat(_("%1$s Errors (%2$s)"),
156 _(guiErrorType(error_type)),
157 from_utf8(buf_->absFileName()));
163 bool GuiErrorList::goTo(int item)
165 ErrorItem const & err = errorList()[item];
166 if (TexRow::isNone(err.start))
169 Buffer const * errbuf = err.buffer ? err.buffer : buf_;
171 if (&buffer() != errbuf) {
172 if (!theBufferList().isLoaded(errbuf))
174 FuncRequest fr(LFUN_BUFFER_SWITCH, errbuf->absFileName());
177 dispatch(TexRow::goToFunc(err.start, err.end));
182 Dialog * createGuiErrorList(GuiView & lv) { return new GuiErrorList(lv); }
184 } // namespace frontend
188 #include "moc_GuiErrorList.cpp"