]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiBibitem.cpp
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / GuiBibitem.cpp
index 746e647edbebae09db26750fe2c1667e585a6f98..20285f8daa224d5ac73959a1a91843e4584c8932 100644 (file)
 #include <config.h>
 
 #include "GuiBibitem.h"
-#include "ControlCommand.h"
 #include "qt_helpers.h"
+#include "FuncRequest.h"
+
+#include "insets/InsetCommand.h"
 
-#include <QCloseEvent>
 #include <QLineEdit>
 #include <QPushButton>
 
@@ -23,19 +24,18 @@ namespace lyx {
 namespace frontend {
 
 
-GuiBibitemDialog::GuiBibitemDialog(LyXView & lv)
-       : GuiDialog(lv, "bibitem")
+GuiBibitem::GuiBibitem(GuiView & lv)
+       : GuiDialog(lv, "bibitem", qt_("Bibliography Entry Settings")),
+         params_(insetCode("bibitem"))
 {
        setupUi(this);
-       setViewTitle(_("Bibliography Entry Settings"));
-       setController(new ControlCommand(*this, "bibitem", "bibitem"));
 
        connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
        connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
 
-       connect(keyED, SIGNAL(textChanged(const QString &)),
+       connect(keyED, SIGNAL(textChanged(QString)),
                this, SLOT(change_adaptor()));
-       connect(labelED, SIGNAL(textChanged(const QString &)),
+       connect(labelED, SIGNAL(textChanged(QString)),
                this, SLOT(change_adaptor()));
 
        bc().setPolicy(ButtonPolicy::OkCancelReadOnlyPolicy);
@@ -46,45 +46,52 @@ GuiBibitemDialog::GuiBibitemDialog(LyXView & lv)
 }
 
 
-ControlCommand & GuiBibitemDialog::controller() const
+void GuiBibitem::change_adaptor()
 {
-       return static_cast<ControlCommand &>(GuiDialog::controller());
+       changed();
 }
 
 
-void GuiBibitemDialog::change_adaptor()
+void GuiBibitem::updateContents()
 {
-       changed();
+       keyED->setText(toqstr(params_["key"]));
+       labelED->setText(toqstr(params_["label"]));
 }
 
 
-void GuiBibitemDialog::closeEvent(QCloseEvent *e)
+void GuiBibitem::applyView()
 {
-       slotWMHide();
-       e->accept();
+       params_["key"] = qstring_to_ucs4(keyED->text());
+       params_["label"] = qstring_to_ucs4(labelED->text());
 }
 
 
-void GuiBibitemDialog::update_contents()
+bool GuiBibitem::isValid()
 {
-       keyED->setText(toqstr(controller().params()["key"]));
-       labelED->setText(toqstr(controller().params()["label"]));
+       return !keyED->text().isEmpty();
 }
 
 
-void GuiBibitemDialog::applyView()
+bool GuiBibitem::initialiseParams(std::string const & data)
 {
-       controller().params()["key"] = qstring_to_ucs4(keyED->text());
-       controller().params()["label"] = qstring_to_ucs4(labelED->text());
+       // The name passed with LFUN_INSET_APPLY is also the name
+       // used to identify the mailer.
+       InsetCommand::string2params("bibitem", data, params_);
+       return true;
 }
 
 
-bool GuiBibitemDialog::isValid()
+void GuiBibitem::dispatchParams()
 {
-       return !keyED->text().isEmpty();
+       std::string const lfun = InsetCommand::params2string("bibitem", params_);
+       dispatch(FuncRequest(getLfun(), lfun));
 }
 
+
+Dialog * createGuiBibitem(GuiView & lv) { return new GuiBibitem(lv); }
+
+
 } // namespace frontend
 } // namespace lyx
 
-#include "GuiBibitem_moc.cpp"
+#include "moc_GuiBibitem.cpp"