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
This commit is contained in:
Abdelrazak Younes 2010-01-30 15:30:49 +00:00
parent 01897c7013
commit db19378bbe
4 changed files with 25 additions and 19 deletions

View File

@ -48,7 +48,7 @@ char const * info_types_gui[] =
GuiInfo::GuiInfo(GuiView & lv) GuiInfo::GuiInfo(GuiView & lv)
: InsetDialog(lv, INFO_CODE, "info", qt_("Info")) : InsetDialog(lv, INFO_CODE, LFUN_INFO_INSERT, "info", "Info")
{ {
setupUi(this); 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) void GuiInfo::on_typeCO_currentIndexChanged(int)
{ {
applyView(); applyView();

View File

@ -34,7 +34,6 @@ public:
//@} //@}
private Q_SLOTS: private Q_SLOTS:
void on_newPB_clicked();
void on_typeCO_currentIndexChanged(int); void on_typeCO_currentIndexChanged(int);
void on_nameLE_textChanged(QString const &); void on_nameLE_textChanged(QString const &);

View File

@ -38,9 +38,10 @@ namespace frontend {
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
InsetDialog::InsetDialog(GuiView & lv, InsetCode code, InsetDialog::InsetDialog(GuiView & lv, InsetCode code, FuncCode creation_code,
QString const & name, QString const & title) char const * name, char const * display_name)
: DialogView(lv, name, title), code_(code) : 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() void InsetDialog::applyView()
{ {
Inset const * i = inset(code_); Inset const * i = inset(inset_code_);
if (!i) if (!i)
return; return;
@ -67,7 +75,7 @@ void InsetDialog::applyView()
void InsetDialog::updateView() void InsetDialog::updateView()
{ {
Inset const * i = inset(code_); Inset const * i = inset(inset_code_);
if (i) if (i)
paramsToDialog(i); paramsToDialog(i);
else else

View File

@ -14,19 +14,22 @@
#include "DialogView.h" #include "DialogView.h"
#include "qt_i18n.h"
namespace lyx { namespace lyx {
class Inset; class Inset;
namespace frontend { namespace frontend {
class InsetDialog : public DialogView class InsetDialog : public DialogView
{ {
Q_OBJECT Q_OBJECT
public: public:
InsetDialog(GuiView & lv, InsetCode code, InsetDialog(GuiView & lv, InsetCode code, FuncCode creation_code,
QString const & name, QString const & title); char const * name, char const * display_name);
/// \name DialogView inherited methods /// \name DialogView inherited methods
//@{ //@{
@ -38,6 +41,7 @@ public:
//@} //@}
protected Q_SLOTS: protected Q_SLOTS:
void on_newPB_clicked();
void on_closePB_clicked(); void on_closePB_clicked();
protected: protected:
@ -45,8 +49,12 @@ protected:
virtual void paramsToDialog(Inset const *) = 0; virtual void paramsToDialog(Inset const *) = 0;
/// ///
virtual docstring dialogToParams() const = 0; virtual docstring dialogToParams() const = 0;
private:
/// ///
InsetCode const code_; InsetCode inset_code_;
///
FuncCode creation_code_;
}; };
} // namespace frontend } // namespace frontend