]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiNote.cpp
rename a few view functions from foo() to fooView()
[lyx.git] / src / frontends / qt4 / GuiNote.cpp
1 /**
2  * \file GuiNote.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Jürgen Spitzmüller
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "GuiNote.h"
14
15 #include "insets/InsetNote.h"
16
17 #include <QCloseEvent>
18
19 namespace lyx {
20 namespace frontend {
21
22 /////////////////////////////////////////////////////////////////////
23 //
24 // GuiNoteDialog
25 //
26 /////////////////////////////////////////////////////////////////////
27
28 GuiNoteDialog::GuiNoteDialog(GuiNote * form)
29         : form_(form)
30 {
31         setupUi(this);
32
33         connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
34         connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
35
36         connect(noteRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
37         connect(greyedoutRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
38         connect(commentRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
39         connect(framedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
40         connect(shadedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
41 }
42
43
44 void GuiNoteDialog::closeEvent(QCloseEvent * e)
45 {
46         form_->slotWMHide();
47         e->accept();
48 }
49
50
51 void GuiNoteDialog::change_adaptor()
52 {
53         form_->changed();
54 }
55
56
57 /////////////////////////////////////////////////////////////////////
58 //
59 // GuiNote
60 //
61 /////////////////////////////////////////////////////////////////////
62
63
64 GuiNote::GuiNote(GuiDialog & parent)
65         : GuiView<GuiNoteDialog>(parent, _("Note Settings"))
66 {}
67
68
69 void GuiNote::build_dialog()
70 {
71         dialog_.reset(new GuiNoteDialog(this));
72
73         bc().setOK(dialog_->okPB);
74         bc().setCancel(dialog_->closePB);
75 }
76
77
78 void GuiNote::update_contents()
79 {
80         QRadioButton * rb = 0;
81
82         switch (controller().params().type) {
83         case InsetNoteParams::Note:
84                 rb = dialog_->noteRB;
85                 break;
86         case InsetNoteParams::Comment:
87                 rb = dialog_->commentRB;
88                 break;
89         case InsetNoteParams::Greyedout:
90                 rb = dialog_->greyedoutRB;
91                 break;
92         case InsetNoteParams::Framed:
93                 rb = dialog_->framedRB;
94                 break;
95         case InsetNoteParams::Shaded:
96                 rb = dialog_->shadedRB;
97                 break;
98         }
99
100         rb->setChecked(true);
101 }
102
103
104 void GuiNote::applyView()
105 {
106         InsetNoteParams::Type type;
107
108         if (dialog_->greyedoutRB->isChecked())
109                 type = InsetNoteParams::Greyedout;
110         else if (dialog_->commentRB->isChecked())
111                 type = InsetNoteParams::Comment;
112         else if (dialog_->framedRB->isChecked())
113                 type = InsetNoteParams::Framed;
114         else if (dialog_->shadedRB->isChecked())
115                 type = InsetNoteParams::Shaded;
116         else
117                 type = InsetNoteParams::Note;
118
119         controller().params().type = type;
120 }
121
122 } // namespace frontend
123 } // namespace lyx
124
125 #include "GuiNote_moc.cpp"