summaryrefslogtreecommitdiff
path: root/client/widgets/widget.cc
diff options
context:
space:
mode:
authordeva <deva>2008-06-03 14:45:48 +0000
committerdeva <deva>2008-06-03 14:45:48 +0000
commit0febf6ea9cbd1a6e04e41339fc46d2e6b07da5e7 (patch)
treeda9cee1a15609b8aa2ed556160c5660819621db2 /client/widgets/widget.cc
parentbb3fad646f94739a876869464a484c99795bce61 (diff)
LUA rocks
Diffstat (limited to 'client/widgets/widget.cc')
-rw-r--r--client/widgets/widget.cc30
1 files changed, 13 insertions, 17 deletions
diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc
index d17754e..61e2a53 100644
--- a/client/widgets/widget.cc
+++ b/client/widgets/widget.cc
@@ -26,10 +26,12 @@
*/
#include "widget.h"
-Widget::Widget(QDomNode &node)
+Widget::Widget(QDomNode &node, MacroWindow *macrowindow)
{
QDomElement elem = node.toElement();
+ this->macrowindow = macrowindow;
+
if(elem.hasAttribute("name")) {
widget_name = elem.attribute("name");
} else {
@@ -37,11 +39,11 @@ Widget::Widget(QDomNode &node)
elem.tagName().toStdString().c_str());
}
- if(elem.hasAttribute("lua_validator")) {
- lua_validator = elem.attribute("lua_validator");
- hasluavalidator = true;
+ if(elem.hasAttribute("lua")) {
+ luaprogram = elem.attribute("lua");
+ hasluaprogram = true;
} else {
- hasluavalidator = false;
+ hasluaprogram = false;
}
if(elem.hasAttribute("regexp")) {
@@ -63,6 +65,10 @@ QString Widget::getValue()
return "";
}
+void Widget::setValue(QString)
+{
+}
+
bool Widget::isValid()
{
return regexpValidator() && luaValidator();
@@ -75,17 +81,7 @@ bool Widget::regexpValidator()
bool Widget::luaValidator()
{
- 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());
+ if(!hasluaprogram) return true;
- return result == "true";
+ return macrowindow->lua->run(luaprogram, getValue());
}