From d2295ad23ed22af07addc93b71e36f7bb688d534 Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 17 Aug 2010 14:29:05 +0000 Subject: New format parser for metawidget et al. DBWidget is broken for the moment... --- client/widgets/dbwidget.cc | 3 +-- client/widgets/metawidget.cc | 26 +++++--------------------- client/widgets/widget.h | 3 ++- 3 files changed, 8 insertions(+), 24 deletions(-) (limited to 'client/widgets') diff --git a/client/widgets/dbwidget.cc b/client/widgets/dbwidget.cc index 4d6240c..08107b1 100644 --- a/client/widgets/dbwidget.cc +++ b/client/widgets/dbwidget.cc @@ -36,7 +36,6 @@ #include #include -#include "formatparser.h" #include "common.h" #define EMPTY_STRING "Write something in the searchfield" @@ -160,7 +159,7 @@ void DBWidget::update_list(QString prefix) QStringList lst; while(query.next()) { - lst << format_parser(format, query); + // lst << format_parser(format, query); } lst.sort(); diff --git a/client/widgets/metawidget.cc b/client/widgets/metawidget.cc index a179138..a866445 100644 --- a/client/widgets/metawidget.cc +++ b/client/widgets/metawidget.cc @@ -31,10 +31,11 @@ #include #include "messagebox.h" -#include "formatparser.h" #include "macrowindow.h" #include "common.h" +#include "debug.h" + MetaWidget::MetaWidget(QDomNode &node, MacroWindow *macrowindow) : Widget(node, macrowindow) { @@ -59,24 +60,7 @@ MetaWidget::MetaWidget(QDomNode &node, MacroWindow *macrowindow) */ // addChildren(node); - // Setup format string - if(elem.hasAttribute("formatlanguage")) { - formatlanguage = elem.attribute("formatlanguage"); - } else { - formatlanguage = "pracro"; - } - - if(elem.hasAttribute("format")) { - format = elem.attribute("format"); - } else { - QVector< Widget* >::iterator i = widgets.begin(); - while (i != widgets.end()) { - Widget* w = *i; - if(format != "") format += ", "; - format += "${" + w->name() + "}"; - i++; - } - } + format = elem.attribute("format", ""); addChildren(node, frame->layout()); @@ -101,12 +85,12 @@ void MetaWidget::changed() QString MetaWidget::value() { - return format_parser(format, this, formatlanguage); + return lua->runScriptS(format, this, "format"); } void MetaWidget::setValue(QString, QString) { - // Nothing reasonable we can do here. + WARN(metawidget, "setValue was attempted on this widget."); } bool MetaWidget::preValid() diff --git a/client/widgets/widget.h b/client/widgets/widget.h index 3315c2e..d172543 100644 --- a/client/widgets/widget.h +++ b/client/widgets/widget.h @@ -95,6 +95,8 @@ protected: void addChildren(QDomNode &xml_node, QLayout *layout); + LUA *lua; + private: QVector< Widget* > children; void createWidget(QDomNode &xml_node, QLayout *layout); @@ -109,7 +111,6 @@ private: QString widget_type; bool widget_local; - LUA *lua; MacroWindow *macrowindow; bool hasOnChangeEvent; -- cgit v1.2.3