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"
17 #include "ControlCommand.h"
18 #include "qt_helpers.h"
22 #include <QPushButton>
25 #include <QCloseEvent>
32 GuiNomenclDialog::GuiNomenclDialog(LyXView & lv)
33 : GuiDialog(lv, "nomenclature")
36 setController(new ControlCommand(*this, "nomenclature", "nomenclature"));
38 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
39 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
40 connect(symbolED, SIGNAL(textChanged(const QString&)),
41 this, SLOT(change_adaptor()));
42 connect(descriptionTE, SIGNAL(textChanged()),
43 this, SLOT(change_adaptor()));
45 setFocusProxy(descriptionTE);
47 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
49 bc().setCancel(closePB);
50 bc().addReadOnly(symbolED);
51 bc().addReadOnly(descriptionTE);
52 bc().addReadOnly(prefixED);
56 ControlCommand & GuiNomenclDialog::controller() const
58 return static_cast<ControlCommand &>(Dialog::controller());
62 void GuiNomenclDialog::showView()
68 void GuiNomenclDialog::change_adaptor()
74 void GuiNomenclDialog::reject()
80 void GuiNomenclDialog::closeEvent(QCloseEvent * e)
87 void GuiNomenclDialog::update_contents()
89 prefixED->setText(toqstr(controller().params()["prefix"]));
90 symbolED->setText(toqstr(controller().params()["symbol"]));
91 QString description = toqstr(controller().params()["description"]);
92 description.replace("\\\\","\n");
93 descriptionTE->setPlainText(description);
95 bc().setValid(isValid());
99 void GuiNomenclDialog::applyView()
101 controller().params()["prefix"] = qstring_to_ucs4(prefixED->text());
102 controller().params()["symbol"] = qstring_to_ucs4(symbolED->text());
103 QString description = descriptionTE->toPlainText();
104 description.replace('\n',"\\\\");
105 controller().params()["description"] = qstring_to_ucs4(description);
109 bool GuiNomenclDialog::isValid()
111 QString const description = descriptionTE->toPlainText();
112 return !symbolED->text().isEmpty() && !description.isEmpty();
115 } // namespace frontend
118 #include "GuiNomencl_moc.cpp"