diff options
Diffstat (limited to 'client/widgets/radiobuttons.cc')
-rw-r--r-- | client/widgets/radiobuttons.cc | 24 |
1 files changed, 17 insertions, 7 deletions
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); + } + } +} |