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