summaryrefslogtreecommitdiff
path: root/client/widgets/widget.cc
diff options
context:
space:
mode:
Diffstat (limited to 'client/widgets/widget.cc')
-rw-r--r--client/widgets/widget.cc40
1 files changed, 33 insertions, 7 deletions
diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc
index 5a433e9..b128a53 100644
--- a/client/widgets/widget.cc
+++ b/client/widgets/widget.cc
@@ -26,20 +26,31 @@
*/
#include "widget.h"
-//Widget::Widget(QString parent_name, QDomNode node)
-Widget::Widget(QDomNode node)
+Widget::Widget(QDomNode &node)
{
QDomElement elem = node.toElement();
if(elem.hasAttribute("name")) {
- //if(parent_name != "")
- // widget_name = parent_name + "." + elem.attribute("name");
- //else
- widget_name = elem.attribute("name");
+ widget_name = elem.attribute("name");
} else {
printf("XML ERROR!! Unnamed widget of type: %s\n",
elem.tagName().toStdString().c_str());
}
+
+ if(elem.hasAttribute("lua_validator")) {
+ // lua_validator = elem.attribute("lua_validator");
+ hasluavalidator = true;
+ } else {
+ hasluavalidator = false;
+ }
+
+ if(elem.hasAttribute("regexp")) {
+ rx = QRegExp(elem.attribute("regexp"));
+ hasregexpvalidator = true;
+ } else {
+ hasregexpvalidator = false;
+ }
+
}
QString Widget::getName()
@@ -47,7 +58,22 @@ QString Widget::getName()
return widget_name;
}
+QString Widget::getValue()
+{
+ return "";
+}
+
bool Widget::isValid()
{
- return true;
+ return regexpValidator() && luaValidator();
+}
+
+bool Widget::regexpValidator()
+{
+ return !hasregexpvalidator || rx.exactMatch(getValue());
+}
+
+bool Widget::luaValidator()
+{
+ return !hasluavalidator || true;
}