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"
20 #include "ButtonController.h"
23 #include <QPushButton>
26 #include <QCloseEvent>
33 /////////////////////////////////////////////////////////////////////
37 /////////////////////////////////////////////////////////////////////
39 QNomenclDialog::QNomenclDialog(QNomencl * 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 QNomenclDialog::show()
61 void QNomenclDialog::change_adaptor()
67 void QNomenclDialog::reject()
73 void QNomenclDialog::closeEvent(QCloseEvent * e)
80 /////////////////////////////////////////////////////////////////////
84 /////////////////////////////////////////////////////////////////////
87 typedef QController<ControlCommand, QView<QNomenclDialog> > NomenBase;
90 QNomencl::QNomencl(Dialog & parent, docstring const & title)
91 : NomenBase(parent, title)
96 void QNomencl::build_dialog()
98 dialog_.reset(new QNomenclDialog(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 QNomencl::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 QNomencl::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 QNomencl::isValid()
132 QString const description = dialog_->descriptionTE->toPlainText();
133 return !dialog_->symbolED->text().isEmpty() && !description.isEmpty();
136 } // namespace frontend
139 #include "QNomencl_moc.cpp"