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/builder.cc | 5 +---- client/macro.cc | 5 +++-- client/widgets/combobox.cc | 7 ++++++- client/widgets/combobox.h | 1 + client/widgets/radiobuttons.cc | 14 +++++++++++++- client/widgets/radiobuttons.h | 1 + 6 files changed, 25 insertions(+), 8 deletions(-) (limited to 'client') diff --git a/client/builder.cc b/client/builder.cc index 29f58d0..b5a9928 100644 --- a/client/builder.cc +++ b/client/builder.cc @@ -130,9 +130,6 @@ bool Builder::doCommit() while (i != widgets.end()) { Widget* w = *i; if(!w->isValid()) faulty++; // Regexp check, returns valid if entry passed - - // All selectable entries return "none" if nothing is selected - //if(w->getValue() == "none") faulty++; // Faulty+1 if error detected i++; } @@ -198,7 +195,7 @@ void Builder::commit() void Builder::reset() { - int ret = QMessageBox::warning(NULL, tr("Reset"), + QMessageBox::warning(NULL, tr("Reset"), tr("Du har valgt at nulstille de indtastede data.\n" "Er du sikker?"), QMessageBox::Yes | QMessageBox::Cancel); diff --git a/client/macro.cc b/client/macro.cc index 5e3b83d..3beb93d 100644 --- a/client/macro.cc +++ b/client/macro.cc @@ -67,10 +67,11 @@ void create_macro(QString name) } // Initiate the macro builder with the xml document - Builder *builder = new Builder(&xml_doc); + new Builder(&xml_doc); + //Builder *builder = new Builder(&xml_doc); } -bool MyEventHandler::eventFilter( QObject *o, QEvent *e ) +bool MyEventHandler::eventFilter( QObject *, QEvent *e ) { if ( e->type() == MY_EVENT_ID ) { 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