3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
14 #include "GuiNomenclature.h"
16 #include "qt_helpers.h"
18 #include "insets/InsetNomencl.h"
25 GuiNomenclature::GuiNomenclature(QWidget * parent) : InsetParamsWidget(parent)
28 connect(symbolED, SIGNAL(textChanged(QString)),
29 this, SIGNAL(changed()));
30 connect(descriptionTE, SIGNAL(textChanged()),
31 this, SIGNAL(changed()));
33 setFocusProxy(descriptionTE);
37 void GuiNomenclature::paramsToDialog(Inset const * inset)
39 InsetNomencl const * nomencl = static_cast<InsetNomencl const *>(inset);
40 InsetCommandParams const & params = nomencl->params();
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();
51 docstring GuiNomenclature::dialogToParams() const
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));
63 bool GuiNomenclature::initialiseParams(std::string const & data)
65 InsetCommandParams p(insetCode());
66 if (!InsetCommand::string2params(data, p))
68 symbolED->setText(toqstr(p["symbol"]));
73 bool GuiNomenclature::checkWidgets() const
75 if (!InsetParamsWidget::checkWidgets())
77 QString const description = descriptionTE->toPlainText();
78 return !symbolED->text().isEmpty() && !description.isEmpty();
81 } // namespace frontend
84 #include "moc_GuiNomenclature.cpp"