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"
23 #include <QPushButton>
26 #include <QCloseEvent>
33 /////////////////////////////////////////////////////////////////////
37 /////////////////////////////////////////////////////////////////////
39 GuiNomenclDialog::GuiNomenclDialog(GuiNomencl * form)
44 connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
45 connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
46 connect(symbolED, SIGNAL(textChanged(const QString&)),
47 this, SLOT(change_adaptor()));
48 connect(descriptionTE, SIGNAL(textChanged()),
49 this, SLOT(change_adaptor()));
51 setFocusProxy(descriptionTE);
55 void GuiNomenclDialog::show()
61 void GuiNomenclDialog::change_adaptor()
67 void GuiNomenclDialog::reject()
73 void GuiNomenclDialog::closeEvent(QCloseEvent * e)
80 /////////////////////////////////////////////////////////////////////
84 /////////////////////////////////////////////////////////////////////
87 typedef QController<ControlCommand, GuiView<GuiNomenclDialog> > NomenBase;
90 GuiNomencl::GuiNomencl(Dialog & parent, docstring const & title)
91 : NomenBase(parent, title)
96 void GuiNomencl::build_dialog()
98 dialog_.reset(new GuiNomenclDialog(this));
100 bcview().setOK(dialog_->okPB);
101 bcview().setCancel(dialog_->closePB);
102 bcview().addReadOnly(dialog_->symbolED);
103 bcview().addReadOnly(dialog_->descriptionTE);
104 bcview().addReadOnly(dialog_->prefixED);
108 void GuiNomencl::update_contents()
110 dialog_->prefixED->setText(toqstr(controller().params()["prefix"]));
111 dialog_->symbolED->setText(toqstr(controller().params()["symbol"]));
112 QString description = toqstr(controller().params()["description"]);
113 description.replace("\\\\","\n");
114 dialog_->descriptionTE->setPlainText(description);
116 bc().valid(isValid());
120 void GuiNomencl::apply()
122 controller().params()["prefix"] = qstring_to_ucs4(dialog_->prefixED->text());
123 controller().params()["symbol"] = qstring_to_ucs4(dialog_->symbolED->text());
124 QString description = dialog_->descriptionTE->toPlainText();
125 description.replace('\n',"\\\\");
126 controller().params()["description"] = qstring_to_ucs4(description);
130 bool GuiNomencl::isValid()
132 QString const description = dialog_->descriptionTE->toPlainText();
133 return !dialog_->symbolED->text().isEmpty() && !description.isEmpty();
136 } // namespace frontend
139 #include "GuiNomencl_moc.cpp"