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.
15 #include "ControlCommand.h"
16 #include "qt_helpers.h"
18 #include "GuiNomencl.h"
20 #include "ButtonController.h"
24 #include <QPushButton>
27 #include <QCloseEvent>
34 /////////////////////////////////////////////////////////////////////
38 /////////////////////////////////////////////////////////////////////
40 GuiNomenclDialog::GuiNomenclDialog(GuiNomencl * form)
45 connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
46 connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
47 connect(symbolED, SIGNAL(textChanged(const QString&)),
48 this, SLOT(change_adaptor()));
49 connect(descriptionTE, SIGNAL(textChanged()),
50 this, SLOT(change_adaptor()));
52 setFocusProxy(descriptionTE);
56 void GuiNomenclDialog::show()
62 void GuiNomenclDialog::change_adaptor()
68 void GuiNomenclDialog::reject()
74 void GuiNomenclDialog::closeEvent(QCloseEvent * e)
81 /////////////////////////////////////////////////////////////////////
85 /////////////////////////////////////////////////////////////////////
88 GuiNomencl::GuiNomencl(Dialog & parent, docstring const & title)
89 : GuiView<GuiNomenclDialog>(parent, title)
94 void GuiNomencl::build_dialog()
96 dialog_.reset(new GuiNomenclDialog(this));
98 bcview().setOK(dialog_->okPB);
99 bcview().setCancel(dialog_->closePB);
100 bcview().addReadOnly(dialog_->symbolED);
101 bcview().addReadOnly(dialog_->descriptionTE);
102 bcview().addReadOnly(dialog_->prefixED);
106 void GuiNomencl::update_contents()
108 dialog_->prefixED->setText(toqstr(controller().params()["prefix"]));
109 dialog_->symbolED->setText(toqstr(controller().params()["symbol"]));
110 QString description = toqstr(controller().params()["description"]);
111 description.replace("\\\\","\n");
112 dialog_->descriptionTE->setPlainText(description);
114 bc().valid(isValid());
118 void GuiNomencl::apply()
120 controller().params()["prefix"] = qstring_to_ucs4(dialog_->prefixED->text());
121 controller().params()["symbol"] = qstring_to_ucs4(dialog_->symbolED->text());
122 QString description = dialog_->descriptionTE->toPlainText();
123 description.replace('\n',"\\\\");
124 controller().params()["description"] = qstring_to_ucs4(description);
128 bool GuiNomencl::isValid()
130 QString const description = dialog_->descriptionTE->toPlainText();
131 return !dialog_->symbolED->text().isEmpty() && !description.isEmpty();
134 } // namespace frontend
137 #include "GuiNomencl_moc.cpp"