]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiErrorList.cpp
ac8ea3df6530daab054e469d90da2bfe8b647da2
[lyx.git] / src / frontends / qt4 / GuiErrorList.cpp
1 /**
2  * \file GuiErrorList.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Alfredo Braunstein
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "GuiErrorList.h"
14 #include "ControlErrorList.h"
15
16 #include "qt_helpers.h"
17
18 #include <QListWidget>
19 #include <QTextBrowser>
20 #include <QPushButton>
21 #include <QCloseEvent>
22
23
24 namespace lyx {
25 namespace frontend {
26
27
28 GuiErrorListDialog::GuiErrorListDialog(LyXView & lv)
29         : GuiDialog(lv, "errorlist")
30 {
31         setupUi(this);
32         setController(new ControlErrorList(*this));
33
34         connect(closePB, SIGNAL(clicked()),
35                 this, SLOT(slotClose()));
36         connect(errorsLW, SIGNAL(itemActivated(QListWidgetItem *)),
37                 this, SLOT(slotClose()));
38         connect( errorsLW, SIGNAL(itemClicked(QListWidgetItem *)),
39                 this, SLOT(select_adaptor(QListWidgetItem *)));
40
41         bc().setPolicy(ButtonPolicy::OkCancelPolicy);
42         bc().setCancel(closePB);
43 }
44
45
46 ControlErrorList & GuiErrorListDialog::controller() const
47 {
48         return static_cast<ControlErrorList &>(GuiDialog::controller());
49 }
50
51
52 void GuiErrorListDialog::select_adaptor(QListWidgetItem * item)
53 {
54         select(item);
55 }
56
57
58 void GuiErrorListDialog::closeEvent(QCloseEvent * e)
59 {
60         slotClose();
61         e->accept();
62 }
63
64
65 void GuiErrorListDialog::showEvent(QShowEvent *e)
66 {
67         errorsLW->setCurrentRow(0);
68         select(errorsLW->item(0));
69         e->accept();
70 }
71
72
73 void GuiErrorListDialog::select(QListWidgetItem * wi)
74 {
75         int const item = errorsLW->row(wi);
76         controller().goTo(item);
77         descriptionTB->setPlainText(toqstr(controller().errorList()[item].description));
78 }
79
80
81 void GuiErrorListDialog::update_contents()
82 {
83         setViewTitle(from_utf8(controller().name()));
84         errorsLW->clear();
85         descriptionTB->setPlainText(QString());
86
87         ErrorList::const_iterator it = controller().errorList().begin();
88         ErrorList::const_iterator end = controller().errorList().end();
89         for (; it != end; ++it)
90                 errorsLW->addItem(toqstr(it->error));
91 }
92
93 } // namespace frontend
94 } // namespace lyx
95
96
97 #include "GuiErrorList_moc.cpp"