summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/okeyfilter.cpp53
-rw-r--r--libopie2/opiecore/okeyfilter.h54
2 files changed, 80 insertions, 27 deletions
diff --git a/libopie2/opiecore/okeyfilter.cpp b/libopie2/opiecore/okeyfilter.cpp
index d806dbd..b064272 100644
--- a/libopie2/opiecore/okeyfilter.cpp
+++ b/libopie2/opiecore/okeyfilter.cpp
@@ -28,92 +28,117 @@ _;:, .> :=|. This program is free software; you can
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
33namespace Opie { 33namespace Opie {
34namespace Core { 34namespace Core {
35 35
36QValueList<QWSServer::KeyboardFilter*> OKeyFilter::filterList; 36class OKeyFilterPrivate:public OKeyFilter, QWSServer::KeyboardFilter
37QValueList<QWSServer::KeyboardFilter*> OKeyFilter::preFilterList; 37{
38 static QValueList<QWSServer::KeyboardFilter*> filterList;
39 static QValueList<QWSServer::KeyboardFilter*> preFilterList;
40protected:
41 OKeyFilterPrivate(const OKeyFilterPrivate&):OKeyFilter(),QWSServer::KeyboardFilter(){};
42 virtual void addPreHandler(QWSServer::KeyboardFilter*);
43 virtual void remPreHandler(QWSServer::KeyboardFilter*);
44
45public:
46 OKeyFilterPrivate();
47 virtual ~OKeyFilterPrivate();
48 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
49 virtual void addHandler(QWSServer::KeyboardFilter*);
50 virtual void remHandler(QWSServer::KeyboardFilter*);
51};
52
53QValueList<QWSServer::KeyboardFilter*> OKeyFilterPrivate::filterList;
54QValueList<QWSServer::KeyboardFilter*> OKeyFilterPrivate::preFilterList;
38 55
39OKeyFilter::OKeyFilter() 56OKeyFilter::OKeyFilter()
40 :QWSServer::KeyboardFilter()
41{ 57{
42 filterList.clear();
43 preFilterList.clear();
44 if ( isQWS( ) ) {
45 QWSServer::setKeyboardFilter ( this );
46 }
47} 58}
48 59
49OKeyFilter::~OKeyFilter() 60OKeyFilter::~OKeyFilter()
50{ 61{
51} 62}
52 63
53OKeyFilter* OKeyFilter::inst() 64OKeyFilter* OKeyFilter::inst()
54{ 65{
55 static OKeyFilter*ofilter = 0; 66 static OKeyFilter*ofilter = 0;
56 if (!ofilter) { 67 if (!ofilter) {
57 ofilter = new OKeyFilter; 68 ofilter = new OKeyFilterPrivate;
58 } 69 }
59 return ofilter; 70 return ofilter;
60} 71}
61 72
62bool OKeyFilter::filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ) 73bool OKeyFilterPrivate::filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat )
63{ 74{
64 QValueList<QWSServer::KeyboardFilter*>::Iterator iter; 75 QValueList<QWSServer::KeyboardFilter*>::Iterator iter;
65 for (iter=preFilterList.begin();iter!=preFilterList.end();++iter) { 76 for (iter=preFilterList.begin();iter!=preFilterList.end();++iter) {
66 if ((*iter)->filter(unicode,keycode,modifiers,isPress,autoRepeat)) { 77 if ((*iter)->filter(unicode,keycode,modifiers,isPress,autoRepeat)) {
67 return true; 78 return true;
68 } 79 }
69 } 80 }
70 for (iter=filterList.begin();iter!=filterList.end();++iter) { 81 for (iter=filterList.begin();iter!=filterList.end();++iter) {
71 if ((*iter)->filter(unicode,keycode,modifiers,isPress,autoRepeat)) { 82 if ((*iter)->filter(unicode,keycode,modifiers,isPress,autoRepeat)) {
72 return true; 83 return true;
73 } 84 }
74 } 85 }
75 return false; 86 return false;
76} 87}
77 88
78void OKeyFilter::addHandler(QWSServer::KeyboardFilter*aF) 89void OKeyFilterPrivate::addHandler(QWSServer::KeyboardFilter*aF)
79{ 90{
80 if (filterList.find(aF)!=filterList.end()) { 91 if (filterList.find(aF)!=filterList.end()) {
81 return; 92 return;
82 } 93 }
83 odebug << "adding a keyboard filter handler"<<oendl; 94 odebug << "adding a keyboard filter handler"<<oendl;
84 filterList.append(aF); 95 filterList.append(aF);
85} 96}
86 97
87void OKeyFilter::remHandler(QWSServer::KeyboardFilter*aF) 98void OKeyFilterPrivate::remHandler(QWSServer::KeyboardFilter*aF)
88{ 99{
89 QValueList<QWSServer::KeyboardFilter*>::Iterator iter; 100 QValueList<QWSServer::KeyboardFilter*>::Iterator iter;
90 if ( (iter=filterList.find(aF))==filterList.end() ) { 101 if ( (iter=filterList.find(aF))==filterList.end() ) {
91 return; 102 return;
92 } 103 }
93 odebug << "removing a keyboard filter handler"<<oendl; 104 odebug << "removing a keyboard filter handler"<<oendl;
94 filterList.remove(iter); 105 filterList.remove(iter);
95} 106}
96 107
97void OKeyFilter::addPreHandler(QWSServer::KeyboardFilter*aF) 108void OKeyFilterPrivate::addPreHandler(QWSServer::KeyboardFilter*aF)
98{ 109{
99 if (preFilterList.find(aF)!=preFilterList.end()) { 110 if (preFilterList.find(aF)!=preFilterList.end()) {
100 return; 111 return;
101 } 112 }
102 odebug << "adding a preferred keyboard filter handler"<<oendl; 113 odebug << "adding a preferred keyboard filter handler"<<oendl;
103 preFilterList.append(aF); 114 preFilterList.append(aF);
104} 115}
105 116
106void OKeyFilter::remPreHandler(QWSServer::KeyboardFilter*aF) 117void OKeyFilterPrivate::remPreHandler(QWSServer::KeyboardFilter*aF)
107{ 118{
108 QValueList<QWSServer::KeyboardFilter*>::Iterator iter; 119 QValueList<QWSServer::KeyboardFilter*>::Iterator iter;
109 if ( (iter=preFilterList.find(aF))==preFilterList.end() ) { 120 if ( (iter=preFilterList.find(aF))==preFilterList.end() ) {
110 return; 121 return;
111 } 122 }
112 odebug << "removing a preferred keyboard filter handler"<<oendl; 123 odebug << "removing a preferred keyboard filter handler"<<oendl;
113 preFilterList.remove(iter); 124 preFilterList.remove(iter);
114} 125}
115 126
127OKeyFilterPrivate::OKeyFilterPrivate()
128 :OKeyFilter(),QWSServer::KeyboardFilter()
129{
130 filterList.clear();
131 preFilterList.clear();
132 if ( isQWS( ) ) {
133 QWSServer::setKeyboardFilter ( this );
134 }
135}
136
137OKeyFilterPrivate::~OKeyFilterPrivate()
138{
139}
140
116/* namespace Core */ 141/* namespace Core */
117} 142}
118/* namespace Opie */ 143/* namespace Opie */
119} 144}
diff --git a/libopie2/opiecore/okeyfilter.h b/libopie2/opiecore/okeyfilter.h
index 3f9f744..a65bc48 100644
--- a/libopie2/opiecore/okeyfilter.h
+++ b/libopie2/opiecore/okeyfilter.h
@@ -42,36 +42,64 @@ namespace Internal {
42 * A singleton which will manage all possible keyboard filters inside opie. 42 * A singleton which will manage all possible keyboard filters inside opie.
43 * It makes sure that key handlers of odevice are checked first than the 43 * It makes sure that key handlers of odevice are checked first than the
44 * keyfilters of software. 44 * keyfilters of software.
45 * @short a keyfilter proxy 45 * @short a keyfilter proxy
46 * @see QWSServer::KeyboardFilter 46 * @see QWSServer::KeyboardFilter
47 * @author Rajko Albrecht 47 * @author Rajko Albrecht
48 * @version 1.0 48 * @version 1.0
49 */ 49 */
50class OKeyFilter:public QWSServer::KeyboardFilter 50class OKeyFilter
51{ 51{
52 friend class Opie::Core::ODevice; 52 friend class Opie::Core::ODevice;
53 friend class Opie::Core::Internal::iPAQ; 53 friend class Opie::Core::Internal::iPAQ;
54 friend class Opie::Core::Internal::SIMpad; 54 friend class Opie::Core::Internal::SIMpad;
55 55
56 static QValueList<QWSServer::KeyboardFilter*> filterList;
57 static QValueList<QWSServer::KeyboardFilter*> preFilterList;
58
59 OKeyFilter();
60 OKeyFilter(const OKeyFilter&):QWSServer::KeyboardFilter(){};
61
62protected: 56protected:
63 void addPreHandler(QWSServer::KeyboardFilter*); 57 /**
64 void remPreHandler(QWSServer::KeyboardFilter*); 58 * Protected constructor - generate class via inst()
59 * @see inst()
60 */
61 OKeyFilter();
62 /**
63 * Protected constructor - generate class via inst()
64 * @see inst()
65 */
66 OKeyFilter(const OKeyFilter&){};
67 /**
68 * Append filter to the primary list.
69 * This is only allowed for friend classes from odevice
70 * @param aFilter a filter to append
71 * @see addHandler
72 */
73 virtual void addPreHandler(QWSServer::KeyboardFilter*aFilter)=0;
74 /**
75 * Remove the specified filter from list and give back ownership.
76 * This is only allowed for friend classes from odevice
77 * @param aFilter a filter to remove
78 * @see remHandler
79 */
80 virtual void remPreHandler(QWSServer::KeyboardFilter*aFilter)=0;
65 81
66public: 82public:
67 virtual ~OKeyFilter(); 83 virtual ~OKeyFilter();
68 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 84 /**
69 85 * Append filter to the secondary list.
70 void addHandler(QWSServer::KeyboardFilter*); 86 * @param aFilter a filter to append
71 void remHandler(QWSServer::KeyboardFilter*); 87 * @see addPreHandler
88 */
89 virtual void addHandler(QWSServer::KeyboardFilter*)=0;
90 /**
91 * Remove the specified filter from list and give back ownership.
92 * @param aFilter a filter to remove
93 * @see remPreHandler
94 */
95 virtual void remHandler(QWSServer::KeyboardFilter*)=0;
72 96
97 /**
98 * Returns a handler to an instance of OKeyFilter
99 * @return a pointer to a working OKeyFilter
100 */
73 static OKeyFilter*inst(); 101 static OKeyFilter*inst();
74}; 102};
75 103
76} 104}
77} 105}