]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiNomenclature.cpp
Implement GuiNomenclature::initialiseParams(), thus restoring the
[lyx.git] / src / frontends / qt4 / GuiNomenclature.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 "GuiNomenclature.h"
15
16 #include "qt_helpers.h"
17
18 #include "insets/InsetNomencl.h"
19
20 using namespace std;
21
22 namespace lyx {
23 namespace frontend {
24
25 GuiNomenclature::GuiNomenclature(QWidget * parent) : InsetParamsWidget(parent)
26 {
27         setupUi(this);
28         connect(symbolED, SIGNAL(textChanged(QString)),
29                 this, SIGNAL(changed()));
30         connect(descriptionTE, SIGNAL(textChanged()),
31                 this, SIGNAL(changed()));
32
33         setFocusProxy(descriptionTE);
34 }
35
36
37 void GuiNomenclature::paramsToDialog(Inset const * inset)
38 {
39         InsetNomencl const * nomencl = static_cast<InsetNomencl const *>(inset);
40         InsetCommandParams const & params = nomencl->params();
41
42         prefixED->setText(toqstr(params["prefix"]));
43         symbolED->setText(toqstr(params["symbol"]));
44         QString description = toqstr(params["description"]);
45         description.replace("\\\\","\n");
46         descriptionTE->setPlainText(description);
47         descriptionTE->setFocus();
48 }
49
50
51 docstring GuiNomenclature::dialogToParams() const
52 {
53         InsetCommandParams params(insetCode());
54         params["prefix"] = qstring_to_ucs4(prefixED->text());
55         params["symbol"] = qstring_to_ucs4(symbolED->text());
56         QString description = descriptionTE->toPlainText();
57         description.replace('\n',"\\\\");
58         params["description"] = qstring_to_ucs4(description);
59         return from_utf8(InsetNomencl::params2string(params));
60 }
61
62
63 bool GuiNomenclature::initialiseParams(std::string const & data)
64 {
65         InsetCommandParams p(insetCode());
66         if (!InsetCommand::string2params(data, p))
67                 return false;
68         symbolED->setText(toqstr(p["symbol"]));
69         return true;
70 }
71
72
73 bool GuiNomenclature::checkWidgets() const
74 {
75         if (!InsetParamsWidget::checkWidgets())
76                 return false;
77         QString const description = descriptionTE->toPlainText();
78         return !symbolED->text().isEmpty() && !description.isEmpty();
79 }
80
81 } // namespace frontend
82 } // namespace lyx
83
84 #include "moc_GuiNomenclature.cpp"