From c4ecebb7a1f33acb38d51a82788b071186ff3c19 Mon Sep 17 00:00:00 2001 From: deva Date: Fri, 13 Aug 2010 09:22:28 +0000 Subject: setValues recursive. Remove old widgetbuilder files. --- client/client.pro | 2 -- client/macrowindow.cc | 4 ++- client/widgetbuilder.cc | 57 ------------------------------------------- client/widgetbuilder.h | 39 ----------------------------- client/widgets/altcombobox.cc | 1 - client/widgets/metawidget.cc | 1 - client/widgets/multilist.cc | 1 - client/widgets/widget.cc | 37 ++++++++++++++++++---------- client/widgets/widget.h | 9 ++++++- 9 files changed, 35 insertions(+), 116 deletions(-) delete mode 100644 client/widgetbuilder.cc delete mode 100644 client/widgetbuilder.h (limited to 'client') diff --git a/client/client.pro b/client/client.pro index 9f2780d..8b2a130 100644 --- a/client/client.pro +++ b/client/client.pro @@ -45,7 +45,6 @@ HEADERS += \ resumewidget.h \ sessions.h \ viewer.h \ - widgetbuilder.h \ widgets.h \ widgets/common.h \ widgets/widget.h \ @@ -82,7 +81,6 @@ SOURCES += \ resumewidget.cc \ sessions.cc \ viewer.cc \ - widgetbuilder.cc \ widgets/common.cc \ widgets/widget.cc \ widgets/label.cc \ diff --git a/client/macrowindow.cc b/client/macrowindow.cc index c439497..649f323 100644 --- a/client/macrowindow.cc +++ b/client/macrowindow.cc @@ -34,7 +34,6 @@ #include "messagebox.h" #include "widgets/widget.h" #include "widgets/window.h" -#include "widgetbuilder.h" #include "lua.h" #include "resumewidget.h" @@ -118,6 +117,8 @@ void MacroWindow::initMacro(QDomNode &node) clear(); mainwidget = window; + mainwidget->setValues(); + /* QDomNodeList children = node.childNodes(); // Insert their values (this must be done last for scripts to work properly) @@ -125,6 +126,7 @@ void MacroWindow::initMacro(QDomNode &node) QDomNode child = children.at(i); setValues(child, mainwidget); } + */ if(waschanged == true) macroChanged(); diff --git a/client/widgetbuilder.cc b/client/widgetbuilder.cc deleted file mode 100644 index e61ecd5..0000000 --- a/client/widgetbuilder.cc +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/*************************************************************************** - * widgetbuilder.cc - * - * Wed Jun 18 08:03:04 CEST 2008 - * Copyright 2008 Bent Bisballe Nyeng - * deva@aasimon.org - ****************************************************************************/ - -/* - * This file is part of Pracro. - * - * Pracro is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Pracro is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Pracro; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ -#include "widgetbuilder.h" - -#include -#include - -#include "widgets.h" -#include "macrowindow.h" - -void setValues(QDomNode &xml_node, Widget *rootwidget) -{ - QDomElement xml_elem = xml_node.toElement(); - - if(xml_elem.tagName() == "item" || - xml_elem.tagName() == "radiobutton") return; - - if(xml_elem.hasAttribute("name") && xml_elem.hasAttribute("value")) { - Widget *widget = rootwidget->findWidget(xml_elem.attribute("name"), true); - if(widget && widget->hasInitialValue() == false) { - // Don't set the value if it is already set indirectly (altcombobox) - widget->setValue(xml_elem.attribute("value"), - xml_elem.attribute("prefilled", "")); - } - } - - QDomNodeList children = xml_node.childNodes(); - - for (int i=0; i -#include -#include "widgets/widget.h" - -//class MacroWindow; -//void widgetBuilder(QDomNode xml_node, Widget *parent, MacroWindow *macrowindow); - -void setValues(QDomNode &xml_node, Widget *rootwidget); - -#endif/*__PRACRO_WIDGETBUILDER_H__*/ 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 #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 #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 #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::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; -- cgit v1.2.3