summaryrefslogtreecommitdiff
path: root/client/widgets/widget.cc
diff options
context:
space:
mode:
authordeva <deva>2008-06-02 13:03:33 +0000
committerdeva <deva>2008-06-02 13:03:33 +0000
commit322a83c48618b2f58e1014daff6f3956af8070ea (patch)
treeaa6124cd9f13ee2308e28d33175dc31eb1d34984 /client/widgets/widget.cc
parentf9f04013fca46fa256664bbf1f983c966f253400 (diff)
A large number of small changes in widgets, primarily validation oriented.
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;
}