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 "GuiNomencl.h"
16 #include "qt_helpers.h"
17 #include "FuncRequest.h"
19 #include "insets/InsetCommand.h"
21 #include "support/debug.h"
31 GuiNomenclature::GuiNomenclature(GuiView & lv)
32 : GuiDialog(lv, "nomenclature", qt_("Nomenclature")),
33 params_(insetCode("nomenclature"))
37 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
38 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
39 connect(symbolED, SIGNAL(textChanged(QString)),
40 this, SLOT(change_adaptor()));
41 connect(descriptionTE, SIGNAL(textChanged()),
42 this, SLOT(change_adaptor()));
44 setFocusProxy(descriptionTE);
46 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
48 bc().setCancel(closePB);
49 bc().addReadOnly(symbolED);
50 bc().addReadOnly(descriptionTE);
51 bc().addReadOnly(prefixED);
55 void GuiNomenclature::change_adaptor()
61 void GuiNomenclature::reject()
67 void GuiNomenclature::paramsToDialog(InsetCommandParams const & /*icp*/)
69 prefixED->setText(toqstr(params_["prefix"]));
70 symbolED->setText(toqstr(params_["symbol"]));
71 QString description = toqstr(params_["description"]);
72 description.replace("\\\\","\n");
73 descriptionTE->setPlainText(description);
75 bc().setValid(isValid());
79 void GuiNomenclature::applyView()
81 params_["prefix"] = qstring_to_ucs4(prefixED->text());
82 params_["symbol"] = qstring_to_ucs4(symbolED->text());
83 QString description = descriptionTE->toPlainText();
84 description.replace('\n',"\\\\");
85 params_["description"] = qstring_to_ucs4(description);
89 bool GuiNomenclature::isValid()
91 QString const description = descriptionTE->toPlainText();
92 return !symbolED->text().isEmpty() && !description.isEmpty();
96 bool GuiNomenclature::initialiseParams(std::string const & data)
98 InsetCommand::string2params("nomenclature", data, params_);
99 paramsToDialog(params_);
104 void GuiNomenclature::dispatchParams()
106 std::string const lfun = InsetCommand::params2string("nomenclature", params_);
107 dispatch(FuncRequest(getLfun(), lfun));
112 Dialog * createGuiNomenclature(GuiView & lv)
114 return new GuiNomenclature(lv);
118 } // namespace frontend
121 #include "GuiNomencl_moc.cpp"