From 5320ce020673013167a23a4221e2762603889453 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Sat, 30 Oct 2010 18:40:53 +0000 Subject: [PATCH] GuiLabel: generalize initialiseParams() and transfer to InsetParamsWidget as this will be used by other insets. The implementation of the new paramsToDialog(InsetCommandParams) is optional. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35933 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiLabel.cpp | 16 ++++++---------- src/frontends/qt4/GuiLabel.h | 2 +- src/frontends/qt4/InsetParamsWidget.cpp | 12 ++++++++++++ src/frontends/qt4/InsetParamsWidget.h | 6 ++++-- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/frontends/qt4/GuiLabel.cpp b/src/frontends/qt4/GuiLabel.cpp index d888ae07d8..570de61a4f 100644 --- a/src/frontends/qt4/GuiLabel.cpp +++ b/src/frontends/qt4/GuiLabel.cpp @@ -46,6 +46,12 @@ void GuiLabel::paramsToDialog(Inset const * inset) { InsetLabel const * label = static_cast(inset); InsetCommandParams const & params = label->params(); + paramsToDialog(params); +} + + +void GuiLabel::paramsToDialog(InsetCommandParams const & params) +{ keywordED->setText(toqstr(params["name"])); } @@ -58,16 +64,6 @@ docstring GuiLabel::dialogToParams() const } -bool GuiLabel::initialiseParams(std::string const & data) -{ - InsetCommandParams p(insetCode()); - if (!InsetCommand::string2params(data, p)) - return false; - keywordED->setText(toqstr(p["name"])); - return true; -} - - bool GuiLabel::checkWidgets() const { if (!InsetParamsWidget::checkWidgets()) diff --git a/src/frontends/qt4/GuiLabel.h b/src/frontends/qt4/GuiLabel.h index d616cbf1f5..bf0454f378 100644 --- a/src/frontends/qt4/GuiLabel.h +++ b/src/frontends/qt4/GuiLabel.h @@ -33,9 +33,9 @@ private: InsetCode insetCode() const { return LABEL_CODE; } FuncCode creationCode() const { return LFUN_INSET_INSERT; } void paramsToDialog(Inset const *); + void paramsToDialog(InsetCommandParams const & params); docstring dialogToParams() const; bool checkWidgets() const; - bool initialiseParams(std::string const &); //@} }; diff --git a/src/frontends/qt4/InsetParamsWidget.cpp b/src/frontends/qt4/InsetParamsWidget.cpp index 5eae61c9ca..51c3be3ab3 100644 --- a/src/frontends/qt4/InsetParamsWidget.cpp +++ b/src/frontends/qt4/InsetParamsWidget.cpp @@ -13,6 +13,8 @@ #include "InsetParamsWidget.h" +#include "insets/InsetCommand.h" + #include "qt_helpers.h" #include @@ -58,6 +60,16 @@ bool InsetParamsWidget::checkWidgets() const return valid; } + +bool InsetParamsWidget::initialiseParams(std::string const & data) +{ + InsetCommandParams p(insetCode()); + if (!InsetCommand::string2params(data, p)) + return false; + paramsToDialog(p); + return true; +} + } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt4/InsetParamsWidget.h b/src/frontends/qt4/InsetParamsWidget.h index df78c7e90f..9cccc0dac1 100644 --- a/src/frontends/qt4/InsetParamsWidget.h +++ b/src/frontends/qt4/InsetParamsWidget.h @@ -25,6 +25,7 @@ class QLineEdit; namespace lyx { class Inset; +class InsetCommandParams; namespace frontend { @@ -66,8 +67,9 @@ public: /// virtual docstring dialogToParams() const = 0; /// - virtual bool initialiseParams(std::string const & /* data */) - { return false; } + virtual void paramsToDialog(InsetCommandParams const & params) {} + /// + virtual bool initialiseParams(std::string const & data); /// \return true if all CheckedWidgets are in a valid state. virtual bool checkWidgets() const; -- 2.39.5