author | alwin <alwin> | 2004-08-01 19:54:12 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-08-01 19:54:12 (UTC) |
commit | 3d67a6ef781f59f9db936442a5b44329a0d5c70b (patch) (unidiff) | |
tree | 904a4a0e0f30fe57cdf94ca86144c4d4a0e330c6 /libopie2 | |
parent | e9f9eb19567a2afa354c36490ee8f4b191cf9395 (diff) | |
download | opie-3d67a6ef781f59f9db936442a5b44329a0d5c70b.zip opie-3d67a6ef781f59f9db936442a5b44329a0d5c70b.tar.gz opie-3d67a6ef781f59f9db936442a5b44329a0d5c70b.tar.bz2 |
0 pointer will not inserted into list
-rw-r--r-- | libopie2/opiecore/okeyfilter.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libopie2/opiecore/okeyfilter.cpp b/libopie2/opiecore/okeyfilter.cpp index b064272..a517333 100644 --- a/libopie2/opiecore/okeyfilter.cpp +++ b/libopie2/opiecore/okeyfilter.cpp | |||
@@ -1,144 +1,148 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | =. Copyright (C) 2004 Rajko 'Alwin' Albrecht <alwin@handhelds.org> | 3 | =. Copyright (C) 2004 Rajko 'Alwin' Albrecht <alwin@handhelds.org> |
4 | .=l. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | .=l. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
19 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | 20 | : = ...= . :.=- |
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
23 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "okeyfilter.h" | 29 | #include "okeyfilter.h" |
30 | #include "device/odevice.h" | 30 | #include "device/odevice.h" |
31 | #include "odebug.h" | 31 | #include "odebug.h" |
32 | 32 | ||
33 | namespace Opie { | 33 | namespace Opie { |
34 | namespace Core { | 34 | namespace Core { |
35 | 35 | ||
36 | class OKeyFilterPrivate:public OKeyFilter, QWSServer::KeyboardFilter | 36 | class OKeyFilterPrivate:public OKeyFilter, QWSServer::KeyboardFilter |
37 | { | 37 | { |
38 | static QValueList<QWSServer::KeyboardFilter*> filterList; | 38 | static QValueList<QWSServer::KeyboardFilter*> filterList; |
39 | static QValueList<QWSServer::KeyboardFilter*> preFilterList; | 39 | static QValueList<QWSServer::KeyboardFilter*> preFilterList; |
40 | protected: | 40 | protected: |
41 | OKeyFilterPrivate(const OKeyFilterPrivate&):OKeyFilter(),QWSServer::KeyboardFilter(){}; | 41 | OKeyFilterPrivate(const OKeyFilterPrivate&):OKeyFilter(),QWSServer::KeyboardFilter(){}; |
42 | virtual void addPreHandler(QWSServer::KeyboardFilter*); | 42 | virtual void addPreHandler(QWSServer::KeyboardFilter*); |
43 | virtual void remPreHandler(QWSServer::KeyboardFilter*); | 43 | virtual void remPreHandler(QWSServer::KeyboardFilter*); |
44 | 44 | ||
45 | public: | 45 | public: |
46 | OKeyFilterPrivate(); | 46 | OKeyFilterPrivate(); |
47 | virtual ~OKeyFilterPrivate(); | 47 | virtual ~OKeyFilterPrivate(); |
48 | virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 48 | virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
49 | virtual void addHandler(QWSServer::KeyboardFilter*); | 49 | virtual void addHandler(QWSServer::KeyboardFilter*); |
50 | virtual void remHandler(QWSServer::KeyboardFilter*); | 50 | virtual void remHandler(QWSServer::KeyboardFilter*); |
51 | }; | 51 | }; |
52 | 52 | ||
53 | QValueList<QWSServer::KeyboardFilter*> OKeyFilterPrivate::filterList; | 53 | QValueList<QWSServer::KeyboardFilter*> OKeyFilterPrivate::filterList; |
54 | QValueList<QWSServer::KeyboardFilter*> OKeyFilterPrivate::preFilterList; | 54 | QValueList<QWSServer::KeyboardFilter*> OKeyFilterPrivate::preFilterList; |
55 | 55 | ||
56 | OKeyFilter::OKeyFilter() | 56 | OKeyFilter::OKeyFilter() |
57 | { | 57 | { |
58 | } | 58 | } |
59 | 59 | ||
60 | OKeyFilter::~OKeyFilter() | 60 | OKeyFilter::~OKeyFilter() |
61 | { | 61 | { |
62 | } | 62 | } |
63 | 63 | ||
64 | OKeyFilter* OKeyFilter::inst() | 64 | OKeyFilter* OKeyFilter::inst() |
65 | { | 65 | { |
66 | static OKeyFilter*ofilter = 0; | 66 | static OKeyFilter*ofilter = 0; |
67 | if (!ofilter) { | 67 | if (!ofilter) { |
68 | ofilter = new OKeyFilterPrivate; | 68 | ofilter = new OKeyFilterPrivate; |
69 | } | 69 | } |
70 | return ofilter; | 70 | return ofilter; |
71 | } | 71 | } |
72 | 72 | ||
73 | bool OKeyFilterPrivate::filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 73 | bool OKeyFilterPrivate::filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
74 | { | 74 | { |
75 | QValueList<QWSServer::KeyboardFilter*>::Iterator iter; | 75 | QValueList<QWSServer::KeyboardFilter*>::Iterator iter; |
76 | for (iter=preFilterList.begin();iter!=preFilterList.end();++iter) { | 76 | for (iter=preFilterList.begin();iter!=preFilterList.end();++iter) { |
77 | if ((*iter)->filter(unicode,keycode,modifiers,isPress,autoRepeat)) { | 77 | if ((*iter)->filter(unicode,keycode,modifiers,isPress,autoRepeat)) { |
78 | return true; | 78 | return true; |
79 | } | 79 | } |
80 | } | 80 | } |
81 | for (iter=filterList.begin();iter!=filterList.end();++iter) { | 81 | for (iter=filterList.begin();iter!=filterList.end();++iter) { |
82 | if ((*iter)->filter(unicode,keycode,modifiers,isPress,autoRepeat)) { | 82 | if ((*iter)->filter(unicode,keycode,modifiers,isPress,autoRepeat)) { |
83 | return true; | 83 | return true; |
84 | } | 84 | } |
85 | } | 85 | } |
86 | return false; | 86 | return false; |
87 | } | 87 | } |
88 | 88 | ||
89 | void OKeyFilterPrivate::addHandler(QWSServer::KeyboardFilter*aF) | 89 | void OKeyFilterPrivate::addHandler(QWSServer::KeyboardFilter*aF) |
90 | { | 90 | { |
91 | if (!aF) return; | ||
91 | if (filterList.find(aF)!=filterList.end()) { | 92 | if (filterList.find(aF)!=filterList.end()) { |
92 | return; | 93 | return; |
93 | } | 94 | } |
94 | odebug << "adding a keyboard filter handler"<<oendl; | 95 | odebug << "adding a keyboard filter handler"<<oendl; |
95 | filterList.append(aF); | 96 | filterList.append(aF); |
96 | } | 97 | } |
97 | 98 | ||
98 | void OKeyFilterPrivate::remHandler(QWSServer::KeyboardFilter*aF) | 99 | void OKeyFilterPrivate::remHandler(QWSServer::KeyboardFilter*aF) |
99 | { | 100 | { |
101 | if (!aF) return; | ||
100 | QValueList<QWSServer::KeyboardFilter*>::Iterator iter; | 102 | QValueList<QWSServer::KeyboardFilter*>::Iterator iter; |
101 | if ( (iter=filterList.find(aF))==filterList.end() ) { | 103 | if ( (iter=filterList.find(aF))==filterList.end() ) { |
102 | return; | 104 | return; |
103 | } | 105 | } |
104 | odebug << "removing a keyboard filter handler"<<oendl; | 106 | odebug << "removing a keyboard filter handler"<<oendl; |
105 | filterList.remove(iter); | 107 | filterList.remove(iter); |
106 | } | 108 | } |
107 | 109 | ||
108 | void OKeyFilterPrivate::addPreHandler(QWSServer::KeyboardFilter*aF) | 110 | void OKeyFilterPrivate::addPreHandler(QWSServer::KeyboardFilter*aF) |
109 | { | 111 | { |
112 | if (!aF) return; | ||
110 | if (preFilterList.find(aF)!=preFilterList.end()) { | 113 | if (preFilterList.find(aF)!=preFilterList.end()) { |
111 | return; | 114 | return; |
112 | } | 115 | } |
113 | odebug << "adding a preferred keyboard filter handler"<<oendl; | 116 | odebug << "adding a preferred keyboard filter handler"<<oendl; |
114 | preFilterList.append(aF); | 117 | preFilterList.append(aF); |
115 | } | 118 | } |
116 | 119 | ||
117 | void OKeyFilterPrivate::remPreHandler(QWSServer::KeyboardFilter*aF) | 120 | void OKeyFilterPrivate::remPreHandler(QWSServer::KeyboardFilter*aF) |
118 | { | 121 | { |
122 | if (!aF) return; | ||
119 | QValueList<QWSServer::KeyboardFilter*>::Iterator iter; | 123 | QValueList<QWSServer::KeyboardFilter*>::Iterator iter; |
120 | if ( (iter=preFilterList.find(aF))==preFilterList.end() ) { | 124 | if ( (iter=preFilterList.find(aF))==preFilterList.end() ) { |
121 | return; | 125 | return; |
122 | } | 126 | } |
123 | odebug << "removing a preferred keyboard filter handler"<<oendl; | 127 | odebug << "removing a preferred keyboard filter handler"<<oendl; |
124 | preFilterList.remove(iter); | 128 | preFilterList.remove(iter); |
125 | } | 129 | } |
126 | 130 | ||
127 | OKeyFilterPrivate::OKeyFilterPrivate() | 131 | OKeyFilterPrivate::OKeyFilterPrivate() |
128 | :OKeyFilter(),QWSServer::KeyboardFilter() | 132 | :OKeyFilter(),QWSServer::KeyboardFilter() |
129 | { | 133 | { |
130 | filterList.clear(); | 134 | filterList.clear(); |
131 | preFilterList.clear(); | 135 | preFilterList.clear(); |
132 | if ( isQWS( ) ) { | 136 | if ( isQWS( ) ) { |
133 | QWSServer::setKeyboardFilter ( this ); | 137 | QWSServer::setKeyboardFilter ( this ); |
134 | } | 138 | } |
135 | } | 139 | } |
136 | 140 | ||
137 | OKeyFilterPrivate::~OKeyFilterPrivate() | 141 | OKeyFilterPrivate::~OKeyFilterPrivate() |
138 | { | 142 | { |
139 | } | 143 | } |
140 | 144 | ||
141 | /* namespace Core */ | 145 | /* namespace Core */ |
142 | } | 146 | } |
143 | /* namespace Opie */ | 147 | /* namespace Opie */ |
144 | } | 148 | } |