From 917aea688614bd29568f7eb37efe8cbd2620b25c Mon Sep 17 00:00:00 2001 From: senator Date: Mon, 24 Mar 2008 13:33:35 +0000 Subject: Fixed isValid for combobox and radiobuttons --- client/widgets/combobox.cc | 7 ++++++- client/widgets/combobox.h | 1 + client/widgets/radiobuttons.cc | 14 +++++++++++++- client/widgets/radiobuttons.h | 1 + 4 files changed, 21 insertions(+), 2 deletions(-) (limited to 'client/widgets') diff --git a/client/widgets/combobox.cc b/client/widgets/combobox.cc index e60ea8e..29bf253 100644 --- a/client/widgets/combobox.cc +++ b/client/widgets/combobox.cc @@ -63,9 +63,14 @@ ComboBox::ComboBox(QDomNode node) if(default_found == 0) setCurrentIndex(-1); // -1 is default for none selected } +bool ComboBox::isValid() +{ + return currentIndex() != -1; +} + QString ComboBox::getValue() { - QString value = "none"; + QString value; if(currentIndex() != -1) value = itemData(currentIndex()).toString(); return value; } diff --git a/client/widgets/combobox.h b/client/widgets/combobox.h index f6baa67..a7f16c8 100644 --- a/client/widgets/combobox.h +++ b/client/widgets/combobox.h @@ -38,6 +38,7 @@ public: ComboBox(QDomNode); public slots: + bool isValid(); QString getValue(); private: diff --git a/client/widgets/radiobuttons.cc b/client/widgets/radiobuttons.cc index dc79831..ccc5506 100644 --- a/client/widgets/radiobuttons.cc +++ b/client/widgets/radiobuttons.cc @@ -75,10 +75,22 @@ RadioButtons::RadioButtons(QDomNode node) } +bool RadioButtons::isValid() +{ + QVector< RadioButton* >::iterator i; + for (i = radiobutton_list.begin(); i != radiobutton_list.end(); ++i) { + RadioButton *widget = *i; + if(widget->isChecked()) { + return true; + } + } + return false; +} + QString RadioButtons::getValue() { QVector< RadioButton* >::iterator i; - QString value = "none"; + QString value; for (i = radiobutton_list.begin(); i != radiobutton_list.end(); ++i) { RadioButton *widget = *i; if(widget->isChecked()) { diff --git a/client/widgets/radiobuttons.h b/client/widgets/radiobuttons.h index 34e90ce..f84555f 100644 --- a/client/widgets/radiobuttons.h +++ b/client/widgets/radiobuttons.h @@ -41,6 +41,7 @@ public: RadioButtons(QDomNode); public slots: + bool isValid(); QString getValue(); private: -- cgit v1.2.3