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