diff options
Diffstat (limited to 'client/widgets')
-rw-r--r-- | client/widgets/altcombobox.cc | 1 | ||||
-rw-r--r-- | client/widgets/metawidget.cc | 1 | ||||
-rw-r--r-- | client/widgets/multilist.cc | 1 | ||||
-rw-r--r-- | client/widgets/widget.cc | 37 | ||||
-rw-r--r-- | client/widgets/widget.h | 9 |
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; |