summaryrefslogtreecommitdiff
path: root/client/widgets
diff options
context:
space:
mode:
authordeva <deva>2008-06-30 11:47:05 +0000
committerdeva <deva>2008-06-30 11:47:05 +0000
commit1c190bfef95d9c48e10bd8e2168692c84b4b4558 (patch)
treecc1e73d3e34313be71cf523d2f8f6404403c55f5 /client/widgets
parent5151bc32413efa8d34a21be21fa10f3bf62517c2 (diff)
Added setValue and cleaned up the code in general.
Diffstat (limited to 'client/widgets')
-rw-r--r--client/widgets/radiobutton.cc12
-rw-r--r--client/widgets/radiobutton.h4
-rw-r--r--client/widgets/radiobuttons.cc24
-rw-r--r--client/widgets/radiobuttons.h1
4 files changed, 24 insertions, 17 deletions
diff --git a/client/widgets/radiobutton.cc b/client/widgets/radiobutton.cc
index 6de030d..b757828 100644
--- a/client/widgets/radiobutton.cc
+++ b/client/widgets/radiobutton.cc
@@ -27,7 +27,7 @@
#include "radiobutton.h"
#include <QRadioButton>
-RadioButton::RadioButton(QDomNode &node, bool radio_bool)
+RadioButton::RadioButton(QDomNode &node)
: QRadioButton()
{
QDomElement elem = node.toElement();
@@ -46,19 +46,15 @@ RadioButton::RadioButton(QDomNode &node, bool radio_bool)
setText("");
}
- if(radio_bool) {
- setChecked(true);
- } else setChecked(false);
-
if(elem.hasAttribute("value")) {
- radio_value = elem.attribute("value");
+ value = elem.attribute("value");
} else {
printf("XML ERROR!!! Radiobutton item has no value\n");
- radio_value = "none";
+ value = "none";
}
}
QString RadioButton::getValue()
{
- return radio_value;
+ return value;
}
diff --git a/client/widgets/radiobutton.h b/client/widgets/radiobutton.h
index 66c971e..d0cf149 100644
--- a/client/widgets/radiobutton.h
+++ b/client/widgets/radiobutton.h
@@ -36,13 +36,13 @@
class RadioButton : public QRadioButton
{
public:
- RadioButton(QDomNode &node, bool radio_bool);
+ RadioButton(QDomNode &node);
public slots:
QString getValue();
private:
- QString radio_value;
+ QString value;
};
diff --git a/client/widgets/radiobuttons.cc b/client/widgets/radiobuttons.cc
index 7508974..bd88601 100644
--- a/client/widgets/radiobuttons.cc
+++ b/client/widgets/radiobuttons.cc
@@ -60,19 +60,16 @@ RadioButtons::RadioButtons(QDomNode &node, MacroWindow *macrowindow)
for (int i=0; i<children.count();i++) {
QDomNode child = children.at(i);
QDomElement radio_elem = child.toElement();
- bool radio_bool = false;
- if(elem.hasAttribute("value")) {
- if(elem.attribute("value") == radio_elem.attribute("value")) {
- radio_bool = true;
- }
- }
- RadioButton *radiobutton = new RadioButton(child, radio_bool);
+ RadioButton *radiobutton = new RadioButton(child);
// Create radiobutton from child, insert in this
layout()->addWidget(radiobutton);
radiobutton_list.push_back(radiobutton);
}
+ if(elem.hasAttribute("value")) {
+ setValue(elem.attribute("value"));
+ }
}
bool RadioButtons::isValid()
@@ -100,3 +97,16 @@ QString RadioButtons::getValue()
}
return value;
}
+
+void RadioButtons::setValue(QString value)
+{
+ QVector< RadioButton* >::iterator i;
+ for (i = radiobutton_list.begin(); i != radiobutton_list.end(); ++i) {
+ RadioButton *widget = *i;
+ if(value == widget->getValue()) {
+ widget->setChecked(true);
+ } else {
+ widget->setChecked(false);
+ }
+ }
+}
diff --git a/client/widgets/radiobuttons.h b/client/widgets/radiobuttons.h
index 67c1cd0..f1c89c4 100644
--- a/client/widgets/radiobuttons.h
+++ b/client/widgets/radiobuttons.h
@@ -42,6 +42,7 @@ public:
public slots:
bool isValid();
QString getValue();
+ void setValue(QString value);
private:
QVector < RadioButton* > radiobutton_list;