-rw-r--r-- | libopie/odevicebutton.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libopie/odevicebutton.cpp b/libopie/odevicebutton.cpp index eccb57c..314eb51 100644 --- a/libopie/odevicebutton.cpp +++ b/libopie/odevicebutton.cpp | |||
@@ -1,235 +1,239 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include <qpixmap.h> | 21 | #include <qpixmap.h> |
22 | #include <qstring.h> | 22 | #include <qstring.h> |
23 | 23 | ||
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
25 | #include <opie/odevicebutton.h> | 25 | #include <opie/odevicebutton.h> |
26 | 26 | ||
27 | using namespace Opie; | 27 | using namespace Opie; |
28 | 28 | ||
29 | 29 | ||
30 | class OQCopMessageData { | 30 | class OQCopMessageData { |
31 | public: | 31 | public: |
32 | QCString m_channel; | 32 | QCString m_channel; |
33 | QCString m_message; | 33 | QCString m_message; |
34 | QByteArray m_data; | 34 | QByteArray m_data; |
35 | }; | 35 | }; |
36 | 36 | ||
37 | 37 | ||
38 | OQCopMessage::OQCopMessage ( ) | 38 | OQCopMessage::OQCopMessage ( ) |
39 | : d ( 0 ) | 39 | : d ( 0 ) |
40 | { | 40 | { |
41 | init ( QCString ( ), QCString ( ), QByteArray ( )); | 41 | init ( QCString ( ), QCString ( ), QByteArray ( )); |
42 | } | 42 | } |
43 | 43 | ||
44 | OQCopMessage::OQCopMessage ( const OQCopMessage © ) | 44 | OQCopMessage::OQCopMessage ( const OQCopMessage © ) |
45 | : d ( 0 ) | 45 | : d ( 0 ) |
46 | { | 46 | { |
47 | init ( copy. channel ( ), copy. message ( ), copy. data ( )); | 47 | init ( copy. channel ( ), copy. message ( ), copy. data ( )); |
48 | } | 48 | } |
49 | 49 | ||
50 | OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign ) | 50 | OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign ) |
51 | { | 51 | { |
52 | init ( assign. channel ( ), assign. message ( ), assign. data ( )); | 52 | init ( assign. channel ( ), assign. message ( ), assign. data ( )); |
53 | return *this; | 53 | return *this; |
54 | } | 54 | } |
55 | 55 | ||
56 | OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg ) | 56 | OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg ) |
57 | : d ( 0 ) | 57 | : d ( 0 ) |
58 | { | 58 | { |
59 | init ( ch, m, arg ); | 59 | init ( ch, m, arg ); |
60 | } | 60 | } |
61 | 61 | ||
62 | void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg ) | 62 | void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg ) |
63 | { | 63 | { |
64 | if ( !d ) | 64 | if ( !d ) |
65 | d = new OQCopMessageData ( ); | 65 | d = new OQCopMessageData ( ); |
66 | d-> m_channel = ch; | 66 | d-> m_channel = ch; |
67 | d-> m_message = m; | 67 | d-> m_message = m; |
68 | d-> m_data = arg; | 68 | d-> m_data = arg; |
69 | } | 69 | } |
70 | 70 | ||
71 | bool OQCopMessage::send ( ) | 71 | bool OQCopMessage::send ( ) |
72 | { | 72 | { |
73 | if ( d-> m_channel. isEmpty ( ) || d-> m_message. isEmpty ( ) ) | 73 | if ( d-> m_channel. isEmpty ( ) || d-> m_message. isEmpty ( ) ) |
74 | return false; | 74 | return false; |
75 | 75 | ||
76 | QCopEnvelope e ( d-> m_channel, d-> m_message ); | 76 | QCopEnvelope e ( d-> m_channel, d-> m_message ); |
77 | 77 | ||
78 | if ( d-> m_data. size ( )) | 78 | if ( d-> m_data. size ( )) |
79 | e. writeRawBytes ( d-> m_data. data ( ), d-> m_data. size ( )); | 79 | e. writeRawBytes ( d-> m_data. data ( ), d-> m_data. size ( )); |
80 | 80 | ||
81 | return true; | 81 | return true; |
82 | } | 82 | } |
83 | 83 | ||
84 | QCString OQCopMessage::channel ( ) const | 84 | QCString OQCopMessage::channel ( ) const |
85 | { | 85 | { |
86 | return d-> m_channel; | 86 | return d-> m_channel; |
87 | } | 87 | } |
88 | 88 | ||
89 | QCString OQCopMessage::message ( ) const | 89 | QCString OQCopMessage::message ( ) const |
90 | { | 90 | { |
91 | return d-> m_message; | 91 | return d-> m_message; |
92 | } | 92 | } |
93 | 93 | ||
94 | QByteArray OQCopMessage::data ( ) const | 94 | QByteArray OQCopMessage::data ( ) const |
95 | { | 95 | { |
96 | return d-> m_data; | 96 | return d-> m_data; |
97 | } | 97 | } |
98 | 98 | ||
99 | bool OQCopMessage::isNull() const | ||
100 | { | ||
101 | return d-> m_message.isNull() || d-> m_channel.isNull(); | ||
102 | } | ||
99 | void OQCopMessage::setChannel ( const QCString &ch ) | 103 | void OQCopMessage::setChannel ( const QCString &ch ) |
100 | { | 104 | { |
101 | d-> m_channel = ch; | 105 | d-> m_channel = ch; |
102 | } | 106 | } |
103 | 107 | ||
104 | void OQCopMessage::setMessage ( const QCString &m ) | 108 | void OQCopMessage::setMessage ( const QCString &m ) |
105 | { | 109 | { |
106 | d-> m_message = m; | 110 | d-> m_message = m; |
107 | } | 111 | } |
108 | 112 | ||
109 | void OQCopMessage::setData ( const QByteArray &data ) | 113 | void OQCopMessage::setData ( const QByteArray &data ) |
110 | { | 114 | { |
111 | d-> m_data = data; | 115 | d-> m_data = data; |
112 | } | 116 | } |
113 | 117 | ||
114 | /*! \class Opie::ODeviceButton | 118 | /*! \class Opie::ODeviceButton |
115 | \brief The Opie::ODeviceButton class represents a physical user mappable button on a Qtopia device. | 119 | \brief The Opie::ODeviceButton class represents a physical user mappable button on a Qtopia device. |
116 | 120 | ||
117 | This class represents a physical button on a Qtopia device. A | 121 | This class represents a physical button on a Qtopia device. A |
118 | device may have "user programmable" buttons. | 122 | device may have "user programmable" buttons. |
119 | The location and number of buttons will vary from device to | 123 | The location and number of buttons will vary from device to |
120 | device. userText() and pixmap() may be used to describe this button | 124 | device. userText() and pixmap() may be used to describe this button |
121 | to the user in help documentation. | 125 | to the user in help documentation. |
122 | 126 | ||
123 | \ingroup qtopiaemb | 127 | \ingroup qtopiaemb |
124 | \internal | 128 | \internal |
125 | */ | 129 | */ |
126 | 130 | ||
127 | ODeviceButton::ODeviceButton() | 131 | ODeviceButton::ODeviceButton() |
128 | { | 132 | { |
129 | } | 133 | } |
130 | 134 | ||
131 | ODeviceButton::~ODeviceButton() | 135 | ODeviceButton::~ODeviceButton() |
132 | { | 136 | { |
133 | } | 137 | } |
134 | 138 | ||
135 | /*! | 139 | /*! |
136 | Returns the button's keycode. | 140 | Returns the button's keycode. |
137 | */ | 141 | */ |
138 | ushort ODeviceButton::keycode() const | 142 | ushort ODeviceButton::keycode() const |
139 | { | 143 | { |
140 | return m_Keycode; | 144 | return m_Keycode; |
141 | } | 145 | } |
142 | 146 | ||
143 | 147 | ||
144 | /*! | 148 | /*! |
145 | This function returns a human readable, translated description of the button. | 149 | This function returns a human readable, translated description of the button. |
146 | */ | 150 | */ |
147 | QString ODeviceButton::userText() const | 151 | QString ODeviceButton::userText() const |
148 | { | 152 | { |
149 | return m_UserText; | 153 | return m_UserText; |
150 | } | 154 | } |
151 | 155 | ||
152 | /*! | 156 | /*! |
153 | This function returns the pixmap for this button. If there isn't one | 157 | This function returns the pixmap for this button. If there isn't one |
154 | it will return an empty (null) pixmap. | 158 | it will return an empty (null) pixmap. |
155 | */ | 159 | */ |
156 | QPixmap ODeviceButton::pixmap() const | 160 | QPixmap ODeviceButton::pixmap() const |
157 | { | 161 | { |
158 | return m_Pixmap; | 162 | return m_Pixmap; |
159 | } | 163 | } |
160 | 164 | ||
161 | /*! | 165 | /*! |
162 | This function returns the factory preset (default) action for when this button | 166 | This function returns the factory preset (default) action for when this button |
163 | is pressed. The return value is a legal QCop message. | 167 | is pressed. The return value is a legal QCop message. |
164 | */ | 168 | */ |
165 | OQCopMessage ODeviceButton::factoryPresetPressedAction() const | 169 | OQCopMessage ODeviceButton::factoryPresetPressedAction() const |
166 | { | 170 | { |
167 | return m_FactoryPresetPressedAction; | 171 | return m_FactoryPresetPressedAction; |
168 | } | 172 | } |
169 | 173 | ||
170 | /*! | 174 | /*! |
171 | This function returns the user assigned action for when this button is pressed. | 175 | This function returns the user assigned action for when this button is pressed. |
172 | If no action is assigned, factoryPresetAction() is returned. | 176 | If no action is assigned, factoryPresetAction() is returned. |
173 | */ | 177 | */ |
174 | OQCopMessage ODeviceButton::pressedAction() const | 178 | OQCopMessage ODeviceButton::pressedAction() const |
175 | { | 179 | { |
176 | if (m_PressedAction.channel().isEmpty()) | 180 | if (m_PressedAction.channel().isEmpty()) |
177 | return factoryPresetPressedAction(); | 181 | return factoryPresetPressedAction(); |
178 | return m_PressedAction; | 182 | return m_PressedAction; |
179 | } | 183 | } |
180 | 184 | ||
181 | /*! | 185 | /*! |
182 | This function returns the factory preset (default) action for when this button | 186 | This function returns the factory preset (default) action for when this button |
183 | is pressed and held. The return value is a legal QCop message. | 187 | is pressed and held. The return value is a legal QCop message. |
184 | */ | 188 | */ |
185 | OQCopMessage ODeviceButton::factoryPresetHeldAction() const | 189 | OQCopMessage ODeviceButton::factoryPresetHeldAction() const |
186 | { | 190 | { |
187 | return m_FactoryPresetHeldAction; | 191 | return m_FactoryPresetHeldAction; |
188 | } | 192 | } |
189 | 193 | ||
190 | /*! | 194 | /*! |
191 | This function returns the user assigned action for when this button is pressed | 195 | This function returns the user assigned action for when this button is pressed |
192 | and held. If no action is assigned, factoryPresetAction() is returned. | 196 | and held. If no action is assigned, factoryPresetAction() is returned. |
193 | */ | 197 | */ |
194 | OQCopMessage ODeviceButton::heldAction() const | 198 | OQCopMessage ODeviceButton::heldAction() const |
195 | { | 199 | { |
196 | if (m_HeldAction.channel().isEmpty()) | 200 | if (m_HeldAction.channel().isEmpty()) |
197 | return factoryPresetHeldAction(); | 201 | return factoryPresetHeldAction(); |
198 | return m_HeldAction; | 202 | return m_HeldAction; |
199 | } | 203 | } |
200 | 204 | ||
201 | void ODeviceButton::setKeycode(ushort keycode) | 205 | void ODeviceButton::setKeycode(ushort keycode) |
202 | { | 206 | { |
203 | m_Keycode = keycode; | 207 | m_Keycode = keycode; |
204 | } | 208 | } |
205 | 209 | ||
206 | void ODeviceButton::setUserText(const QString& text) | 210 | void ODeviceButton::setUserText(const QString& text) |
207 | { | 211 | { |
208 | m_UserText = text; | 212 | m_UserText = text; |
209 | } | 213 | } |
210 | 214 | ||
211 | void ODeviceButton::setPixmap(const QPixmap& picture) | 215 | void ODeviceButton::setPixmap(const QPixmap& picture) |
212 | { | 216 | { |
213 | m_Pixmap = picture; | 217 | m_Pixmap = picture; |
214 | } | 218 | } |
215 | 219 | ||
216 | void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action) | 220 | void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action) |
217 | { | 221 | { |
218 | m_FactoryPresetPressedAction = action; | 222 | m_FactoryPresetPressedAction = action; |
219 | } | 223 | } |
220 | 224 | ||
221 | 225 | ||
222 | void ODeviceButton::setPressedAction(const OQCopMessage& action) | 226 | void ODeviceButton::setPressedAction(const OQCopMessage& action) |
223 | { | 227 | { |
224 | m_PressedAction = action; | 228 | m_PressedAction = action; |
225 | } | 229 | } |
226 | 230 | ||
227 | void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action) | 231 | void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action) |
228 | { | 232 | { |
229 | m_FactoryPresetHeldAction = action; | 233 | m_FactoryPresetHeldAction = action; |
230 | } | 234 | } |
231 | 235 | ||
232 | void ODeviceButton::setHeldAction(const OQCopMessage& action) | 236 | void ODeviceButton::setHeldAction(const OQCopMessage& action) |
233 | { | 237 | { |
234 | m_HeldAction = action; | 238 | m_HeldAction = action; |
235 | } | 239 | } |