]> 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 c244354e8c1b6a848798d741b505efc64aa7bb42..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,66 +52,71 @@ GuiNomenclDialog::GuiNomenclDialog(LyXView & lv)
 }
 
 
-ControlCommand & GuiNomenclDialog::controller() const
+void GuiNomenclature::change_adaptor()
 {
-       return static_cast<ControlCommand &>(Dialog::controller());
+       changed();
 }
 
 
-void GuiNomenclDialog::showView()
+void GuiNomenclature::reject()
 {
-       QDialog::show();
+       slotClose();
 }
 
 
-void GuiNomenclDialog::change_adaptor()
+void GuiNomenclature::paramsToDialog(InsetCommandParams const & /*icp*/)
 {
-       changed();
+       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::reject()
+void GuiNomenclature::applyView()
 {
-       slotClose();
+       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 GuiNomenclDialog::closeEvent(QCloseEvent * e)
+bool GuiNomenclature::isValid()
 {
-       slotWMHide();
-       e->accept();
+       QString const description = descriptionTE->toPlainText();
+       return !symbolED->text().isEmpty() && !description.isEmpty();
 }
 
 
-void GuiNomenclDialog::update_contents()
+bool GuiNomenclature::initialiseParams(std::string const & data)
 {
-       prefixED->setText(toqstr(controller().params()["prefix"]));
-       symbolED->setText(toqstr(controller().params()["symbol"]));
-       QString description = toqstr(controller().params()["description"]);
-       description.replace("\\\\","\n");
-       descriptionTE->setPlainText(description);
-
-       bc().setValid(isValid());
+       InsetCommand::string2params("nomenclature", data, params_);
+       paramsToDialog(params_);
+       return true;
 }
 
 
-void GuiNomenclDialog::applyView()
+void GuiNomenclature::dispatchParams()
 {
-       controller().params()["prefix"] = qstring_to_ucs4(prefixED->text());
-       controller().params()["symbol"] = qstring_to_ucs4(symbolED->text());
-       QString description = 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 GuiNomenclDialog::isValid()
+
+Dialog * createGuiNomenclature(GuiView & lv)
 {
-       QString const description = descriptionTE->toPlainText();
-       return !symbolED->text().isEmpty() && !description.isEmpty();
+       return new GuiNomenclature(lv);
 }
 
+
 } // namespace frontend
 } // namespace lyx
 
-#include "GuiNomencl_moc.cpp"
+#include "moc_GuiNomencl.cpp"