]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiNomencl.cpp
'using namespace std' instead of 'using std::xxx'
[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 #include <QCloseEvent>
25
26 using namespace std;
27
28 namespace lyx {
29 namespace frontend {
30
31 GuiNomenclature::GuiNomenclature(GuiView & lv)
32         : GuiCommand(lv, "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::closeEvent(QCloseEvent * e)
67 {
68         slotClose();
69         e->accept();
70 }
71
72
73 void GuiNomenclature::updateContents()
74 {
75         prefixED->setText(toqstr(params_["prefix"]));
76         symbolED->setText(toqstr(params_["symbol"]));
77         QString description = toqstr(params_["description"]);
78         description.replace("\\\\","\n");
79         descriptionTE->setPlainText(description);
80
81         bc().setValid(isValid());
82 }
83
84
85 void GuiNomenclature::applyView()
86 {
87         params_["prefix"] = qstring_to_ucs4(prefixED->text());
88         params_["symbol"] = qstring_to_ucs4(symbolED->text());
89         QString description = descriptionTE->toPlainText();
90         description.replace('\n',"\\\\");
91         params_["description"] = qstring_to_ucs4(description);
92 }
93
94
95 bool GuiNomenclature::isValid()
96 {
97         QString const description = descriptionTE->toPlainText();
98         return !symbolED->text().isEmpty() && !description.isEmpty();
99 }
100
101
102 Dialog * createGuiNomenclature(GuiView & lv)
103 {
104         return new GuiNomenclature(lv);
105 }
106
107
108 } // namespace frontend
109 } // namespace lyx
110
111 #include "GuiNomencl_moc.cpp"