summaryrefslogtreecommitdiff
path: root/client/widgets
diff options
context:
space:
mode:
authordeva <deva>2010-08-13 09:22:28 +0000
committerdeva <deva>2010-08-13 09:22:28 +0000
commitc4ecebb7a1f33acb38d51a82788b071186ff3c19 (patch)
tree30f0b6fdc550f0724f71926cbfd38d25d22dd7aa /client/widgets
parentdb2fdbe872cc6c1b224a1c4c735fac4369b3802e (diff)
setValues recursive. Remove old widgetbuilder files.
Diffstat (limited to 'client/widgets')
-rw-r--r--client/widgets/altcombobox.cc1
-rw-r--r--client/widgets/metawidget.cc1
-rw-r--r--client/widgets/multilist.cc1
-rw-r--r--client/widgets/widget.cc37
-rw-r--r--client/widgets/widget.h9
5 files changed, 32 insertions, 17 deletions
diff --git a/client/widgets/altcombobox.cc b/client/widgets/altcombobox.cc
index a4f5e76..88ce376 100644
--- a/client/widgets/altcombobox.cc
+++ b/client/widgets/altcombobox.cc
@@ -32,7 +32,6 @@
#include <QComboBox>
#include "common.h"
-#include "widgetbuilder.h"
#include "multilist.h"
#include "macrowindow.h"
diff --git a/client/widgets/metawidget.cc b/client/widgets/metawidget.cc
index ff359f4..55a8bd4 100644
--- a/client/widgets/metawidget.cc
+++ b/client/widgets/metawidget.cc
@@ -31,7 +31,6 @@
#include <QFrame>
#include "messagebox.h"
-#include "widgetbuilder.h"
#include "formatparser.h"
#include "macrowindow.h"
#include "common.h"
diff --git a/client/widgets/multilist.cc b/client/widgets/multilist.cc
index cccad5a..0160440 100644
--- a/client/widgets/multilist.cc
+++ b/client/widgets/multilist.cc
@@ -36,7 +36,6 @@
#include <QKeyEvent>
#include "messagebox.h"
-#include "widgetbuilder.h"
#include "common.h"
#include "macrowindow.h"
diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc
index 93deb31..f3247a0 100644
--- a/client/widgets/widget.cc
+++ b/client/widgets/widget.cc
@@ -55,8 +55,9 @@ Widget::Widget(QDomNode &node, MacroWindow *macrowindow)
prefilled = elem.attribute("prefilled");
}
- has_initial_value = false;
- initial_value = "";
+ has_initial_value = elem.hasAttribute("name") && elem.hasAttribute("value");
+ lazy_value = elem.attribute("value", "");
+ lazy_source = elem.attribute("prefilled", "");
if((hasOnChangeEvent = elem.hasAttribute("onChange"))) {
onChangeEventScript = elem.attribute("onChange");
@@ -90,15 +91,6 @@ Widget::~Widget()
}
}
-void Widget::addChildren(QDomNode &node, QLayout *layout)
-{
- QDomNodeList children = node.childNodes();
- for (int i=0; i<children.count();i++) {
- QDomNode child = children.at(i);
- widgetBuilder(child, layout);
- }
-}
-
QString Widget::name()
{
return widget_name;
@@ -236,10 +228,29 @@ void Widget::addChild(Widget *widget)
connect(widget, SIGNAL(wasChanged()), this, SLOT(childWasChanged()));
}
-void Widget::widgetBuilder(QDomNode &xml_node, QLayout *layout)
+void Widget::addChildren(QDomNode &node, QLayout *layout)
{
- QDomElement xml_elem = xml_node.toElement();
+ QDomNodeList children = node.childNodes();
+ for (int i=0; i<children.count();i++) {
+ QDomNode child = children.at(i);
+ createWidget(child, layout);
+ }
+}
+
+void Widget::setValues()
+{
+ if(has_lazy) setValue(lazy_value, lazy_source);
+
+ QVector< Widget* >::iterator i = children.begin();
+ while(i != children.end()) {
+ if(*i) (*i)->setValues();
+ i++;
+ }
+}
+void Widget::createWidget(QDomNode &xml_node, QLayout *layout)
+{
+ QDomElement xml_elem = xml_node.toElement();
// TODO: Why do we do this??
if(xml_elem.hasAttribute("prefilled") &&
diff --git a/client/widgets/widget.h b/client/widgets/widget.h
index 960dca9..2a95294 100644
--- a/client/widgets/widget.h
+++ b/client/widgets/widget.h
@@ -80,6 +80,7 @@ public:
Widget *findWidget(QString name, bool deep = false);
QVector< Widget* > widgetList(bool deep = false);
void addChild(Widget *widget);
+ void setValues();
signals:
void wasChanged();
@@ -96,11 +97,16 @@ protected:
QWidget *widget;
bool hideChildren;
- void widgetBuilder(QDomNode &xml_node, QLayout *layout);
void addChildren(QDomNode &xml_node, QLayout *layout);
private:
QVector< Widget* > children;
+ void createWidget(QDomNode &xml_node, QLayout *layout);
+
+ // Store value in constructor to be set later.
+ bool has_lazy;
+ QString lazy_value;
+ QString lazy_source;
bool is_valid;
QString widget_name;
@@ -114,6 +120,7 @@ private:
QString onChangeEventScript;
QString initial_value;
+ QString initial_source;
bool has_initial_value;
QString prefilled;