summaryrefslogtreecommitdiff
authorzecke <zecke>2004-08-14 17:15:44 (UTC)
committer zecke <zecke>2004-08-14 17:15:44 (UTC)
commit74363a9e1d5688d65286e7fea156227b68a28002 (patch) (unidiff)
tree3926a1a3bd42bebb2f67b3334735bc3b3931f796
parent7657b6986a600ec1b3626c83e8f19036bf69e493 (diff)
downloadopie-74363a9e1d5688d65286e7fea156227b68a28002.zip
opie-74363a9e1d5688d65286e7fea156227b68a28002.tar.gz
opie-74363a9e1d5688d65286e7fea156227b68a28002.tar.bz2
-Remove the KeyFilter on destruction
Alwin could we either add a 'QObject' as a owner so that we could use QGuardedPtr or look for the deleteEvent ourselves. Or let us create a KeyFilter ourselves that auto registers (maybe) but cleans up itself in any case?
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--development/keyview/keyboardimpl.cpp4
-rw-r--r--development/keyview/keyview.cpp7
-rw-r--r--development/keyview/keyview.h2
3 files changed, 11 insertions, 2 deletions
diff --git a/development/keyview/keyboardimpl.cpp b/development/keyview/keyboardimpl.cpp
index 673eaa5..0216110 100644
--- a/development/keyview/keyboardimpl.cpp
+++ b/development/keyview/keyboardimpl.cpp
@@ -161,24 +161,28 @@ QString KeyboardImpl::name()
161 // return qApp->translate( "InputMethods", "Keyboard" ); 161 // return qApp->translate( "InputMethods", "Keyboard" );
162 return "Keyview"; 162 return "Keyview";
163} 163}
164 164
165void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot ) 165void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot )
166{ 166{
167 Q_UNUSED( receiver );
168 Q_CONST_UNUSED( slot );
167 //if ( input ) 169 //if ( input )
168 //QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot ); 170 //QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot );
169} 171}
170 172
171#ifndef QT_NO_COMPONENT 173#ifndef QT_NO_COMPONENT
172QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) 174QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
173{ 175{
174 *iface = 0; 176 *iface = 0;
175 if ( uuid == IID_QUnknown ) 177 if ( uuid == IID_QUnknown )
176 *iface = this; 178 *iface = this;
177 else if ( uuid == IID_InputMethod ) 179 else if ( uuid == IID_InputMethod )
178 *iface = this; 180 *iface = this;
181 else
182 return QS_FALSE;
179 183
180 if ( *iface ) 184 if ( *iface )
181 (*iface)->addRef(); 185 (*iface)->addRef();
182 return QS_OK; 186 return QS_OK;
183} 187}
184 188
diff --git a/development/keyview/keyview.cpp b/development/keyview/keyview.cpp
index 8187744..cf082a8 100644
--- a/development/keyview/keyview.cpp
+++ b/development/keyview/keyview.cpp
@@ -62,15 +62,20 @@ void Keyview::updateItems(int u, int k, int m, bool p, bool a) {
62} 62}
63 63
64KeyFilter::KeyFilter(QObject * parent, const char *name) : QObject( parent, name ) 64KeyFilter::KeyFilter(QObject * parent, const char *name) : QObject( parent, name )
65{ 65{
66} 66}
67 67
68KeyFilter::~KeyFilter() {
69 /* we need to remove the KeyFilter */
70 Opie::Core::OKeyFilter::inst()->remHandler( this );
71}
72
68bool KeyFilter::filter(int unicode, int keycode, int modifiers, bool isPress, 73bool KeyFilter::filter(int unicode, int keycode, int modifiers, bool isPress,
69 bool autoRepeat) { 74 bool autoRepeat) {
70 75
71 qDebug( "unicode: %d, keycode: %d, modifiers: %0x, isPress: %d, autoRepeat: %d", 76 qDebug( "unicode: %d, keycode: %d, modifiers: %0x, isPress: %d, autoRepeat: %d",
72 unicode, keycode, modifiers, isPress ); 77 unicode, keycode, modifiers, isPress, autoRepeat );
73 emit keyPressed(unicode, keycode, modifiers, isPress, autoRepeat); 78 emit keyPressed(unicode, keycode, modifiers, isPress, autoRepeat);
74 return 0; // return 1 to stop key emiting 79 return 0; // return 1 to stop key emiting
75 80
76} 81}
diff --git a/development/keyview/keyview.h b/development/keyview/keyview.h
index 5f1e943..87c0d15 100644
--- a/development/keyview/keyview.h
+++ b/development/keyview/keyview.h
@@ -20,21 +20,21 @@ private:
20 20
21 QLineEdit *unicode; 21 QLineEdit *unicode;
22 QLineEdit *keycode; 22 QLineEdit *keycode;
23 QLineEdit *modifiers; 23 QLineEdit *modifiers;
24 QLineEdit *isPress; 24 QLineEdit *isPress;
25 QLineEdit *autoRepeat; 25 QLineEdit *autoRepeat;
26
27}; 26};
28 27
29class KeyFilter : public QObject, public QWSServer::KeyboardFilter 28class KeyFilter : public QObject, public QWSServer::KeyboardFilter
30{ 29{
31 Q_OBJECT 30 Q_OBJECT
32 31
33public: 32public:
34 KeyFilter( QObject* parent, const char* name = 0); 33 KeyFilter( QObject* parent, const char* name = 0);
34 virtual ~KeyFilter();
35 virtual bool filter(int unicode, int keycode, int modifiers, bool isPress, 35 virtual bool filter(int unicode, int keycode, int modifiers, bool isPress,
36 bool autoRepeat); 36 bool autoRepeat);
37 37
38signals: 38signals:
39 void keyPressed(int, int, int, bool, bool); 39 void keyPressed(int, int, int, bool, bool);
40 40