#include "GuiNomencl.h"
-#include "debug.h"
-#include "ControlCommand.h"
#include "qt_helpers.h"
+#include "FuncRequest.h"
+
+#include "insets/InsetCommand.h"
+
+#include "support/debug.h"
#include <QLabel>
#include <QLineEdit>
-#include <QPushButton>
-#include <QTextEdit>
-#include <QWhatsThis>
-#include <QCloseEvent>
-using std::string;
+using namespace std;
namespace lyx {
namespace frontend {
-/////////////////////////////////////////////////////////////////////
-//
-// GuiNomenclDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-GuiNomenclDialog::GuiNomenclDialog(GuiNomencl * form)
- : form_(form)
+GuiNomenclature::GuiNomenclature(GuiView & lv)
+ : GuiDialog(lv, "nomenclature", qt_("Nomenclature")),
+ params_(insetCode("nomenclature"))
{
setupUi(this);
- connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
- connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
- connect(symbolED, SIGNAL(textChanged(const QString&)),
+ connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
+ connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
+ connect(symbolED, SIGNAL(textChanged(QString)),
this, SLOT(change_adaptor()));
connect(descriptionTE, SIGNAL(textChanged()),
this, SLOT(change_adaptor()));
setFocusProxy(descriptionTE);
-}
-
-void GuiNomenclDialog::showView()
-{
- QDialog::show();
+ bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
+ bc().setOK(okPB);
+ bc().setCancel(closePB);
+ bc().addReadOnly(symbolED);
+ bc().addReadOnly(descriptionTE);
+ bc().addReadOnly(prefixED);
}
-void GuiNomenclDialog::change_adaptor()
+void GuiNomenclature::change_adaptor()
{
- form_->changed();
+ changed();
}
-void GuiNomenclDialog::reject()
+void GuiNomenclature::reject()
{
- form_->slotClose();
+ slotClose();
}
-void GuiNomenclDialog::closeEvent(QCloseEvent * e)
+void GuiNomenclature::updateContents()
{
- form_->slotWMHide();
- e->accept();
-}
-
+ prefixED->setText(toqstr(params_["prefix"]));
+ symbolED->setText(toqstr(params_["symbol"]));
+ QString description = toqstr(params_["description"]);
+ description.replace("\\\\","\n");
+ descriptionTE->setPlainText(description);
-/////////////////////////////////////////////////////////////////////
-//
-// GuiNomencl
-//
-/////////////////////////////////////////////////////////////////////
+ bc().setValid(isValid());
+}
-GuiNomencl::GuiNomencl(GuiDialog & parent, docstring const & title)
- : GuiView<GuiNomenclDialog>(parent, title)
+void GuiNomenclature::applyView()
{
+ params_["prefix"] = qstring_to_ucs4(prefixED->text());
+ params_["symbol"] = qstring_to_ucs4(symbolED->text());
+ QString description = descriptionTE->toPlainText();
+ description.replace('\n',"\\\\");
+ params_["description"] = qstring_to_ucs4(description);
}
-void GuiNomencl::build_dialog()
+bool GuiNomenclature::isValid()
{
- dialog_.reset(new GuiNomenclDialog(this));
-
- bc().setOK(dialog_->okPB);
- bc().setCancel(dialog_->closePB);
- bc().addReadOnly(dialog_->symbolED);
- bc().addReadOnly(dialog_->descriptionTE);
- bc().addReadOnly(dialog_->prefixED);
+ QString const description = descriptionTE->toPlainText();
+ return !symbolED->text().isEmpty() && !description.isEmpty();
}
-void GuiNomencl::update_contents()
+bool GuiNomenclature::initialiseParams(std::string const & data)
{
- dialog_->prefixED->setText(toqstr(controller().params()["prefix"]));
- dialog_->symbolED->setText(toqstr(controller().params()["symbol"]));
- QString description = toqstr(controller().params()["description"]);
- description.replace("\\\\","\n");
- dialog_->descriptionTE->setPlainText(description);
-
- bc().setValid(isValid());
+ InsetCommand::string2params("nomenclature", data, params_);
+ return true;
}
-void GuiNomencl::applyView()
+void GuiNomenclature::dispatchParams()
{
- controller().params()["prefix"] = qstring_to_ucs4(dialog_->prefixED->text());
- controller().params()["symbol"] = qstring_to_ucs4(dialog_->symbolED->text());
- QString description = dialog_->descriptionTE->toPlainText();
- description.replace('\n',"\\\\");
- controller().params()["description"] = qstring_to_ucs4(description);
+ std::string const lfun = InsetCommand::params2string("nomenclature", params_);
+ dispatch(FuncRequest(getLfun(), lfun));
}
-bool GuiNomencl::isValid()
+
+Dialog * createGuiNomenclature(GuiView & lv)
{
- QString const description = dialog_->descriptionTE->toPlainText();
- return !dialog_->symbolED->text().isEmpty() && !description.isEmpty();
+ return new GuiNomenclature(lv);
}
+
} // namespace frontend
} // namespace lyx