]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QNote.C
Rename .C ==> .cpp for files in src/frontends/qt4, part one
[lyx.git] / src / frontends / qt4 / QNote.C
1 /**
2  * \file QNote.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 "QNote.h"
14 #include "Qt2BC.h"
15
16 #include "controllers/ControlNote.h"
17
18 #include "insets/InsetNote.h"
19
20 #include <QCloseEvent>
21
22 namespace lyx {
23 namespace frontend {
24
25 /////////////////////////////////////////////////////////////////////
26 //
27 // QNoteDialog
28 //
29 /////////////////////////////////////////////////////////////////////
30
31 QNoteDialog::QNoteDialog(QNote * form)
32         : form_(form)
33 {
34         setupUi(this);
35
36         connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
37         connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
38
39         connect(noteRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
40         connect(greyedoutRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
41         connect(commentRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
42         connect(framedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
43         connect(shadedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
44 }
45
46
47 void QNoteDialog::closeEvent(QCloseEvent * e)
48 {
49         form_->slotWMHide();
50         e->accept();
51 }
52
53
54 void QNoteDialog::change_adaptor()
55 {
56         form_->changed();
57 }
58
59
60 /////////////////////////////////////////////////////////////////////
61 //
62 // QNote
63 //
64 /////////////////////////////////////////////////////////////////////
65
66 typedef QController<ControlNote, QView<QNoteDialog> > NoteBase;
67
68
69 QNote::QNote(Dialog & parent)
70         : NoteBase(parent, _("Note Settings"))
71 {}
72
73
74 void QNote::build_dialog()
75 {
76         dialog_.reset(new QNoteDialog(this));
77
78         bcview().setOK(dialog_->okPB);
79         bcview().setCancel(dialog_->closePB);
80 }
81
82
83 void QNote::update_contents()
84 {
85         QRadioButton * rb = 0;
86
87         switch (controller().params().type) {
88         case InsetNoteParams::Note:
89                 rb = dialog_->noteRB;
90                 break;
91         case InsetNoteParams::Comment:
92                 rb = dialog_->commentRB;
93                 break;
94         case InsetNoteParams::Greyedout:
95                 rb = dialog_->greyedoutRB;
96                 break;
97         case InsetNoteParams::Framed:
98                 rb = dialog_->framedRB;
99                 break;
100         case InsetNoteParams::Shaded:
101                 rb = dialog_->shadedRB;
102                 break;
103         }
104
105         rb->setChecked(true);
106 }
107
108
109 void QNote::apply()
110 {
111         InsetNoteParams::Type type;
112
113         if (dialog_->greyedoutRB->isChecked())
114                 type = InsetNoteParams::Greyedout;
115         else if (dialog_->commentRB->isChecked())
116                 type = InsetNoteParams::Comment;
117         else if (dialog_->framedRB->isChecked())
118                 type = InsetNoteParams::Framed;
119         else if (dialog_->shadedRB->isChecked())
120                 type = InsetNoteParams::Shaded;
121         else
122                 type = InsetNoteParams::Note;
123
124         controller().params().type = type;
125 }
126
127 } // namespace frontend
128 } // namespace lyx
129
130 #include "QNote_moc.cpp"