From dfa6760020c62d5fd797feef6b20c1cbae0ce876 Mon Sep 17 00:00:00 2001 From: deva Date: Mon, 14 Mar 2011 09:15:41 +0000 Subject: Make setKeyboardFocus recursive instead of iterative. --- client/widgets/checkgroupbox.cc | 14 ++++++++++++++ client/widgets/checkgroupbox.h | 2 ++ client/widgets/frame.cc | 14 ++++++++++++++ client/widgets/frame.h | 2 +- client/widgets/groupbox.cc | 14 ++++++++++++++ client/widgets/groupbox.h | 2 +- client/widgets/widget.h | 1 - client/widgets/window.cc | 14 ++++++++++++++ client/widgets/window.h | 2 +- 9 files changed, 61 insertions(+), 4 deletions(-) (limited to 'client/widgets') diff --git a/client/widgets/checkgroupbox.cc b/client/widgets/checkgroupbox.cc index 8020a45..7204418 100644 --- a/client/widgets/checkgroupbox.cc +++ b/client/widgets/checkgroupbox.cc @@ -137,3 +137,17 @@ void CheckGroupBox::setWdgValid(bool valid) groupbox->setPalette(palette); } + +bool CheckGroupBox::setKeyboardFocus() +{ + QVector< Widget* >::iterator i = children.begin(); + while(i != children.end()) { + Widget *w = *i; + if(w) { + if(w->setKeyboardFocus()) return true; + } + i++; + } + + return false; +} diff --git a/client/widgets/checkgroupbox.h b/client/widgets/checkgroupbox.h index e526092..7088832 100644 --- a/client/widgets/checkgroupbox.h +++ b/client/widgets/checkgroupbox.h @@ -47,6 +47,8 @@ public: bool checked(); void setChecked(bool checked); + bool setKeyboardFocus(); + public slots: void state_change(bool); diff --git a/client/widgets/frame.cc b/client/widgets/frame.cc index d6f8187..076816a 100644 --- a/client/widgets/frame.cc +++ b/client/widgets/frame.cc @@ -50,3 +50,17 @@ Frame::~Frame() { // delete frame; } + +bool Frame::setKeyboardFocus() +{ + QVector< Widget* >::iterator i = children.begin(); + while(i != children.end()) { + Widget *w = *i; + if(w) { + if(w->setKeyboardFocus()) return true; + } + i++; + } + + return false; +} diff --git a/client/widgets/frame.h b/client/widgets/frame.h index 219ecf8..04e6b9e 100644 --- a/client/widgets/frame.h +++ b/client/widgets/frame.h @@ -43,7 +43,7 @@ public: void setWdgValid(bool) {} - bool setKeyboardFocus() { return false; } + bool setKeyboardFocus(); private: QFrame *frame; diff --git a/client/widgets/groupbox.cc b/client/widgets/groupbox.cc index 3c00fa4..0d720ea 100644 --- a/client/widgets/groupbox.cc +++ b/client/widgets/groupbox.cc @@ -56,3 +56,17 @@ GroupBox::~GroupBox() { // delete groupbox; } + +bool GroupBox::setKeyboardFocus() +{ + QVector< Widget* >::iterator i = children.begin(); + while(i != children.end()) { + Widget *w = *i; + if(w) { + if(w->setKeyboardFocus()) return true; + } + i++; + } + + return false; +} diff --git a/client/widgets/groupbox.h b/client/widgets/groupbox.h index 22aa644..f2da306 100644 --- a/client/widgets/groupbox.h +++ b/client/widgets/groupbox.h @@ -43,7 +43,7 @@ public: void setWdgValid(bool) {} - bool setKeyboardFocus() { return false; } + bool setKeyboardFocus(); private: QGroupBox *groupbox; diff --git a/client/widgets/widget.h b/client/widgets/widget.h index 37a365f..3d06ef3 100644 --- a/client/widgets/widget.h +++ b/client/widgets/widget.h @@ -100,7 +100,6 @@ protected: LUA *lua; -private: void createWidget(QDomNode &xml_node, QLayout *layout); QVector< Widget* > children; diff --git a/client/widgets/window.cc b/client/widgets/window.cc index b480189..a305171 100644 --- a/client/widgets/window.cc +++ b/client/widgets/window.cc @@ -69,3 +69,17 @@ Window::~Window() //delete widget; } + +bool Window::setKeyboardFocus() +{ + QVector< Widget* >::iterator i = children.begin(); + while(i != children.end()) { + Widget *w = *i; + if(w) { + if(w->setKeyboardFocus()) return true; + } + i++; + } + + return false; +} diff --git a/client/widgets/window.h b/client/widgets/window.h index 2214b16..109cf11 100644 --- a/client/widgets/window.h +++ b/client/widgets/window.h @@ -41,7 +41,7 @@ public: void setWdgValid(bool) {} - bool setKeyboardFocus() { return false; } + bool setKeyboardFocus(); }; #endif/*__PRACRO_WINDOW_H__*/ -- cgit v1.2.3