mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 19:07:45 +00:00
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
This commit is contained in:
parent
eb0c10b6b4
commit
5320ce0206
@ -46,6 +46,12 @@ void GuiLabel::paramsToDialog(Inset const * inset)
|
|||||||
{
|
{
|
||||||
InsetLabel const * label = static_cast<InsetLabel const *>(inset);
|
InsetLabel const * label = static_cast<InsetLabel const *>(inset);
|
||||||
InsetCommandParams const & params = label->params();
|
InsetCommandParams const & params = label->params();
|
||||||
|
paramsToDialog(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiLabel::paramsToDialog(InsetCommandParams const & params)
|
||||||
|
{
|
||||||
keywordED->setText(toqstr(params["name"]));
|
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
|
bool GuiLabel::checkWidgets() const
|
||||||
{
|
{
|
||||||
if (!InsetParamsWidget::checkWidgets())
|
if (!InsetParamsWidget::checkWidgets())
|
||||||
|
@ -33,9 +33,9 @@ private:
|
|||||||
InsetCode insetCode() const { return LABEL_CODE; }
|
InsetCode insetCode() const { return LABEL_CODE; }
|
||||||
FuncCode creationCode() const { return LFUN_INSET_INSERT; }
|
FuncCode creationCode() const { return LFUN_INSET_INSERT; }
|
||||||
void paramsToDialog(Inset const *);
|
void paramsToDialog(Inset const *);
|
||||||
|
void paramsToDialog(InsetCommandParams const & params);
|
||||||
docstring dialogToParams() const;
|
docstring dialogToParams() const;
|
||||||
bool checkWidgets() const;
|
bool checkWidgets() const;
|
||||||
bool initialiseParams(std::string const &);
|
|
||||||
//@}
|
//@}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
#include "InsetParamsWidget.h"
|
#include "InsetParamsWidget.h"
|
||||||
|
|
||||||
|
#include "insets/InsetCommand.h"
|
||||||
|
|
||||||
#include "qt_helpers.h"
|
#include "qt_helpers.h"
|
||||||
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
@ -58,6 +60,16 @@ bool InsetParamsWidget::checkWidgets() const
|
|||||||
return valid;
|
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 frontend
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ class QLineEdit;
|
|||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
class Inset;
|
class Inset;
|
||||||
|
class InsetCommandParams;
|
||||||
|
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
@ -66,8 +67,9 @@ public:
|
|||||||
///
|
///
|
||||||
virtual docstring dialogToParams() const = 0;
|
virtual docstring dialogToParams() const = 0;
|
||||||
///
|
///
|
||||||
virtual bool initialiseParams(std::string const & /* data */)
|
virtual void paramsToDialog(InsetCommandParams const & params) {}
|
||||||
{ return false; }
|
///
|
||||||
|
virtual bool initialiseParams(std::string const & data);
|
||||||
|
|
||||||
/// \return true if all CheckedWidgets are in a valid state.
|
/// \return true if all CheckedWidgets are in a valid state.
|
||||||
virtual bool checkWidgets() const;
|
virtual bool checkWidgets() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user