diff options
| author | deva <deva> | 2008-06-30 11:47:05 +0000 | 
|---|---|---|
| committer | deva <deva> | 2008-06-30 11:47:05 +0000 | 
| commit | 1c190bfef95d9c48e10bd8e2168692c84b4b4558 (patch) | |
| tree | cc1e73d3e34313be71cf523d2f8f6404403c55f5 /client/widgets/radiobuttons.cc | |
| parent | 5151bc32413efa8d34a21be21fa10f3bf62517c2 (diff) | |
Added setValue and cleaned up the code in general.
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); +    } +  } +} | 
