]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiNomencl.cpp
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / GuiNomencl.cpp
index 11acc63959c87f7633f4ee164b41deab76d13912..6aa35f827810c6e0fdbce6367a8fd21dc2b0a722 100644 (file)
 
 #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(LyXView & lv)
-       : GuiDialog(lv, "nomenclature")
+GuiNomenclature::GuiNomenclature(GuiView & lv)
+       : GuiDialog(lv, "nomenclature", qt_("Nomenclature")),
+         params_(insetCode("nomenclature"))
 {
        setupUi(this);
-       setController(new ControlCommand(*this, "nomenclature", "nomenclature"));
 
        connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
        connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
-       connect(symbolED, SIGNAL(textChanged(const QString&)),
+       connect(symbolED, SIGNAL(textChanged(QString)),
                this, SLOT(change_adaptor()));
        connect(descriptionTE, SIGNAL(textChanged()),
                this, SLOT(change_adaptor()));
@@ -53,60 +52,71 @@ GuiNomenclDialog::GuiNomenclDialog(LyXView & lv)
 }
 
 
-ControlCommand & GuiNomenclDialog::controller() const
-{
-       return static_cast<ControlCommand &>(GuiDialog::controller());
-}
-
-
-void GuiNomenclDialog::change_adaptor()
+void GuiNomenclature::change_adaptor()
 {
        changed();
 }
 
 
-void GuiNomenclDialog::reject()
+void GuiNomenclature::reject()
 {
        slotClose();
 }
 
 
-void GuiNomenclDialog::closeEvent(QCloseEvent * e)
+void GuiNomenclature::paramsToDialog(InsetCommandParams const & /*icp*/)
 {
-       slotClose();
-       e->accept();
-}
-
-
-void GuiNomenclDialog::update_contents()
-{
-       prefixED->setText(toqstr(controller().params()["prefix"]));
-       symbolED->setText(toqstr(controller().params()["symbol"]));
-       QString description = toqstr(controller().params()["description"]);
+       prefixED->setText(toqstr(params_["prefix"]));
+       symbolED->setText(toqstr(params_["symbol"]));
+       QString description = toqstr(params_["description"]);
        description.replace("\\\\","\n");
        descriptionTE->setPlainText(description);
+       descriptionTE->setFocus();
 
        bc().setValid(isValid());
 }
 
 
-void GuiNomenclDialog::applyView()
+void GuiNomenclature::applyView()
 {
-       controller().params()["prefix"] = qstring_to_ucs4(prefixED->text());
-       controller().params()["symbol"] = qstring_to_ucs4(symbolED->text());
+       params_["prefix"] = qstring_to_ucs4(prefixED->text());
+       params_["symbol"] = qstring_to_ucs4(symbolED->text());
        QString description = descriptionTE->toPlainText();
        description.replace('\n',"\\\\");
-       controller().params()["description"] = qstring_to_ucs4(description);
+       params_["description"] = qstring_to_ucs4(description);
 }
 
 
-bool GuiNomenclDialog::isValid()
+bool GuiNomenclature::isValid()
 {
        QString const description = descriptionTE->toPlainText();
        return !symbolED->text().isEmpty() && !description.isEmpty();
 }
 
+
+bool GuiNomenclature::initialiseParams(std::string const & data)
+{
+       InsetCommand::string2params("nomenclature", data, params_);
+       paramsToDialog(params_);
+       return true;
+}
+
+
+void GuiNomenclature::dispatchParams()
+{
+       std::string const lfun = InsetCommand::params2string("nomenclature", params_);
+       dispatch(FuncRequest(getLfun(), lfun));
+}
+
+
+
+Dialog * createGuiNomenclature(GuiView & lv)
+{
+       return new GuiNomenclature(lv);
+}
+
+
 } // namespace frontend
 } // namespace lyx
 
-#include "GuiNomencl_moc.cpp"
+#include "moc_GuiNomencl.cpp"