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