X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiBibitem.cpp;h=20285f8daa224d5ac73959a1a91843e4584c8932;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=88512371c3e94769253f48cfde6025ad81306b5e;hpb=fc36725282df43059aee9a821f098309ccdbd523;p=lyx.git diff --git a/src/frontends/qt4/GuiBibitem.cpp b/src/frontends/qt4/GuiBibitem.cpp index 88512371c3..20285f8daa 100644 --- a/src/frontends/qt4/GuiBibitem.cpp +++ b/src/frontends/qt4/GuiBibitem.cpp @@ -11,10 +11,11 @@ #include #include "GuiBibitem.h" -#include "Qt2BC.h" #include "qt_helpers.h" +#include "FuncRequest.h" + +#include "insets/InsetCommand.h" -#include #include #include @@ -22,83 +23,75 @@ 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(Dialog & parent) - : GuiView(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)); - - bcview().setOK(dialog_->okPB); - bcview().setCancel(dialog_->closePB); - bcview().addReadOnly(dialog_->keyED); - bcview().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::apply() +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 -#include "GuiBibitem_moc.cpp" +#include "moc_GuiBibitem.cpp"