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()));
32 connect(literalCB, SIGNAL(clicked()),
33 this, SIGNAL(changed()));
35 setFocusProxy(descriptionTE);
39 void GuiNomenclature::paramsToDialog(Inset const * inset)
41 InsetNomencl const * nomencl = static_cast<InsetNomencl const *>(inset);
42 InsetCommandParams const & params = nomencl->params();
44 prefixED->setText(toqstr(params["prefix"]));
45 symbolED->setText(toqstr(params["symbol"]));
46 literalCB->setChecked(params["literal"] == "true");
47 QString description = toqstr(params["description"]);
48 description.replace("\\\\","\n");
49 descriptionTE->setPlainText(description);
50 descriptionTE->setFocus();
54 docstring GuiNomenclature::dialogToParams() const
56 InsetCommandParams params(insetCode());
57 params["prefix"] = qstring_to_ucs4(prefixED->text());
58 params["symbol"] = qstring_to_ucs4(symbolED->text());
59 QString description = descriptionTE->toPlainText();
60 description.replace('\n',"\\\\");
61 params["description"] = qstring_to_ucs4(description);
62 params["literal"] = literalCB->isChecked()
63 ? from_ascii("true") : from_ascii("false");
64 return from_utf8(InsetNomencl::params2string(params));
68 bool GuiNomenclature::initialiseParams(std::string const & data)
70 InsetCommandParams p(insetCode());
71 if (!InsetCommand::string2params(data, p))
73 symbolED->setText(toqstr(p["symbol"]));
78 bool GuiNomenclature::checkWidgets(bool readonly) const
80 symbolED->setReadOnly(readonly);
81 descriptionTE->setReadOnly(readonly);
82 if (!InsetParamsWidget::checkWidgets())
84 QString const description = descriptionTE->toPlainText();
85 return !symbolED->text().isEmpty() && !description.isEmpty();
88 } // namespace frontend
91 #include "moc_GuiNomenclature.cpp"