summaryrefslogtreecommitdiff
path: root/client/widgets/combobox.cc
diff options
context:
space:
mode:
Diffstat (limited to 'client/widgets/combobox.cc')
-rw-r--r--client/widgets/combobox.cc35
1 files changed, 33 insertions, 2 deletions
diff --git a/client/widgets/combobox.cc b/client/widgets/combobox.cc
index 5499d09..22efc96 100644
--- a/client/widgets/combobox.cc
+++ b/client/widgets/combobox.cc
@@ -2,7 +2,7 @@
/***************************************************************************
* combobox.cc
*
- * Wed Jul 18 09:39:40 CEST 2007
+ * Wed Jul 18 10:35:52 CEST 2007
* Copyright 2007 Bent Bisballe Nyeng, Lars Bisballe Jensen and Peter Skaarup
* deva@aasimon.org, elsenator@gmail.com and piparum@piparum.dk
****************************************************************************/
@@ -25,14 +25,45 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#include "combobox.h"
+#include <QDomNodeList>
ComboBox::ComboBox(QDomNode node)
: QComboBox(), Widget(node)
{
QDomElement elem = node.toElement();
+
+ if(elem.hasAttribute("width")) {
+ resize(elem.attribute("width").toInt(), height());
+ }
+
+ if(elem.hasAttribute("height")) {
+ resize(width(), elem.attribute("height").toInt());
+ }
+
+ QDomNodeList children = node.childNodes();
+ int default_found = 0;
+
+ for (int i=0; i<children.count();i++) {
+ QDomNode child = children.at(i);
+ QDomElement combo_elem = child.toElement();
+
+ if(combo_elem.hasAttribute("caption") && combo_elem.hasAttribute("value")) {
+ // insert item into current combobox
+ addItem(combo_elem.attribute("caption"), combo_elem.attribute("value"));
+ if(elem.attribute("value") == combo_elem.attribute("value")) {
+ setCurrentIndex(count() - 1);
+ default_found = 1;
+ }
+ } else {
+ printf("XML Error!!! Combobox item is missing one or more attributes...\n");
+ }
+ }
+ if(default_found == 0) setCurrentIndex(-1); // -1 is default for none selected
}
QString ComboBox::getValue()
{
- return "combobox";
+ QString value = "none";
+ if(currentIndex() != -1) value = itemData(currentIndex()).toString();
+ return value;
}