diff options
Diffstat (limited to 'client/widgets/multilist.cc')
-rw-r--r-- | client/widgets/multilist.cc | 64 |
1 files changed, 25 insertions, 39 deletions
diff --git a/client/widgets/multilist.cc b/client/widgets/multilist.cc index a33c054..d83423c 100644 --- a/client/widgets/multilist.cc +++ b/client/widgets/multilist.cc @@ -32,7 +32,6 @@ #include <QPushButton> #include "widgetbuilder.h" -#include "formatparser.h" #include "common.h" @@ -61,17 +60,34 @@ MultiList::MultiList(QDomNode &node, MacroWindow *macrowindow) QHBoxLayout *layout = new QHBoxLayout(); inputbox->setLayout(layout); } - + inputbox->layout()->setContentsMargins(0,0,0,0); QDomNodeList children = node.childNodes(); - + + QVector< Widget* > widgets; for (int i=0; i<children.count();i++) { QDomNode child = children.at(i); widgets += widgetBuilder(child, inputbox, macrowindow); } macrowindow->addAuxWidgets(widgets); - + + innerwidget = NULL; + if(elem.hasAttribute("innerwidget")) { + QString iwname = elem.attribute("innerwidget"); + QVector< Widget* >::iterator ws = widgets.begin(); + while(ws != widgets.end()) { + if((*ws)->getName() == iwname) innerwidget = *ws; + ws++; + } + if(innerwidget == NULL) { + printf("ERROR: Inner Widget %s not found (in multilist)!\n", + iwname.toStdString().c_str()); + } + } else { + printf("ERROR: Missing 'innerwidget' attribute on multilist!\n"); + } + QPushButton *add = new QPushButton(this); connect(add, SIGNAL(clicked()), this, SLOT(add())); add->setText("Tilføj"); @@ -94,41 +110,6 @@ MultiList::MultiList(QDomNode &node, MacroWindow *macrowindow) } */ - 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->getName() + "}"; - i++; - } - } - - /* - QVector< Widget* >::iterator i = widgets.begin(); - while (i != widgets.end()) { - for (int j = 0; j < children.count(); j++) { - QDomNode child = children.at(j); - QDomElement elem = child.toElement(); - if(elem.attribute("name") == (*i)->getName()) { - printf("Set\n"); - (*i)->setValue(elem.attribute("value")); - } - } - i++; - } - */ - - if(elem.hasAttribute("width")) { - setMinimumWidth(elem.attribute("width").toInt()); - } - - if(elem.hasAttribute("height")) { - setMinimumHeight(elem.attribute("height").toInt()); - } - layout->setContentsMargins(0,0,0,0); } @@ -173,12 +154,17 @@ void MultiList::remove() void MultiList::add() { + /* QVector< Widget * >::iterator i = widgets.begin(); while(i != widgets.end()) { if(!(*i)->isValid()) return; i++; } list->addItem(format_parser(format, widgets)); + */ + + if(innerwidget && innerwidget->isValid()) list->addItem(innerwidget->getValue()); + } void MultiList::enable() |