diff options
author | deva <deva> | 2008-06-02 13:52:54 +0000 |
---|---|---|
committer | deva <deva> | 2008-06-02 13:52:54 +0000 |
commit | 56be5c89d8121432478f58a886be5aee77a34866 (patch) | |
tree | f715e511a5347e7773a1a2a4d2ba886ac6d7e856 /client/widgets/widget.cc | |
parent | 322a83c48618b2f58e1014daff6f3956af8070ea (diff) |
First real shot at lua validation.
Diffstat (limited to 'client/widgets/widget.cc')
-rw-r--r-- | client/widgets/widget.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc index b128a53..d17754e 100644 --- a/client/widgets/widget.cc +++ b/client/widgets/widget.cc @@ -38,7 +38,7 @@ Widget::Widget(QDomNode &node) } if(elem.hasAttribute("lua_validator")) { - // lua_validator = elem.attribute("lua_validator"); + lua_validator = elem.attribute("lua_validator"); hasluavalidator = true; } else { hasluavalidator = false; @@ -75,5 +75,17 @@ bool Widget::regexpValidator() bool Widget::luaValidator() { - return !hasluavalidator || true; + if(!hasluavalidator) return true; + + Variables v; + v["value"] = getValue().toStdString(); + LUA lua(v); + + std::string program = lua_validator.toStdString(); + + std::string result = lua.run(program); + + // printf("Running [%s] => [%s]\n", program.c_str(), result.c_str()); + + return result == "true"; } |