From 4497bea2b68a883d1bed72797f27275c833843ea Mon Sep 17 00:00:00 2001 From: deva Date: Thu, 15 Jan 2009 07:24:30 +0000 Subject: Added isDisabled method to all widget classes and made sure that only enabled widgets send their values on commit. --- client/netcom.cc | 6 ++++-- client/widgetbuilder.cc | 4 ++-- client/widgets/altcombobox.cc | 5 +++++ client/widgets/altcombobox.h | 3 ++- client/widgets/button.cc | 15 +++++++++++++++ client/widgets/button.h | 4 ++++ client/widgets/checkbox.cc | 15 +++++++++++++++ client/widgets/checkbox.h | 4 ++++ client/widgets/combobox.cc | 5 +++++ client/widgets/combobox.h | 3 ++- client/widgets/datetime.cc | 5 +++++ client/widgets/datetime.h | 4 +++- client/widgets/dbwidget.cc | 5 +++++ client/widgets/dbwidget.h | 3 ++- client/widgets/frame.cc | 5 +++++ client/widgets/frame.h | 3 ++- client/widgets/groupbox.cc | 5 +++++ client/widgets/groupbox.h | 3 ++- client/widgets/label.cc | 15 +++++++++++++++ client/widgets/label.h | 5 +++++ client/widgets/lineedit.cc | 5 +++++ client/widgets/lineedit.h | 2 ++ client/widgets/listbox.cc | 15 +++++++++++++++ client/widgets/listbox.h | 4 ++++ client/widgets/metawidget.cc | 5 +++++ client/widgets/metawidget.h | 7 ++++--- client/widgets/multilist.cc | 5 +++++ client/widgets/multilist.h | 7 ++++--- client/widgets/radiobuttons.cc | 15 +++++++++++++++ client/widgets/radiobuttons.h | 4 ++++ client/widgets/textedit.cc | 15 +++++++++++++++ client/widgets/textedit.h | 4 ++++ client/widgets/window.cc | 15 +++++++++++++++ client/widgets/window.h | 5 +++++ 34 files changed, 209 insertions(+), 16 deletions(-) (limited to 'client') diff --git a/client/netcom.cc b/client/netcom.cc index b6b5bd9..18af92e 100644 --- a/client/netcom.cc +++ b/client/netcom.cc @@ -101,7 +101,7 @@ void NetCom::send(QVector< Widget* > widgets, QString macro, QString version) printf("Socket state: %d\n", socket.state()); if(socket.state() != 3) printf("Socket state not connected: %s\n", socket.errorString().toStdString().c_str()); - if(qApp->activeWindow()) qApp->activeWindow()->setEnabled(false); + // if(qApp->activeWindow()) qApp->activeWindow()->setEnabled(false); // Moved down! QDomDocument doc; @@ -124,7 +124,7 @@ void NetCom::send(QVector< Widget* > widgets, QString macro, QString version) while (i != widgets.end()) { Widget* w = *i; - if(!w->isDisabled()) { + if(!w->isDisabled() && w->getName() != "") { QDomElement field_elem = doc.createElement("field"); field_elem.setAttribute("name", w->getName()); field_elem.setAttribute("value", w->getValue()); @@ -134,6 +134,8 @@ void NetCom::send(QVector< Widget* > widgets, QString macro, QString version) i++; } + if(qApp->activeWindow()) qApp->activeWindow()->setEnabled(false); + printf("\nSending commit:\n%s", doc.toString().toStdString().c_str()); socket.write(doc.toByteArray()); diff --git a/client/widgetbuilder.cc b/client/widgetbuilder.cc index 848157c..144b2a1 100644 --- a/client/widgetbuilder.cc +++ b/client/widgetbuilder.cc @@ -43,11 +43,11 @@ QVector< Widget* > widgetBuilder(QDomNode xml_node, QWidget *parent, } else if(xml_elem.tagName() == "frame") { if(xml_elem.hasAttribute("caption")) { GroupBox *frame = new GroupBox(xml_elem, macrowindow); - // widgets.push_back(frame); + widgets.push_back(frame); widget = frame; } else { Frame *frame = new Frame(xml_elem, macrowindow); - // widgets.push_back(frame); + widgets.push_back(frame); widget = frame; } diff --git a/client/widgets/altcombobox.cc b/client/widgets/altcombobox.cc index c68f816..352cd19 100644 --- a/client/widgets/altcombobox.cc +++ b/client/widgets/altcombobox.cc @@ -203,6 +203,11 @@ void AltComboBox::disable() setEnabled(false); } +bool AltComboBox::isDisabled() +{ + return isEnabled() == false; +} + void AltComboBox::onChildChange() { emit wasChanged(); diff --git a/client/widgets/altcombobox.h b/client/widgets/altcombobox.h index 5504f4a..c52bd20 100644 --- a/client/widgets/altcombobox.h +++ b/client/widgets/altcombobox.h @@ -46,8 +46,9 @@ public: QString getValue(); void setValue(QString value, QString source = ""); - void enable(); void disable(); + void enable(); + bool isDisabled(); void connectFrom(const char *signal, const QObject *receiver, const char *method); diff --git a/client/widgets/button.cc b/client/widgets/button.cc index 6032678..963242c 100644 --- a/client/widgets/button.cc +++ b/client/widgets/button.cc @@ -141,3 +141,18 @@ void Button::reset() { if(resetToDisabled) setEnabled(false); } + +void Button::enable() +{ + setEnabled(true); +} + +void Button::disable() +{ + setEnabled(false); +} + +bool Button::isDisabled() +{ + return isEnabled() == false; +} diff --git a/client/widgets/button.h b/client/widgets/button.h index d9d0b26..64d51f9 100644 --- a/client/widgets/button.h +++ b/client/widgets/button.h @@ -51,6 +51,10 @@ public: void reset(); + void disable(); + void enable(); + bool isDisabled(); + public slots: void commit(); void _reset(); diff --git a/client/widgets/checkbox.cc b/client/widgets/checkbox.cc index 4fbdad1..e550289 100644 --- a/client/widgets/checkbox.cc +++ b/client/widgets/checkbox.cc @@ -119,3 +119,18 @@ bool CheckBox::setKeyboardFocus() setFocus(); return true; } + +void CheckBox::enable() +{ + setEnabled(true); +} + +void CheckBox::disable() +{ + setEnabled(false); +} + +bool CheckBox::isDisabled() +{ + return isEnabled() == false; +} diff --git a/client/widgets/checkbox.h b/client/widgets/checkbox.h index 34cac6b..5131f56 100644 --- a/client/widgets/checkbox.h +++ b/client/widgets/checkbox.h @@ -52,6 +52,10 @@ public: bool setKeyboardFocus(); + void enable(); + void disable(); + bool isDisabled(); + public slots: void state_change(int); diff --git a/client/widgets/combobox.cc b/client/widgets/combobox.cc index 4db6172..2818db3 100644 --- a/client/widgets/combobox.cc +++ b/client/widgets/combobox.cc @@ -173,6 +173,11 @@ void ComboBox::disable() setEnabled(false); } +bool ComboBox::isDisabled() +{ + return isEnabled() == false; +} + void ComboBox::connectFrom(const char *signal, const QObject *receiver, const char *method) { diff --git a/client/widgets/combobox.h b/client/widgets/combobox.h index 2691ec3..922d51d 100644 --- a/client/widgets/combobox.h +++ b/client/widgets/combobox.h @@ -49,8 +49,9 @@ public: QString getValue(); void setValue(QString value, QString source = ""); - void enable(); void disable(); + void enable(); + bool isDisabled(); void connectFrom(const char *signal, const QObject *receiver, const char *method); diff --git a/client/widgets/datetime.cc b/client/widgets/datetime.cc index 1ca52ed..40aa31a 100644 --- a/client/widgets/datetime.cc +++ b/client/widgets/datetime.cc @@ -96,6 +96,11 @@ void DateTime::disable() setEnabled(false); } +bool DateTime::isDisabled() +{ + return isEnabled() == false; +} + void DateTime::connectFrom(const char *signal, const QObject *receiver, const char *method) { diff --git a/client/widgets/datetime.h b/client/widgets/datetime.h index 0fb5703..8699816 100644 --- a/client/widgets/datetime.h +++ b/client/widgets/datetime.h @@ -39,8 +39,10 @@ public: QString getValue(); void setValue(QString value, QString source = ""); - void enable(); + void disable(); + void enable(); + bool isDisabled(); void connectFrom(const char *signal, const QObject *receiver, const char *method); diff --git a/client/widgets/dbwidget.cc b/client/widgets/dbwidget.cc index 00b3886..9ec0c0d 100644 --- a/client/widgets/dbwidget.cc +++ b/client/widgets/dbwidget.cc @@ -186,6 +186,11 @@ void DBWidget::disable() setEnabled(false); } +bool DBWidget::isDisabled() +{ + return isEnabled() == false; +} + void DBWidget::connectFrom(const char *signal, const QObject *receiver, const char *method) { diff --git a/client/widgets/dbwidget.h b/client/widgets/dbwidget.h index 13e552d..ce2b596 100644 --- a/client/widgets/dbwidget.h +++ b/client/widgets/dbwidget.h @@ -47,8 +47,9 @@ public: QString getValue(); void setValue(QString value, QString source = ""); - void enable(); void disable(); + void enable(); + bool isDisabled(); void connectFrom(const char *signal, const QObject *receiver, const char *method); diff --git a/client/widgets/frame.cc b/client/widgets/frame.cc index 04a0e90..d6f4fb2 100644 --- a/client/widgets/frame.cc +++ b/client/widgets/frame.cc @@ -49,6 +49,11 @@ void Frame::disable() setEnabled(false); } +bool Frame::isDisabled() +{ + return isEnabled() == false; +} + void Frame::connectFrom(const char *signal, const QObject *receiver, const char *method) { diff --git a/client/widgets/frame.h b/client/widgets/frame.h index 5375d06..3f83fc4 100644 --- a/client/widgets/frame.h +++ b/client/widgets/frame.h @@ -36,8 +36,9 @@ class Frame : public QFrame, public Widget public: Frame(QDomNode &node, MacroWindow *macrowindow); - void enable(); void disable(); + void enable(); + bool isDisabled(); void connectFrom(const char *signal, const QObject *receiver, const char *method); diff --git a/client/widgets/groupbox.cc b/client/widgets/groupbox.cc index f6c9b28..e6f8b97 100644 --- a/client/widgets/groupbox.cc +++ b/client/widgets/groupbox.cc @@ -55,6 +55,11 @@ void GroupBox::disable() setEnabled(false); } +bool GroupBox::isDisabled() +{ + return isEnabled() == false; +} + void GroupBox::connectFrom(const char *signal, const QObject *receiver, const char *method) { diff --git a/client/widgets/groupbox.h b/client/widgets/groupbox.h index d1ffb86..ed848f7 100644 --- a/client/widgets/groupbox.h +++ b/client/widgets/groupbox.h @@ -36,8 +36,9 @@ class GroupBox : public QGroupBox, public Widget public: GroupBox(QDomNode &node, MacroWindow *macrowindow); - void enable(); void disable(); + void enable(); + bool isDisabled(); void connectFrom(const char *signal, const QObject *receiver, const char *method); diff --git a/client/widgets/label.cc b/client/widgets/label.cc index 3f69861..fc81099 100644 --- a/client/widgets/label.cc +++ b/client/widgets/label.cc @@ -77,3 +77,18 @@ void Label::setVisibility(bool visible) { setVisible(visible); } + +void Label::enable() +{ + setEnabled(true); +} + +void Label::disable() +{ + setEnabled(false); +} + +bool Label::isDisabled() +{ + return isEnabled() == false; +} diff --git a/client/widgets/label.h b/client/widgets/label.h index 6c02d1b..ff905a7 100644 --- a/client/widgets/label.h +++ b/client/widgets/label.h @@ -43,7 +43,12 @@ public: void connectTo(const QObject *sender, const char *signal, const char *method); + void setVisibility(bool visible); + + void disable(); + void enable(); + bool isDisabled(); }; #endif/*__PRACRO_LABEL_H__*/ diff --git a/client/widgets/lineedit.cc b/client/widgets/lineedit.cc index b699553..49b3704 100644 --- a/client/widgets/lineedit.cc +++ b/client/widgets/lineedit.cc @@ -100,6 +100,11 @@ void LineEdit::disable() setEnabled(false); } +bool LineEdit::isDisabled() +{ + return isEnabled() == false; +} + void LineEdit::connectFrom(const char *signal, const QObject *receiver, const char *method) { diff --git a/client/widgets/lineedit.h b/client/widgets/lineedit.h index 0e060d6..5af912f 100644 --- a/client/widgets/lineedit.h +++ b/client/widgets/lineedit.h @@ -40,8 +40,10 @@ public: QString getValue(); void setValue(QString value, QString source = ""); + void enable(); void disable(); + bool isDisabled(); void connectFrom(const char *signal, const QObject *receiver, const char *method); diff --git a/client/widgets/listbox.cc b/client/widgets/listbox.cc index 303d288..bddc34f 100644 --- a/client/widgets/listbox.cc +++ b/client/widgets/listbox.cc @@ -143,3 +143,18 @@ bool ListBox::setKeyboardFocus() setFocus(); return true; } + +void ListBox::enable() +{ + setEnabled(true); +} + +void ListBox::disable() +{ + setEnabled(false); +} + +bool ListBox::isDisabled() +{ + return isEnabled() == false; +} diff --git a/client/widgets/listbox.h b/client/widgets/listbox.h index 1485225..b48e258 100644 --- a/client/widgets/listbox.h +++ b/client/widgets/listbox.h @@ -51,6 +51,10 @@ public: bool setKeyboardFocus(); + void disable(); + void enable(); + bool isDisabled(); + public slots: void changed(); diff --git a/client/widgets/metawidget.cc b/client/widgets/metawidget.cc index 91c62ec..5102a04 100644 --- a/client/widgets/metawidget.cc +++ b/client/widgets/metawidget.cc @@ -101,6 +101,11 @@ void MetaWidget::disable() setEnabled(false); } +bool MetaWidget::isDisabled() +{ + return isEnabled() == false; +} + bool MetaWidget::isValid() { // If children are stored they will validate themselves. diff --git a/client/widgets/metawidget.h b/client/widgets/metawidget.h index e920236..77b79d7 100644 --- a/client/widgets/metawidget.h +++ b/client/widgets/metawidget.h @@ -43,9 +43,6 @@ public: QString getValue(); void setValue(QString value, QString source = ""); - void enable(); - void disable(); - bool isValid(); void connectFrom(const char *signal, @@ -59,6 +56,10 @@ public: void reset(); + void disable(); + void enable(); + bool isDisabled(); + public slots: void changed(); diff --git a/client/widgets/multilist.cc b/client/widgets/multilist.cc index 5f28368..dbc23b9 100644 --- a/client/widgets/multilist.cc +++ b/client/widgets/multilist.cc @@ -179,6 +179,11 @@ void MultiList::disable() setEnabled(false); } +bool MultiList::isDisabled() +{ + return isEnabled() == false; +} + void MultiList::connectFrom(const char *signal, const QObject *receiver, const char *method) { diff --git a/client/widgets/multilist.h b/client/widgets/multilist.h index 3bd7b9c..1e8b4bd 100644 --- a/client/widgets/multilist.h +++ b/client/widgets/multilist.h @@ -43,9 +43,6 @@ public: QString getValue(); void setValue(QString value, QString source = ""); - void enable(); - void disable(); - void connectFrom(const char *signal, const QObject *receiver, const char *method); @@ -55,6 +52,10 @@ public: bool setKeyboardFocus(); void setVisibility(bool visible); + void disable(); + void enable(); + bool isDisabled(); + public slots: void changed(); void remove(); diff --git a/client/widgets/radiobuttons.cc b/client/widgets/radiobuttons.cc index ae40677..5846ff7 100644 --- a/client/widgets/radiobuttons.cc +++ b/client/widgets/radiobuttons.cc @@ -140,3 +140,18 @@ void RadioButtons::childChanged() { emit wasChanged(); } + +void RadioButtons::enable() +{ + setEnabled(true); +} + +void RadioButtons::disable() +{ + setEnabled(false); +} + +bool RadioButtons::isDisabled() +{ + return isEnabled() == false; +} diff --git a/client/widgets/radiobuttons.h b/client/widgets/radiobuttons.h index cfdf1ef..b0f6cd3 100644 --- a/client/widgets/radiobuttons.h +++ b/client/widgets/radiobuttons.h @@ -53,6 +53,10 @@ public: bool setKeyboardFocus(); void setVisibility(bool visible); + void disable(); + void enable(); + bool isDisabled(); + public slots: void childChanged(); diff --git a/client/widgets/textedit.cc b/client/widgets/textedit.cc index ec7e3fc..83ef62a 100644 --- a/client/widgets/textedit.cc +++ b/client/widgets/textedit.cc @@ -115,3 +115,18 @@ void TextEdit::setVisibility(bool visible) { setVisible(visible); } + +void TextEdit::enable() +{ + setEnabled(true); +} + +void TextEdit::disable() +{ + setEnabled(false); +} + +bool TextEdit::isDisabled() +{ + return isEnabled() == false; +} diff --git a/client/widgets/textedit.h b/client/widgets/textedit.h index 722abcd..f3e1989 100644 --- a/client/widgets/textedit.h +++ b/client/widgets/textedit.h @@ -52,6 +52,10 @@ public: void setVisibility(bool visible); + void disable(); + void enable(); + bool isDisabled(); + signals: void wasChanged(); diff --git a/client/widgets/window.cc b/client/widgets/window.cc index e685e79..ea27321 100644 --- a/client/widgets/window.cc +++ b/client/widgets/window.cc @@ -63,3 +63,18 @@ void Window::connectTo(const QObject *sender, const char *signal, { connect(sender, signal, this, method); } + +void Window::enable() +{ + setEnabled(true); +} + +void Window::disable() +{ + setEnabled(false); +} + +bool Window::isDisabled() +{ + return isEnabled() == false; +} diff --git a/client/widgets/window.h b/client/widgets/window.h index 6e3d5be..497c237 100644 --- a/client/widgets/window.h +++ b/client/widgets/window.h @@ -41,6 +41,11 @@ public: void connectTo(const QObject *sender, const char *signal, const char *method); + + void disable(); + void enable(); + bool isDisabled(); + }; #endif/*__PRACRO_WINDOW_H__*/ -- cgit v1.2.3