From 024c2a5905c3f82a360e636d9f7db9941e30db23 Mon Sep 17 00:00:00 2001 From: deva Date: Thu, 19 Aug 2010 12:52:30 +0000 Subject: More enable/valid fixes. --- client/widgets/widget.cc | 34 ++++++++++++++++++++++++++++------ client/widgets/widget.h | 2 ++ 2 files changed, 30 insertions(+), 6 deletions(-) (limited to 'client/widgets') diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc index 9e15bf2..4c44904 100644 --- a/client/widgets/widget.cc +++ b/client/widgets/widget.cc @@ -148,8 +148,12 @@ void Widget::setValid(bool valid, bool deep) void Widget::runEventOnChange(bool deep) { - if(enabled() && hasOnChangeEvent) - lua->runScript(onChangeEventScript, this, "onChange"); + if(enabled()) { + //if(preValid() == false) setWdgValid(false); + setWdgValid(valid()); + if(hasOnChangeEvent) + lua->runScript(onChangeEventScript, this, "onChange"); + } if(!deep) return; @@ -160,12 +164,30 @@ void Widget::runEventOnChange(bool deep) } } +void Widget::setWdgValidRecursive(bool forcevalid) +{ + if(forcevalid) setWdgValid(true); + else setWdgValid(valid()); + + QVector< Widget* >::iterator i = children.begin(); + while(i != children.end()) { + if(*i) (*i)->setWdgValidRecursive(forcevalid); + i++; + } +} + void Widget::setEnabled(bool enabled) { widget->setEnabled(enabled); - if(enabled) emit eventOnChange(); - else setValid(true, true); // Force disabled widgets to be valid + if(enabled == false) setWdgValidRecursive(true); + else setWdgValidRecursive(false); + /* + if(enabled) { + setValid(valid(), true); + emit eventOnChange(); + } else setValid(true, true); // Force disabled widgets to be valid + */ QVector< Widget* >::iterator i = children.begin(); while(i != children.end()) { if(*i) (*i)->runEventOnChange(true); @@ -204,7 +226,7 @@ bool Widget::setKeyboardFocus() Widget *Widget::findWidget(QString n, bool deep) { - DEBUG(widget, "Find Widget %p\n", this); + // DEBUG(widget, "Find Widget %p\n", this); if(n == name()) return this; @@ -224,7 +246,7 @@ Widget *Widget::findWidget(QString n, bool deep) QVector< Widget* > Widget::widgetList(bool deep) { - DEBUG(widget, "Widget List %p\n", this); + // DEBUG(widget, "Widget List %p\n", this); QVector< Widget* > lst; diff --git a/client/widgets/widget.h b/client/widgets/widget.h index 5d5f816..d964974 100644 --- a/client/widgets/widget.h +++ b/client/widgets/widget.h @@ -102,6 +102,8 @@ private: void createWidget(QDomNode &xml_node, QLayout *layout); QVector< Widget* > children; + void setWdgValidRecursive(bool valid); + // Store value in constructor to be set later. bool has_lazy; QString lazy_value; -- cgit v1.2.3