From 175d195c0ed56487322a03939a1c60cb05cb3f8e Mon Sep 17 00:00:00 2001 From: deva Date: Wed, 13 Apr 2011 12:16:56 +0000 Subject: Introduce new committable/preCommit methods, that can be used to block a commit from inside the widgets. --- client/widgets/widget.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'client/widgets/widget.h') diff --git a/client/widgets/widget.h b/client/widgets/widget.h index bb37c51..3de148f 100644 --- a/client/widgets/widget.h +++ b/client/widgets/widget.h @@ -52,6 +52,9 @@ * value. * @att help This attribute contains a help text for this widget. It will be * shown to the user when the mouse is hovering over the widget. + * @att local This attribute is a boolean telling wether the field can be stored + * in the database on commits. It can be either 'true' or 'false'. The default + * is 'false'. */ class QLayout; @@ -75,6 +78,9 @@ public: bool valid(bool deep = false); void setValid(bool valid, bool deep = false); + // Make sanity check before commit. + bool committable(bool deep = false); + // Implement in subclasses to contribute to the validation. virtual bool preValid() { return true; } @@ -95,7 +101,8 @@ public: Widget *findWidget(QString name, bool deep = false); QVector< Widget* > widgetList(bool deep = false); void addChild(Widget *widget); - void setValues(); + + virtual void setValues(); signals: void wasChanged(); @@ -115,6 +122,11 @@ protected: QWidget *widget; bool hideChildren; + // Implement in subclasses to be able to block commits. + virtual bool preCommit() { return true; } + + // Overload this to avoid children 'wasChanged' connection. + virtual void connectChild(Widget *child); void addChildren(QDomNode &xml_node, QLayout *layout); LUA *lua; -- cgit v1.2.3