diff options
author | deva <deva> | 2011-03-10 15:07:26 +0000 |
---|---|---|
committer | deva <deva> | 2011-03-10 15:07:26 +0000 |
commit | 3b4966ef4dbabbbc0fcb62b7b1a52ad9f327de1d (patch) | |
tree | f777d58b8cf08b6fa6a17e233c85eff91c82665f /client/widgets | |
parent | 56deeeb81d9ed9e535cb0f9a74f355eaed6281ec (diff) |
New lua functions: template(), macro(), user() and patientid(). New onInit lua callback attribute.
Diffstat (limited to 'client/widgets')
-rw-r--r-- | client/widgets/widget.cc | 24 | ||||
-rw-r--r-- | client/widgets/widget.h | 5 |
2 files changed, 29 insertions, 0 deletions
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__*/ |