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 /////////////////////////////////////////////////////////////////////
36 /////////////////////////////////////////////////////////////////////
38 GuiNomenclDialog::GuiNomenclDialog(GuiNomencl * form)
43 connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
44 connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
45 connect(symbolED, SIGNAL(textChanged(const QString&)),
46 this, SLOT(change_adaptor()));
47 connect(descriptionTE, SIGNAL(textChanged()),
48 this, SLOT(change_adaptor()));
50 setFocusProxy(descriptionTE);
54 void GuiNomenclDialog::show()
60 void GuiNomenclDialog::change_adaptor()
66 void GuiNomenclDialog::reject()
72 void GuiNomenclDialog::closeEvent(QCloseEvent * e)
79 /////////////////////////////////////////////////////////////////////
83 /////////////////////////////////////////////////////////////////////
86 GuiNomencl::GuiNomencl(GuiDialog & parent, docstring const & title)
87 : GuiView<GuiNomenclDialog>(parent, title)
92 void GuiNomencl::build_dialog()
94 dialog_.reset(new GuiNomenclDialog(this));
96 bc().setOK(dialog_->okPB);
97 bc().setCancel(dialog_->closePB);
98 bc().addReadOnly(dialog_->symbolED);
99 bc().addReadOnly(dialog_->descriptionTE);
100 bc().addReadOnly(dialog_->prefixED);
104 void GuiNomencl::update_contents()
106 dialog_->prefixED->setText(toqstr(controller().params()["prefix"]));
107 dialog_->symbolED->setText(toqstr(controller().params()["symbol"]));
108 QString description = toqstr(controller().params()["description"]);
109 description.replace("\\\\","\n");
110 dialog_->descriptionTE->setPlainText(description);
112 bc().setValid(isValid());
116 void GuiNomencl::apply()
118 controller().params()["prefix"] = qstring_to_ucs4(dialog_->prefixED->text());
119 controller().params()["symbol"] = qstring_to_ucs4(dialog_->symbolED->text());
120 QString description = dialog_->descriptionTE->toPlainText();
121 description.replace('\n',"\\\\");
122 controller().params()["description"] = qstring_to_ucs4(description);
126 bool GuiNomencl::isValid()
128 QString const description = dialog_->descriptionTE->toPlainText();
129 return !dialog_->symbolED->text().isEmpty() && !description.isEmpty();
132 } // namespace frontend
135 #include "GuiNomencl_moc.cpp"