diff --git a/src/frontends/qt4/Dialogs.cpp b/src/frontends/qt4/Dialogs.cpp index 35c2d6ca07..64962d0615 100644 --- a/src/frontends/qt4/Dialogs.cpp +++ b/src/frontends/qt4/Dialogs.cpp @@ -16,7 +16,6 @@ #include "ButtonController.h" #include "DialogView.h" #include "DockView.h" -#include "GuiBibitem.h" #include "GuiDelimiter.h" #include "GuiIndex.h" #include "GuiMathMatrix.h" @@ -96,7 +95,7 @@ Dialog * createGuiLog(LyXView & lv); Dialog * createGuiMath(LyXView & lv); Dialog * createGuiNomencl(LyXView & lv); Dialog * createGuiNote(LyXView & lv); -Dialog * createGuiParagraph(LyXView & lv) +Dialog * createGuiParagraph(LyXView & lv); Dialog * createGuiPreferences(LyXView & lv); Dialog * createGuiPrint(LyXView & lv); Dialog * createGuiRef(LyXView & lv); @@ -129,7 +128,7 @@ Dialog * Dialogs::build(string const & name) if (name == "aboutlyx") return createGuiAbout(lyxview_); if (name == "bibitem") - return new GuiBibitemDialog(lyxview_); + return createGuiBibitem(lyxview_); if (name == "bibtex") return createGuiBibtex(lyxview_); if (name == "box") diff --git a/src/frontends/qt4/GuiBibitem.cpp b/src/frontends/qt4/GuiBibitem.cpp index 2a9294d19f..7f49de22b4 100644 --- a/src/frontends/qt4/GuiBibitem.cpp +++ b/src/frontends/qt4/GuiBibitem.cpp @@ -13,6 +13,9 @@ #include "GuiBibitem.h" #include "ControlCommand.h" #include "qt_helpers.h" +#include "FuncRequest.h" + +#include "insets/InsetCommand.h" #include #include @@ -23,19 +26,19 @@ namespace lyx { namespace frontend { -GuiBibitemDialog::GuiBibitemDialog(LyXView & lv) - : GuiDialog(lv, "bibitem") +GuiBibitem::GuiBibitem(LyXView & lv) + : GuiDialog(lv, "bibitem"), Controller(this), params_("bibitem") { setupUi(this); setViewTitle(_("Bibliography Entry Settings")); - setController(new ControlCommand(*this, "bibitem")); + setController(this, false); 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,44 +49,58 @@ GuiBibitemDialog::GuiBibitemDialog(LyXView & lv) } -ControlCommand & GuiBibitemDialog::controller() -{ - return static_cast(GuiDialog::controller()); -} - - -void GuiBibitemDialog::change_adaptor() +void GuiBibitem::change_adaptor() { changed(); } -void GuiBibitemDialog::closeEvent(QCloseEvent *e) +void GuiBibitem::closeEvent(QCloseEvent *e) { slotClose(); e->accept(); } -void GuiBibitemDialog::updateContents() +void GuiBibitem::updateContents() { - keyED->setText(toqstr(controller().params()["key"])); - labelED->setText(toqstr(controller().params()["label"])); + keyED->setText(toqstr(params_["key"])); + labelED->setText(toqstr(params_["label"])); } -void GuiBibitemDialog::applyView() +void GuiBibitem::applyView() { - controller().params()["key"] = qstring_to_ucs4(keyED->text()); - controller().params()["label"] = qstring_to_ucs4(labelED->text()); + params_["key"] = qstring_to_ucs4(keyED->text()); + params_["label"] = qstring_to_ucs4(labelED->text()); } -bool GuiBibitemDialog::isValid() +bool GuiBibitem::isValid() { return !keyED->text().isEmpty(); } + +bool GuiBibitem::initialiseParams(std::string const & data) +{ + // The name passed with LFUN_INSET_APPLY is also the name + // used to identify the mailer. + InsetCommandMailer::string2params("bibitem", data, params_); + return true; +} + + +void GuiBibitem::dispatchParams() +{ + std::string const lfun = InsetCommandMailer::params2string("bibitem", params_); + dispatch(FuncRequest(getLfun(), lfun)); +} + + +Dialog * createGuiBibitem(LyXView & lv) { return new GuiBibitem(lv); } + + } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt4/GuiBibitem.h b/src/frontends/qt4/GuiBibitem.h index 671021a130..e096be582c 100644 --- a/src/frontends/qt4/GuiBibitem.h +++ b/src/frontends/qt4/GuiBibitem.h @@ -4,6 +4,7 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * + * \author Angus Leeming * \author John Levon * * Full author contact details are available in file CREDITS. @@ -13,18 +14,21 @@ #define GUIBIBITEM_H #include "GuiDialog.h" -#include "ControlCommand.h" #include "ui_BibitemUi.h" +#include "frontends/Dialog.h" + +#include "insets/InsetCommandParams.h" + namespace lyx { namespace frontend { -class GuiBibitemDialog : public GuiDialog, public Ui::BibitemUi +class GuiBibitem : public GuiDialog, public Ui::BibitemUi, public Controller { Q_OBJECT public: - GuiBibitemDialog(LyXView & lv); + GuiBibitem(LyXView & lv); private Q_SLOTS: void change_adaptor(); @@ -33,7 +37,7 @@ private: /// void closeEvent(QCloseEvent * e); /// parent controller - ControlCommand & controller(); + Controller & controller() { return *this; } private: /// @@ -42,6 +46,18 @@ private: void applyView(); /// update void updateContents(); + /// + bool initialiseParams(std::string const & data); + /// clean-up on hide. + void clearParams() { params_.clear(); } + /// clean-up on hide. + void dispatchParams(); + /// + bool isBufferDependent() const { return true; } + +private: + /// + InsetCommandParams params_; }; } // namespace frontend diff --git a/src/frontends/qt4/GuiParagraph.cpp b/src/frontends/qt4/GuiParagraph.cpp index 55704b0f04..5f69174299 100644 --- a/src/frontends/qt4/GuiParagraph.cpp +++ b/src/frontends/qt4/GuiParagraph.cpp @@ -22,6 +22,9 @@ #include "gettext.h" #include "ParagraphParameters.h" #include "Spacing.h" +#include "GuiView.h" +#include "DialogView.h" +#include "DockView.h" #include #include @@ -251,10 +254,10 @@ Dialog * createGuiParagraph(LyXView & lv) { GuiViewBase & guiview = static_cast(lv); #ifdef USE_DOCK_WIDGET - return new DockView(guiview, name, + return new DockView(guiview, "paragraph", Qt::TopDockWidgetArea); #else - return new DialogView(guiview, name); + return new DialogView(guiview, "paragraph"); #endif }