]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiNomencl.cpp
Complete the removal of the embedding stuff. Maybe. It's hard to be sure we got every...
[lyx.git] / src / frontends / qt4 / GuiNomencl.cpp
index 13abbeaa77ae3482a893ca9f939dbe01d28b42b3..b34ba798cd142146d63ecbfb5cdeb25f98a23cc3 100644 (file)
 
 #include "GuiNomencl.h"
 
-#include "debug.h"
-#include "ControlCommand.h"
 #include "qt_helpers.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)
+       : GuiCommand(lv, "nomenclature", qt_("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();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// GuiNomencl
-//
-/////////////////////////////////////////////////////////////////////
-
+       prefixED->setText(toqstr(params_["prefix"]));
+       symbolED->setText(toqstr(params_["symbol"]));
+       QString description = toqstr(params_["description"]);
+       description.replace("\\\\","\n");
+       descriptionTE->setPlainText(description);
 
-GuiNomencl::GuiNomencl(GuiDialog & parent, docstring const & title)
-       : GuiView<GuiNomenclDialog>(parent, title)
-{
+       bc().setValid(isValid());
 }
 
 
-void GuiNomencl::build_dialog()
+void GuiNomenclature::applyView()
 {
-       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);
+       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::update_contents()
+bool GuiNomenclature::isValid()
 {
-       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());
+       QString const description = descriptionTE->toPlainText();
+       return !symbolED->text().isEmpty() && !description.isEmpty();
 }
 
 
-void GuiNomencl::applyView()
+Dialog * createGuiNomenclature(GuiView & lv)
 {
-       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);
+       return new GuiNomenclature(lv);
 }
 
 
-bool GuiNomencl::isValid()
-{
-       QString const description = dialog_->descriptionTE->toPlainText();
-       return !dialog_->symbolED->text().isEmpty() && !description.isEmpty();
-}
-
 } // namespace frontend
 } // namespace lyx