]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QERT.cpp
Streamlining CollapseStatus stuff
[lyx.git] / src / frontends / qt4 / QERT.cpp
1 /**
2  * \file QERT.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "QERT.h"
14 #include "Qt2BC.h"
15
16 #include "controllers/ControlERT.h"
17
18 #include <QRadioButton>
19 #include <QPushButton>
20 #include <QCloseEvent>
21
22
23 namespace lyx {
24 namespace frontend {
25
26 /////////////////////////////////////////////////////////////////////
27 //
28 // QERTDialog
29 //
30 /////////////////////////////////////////////////////////////////////
31
32
33 QERTDialog::QERTDialog(QERT * form)
34         : form_(form)
35 {
36         setupUi(this);
37         connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
38         connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
39         connect(collapsedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
40         connect(openRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
41 }
42
43
44 void QERTDialog::closeEvent(QCloseEvent * e)
45 {
46         form_->slotWMHide();
47         e->accept();
48 }
49
50
51 void QERTDialog::change_adaptor()
52 {
53         form_->changed();
54 }
55
56
57 /////////////////////////////////////////////////////////////////////
58 //
59 // QERT
60 //
61 /////////////////////////////////////////////////////////////////////
62
63 typedef QController<ControlERT, QView<QERTDialog> > ERTBase;
64
65
66 QERT::QERT(Dialog & parent)
67         : ERTBase(parent, _("TeX Code Settings"))
68 {
69 }
70
71
72 void QERT::build_dialog()
73 {
74         dialog_.reset(new QERTDialog(this));
75
76         bcview().setOK(dialog_->okPB);
77         bcview().setCancel(dialog_->closePB);
78 }
79
80
81 void QERT::apply()
82 {
83         if (dialog_->openRB->isChecked())
84                 controller().setStatus(Inset::Open);
85         else
86                 controller().setStatus(Inset::Collapsed);
87 }
88
89
90 void QERT::update_contents()
91 {
92         QRadioButton * rb = 0;
93
94         switch (controller().status()) {
95                 case InsetERT::Open: rb = dialog_->openRB; break;
96                 case InsetERT::Collapsed: rb = dialog_->collapsedRB; break;
97         }
98
99         rb->setChecked(true);
100 }
101
102 } // namespace frontend
103 } // namespace lyx
104
105 #include "QERT_moc.cpp"