summaryrefslogtreecommitdiff
path: root/client/widgets
diff options
context:
space:
mode:
authordeva <deva>2010-08-03 12:30:27 +0000
committerdeva <deva>2010-08-03 12:30:27 +0000
commitdbab8458dcce186e7eb7a114a83f759d7db5445a (patch)
tree5abbd9e97b17a0e8321adea983594d818157e8e2 /client/widgets
parentd285c1bdb79752ef23a7252c9c2d9f408f0c9f49 (diff)
New scripting interface part1.
Diffstat (limited to 'client/widgets')
-rw-r--r--client/widgets/datetime.cc12
-rw-r--r--client/widgets/metawidget.cc4
-rw-r--r--client/widgets/multilist.cc2
-rw-r--r--client/widgets/widget.cc20
-rw-r--r--client/widgets/widget.h8
5 files changed, 29 insertions, 17 deletions
diff --git a/client/widgets/datetime.cc b/client/widgets/datetime.cc
index f5e74e7..0b91a40 100644
--- a/client/widgets/datetime.cc
+++ b/client/widgets/datetime.cc
@@ -47,28 +47,28 @@ DateTime::DateTime(QDomNode &node, MacroWindow *macrowindow)
break;
case 2:
- setDisplayFormat("MMM yyyy");
+ setDisplayFormat("MMMM yyyy");
break;
case 3:
- setDisplayFormat("dd MMM yyyy");
+ setDisplayFormat("dd MMMM yyyy");
break;
case 4:
- setDisplayFormat("dd MMM yyyy hh");
+ setDisplayFormat("dd MMMM yyyy hh");
break;
case 5:
- setDisplayFormat("dd MMM yyyy hh:mm");
+ setDisplayFormat("dd MMMM yyyy hh:mm");
break;
case 6:
- setDisplayFormat("dd MMM yyyy hh:mm:ss");
+ setDisplayFormat("dd MMMM yyyy hh:mm:ss");
break;
case 7:
default:
- setDisplayFormat("dd MMM yyyy hh:mm:ss:zzz");
+ setDisplayFormat("dd MMMM yyyy hh:mm:ss:zzz");
break;
}
diff --git a/client/widgets/metawidget.cc b/client/widgets/metawidget.cc
index 5491790..5933212 100644
--- a/client/widgets/metawidget.cc
+++ b/client/widgets/metawidget.cc
@@ -68,7 +68,7 @@ MetaWidget::MetaWidget(QDomNode &node, MacroWindow *macrowindow)
while (i != widgets.end()) {
Widget* w = *i;
if(format != "") format += ", ";
- format += "${" + w->getName() + "}";
+ format += "${" + w->name() + "}";
i++;
}
}
@@ -121,7 +121,7 @@ bool MetaWidget::isValid()
Widget* w = *i;
if(w->isValid() == false) {
MessageBox::critical(NULL, "Fejl",
- "Et af inputfelterne (" + w->getName()
+ "Et af inputfelterne (" + w->name()
+ ") er ikke udfyldt korrekt, prøv igen.\n"
, MessageBox::Ok);
return false;
diff --git a/client/widgets/multilist.cc b/client/widgets/multilist.cc
index 2788383..01a2d77 100644
--- a/client/widgets/multilist.cc
+++ b/client/widgets/multilist.cc
@@ -101,7 +101,7 @@ MultiList::MultiList(QDomNode &node, MacroWindow *macrowindow)
QString iwname = elem.attribute("innerwidget");
QVector< Widget* >::iterator ws = widgets.begin();
while(ws != widgets.end()) {
- if((*ws)->getName() == iwname) {
+ if((*ws)->name() == iwname) {
innerwidget = *ws;
innerwidget->connectFrom(SIGNAL(wasChanged()), this, SLOT(changed()));
}
diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc
index 5899839..c17633f 100644
--- a/client/widgets/widget.cc
+++ b/client/widgets/widget.cc
@@ -31,7 +31,9 @@ Widget::Widget(QDomNode &node, MacroWindow *macrowindow)
QDomElement elem = node.toElement();
this->macrowindow = macrowindow;
-
+
+ widget_type = elem.tagName();
+
if(elem.hasAttribute("name")) {
widget_name = elem.attribute("name");
} else {
@@ -63,11 +65,16 @@ Widget::Widget(QDomNode &node, MacroWindow *macrowindow)
initial_value = "";
}
-QString Widget::getName()
+QString Widget::name()
{
return widget_name;
}
+QString Widget::type()
+{
+ return widget_type;
+}
+
void Widget::setValue(QString, QString)
{
}
@@ -85,11 +92,12 @@ bool Widget::regexpValidator()
bool Widget::luaValidator()
{
if(!hasluaprogram) return true;
-
- if(macrowindow->luaprograms.contains(luaprogram) == false) return false;
- QString program = macrowindow->luaprograms.value(luaprogram);
- return macrowindow->lua->runValidator(program, getName(), getValue());
+ QString program = "";
+
+ program += luaprogram;
+
+ return macrowindow->lua->runValidator(program, this, name(), getValue());
}
void Widget::setInitialValue(QString value)
diff --git a/client/widgets/widget.h b/client/widgets/widget.h
index bd84705..732dce9 100644
--- a/client/widgets/widget.h
+++ b/client/widgets/widget.h
@@ -43,14 +43,17 @@ public:
virtual void setValue(QString value, QString source = "");
virtual bool isValid();
+ virtual void setValid(bool valid) { valid = valid; }
virtual void disable() {}
virtual void enable() {}
virtual bool isDisabled() { return false; }
virtual void setVisibility(bool) {}
-
- QString getName();
+ virtual bool getVisibility() { return true; }
+
+ QString name();
+ QString type();
/**
* Connect some signal from this object to some slot in some other object.
@@ -70,6 +73,7 @@ public:
protected:
QString widget_name;
+ QString widget_type;
bool luaValidator();
bool regexpValidator();