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);
74 descriptionTE->setFocus();
76 bc().setValid(isValid());
80 void GuiNomenclature::applyView()
82 params_["prefix"] = qstring_to_ucs4(prefixED->text());
83 params_["symbol"] = qstring_to_ucs4(symbolED->text());
84 QString description = descriptionTE->toPlainText();
85 description.replace('\n',"\\\\");
86 params_["description"] = qstring_to_ucs4(description);
90 bool GuiNomenclature::isValid()
92 QString const description = descriptionTE->toPlainText();
93 return !symbolED->text().isEmpty() && !description.isEmpty();
97 bool GuiNomenclature::initialiseParams(std::string const & data)
99 InsetCommand::string2params("nomenclature", data, params_);
100 paramsToDialog(params_);
105 void GuiNomenclature::dispatchParams()
107 std::string const lfun = InsetCommand::params2string("nomenclature", params_);
108 dispatch(FuncRequest(getLfun(), lfun));
113 Dialog * createGuiNomenclature(GuiView & lv)
115 return new GuiNomenclature(lv);
119 } // namespace frontend
122 #include "moc_GuiNomencl.cpp"