summaryrefslogtreecommitdiff
path: root/libopie/odevicebutton.cpp
Unidiff
Diffstat (limited to 'libopie/odevicebutton.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevicebutton.cpp2
1 files changed, 0 insertions, 2 deletions
diff --git a/libopie/odevicebutton.cpp b/libopie/odevicebutton.cpp
index 314eb51..647ac4b 100644
--- a/libopie/odevicebutton.cpp
+++ b/libopie/odevicebutton.cpp
@@ -1,239 +1,237 @@
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>
22#include <qstring.h>
23 21
24#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
25#include <opie/odevicebutton.h> 23#include <opie/odevicebutton.h>
26 24
27using namespace Opie; 25using namespace Opie;
28 26
29 27
30class OQCopMessageData { 28class OQCopMessageData {
31public: 29public:
32 QCString m_channel; 30 QCString m_channel;
33 QCString m_message; 31 QCString m_message;
34 QByteArray m_data; 32 QByteArray m_data;
35}; 33};
36 34
37 35
38OQCopMessage::OQCopMessage ( ) 36OQCopMessage::OQCopMessage ( )
39 : d ( 0 ) 37 : d ( 0 )
40{ 38{
41 init ( QCString ( ), QCString ( ), QByteArray ( )); 39 init ( QCString ( ), QCString ( ), QByteArray ( ));
42} 40}
43 41
44OQCopMessage::OQCopMessage ( const OQCopMessage &copy ) 42OQCopMessage::OQCopMessage ( const OQCopMessage &copy )
45 : d ( 0 ) 43 : d ( 0 )
46{ 44{
47 init ( copy. channel ( ), copy. message ( ), copy. data ( )); 45 init ( copy. channel ( ), copy. message ( ), copy. data ( ));
48} 46}
49 47
50OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign ) 48OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign )
51{ 49{
52 init ( assign. channel ( ), assign. message ( ), assign. data ( )); 50 init ( assign. channel ( ), assign. message ( ), assign. data ( ));
53 return *this; 51 return *this;
54} 52}
55 53
56OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg ) 54OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg )
57 : d ( 0 ) 55 : d ( 0 )
58{ 56{
59 init ( ch, m, arg ); 57 init ( ch, m, arg );
60} 58}
61 59
62void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg ) 60void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg )
63{ 61{
64 if ( !d ) 62 if ( !d )
65 d = new OQCopMessageData ( ); 63 d = new OQCopMessageData ( );
66 d-> m_channel = ch; 64 d-> m_channel = ch;
67 d-> m_message = m; 65 d-> m_message = m;
68 d-> m_data = arg; 66 d-> m_data = arg;
69} 67}
70 68
71bool OQCopMessage::send ( ) 69bool OQCopMessage::send ( )
72{ 70{
73 if ( d-> m_channel. isEmpty ( ) || d-> m_message. isEmpty ( ) ) 71 if ( d-> m_channel. isEmpty ( ) || d-> m_message. isEmpty ( ) )
74 return false; 72 return false;
75 73
76 QCopEnvelope e ( d-> m_channel, d-> m_message ); 74 QCopEnvelope e ( d-> m_channel, d-> m_message );
77 75
78 if ( d-> m_data. size ( )) 76 if ( d-> m_data. size ( ))
79 e. writeRawBytes ( d-> m_data. data ( ), d-> m_data. size ( )); 77 e. writeRawBytes ( d-> m_data. data ( ), d-> m_data. size ( ));
80 78
81 return true; 79 return true;
82} 80}
83 81
84QCString OQCopMessage::channel ( ) const 82QCString OQCopMessage::channel ( ) const
85{ 83{
86 return d-> m_channel; 84 return d-> m_channel;
87} 85}
88 86
89QCString OQCopMessage::message ( ) const 87QCString OQCopMessage::message ( ) const
90{ 88{
91 return d-> m_message; 89 return d-> m_message;
92} 90}
93 91
94QByteArray OQCopMessage::data ( ) const 92QByteArray OQCopMessage::data ( ) const
95{ 93{
96 return d-> m_data; 94 return d-> m_data;
97} 95}
98 96
99bool OQCopMessage::isNull() const 97bool OQCopMessage::isNull() const
100{ 98{
101 return d-> m_message.isNull() || d-> m_channel.isNull(); 99 return d-> m_message.isNull() || d-> m_channel.isNull();
102} 100}
103void OQCopMessage::setChannel ( const QCString &ch ) 101void OQCopMessage::setChannel ( const QCString &ch )
104{ 102{
105 d-> m_channel = ch; 103 d-> m_channel = ch;
106} 104}
107 105
108void OQCopMessage::setMessage ( const QCString &m ) 106void OQCopMessage::setMessage ( const QCString &m )
109{ 107{
110 d-> m_message = m; 108 d-> m_message = m;
111} 109}
112 110
113void OQCopMessage::setData ( const QByteArray &data ) 111void OQCopMessage::setData ( const QByteArray &data )
114{ 112{
115 d-> m_data = data; 113 d-> m_data = data;
116} 114}
117 115
118/*! \class Opie::ODeviceButton 116/*! \class Opie::ODeviceButton
119 \brief The Opie::ODeviceButton class represents a physical user mappable button on a Qtopia device. 117 \brief The Opie::ODeviceButton class represents a physical user mappable button on a Qtopia device.
120 118
121 This class represents a physical button on a Qtopia device. A 119 This class represents a physical button on a Qtopia device. A
122 device may have "user programmable" buttons. 120 device may have "user programmable" buttons.
123 The location and number of buttons will vary from device to 121 The location and number of buttons will vary from device to
124 device. userText() and pixmap() may be used to describe this button 122 device. userText() and pixmap() may be used to describe this button
125 to the user in help documentation. 123 to the user in help documentation.
126 124
127 \ingroup qtopiaemb 125 \ingroup qtopiaemb
128 \internal 126 \internal
129*/ 127*/
130 128
131ODeviceButton::ODeviceButton() 129ODeviceButton::ODeviceButton()
132{ 130{
133} 131}
134 132
135ODeviceButton::~ODeviceButton() 133ODeviceButton::~ODeviceButton()
136{ 134{
137} 135}
138 136
139/*! 137/*!
140 Returns the button's keycode. 138 Returns the button's keycode.
141 */ 139 */
142ushort ODeviceButton::keycode() const 140ushort ODeviceButton::keycode() const
143{ 141{
144 return m_Keycode; 142 return m_Keycode;
145} 143}
146 144
147 145
148/*! 146/*!
149 This function returns a human readable, translated description of the button. 147 This function returns a human readable, translated description of the button.
150 */ 148 */
151QString ODeviceButton::userText() const 149QString ODeviceButton::userText() const
152{ 150{
153 return m_UserText; 151 return m_UserText;
154} 152}
155 153
156/*! 154/*!
157 This function returns the pixmap for this button. If there isn't one 155 This function returns the pixmap for this button. If there isn't one
158 it will return an empty (null) pixmap. 156 it will return an empty (null) pixmap.
159 */ 157 */
160QPixmap ODeviceButton::pixmap() const 158QPixmap ODeviceButton::pixmap() const
161{ 159{
162 return m_Pixmap; 160 return m_Pixmap;
163} 161}
164 162
165/*! 163/*!
166 This function returns the factory preset (default) action for when this button 164 This function returns the factory preset (default) action for when this button
167 is pressed. The return value is a legal QCop message. 165 is pressed. The return value is a legal QCop message.
168 */ 166 */
169OQCopMessage ODeviceButton::factoryPresetPressedAction() const 167OQCopMessage ODeviceButton::factoryPresetPressedAction() const
170{ 168{
171 return m_FactoryPresetPressedAction; 169 return m_FactoryPresetPressedAction;
172} 170}
173 171
174/*! 172/*!
175 This function returns the user assigned action for when this button is pressed. 173 This function returns the user assigned action for when this button is pressed.
176 If no action is assigned, factoryPresetAction() is returned. 174 If no action is assigned, factoryPresetAction() is returned.
177 */ 175 */
178OQCopMessage ODeviceButton::pressedAction() const 176OQCopMessage ODeviceButton::pressedAction() const
179{ 177{
180 if (m_PressedAction.channel().isEmpty()) 178 if (m_PressedAction.channel().isEmpty())
181 return factoryPresetPressedAction(); 179 return factoryPresetPressedAction();
182 return m_PressedAction; 180 return m_PressedAction;
183} 181}
184 182
185/*! 183/*!
186 This function returns the factory preset (default) action for when this button 184 This function returns the factory preset (default) action for when this button
187 is pressed and held. The return value is a legal QCop message. 185 is pressed and held. The return value is a legal QCop message.
188 */ 186 */
189OQCopMessage ODeviceButton::factoryPresetHeldAction() const 187OQCopMessage ODeviceButton::factoryPresetHeldAction() const
190{ 188{
191 return m_FactoryPresetHeldAction; 189 return m_FactoryPresetHeldAction;
192} 190}
193 191
194/*! 192/*!
195 This function returns the user assigned action for when this button is pressed 193 This function returns the user assigned action for when this button is pressed
196 and held. If no action is assigned, factoryPresetAction() is returned. 194 and held. If no action is assigned, factoryPresetAction() is returned.
197 */ 195 */
198OQCopMessage ODeviceButton::heldAction() const 196OQCopMessage ODeviceButton::heldAction() const
199{ 197{
200 if (m_HeldAction.channel().isEmpty()) 198 if (m_HeldAction.channel().isEmpty())
201 return factoryPresetHeldAction(); 199 return factoryPresetHeldAction();
202 return m_HeldAction; 200 return m_HeldAction;
203} 201}
204 202
205void ODeviceButton::setKeycode(ushort keycode) 203void ODeviceButton::setKeycode(ushort keycode)
206{ 204{
207 m_Keycode = keycode; 205 m_Keycode = keycode;
208} 206}
209 207
210void ODeviceButton::setUserText(const QString& text) 208void ODeviceButton::setUserText(const QString& text)
211{ 209{
212 m_UserText = text; 210 m_UserText = text;
213} 211}
214 212
215void ODeviceButton::setPixmap(const QPixmap& picture) 213void ODeviceButton::setPixmap(const QPixmap& picture)
216{ 214{
217 m_Pixmap = picture; 215 m_Pixmap = picture;
218} 216}
219 217
220void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action) 218void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action)
221{ 219{
222 m_FactoryPresetPressedAction = action; 220 m_FactoryPresetPressedAction = action;
223} 221}
224 222
225 223
226void ODeviceButton::setPressedAction(const OQCopMessage& action) 224void ODeviceButton::setPressedAction(const OQCopMessage& action)
227{ 225{
228 m_PressedAction = action; 226 m_PressedAction = action;
229} 227}
230 228
231void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action) 229void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action)
232{ 230{
233 m_FactoryPresetHeldAction = action; 231 m_FactoryPresetHeldAction = action;
234} 232}
235 233
236void ODeviceButton::setHeldAction(const OQCopMessage& action) 234void ODeviceButton::setHeldAction(const OQCopMessage& action)
237{ 235{
238 m_HeldAction = action; 236 m_HeldAction = action;
239} 237}