From 3b4966ef4dbabbbc0fcb62b7b1a52ad9f327de1d Mon Sep 17 00:00:00 2001 From: deva Date: Thu, 10 Mar 2011 15:07:26 +0000 Subject: New lua functions: template(), macro(), user() and patientid(). New onInit lua callback attribute. --- client/widgets/widget.cc | 24 ++++++++++++++++++++++++ client/widgets/widget.h | 5 +++++ 2 files changed, 29 insertions(+) (limited to 'client/widgets') diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc index 1fefae8..085ac21 100644 --- a/client/widgets/widget.cc +++ b/client/widgets/widget.cc @@ -62,11 +62,17 @@ Widget::Widget(QDomNode &node, MacroWindow *macrowindow) hasOnChangeEvent = elem.hasAttribute("onChange"); onChangeEventScript = elem.attribute("onChange", ""); + hasOnInitEvent = elem.hasAttribute("onInit"); + onInitEventScript = elem.attribute("onInit", ""); + is_valid = true; connect(this, SIGNAL(eventOnChange()), this, SLOT(runEventOnChange()), Qt::QueuedConnection); + connect(this, SIGNAL(eventOnInit()), + this, SLOT(runEventOnInit()), Qt::QueuedConnection); + DEBUG(widget, "Create Widget '%s' of type '%s'\n", name().toStdString().c_str(), type().toStdString().c_str()); @@ -160,6 +166,24 @@ void Widget::runEventOnChange(bool deep) } } +void Widget::runEventOnInit(bool deep) +{ + if(enabled()) { + //if(preValid() == false) setWdgValid(false); + setWdgValid(valid()); + if(hasOnInitEvent) + lua->runScript(onInitEventScript, this, "onInit"); + } + + if(!deep) return; + + QVector< Widget* >::iterator i = children.begin(); + while(i != children.end()) { + if(*i) (*i)->runEventOnInit(deep); + i++; + } +} + void Widget::setWdgValidRecursive(bool forcevalid) { if(forcevalid) setWdgValid(true); diff --git a/client/widgets/widget.h b/client/widgets/widget.h index d964974..37a365f 100644 --- a/client/widgets/widget.h +++ b/client/widgets/widget.h @@ -85,10 +85,12 @@ signals: * LUA scripting events: */ void eventOnChange(bool deep = false); + void eventOnInit(bool deep = false); public slots: void childWasChanged(); void runEventOnChange(bool deep = false); + void runEventOnInit(bool deep = false); protected: QWidget *widget; @@ -118,6 +120,9 @@ private: bool hasOnChangeEvent; QString onChangeEventScript; + + bool hasOnInitEvent; + QString onInitEventScript; }; #endif/*__PRACRO_WIDGET_H__*/ -- cgit v1.2.3