#include "GuiBibitem.h"
#include "qt_helpers.h"
+#include "FuncRequest.h"
+
+#include "insets/InsetCommand.h"
-#include <QCloseEvent>
#include <QLineEdit>
#include <QPushButton>
namespace lyx {
namespace frontend {
-/////////////////////////////////////////////////////////////////////
-//
-// GuiBibItemDialog
-//
-/////////////////////////////////////////////////////////////////////
-GuiBibitemDialog::GuiBibitemDialog(GuiBibitem * form)
- : form_(form)
+GuiBibitem::GuiBibitem(GuiView & lv)
+ : GuiDialog(lv, "bibitem", qt_("Bibliography Entry Settings")),
+ params_(insetCode("bibitem"))
{
setupUi(this);
- connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
- connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
- connect(keyED, SIGNAL(textChanged(const QString &)),
+ connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
+ connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
+
+ 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);
+ bc().setOK(okPB);
+ bc().setCancel(closePB);
+ bc().addReadOnly(keyED);
+ bc().addReadOnly(labelED);
}
-void GuiBibitemDialog::change_adaptor()
+void GuiBibitem::change_adaptor()
{
- form_->changed();
+ changed();
}
-void GuiBibitemDialog::closeEvent(QCloseEvent *e)
+void GuiBibitem::updateContents()
{
- form_->slotWMHide();
- e->accept();
+ keyED->setText(toqstr(params_["key"]));
+ labelED->setText(toqstr(params_["label"]));
}
-/////////////////////////////////////////////////////////////////////
-//
-// GuiBibItem
-//
-/////////////////////////////////////////////////////////////////////
-
-
-GuiBibitem::GuiBibitem(GuiDialog & parent)
- : GuiView<GuiBibitemDialog>(parent, _("Bibliography Entry Settings"))
+void GuiBibitem::applyView()
{
+ params_["key"] = qstring_to_ucs4(keyED->text());
+ params_["label"] = qstring_to_ucs4(labelED->text());
}
-void GuiBibitem::build_dialog()
+bool GuiBibitem::isValid()
{
- dialog_.reset(new GuiBibitemDialog(this));
-
- bc().setOK(dialog_->okPB);
- bc().setCancel(dialog_->closePB);
- bc().addReadOnly(dialog_->keyED);
- bc().addReadOnly(dialog_->labelED);
+ return !keyED->text().isEmpty();
}
-void GuiBibitem::update_contents()
+bool GuiBibitem::initialiseParams(std::string const & data)
{
- dialog_->keyED->setText(toqstr(controller().params()["key"]));
- dialog_->labelED->setText(toqstr(controller().params()["label"]));
+ // The name passed with LFUN_INSET_APPLY is also the name
+ // used to identify the mailer.
+ InsetCommand::string2params("bibitem", data, params_);
+ return true;
}
-void GuiBibitem::applyView()
+void GuiBibitem::dispatchParams()
{
- controller().params()["key"] = qstring_to_ucs4(dialog_->keyED->text());
- controller().params()["label"] = qstring_to_ucs4(dialog_->labelED->text());
+ std::string const lfun = InsetCommand::params2string("bibitem", params_);
+ dispatch(FuncRequest(getLfun(), lfun));
}
-bool GuiBibitem::isValid()
-{
- return !dialog_->keyED->text().isEmpty();
-}
+Dialog * createGuiBibitem(GuiView & lv) { return new GuiBibitem(lv); }
+
} // namespace frontend
} // namespace lyx