]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiNote.cpp
move Controller inheritance further up the tree
[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 Angus Leeming
7  * \author Jürgen Spitzmüller
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "GuiNote.h"
15 #include "FuncRequest.h"
16 #include "gettext.h"
17
18 #include "insets/InsetNote.h"
19
20 #include <QCloseEvent>
21
22 using std::string;
23
24
25 namespace lyx {
26 namespace frontend {
27
28 GuiNote::GuiNote(LyXView & lv)
29         : GuiDialog(lv, "note")
30 {
31         setupUi(this);
32         setViewTitle(_("Note Settings"));
33
34         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
35         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
36
37         connect(noteRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
38         connect(greyedoutRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
39         connect(commentRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
40         connect(framedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
41         connect(shadedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
42
43         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
44         bc().setOK(okPB);
45         bc().setCancel(closePB);
46 }
47
48
49 void GuiNote::closeEvent(QCloseEvent * e)
50 {
51         slotClose();
52         e->accept();
53 }
54
55
56 void GuiNote::change_adaptor()
57 {
58         changed();
59 }
60
61
62 void GuiNote::updateContents()
63 {
64         switch (params_.type) {
65         case InsetNoteParams::Note:
66                 noteRB->setChecked(true);
67                 break;
68         case InsetNoteParams::Comment:
69                 commentRB->setChecked(true);
70                 break;
71         case InsetNoteParams::Greyedout:
72                 greyedoutRB->setChecked(true);
73                 break;
74         case InsetNoteParams::Framed:
75                 framedRB->setChecked(true);
76                 break;
77         case InsetNoteParams::Shaded:
78                 shadedRB->setChecked(true);
79                 break;
80         }
81 }
82
83
84 void GuiNote::applyView()
85 {
86         if (greyedoutRB->isChecked())
87                 params_.type = InsetNoteParams::Greyedout;
88         else if (commentRB->isChecked())
89                 params_.type = InsetNoteParams::Comment;
90         else if (framedRB->isChecked())
91                 params_.type = InsetNoteParams::Framed;
92         else if (shadedRB->isChecked())
93                 params_.type = InsetNoteParams::Shaded;
94         else
95                 params_.type = InsetNoteParams::Note;
96 }
97
98
99 bool GuiNote::initialiseParams(string const & data)
100 {
101         InsetNoteMailer::string2params(data, params_);
102         return true;
103 }
104
105
106 void GuiNote::clearParams()
107 {
108         params_ = InsetNoteParams();
109 }
110
111
112 void GuiNote::dispatchParams()
113 {
114         dispatch(FuncRequest(getLfun(), InsetNoteMailer::params2string(params_)));
115 }
116
117
118 Dialog * createGuiNote(LyXView & lv) { return new GuiNote(lv); }
119
120
121 } // namespace frontend
122 } // namespace lyx
123
124 #include "GuiNote_moc.cpp"