]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiNomencl.cpp
header cleanup
[lyx.git] / src / frontends / qt4 / GuiNomencl.cpp
1 /**
2  * \file GuiNomencl.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  * \author O. U. Baran
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "GuiNomencl.h"
15
16 #include "support/debug.h"
17 #include "qt_helpers.h"
18
19 #include <QLabel>
20 #include <QLineEdit>
21 #include <QPushButton>
22 #include <QTextEdit>
23 #include <QWhatsThis>
24
25 using namespace std;
26
27 namespace lyx {
28 namespace frontend {
29
30 GuiNomenclature::GuiNomenclature(GuiView & lv)
31         : GuiCommand(lv, "nomenclature", qt_("Nomenclature"))
32 {
33         setupUi(this);
34
35         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
36         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
37         connect(symbolED, SIGNAL(textChanged(QString)),
38                 this, SLOT(change_adaptor()));
39         connect(descriptionTE, SIGNAL(textChanged()),
40                 this, SLOT(change_adaptor()));
41
42         setFocusProxy(descriptionTE);
43
44         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
45         bc().setOK(okPB);
46         bc().setCancel(closePB);
47         bc().addReadOnly(symbolED);
48         bc().addReadOnly(descriptionTE);
49         bc().addReadOnly(prefixED);
50 }
51
52
53 void GuiNomenclature::change_adaptor()
54 {
55         changed();
56 }
57
58
59 void GuiNomenclature::reject()
60 {
61         slotClose();
62 }
63
64
65 void GuiNomenclature::updateContents()
66 {
67         prefixED->setText(toqstr(params_["prefix"]));
68         symbolED->setText(toqstr(params_["symbol"]));
69         QString description = toqstr(params_["description"]);
70         description.replace("\\\\","\n");
71         descriptionTE->setPlainText(description);
72
73         bc().setValid(isValid());
74 }
75
76
77 void GuiNomenclature::applyView()
78 {
79         params_["prefix"] = qstring_to_ucs4(prefixED->text());
80         params_["symbol"] = qstring_to_ucs4(symbolED->text());
81         QString description = descriptionTE->toPlainText();
82         description.replace('\n',"\\\\");
83         params_["description"] = qstring_to_ucs4(description);
84 }
85
86
87 bool GuiNomenclature::isValid()
88 {
89         QString const description = descriptionTE->toPlainText();
90         return !symbolED->text().isEmpty() && !description.isEmpty();
91 }
92
93
94 Dialog * createGuiNomenclature(GuiView & lv)
95 {
96         return new GuiNomenclature(lv);
97 }
98
99
100 } // namespace frontend
101 } // namespace lyx
102
103 #include "GuiNomencl_moc.cpp"