From 2e87c4608a9fb888fd7669756d8cb457ac305f71 Mon Sep 17 00:00:00 2001 From: senator Date: Mon, 24 Mar 2008 13:16:38 +0000 Subject: next button now works; listbox isValid check improved; start macro implemented --- client/widgets/listbox.cc | 42 ++++++++++++++++++++++++++++++++++++------ client/widgets/listbox.h | 1 + client/widgets/pushbutton.cc | 2 +- client/widgets/pushbutton.h | 2 +- 4 files changed, 39 insertions(+), 8 deletions(-) (limited to 'client/widgets') diff --git a/client/widgets/listbox.cc b/client/widgets/listbox.cc index 9435ac1..823a4bb 100644 --- a/client/widgets/listbox.cc +++ b/client/widgets/listbox.cc @@ -25,6 +25,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include "listbox.h" +#include ListBox::ListBox(QDomNode node) : QListWidget(), Widget(node) @@ -47,21 +48,50 @@ ListBox::ListBox(QDomNode node) for (int i=0; i < children.count(); i++) { QDomNode child = children.at(i); QDomElement list_elem = child.toElement(); - - if(list_elem.hasAttribute("caption") && list_elem.hasAttribute("value")) { + + if(list_elem.hasAttribute("type")) { + if(list_elem.attribute("type") == "header") { + // create header element + QListWidgetItem *header = new + QListWidgetItem(list_elem.attribute("caption")); + //header->setBackground(Qt::HorPattern); + header->setFlags(0); + QFont headerfont; + headerfont.setBold(true); + headerfont.setItalic(true); + header->setFont(headerfont); + QBrush headerbrush(Qt::SolidPattern); + headerbrush.setColor(Qt::lightGray); + header->setBackground(headerbrush); + addItem(header); + } else if (list_elem.attribute("type") == "separator") { + // insert separator + QListWidgetItem *separator = new QListWidgetItem(" "); + //separator->setBackground(Qt::HorPattern); + separator->setFlags(0); + addItem(separator); + } + } else if(list_elem.hasAttribute("caption") && + list_elem.hasAttribute("value")) { // insert item into current listbox addItem(list_elem.attribute("caption")); - if(elem.attribute("value") == list_elem.attribute("value")) { - setCurrentRow(count() - 1); - default_found = 1; + if(default_found == 0 && elem.attribute("value") == list_elem.attribute("value")) { + //setCurrentRow(count() - 1); + //default_found = 1; } } else { - printf("XML Error!!! Listbox item is missing one or more attributes...\n"); + printf("XML Error!!! Listbox item is missing one or more " + "attributes...\n"); } } if(default_found == 0) setCurrentRow(-1); // -1 is default for none selected } +bool ListBox::isValid() +{ + return selectedItems().size() != 0; +} + QString ListBox::getValue() { QString value = "none"; diff --git a/client/widgets/listbox.h b/client/widgets/listbox.h index bf70420..30c4129 100644 --- a/client/widgets/listbox.h +++ b/client/widgets/listbox.h @@ -38,6 +38,7 @@ public: ListBox(QDomNode); public slots: + bool isValid(); QString getValue(); private: diff --git a/client/widgets/pushbutton.cc b/client/widgets/pushbutton.cc index 8d74e4e..26ae83c 100644 --- a/client/widgets/pushbutton.cc +++ b/client/widgets/pushbutton.cc @@ -92,6 +92,6 @@ void PushButton::cancel() void PushButton::cont() { - emit act_continue(); + emit act_continue(field); printf("Emit: continue\n"); } diff --git a/client/widgets/pushbutton.h b/client/widgets/pushbutton.h index 663be79..4db5952 100644 --- a/client/widgets/pushbutton.h +++ b/client/widgets/pushbutton.h @@ -52,7 +52,7 @@ signals: void act_commit(); void act_reset(); void act_cancel(); - void act_continue(); + void act_continue(QString); private: -- cgit v1.2.3