From db19378bbe185f9bcbc3e67f63fa9434e18b0a7c Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Sat, 30 Jan 2010 15:30:49 +0000 Subject: [PATCH] GuiInfo: Migrate [New] push button slot to InsetDialog. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33276 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiInfo.cpp | 11 +---------- src/frontends/qt4/GuiInfo.h | 1 - src/frontends/qt4/InsetDialog.cpp | 18 +++++++++++++----- src/frontends/qt4/InsetDialog.h | 14 +++++++++++--- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/frontends/qt4/GuiInfo.cpp b/src/frontends/qt4/GuiInfo.cpp index 6c37c819f5..89ebfd298b 100644 --- a/src/frontends/qt4/GuiInfo.cpp +++ b/src/frontends/qt4/GuiInfo.cpp @@ -48,7 +48,7 @@ char const * info_types_gui[] = GuiInfo::GuiInfo(GuiView & lv) - : InsetDialog(lv, INFO_CODE, "info", qt_("Info")) + : InsetDialog(lv, INFO_CODE, LFUN_INFO_INSERT, "info", "Info") { setupUi(this); @@ -59,15 +59,6 @@ GuiInfo::GuiInfo(GuiView & lv) } -void GuiInfo::on_newPB_clicked() -{ - // FIXME: if we used a standard LFUN_INSET_INSERT command, - // This slot could be transferred to InsetDialog. - docstring const argument = dialogToParams(); - dispatch(FuncRequest(LFUN_INFO_INSERT, argument)); -} - - void GuiInfo::on_typeCO_currentIndexChanged(int) { applyView(); diff --git a/src/frontends/qt4/GuiInfo.h b/src/frontends/qt4/GuiInfo.h index 562a9a1faf..001a9a81af 100644 --- a/src/frontends/qt4/GuiInfo.h +++ b/src/frontends/qt4/GuiInfo.h @@ -34,7 +34,6 @@ public: //@} private Q_SLOTS: - void on_newPB_clicked(); void on_typeCO_currentIndexChanged(int); void on_nameLE_textChanged(QString const &); diff --git a/src/frontends/qt4/InsetDialog.cpp b/src/frontends/qt4/InsetDialog.cpp index 7f3e90fff7..38b543c165 100644 --- a/src/frontends/qt4/InsetDialog.cpp +++ b/src/frontends/qt4/InsetDialog.cpp @@ -38,9 +38,10 @@ namespace frontend { ///////////////////////////////////////////////////////////////// -InsetDialog::InsetDialog(GuiView & lv, InsetCode code, - QString const & name, QString const & title) - : DialogView(lv, name, title), code_(code) +InsetDialog::InsetDialog(GuiView & lv, InsetCode code, FuncCode creation_code, + char const * name, char const * display_name) + : DialogView(lv, name, qt_(display_name)), inset_code_(code), + creation_code_(creation_code) { } @@ -51,9 +52,16 @@ void InsetDialog::on_closePB_clicked() } +void InsetDialog::on_newPB_clicked() +{ + docstring const argument = dialogToParams(); + dispatch(FuncRequest(creation_code_, argument)); +} + + void InsetDialog::applyView() { - Inset const * i = inset(code_); + Inset const * i = inset(inset_code_); if (!i) return; @@ -67,7 +75,7 @@ void InsetDialog::applyView() void InsetDialog::updateView() { - Inset const * i = inset(code_); + Inset const * i = inset(inset_code_); if (i) paramsToDialog(i); else diff --git a/src/frontends/qt4/InsetDialog.h b/src/frontends/qt4/InsetDialog.h index d6595d188e..bf0336df0a 100644 --- a/src/frontends/qt4/InsetDialog.h +++ b/src/frontends/qt4/InsetDialog.h @@ -14,19 +14,22 @@ #include "DialogView.h" +#include "qt_i18n.h" + namespace lyx { class Inset; namespace frontend { + class InsetDialog : public DialogView { Q_OBJECT public: - InsetDialog(GuiView & lv, InsetCode code, - QString const & name, QString const & title); + InsetDialog(GuiView & lv, InsetCode code, FuncCode creation_code, + char const * name, char const * display_name); /// \name DialogView inherited methods //@{ @@ -38,6 +41,7 @@ public: //@} protected Q_SLOTS: + void on_newPB_clicked(); void on_closePB_clicked(); protected: @@ -45,8 +49,12 @@ protected: virtual void paramsToDialog(Inset const *) = 0; /// virtual docstring dialogToParams() const = 0; + +private: /// - InsetCode const code_; + InsetCode inset_code_; + /// + FuncCode creation_code_; }; } // namespace frontend