Diffstat (limited to 'libopie2/opiecore/device/odevicebutton.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevicebutton.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/libopie2/opiecore/device/odevicebutton.cpp b/libopie2/opiecore/device/odevicebutton.cpp index 0b593d5..a081b7f 100644 --- a/libopie2/opiecore/device/odevicebutton.cpp +++ b/libopie2/opiecore/device/odevicebutton.cpp | |||
@@ -1,246 +1,255 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <qpixmap.h> | 30 | #include <qpixmap.h> |
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | 32 | ||
33 | #include <qpe/qcopenvelope_qws.h> | 33 | #include <qpe/qcopenvelope_qws.h> |
34 | #include <opie2/odevicebutton.h> | 34 | #include <opie2/odevicebutton.h> |
35 | 35 | ||
36 | using namespace Opie; | 36 | |
37 | namespace Opie { | ||
38 | namespace Core { | ||
39 | namespace Private { | ||
37 | 40 | ||
38 | class OQCopMessageData | 41 | class OQCopMessageData |
39 | { | 42 | { |
40 | public: | 43 | public: |
41 | QCString m_channel; | 44 | QCString m_channel; |
42 | QCString m_message; | 45 | QCString m_message; |
43 | QByteArray m_data; | 46 | QByteArray m_data; |
44 | }; | 47 | }; |
48 | } | ||
45 | 49 | ||
50 | using namespace Opie::Core; | ||
51 | using namespace Opie::Core::Private; | ||
46 | 52 | ||
47 | OQCopMessage::OQCopMessage() | 53 | OQCopMessage::OQCopMessage() |
48 | : d ( 0 ) | 54 | : d ( 0 ) |
49 | { | 55 | { |
50 | init ( QCString(), QCString(), QByteArray()); | 56 | init ( QCString(), QCString(), QByteArray()); |
51 | } | 57 | } |
52 | 58 | ||
53 | OQCopMessage::OQCopMessage ( const OQCopMessage © ) | 59 | OQCopMessage::OQCopMessage ( const OQCopMessage © ) |
54 | : d ( 0 ) | 60 | : d ( 0 ) |
55 | { | 61 | { |
56 | init ( copy. channel(), copy. message(), copy. data()); | 62 | init ( copy. channel(), copy. message(), copy. data()); |
57 | } | 63 | } |
58 | 64 | ||
59 | OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign ) | 65 | OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign ) |
60 | { | 66 | { |
61 | init ( assign. channel(), assign. message(), assign. data()); | 67 | init ( assign. channel(), assign. message(), assign. data()); |
62 | return *this; | 68 | return *this; |
63 | } | 69 | } |
64 | 70 | ||
65 | OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg ) | 71 | OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg ) |
66 | : d ( 0 ) | 72 | : d ( 0 ) |
67 | { | 73 | { |
68 | init ( ch, m, arg ); | 74 | init ( ch, m, arg ); |
69 | } | 75 | } |
70 | 76 | ||
71 | void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg ) | 77 | void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg ) |
72 | { | 78 | { |
73 | if ( !d ) | 79 | if ( !d ) |
74 | d = new OQCopMessageData(); | 80 | d = new OQCopMessageData(); |
75 | d->m_channel = ch; | 81 | d->m_channel = ch; |
76 | d->m_message = m; | 82 | d->m_message = m; |
77 | d->m_data = arg; | 83 | d->m_data = arg; |
78 | } | 84 | } |
79 | 85 | ||
80 | bool OQCopMessage::send() | 86 | bool OQCopMessage::send() |
81 | { | 87 | { |
82 | if ( d->m_channel. isEmpty() || d->m_message. isEmpty() ) | 88 | if ( d->m_channel. isEmpty() || d->m_message. isEmpty() ) |
83 | return false; | 89 | return false; |
84 | 90 | ||
85 | QCopEnvelope e ( d->m_channel, d->m_message ); | 91 | QCopEnvelope e ( d->m_channel, d->m_message ); |
86 | 92 | ||
87 | if ( d->m_data. size()) | 93 | if ( d->m_data. size()) |
88 | e. writeRawBytes ( d->m_data. data(), d->m_data. size()); | 94 | e. writeRawBytes ( d->m_data. data(), d->m_data. size()); |
89 | 95 | ||
90 | return true; | 96 | return true; |
91 | } | 97 | } |
92 | 98 | ||
93 | QCString OQCopMessage::channel() const | 99 | QCString OQCopMessage::channel() const |
94 | { | 100 | { |
95 | return d->m_channel; | 101 | return d->m_channel; |
96 | } | 102 | } |
97 | 103 | ||
98 | QCString OQCopMessage::message() const | 104 | QCString OQCopMessage::message() const |
99 | { | 105 | { |
100 | return d->m_message; | 106 | return d->m_message; |
101 | } | 107 | } |
102 | 108 | ||
103 | QByteArray OQCopMessage::data() const | 109 | QByteArray OQCopMessage::data() const |
104 | { | 110 | { |
105 | return d->m_data; | 111 | return d->m_data; |
106 | } | 112 | } |
107 | 113 | ||
108 | bool OQCopMessage::isNull() const | 114 | bool OQCopMessage::isNull() const |
109 | { | 115 | { |
110 | return d->m_message.isNull() || d->m_channel.isNull(); | 116 | return d->m_message.isNull() || d->m_channel.isNull(); |
111 | } | 117 | } |
112 | void OQCopMessage::setChannel ( const QCString &ch ) | 118 | void OQCopMessage::setChannel ( const QCString &ch ) |
113 | { | 119 | { |
114 | d->m_channel = ch; | 120 | d->m_channel = ch; |
115 | } | 121 | } |
116 | 122 | ||
117 | void OQCopMessage::setMessage ( const QCString &m ) | 123 | void OQCopMessage::setMessage ( const QCString &m ) |
118 | { | 124 | { |
119 | d->m_message = m; | 125 | d->m_message = m; |
120 | } | 126 | } |
121 | 127 | ||
122 | void OQCopMessage::setData ( const QByteArray &data ) | 128 | void OQCopMessage::setData ( const QByteArray &data ) |
123 | { | 129 | { |
124 | d->m_data = data; | 130 | d->m_data = data; |
125 | } | 131 | } |
126 | 132 | ||
127 | /*! \class Opie::ODeviceButton | 133 | /*! \class Opie::Core::ODeviceButton |
128 | \brief The Opie::ODeviceButton class represents a physical user mappable button on a Qtopia device. | 134 | \brief The Opie::Core::ODeviceButton class represents a physical user mappable button on a Qtopia device. |
129 | 135 | ||
130 | This class represents a physical button on a Qtopia device. A | 136 | This class represents a physical button on a Qtopia device. A |
131 | device may have "user programmable" buttons. | 137 | device may have "user programmable" buttons. |
132 | The location and number of buttons will vary from device to | 138 | The location and number of buttons will vary from device to |
133 | device. userText() and pixmap() may be used to describe this button | 139 | device. userText() and pixmap() may be used to describe this button |
134 | to the user in help documentation. | 140 | to the user in help documentation. |
135 | 141 | ||
136 | \ingroup qtopiaemb | 142 | \ingroup qtopiaemb |
137 | \internal | 143 | \internal |
138 | */ | 144 | */ |
139 | 145 | ||
140 | ODeviceButton::ODeviceButton() | 146 | ODeviceButton::ODeviceButton() |
141 | {} | 147 | {} |
142 | 148 | ||
143 | ODeviceButton::~ODeviceButton() | 149 | ODeviceButton::~ODeviceButton() |
144 | {} | 150 | {} |
145 | 151 | ||
146 | /*! | 152 | /*! |
147 | Returns the button's keycode. | 153 | Returns the button's keycode. |
148 | */ | 154 | */ |
149 | ushort ODeviceButton::keycode() const | 155 | ushort ODeviceButton::keycode() const |
150 | { | 156 | { |
151 | return m_Keycode; | 157 | return m_Keycode; |
152 | } | 158 | } |
153 | 159 | ||
154 | 160 | ||
155 | /*! | 161 | /*! |
156 | This function returns a human readable, translated description of the button. | 162 | This function returns a human readable, translated description of the button. |
157 | */ | 163 | */ |
158 | QString ODeviceButton::userText() const | 164 | QString ODeviceButton::userText() const |
159 | { | 165 | { |
160 | return m_UserText; | 166 | return m_UserText; |
161 | } | 167 | } |
162 | 168 | ||
163 | /*! | 169 | /*! |
164 | This function returns the pixmap for this button. If there isn't one | 170 | This function returns the pixmap for this button. If there isn't one |
165 | it will return an empty (null) pixmap. | 171 | it will return an empty (null) pixmap. |
166 | */ | 172 | */ |
167 | QPixmap ODeviceButton::pixmap() const | 173 | QPixmap ODeviceButton::pixmap() const |
168 | { | 174 | { |
169 | return m_Pixmap; | 175 | return m_Pixmap; |
170 | } | 176 | } |
171 | 177 | ||
172 | /*! | 178 | /*! |
173 | This function returns the factory preset (default) action for when this button | 179 | This function returns the factory preset (default) action for when this button |
174 | is pressed. The return value is a legal QCop message. | 180 | is pressed. The return value is a legal QCop message. |
175 | */ | 181 | */ |
176 | OQCopMessage ODeviceButton::factoryPresetPressedAction() const | 182 | OQCopMessage ODeviceButton::factoryPresetPressedAction() const |
177 | { | 183 | { |
178 | return m_FactoryPresetPressedAction; | 184 | return m_FactoryPresetPressedAction; |
179 | } | 185 | } |
180 | 186 | ||
181 | /*! | 187 | /*! |
182 | This function returns the user assigned action for when this button is pressed. | 188 | This function returns the user assigned action for when this button is pressed. |
183 | If no action is assigned, factoryPresetAction() is returned. | 189 | If no action is assigned, factoryPresetAction() is returned. |
184 | */ | 190 | */ |
185 | OQCopMessage ODeviceButton::pressedAction() const | 191 | OQCopMessage ODeviceButton::pressedAction() const |
186 | { | 192 | { |
187 | if (m_PressedAction.channel().isEmpty()) | 193 | if (m_PressedAction.channel().isEmpty()) |
188 | return factoryPresetPressedAction(); | 194 | return factoryPresetPressedAction(); |
189 | return m_PressedAction; | 195 | return m_PressedAction; |
190 | } | 196 | } |
191 | 197 | ||
192 | /*! | 198 | /*! |
193 | This function returns the factory preset (default) action for when this button | 199 | This function returns the factory preset (default) action for when this button |
194 | is pressed and held. The return value is a legal QCop message. | 200 | is pressed and held. The return value is a legal QCop message. |
195 | */ | 201 | */ |
196 | OQCopMessage ODeviceButton::factoryPresetHeldAction() const | 202 | OQCopMessage ODeviceButton::factoryPresetHeldAction() const |
197 | { | 203 | { |
198 | return m_FactoryPresetHeldAction; | 204 | return m_FactoryPresetHeldAction; |
199 | } | 205 | } |
200 | 206 | ||
201 | /*! | 207 | /*! |
202 | This function returns the user assigned action for when this button is pressed | 208 | This function returns the user assigned action for when this button is pressed |
203 | and held. If no action is assigned, factoryPresetAction() is returned. | 209 | and held. If no action is assigned, factoryPresetAction() is returned. |
204 | */ | 210 | */ |
205 | OQCopMessage ODeviceButton::heldAction() const | 211 | OQCopMessage ODeviceButton::heldAction() const |
206 | { | 212 | { |
207 | if (m_HeldAction.channel().isEmpty()) | 213 | if (m_HeldAction.channel().isEmpty()) |
208 | return factoryPresetHeldAction(); | 214 | return factoryPresetHeldAction(); |
209 | return m_HeldAction; | 215 | return m_HeldAction; |
210 | } | 216 | } |
211 | 217 | ||
212 | void ODeviceButton::setKeycode(ushort keycode) | 218 | void ODeviceButton::setKeycode(ushort keycode) |
213 | { | 219 | { |
214 | m_Keycode = keycode; | 220 | m_Keycode = keycode; |
215 | } | 221 | } |
216 | 222 | ||
217 | void ODeviceButton::setUserText(const QString& text) | 223 | void ODeviceButton::setUserText(const QString& text) |
218 | { | 224 | { |
219 | m_UserText = text; | 225 | m_UserText = text; |
220 | } | 226 | } |
221 | 227 | ||
222 | void ODeviceButton::setPixmap(const QPixmap& picture) | 228 | void ODeviceButton::setPixmap(const QPixmap& picture) |
223 | { | 229 | { |
224 | m_Pixmap = picture; | 230 | m_Pixmap = picture; |
225 | } | 231 | } |
226 | 232 | ||
227 | void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action) | 233 | void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action) |
228 | { | 234 | { |
229 | m_FactoryPresetPressedAction = action; | 235 | m_FactoryPresetPressedAction = action; |
230 | } | 236 | } |
231 | 237 | ||
232 | 238 | ||
233 | void ODeviceButton::setPressedAction(const OQCopMessage& action) | 239 | void ODeviceButton::setPressedAction(const OQCopMessage& action) |
234 | { | 240 | { |
235 | m_PressedAction = action; | 241 | m_PressedAction = action; |
236 | } | 242 | } |
237 | 243 | ||
238 | void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action) | 244 | void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action) |
239 | { | 245 | { |
240 | m_FactoryPresetHeldAction = action; | 246 | m_FactoryPresetHeldAction = action; |
241 | } | 247 | } |
242 | 248 | ||
243 | void ODeviceButton::setHeldAction(const OQCopMessage& action) | 249 | void ODeviceButton::setHeldAction(const OQCopMessage& action) |
244 | { | 250 | { |
245 | m_HeldAction = action; | 251 | m_HeldAction = action; |
246 | } | 252 | } |
253 | |||
254 | } | ||
255 | } | ||