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::change_adaptor()
68 void GuiNomenclDialog::reject()
74 void GuiNomenclDialog::closeEvent(QCloseEvent * e)
81 void GuiNomenclDialog::update_contents()
83 prefixED->setText(toqstr(controller().params()["prefix"]));
84 symbolED->setText(toqstr(controller().params()["symbol"]));
85 QString description = toqstr(controller().params()["description"]);
86 description.replace("\\\\","\n");
87 descriptionTE->setPlainText(description);
89 bc().setValid(isValid());
93 void GuiNomenclDialog::applyView()
95 controller().params()["prefix"] = qstring_to_ucs4(prefixED->text());
96 controller().params()["symbol"] = qstring_to_ucs4(symbolED->text());
97 QString description = descriptionTE->toPlainText();
98 description.replace('\n',"\\\\");
99 controller().params()["description"] = qstring_to_ucs4(description);
103 bool GuiNomenclDialog::isValid()
105 QString const description = descriptionTE->toPlainText();
106 return !symbolED->text().isEmpty() && !description.isEmpty();
109 } // namespace frontend
112 #include "GuiNomencl_moc.cpp"