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.cc | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'client/widgets/widget.cc') diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc index 33e4309..c0c9e81 100644 --- a/client/widgets/widget.cc +++ b/client/widgets/widget.cc @@ -118,6 +118,21 @@ bool Widget::local() return widget_local; } +bool Widget::committable(bool deep) +{ + if(preCommit() == false) return false; + + if(deep == false) return true; + + QVector< Widget* >::iterator i = children.begin(); + while(i != children.end()) { + if(*i && (*i)->committable(deep) == false) return false; + i++; + } + + return true; +} + bool Widget::valid(bool deep) { if(enabled() == false) return true; @@ -288,6 +303,11 @@ void Widget::childWasChanged() emit wasChanged(); } +void Widget::connectChild(Widget *child) +{ + connect(child, SIGNAL(wasChanged()), this, SLOT(childWasChanged())); +} + void Widget::addChild(Widget *widget) { if(widget == NULL) { @@ -296,7 +316,7 @@ void Widget::addChild(Widget *widget) return; } children.push_back(widget); - connect(widget, SIGNAL(wasChanged()), this, SLOT(childWasChanged())); + connectChild(widget); //widget->setParent(this); } -- cgit v1.2.3