]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiErrorList.cpp
526f2996887dbd2a9d930e9f8098e2d738bdcc8a
[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 "qt_helpers.h"
15
16 #include <QListWidget>
17 #include <QTextBrowser>
18 #include <QPushButton>
19 #include <QCloseEvent>
20
21 namespace lyx {
22 namespace frontend {
23
24 /////////////////////////////////////////////////////////////////////
25 //
26 // GuiErrorListDialog
27 //
28 /////////////////////////////////////////////////////////////////////
29
30 GuiErrorListDialog::GuiErrorListDialog(GuiErrorList * form)
31         : form_(form)
32 {
33         setupUi(this);
34         connect(closePB, SIGNAL(clicked()),
35                 form, SLOT(slotClose()));
36         connect(errorsLW, SIGNAL( itemActivated(QListWidgetItem *)),
37                 form, SLOT(slotClose()));
38         connect( errorsLW, SIGNAL( itemClicked(QListWidgetItem *)),
39                 this, SLOT(select_adaptor(QListWidgetItem *)));
40 }
41
42
43 void GuiErrorListDialog::select_adaptor(QListWidgetItem * item)
44 {
45         form_->select(item);
46 }
47
48
49 void GuiErrorListDialog::closeEvent(QCloseEvent * e)
50 {
51         form_->slotWMHide();
52         e->accept();
53 }
54
55
56 void GuiErrorListDialog::showEvent(QShowEvent *e)
57 {
58         errorsLW->setCurrentRow(0);
59         form_->select(errorsLW->item(0));
60         e->accept();
61 }
62
63
64 /////////////////////////////////////////////////////////////////////
65 //
66 // GuiErrorList
67 //
68 /////////////////////////////////////////////////////////////////////
69
70
71 GuiErrorList::GuiErrorList(GuiDialog & parent)
72         :  GuiView<GuiErrorListDialog>(parent, docstring())
73 {}
74
75
76 void GuiErrorList::build_dialog()
77 {
78         dialog_.reset(new GuiErrorListDialog(this));
79         bc().setCancel(dialog_->closePB);
80 }
81
82
83 void GuiErrorList::select(QListWidgetItem * wi)
84 {
85         int const item = dialog_->errorsLW->row(wi);
86         controller().goTo(item);
87         dialog_->descriptionTB->setPlainText(toqstr(controller().errorList()[item].description));
88 }
89
90
91 void GuiErrorList::update_contents()
92 {
93         setTitle(from_utf8(controller().name()));
94         dialog_->errorsLW->clear();
95         dialog_->descriptionTB->setPlainText(QString());
96
97         ErrorList::const_iterator it = controller().errorList().begin();
98         ErrorList::const_iterator end = controller().errorList().end();
99         for(; it != end; ++it) {
100                 dialog_->errorsLW->addItem(toqstr(it->error));
101         }
102 }
103
104 } // namespace frontend
105 } // namespace lyx
106
107
108 #include "GuiErrorList_moc.cpp"