summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device/odevicebutton.cpp
Unidiff
Diffstat (limited to 'libopie2/opiecore/device/odevicebutton.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevicebutton.cpp15
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
36using namespace Opie; 36
37namespace Opie {
38namespace Core {
39namespace Private {
37 40
38class OQCopMessageData 41class 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
50using namespace Opie::Core;
51using namespace Opie::Core::Private;
46 52
47OQCopMessage::OQCopMessage() 53OQCopMessage::OQCopMessage()
48 : d ( 0 ) 54 : d ( 0 )
49{ 55{
50 init ( QCString(), QCString(), QByteArray()); 56 init ( QCString(), QCString(), QByteArray());
51} 57}
52 58
53OQCopMessage::OQCopMessage ( const OQCopMessage &copy ) 59OQCopMessage::OQCopMessage ( const OQCopMessage &copy )
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
59OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign ) 65OQCopMessage &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
65OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg ) 71OQCopMessage::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
71void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg ) 77void 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
80bool OQCopMessage::send() 86bool 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
93QCString OQCopMessage::channel() const 99QCString OQCopMessage::channel() const
94{ 100{
95 return d->m_channel; 101 return d->m_channel;
96} 102}
97 103
98QCString OQCopMessage::message() const 104QCString OQCopMessage::message() const
99{ 105{
100 return d->m_message; 106 return d->m_message;
101} 107}
102 108
103QByteArray OQCopMessage::data() const 109QByteArray OQCopMessage::data() const
104{ 110{
105 return d->m_data; 111 return d->m_data;
106} 112}
107 113
108bool OQCopMessage::isNull() const 114bool 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}
112void OQCopMessage::setChannel ( const QCString &ch ) 118void OQCopMessage::setChannel ( const QCString &ch )
113{ 119{
114 d->m_channel = ch; 120 d->m_channel = ch;
115} 121}
116 122
117void OQCopMessage::setMessage ( const QCString &m ) 123void OQCopMessage::setMessage ( const QCString &m )
118{ 124{
119 d->m_message = m; 125 d->m_message = m;
120} 126}
121 127
122void OQCopMessage::setData ( const QByteArray &data ) 128void 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
140ODeviceButton::ODeviceButton() 146ODeviceButton::ODeviceButton()
141{} 147{}
142 148
143ODeviceButton::~ODeviceButton() 149ODeviceButton::~ODeviceButton()
144{} 150{}
145 151
146/*! 152/*!
147Returns the button's keycode. 153Returns the button's keycode.
148*/ 154*/
149ushort ODeviceButton::keycode() const 155ushort ODeviceButton::keycode() const
150{ 156{
151 return m_Keycode; 157 return m_Keycode;
152} 158}
153 159
154 160
155/*! 161/*!
156This function returns a human readable, translated description of the button. 162This function returns a human readable, translated description of the button.
157*/ 163*/
158QString ODeviceButton::userText() const 164QString ODeviceButton::userText() const
159{ 165{
160 return m_UserText; 166 return m_UserText;
161} 167}
162 168
163/*! 169/*!
164This function returns the pixmap for this button. If there isn't one 170This function returns the pixmap for this button. If there isn't one
165it will return an empty (null) pixmap. 171it will return an empty (null) pixmap.
166*/ 172*/
167QPixmap ODeviceButton::pixmap() const 173QPixmap ODeviceButton::pixmap() const
168{ 174{
169 return m_Pixmap; 175 return m_Pixmap;
170} 176}
171 177
172/*! 178/*!
173This function returns the factory preset (default) action for when this button 179This function returns the factory preset (default) action for when this button
174is pressed. The return value is a legal QCop message. 180is pressed. The return value is a legal QCop message.
175*/ 181*/
176OQCopMessage ODeviceButton::factoryPresetPressedAction() const 182OQCopMessage ODeviceButton::factoryPresetPressedAction() const
177{ 183{
178 return m_FactoryPresetPressedAction; 184 return m_FactoryPresetPressedAction;
179} 185}
180 186
181/*! 187/*!
182This function returns the user assigned action for when this button is pressed. 188This function returns the user assigned action for when this button is pressed.
183If no action is assigned, factoryPresetAction() is returned. 189If no action is assigned, factoryPresetAction() is returned.
184*/ 190*/
185OQCopMessage ODeviceButton::pressedAction() const 191OQCopMessage 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/*!
193This function returns the factory preset (default) action for when this button 199This function returns the factory preset (default) action for when this button
194is pressed and held. The return value is a legal QCop message. 200is pressed and held. The return value is a legal QCop message.
195*/ 201*/
196OQCopMessage ODeviceButton::factoryPresetHeldAction() const 202OQCopMessage ODeviceButton::factoryPresetHeldAction() const
197{ 203{
198 return m_FactoryPresetHeldAction; 204 return m_FactoryPresetHeldAction;
199} 205}
200 206
201/*! 207/*!
202This function returns the user assigned action for when this button is pressed 208This function returns the user assigned action for when this button is pressed
203and held. If no action is assigned, factoryPresetAction() is returned. 209and held. If no action is assigned, factoryPresetAction() is returned.
204*/ 210*/
205OQCopMessage ODeviceButton::heldAction() const 211OQCopMessage 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
212void ODeviceButton::setKeycode(ushort keycode) 218void ODeviceButton::setKeycode(ushort keycode)
213{ 219{
214 m_Keycode = keycode; 220 m_Keycode = keycode;
215} 221}
216 222
217void ODeviceButton::setUserText(const QString& text) 223void ODeviceButton::setUserText(const QString& text)
218{ 224{
219 m_UserText = text; 225 m_UserText = text;
220} 226}
221 227
222void ODeviceButton::setPixmap(const QPixmap& picture) 228void ODeviceButton::setPixmap(const QPixmap& picture)
223{ 229{
224 m_Pixmap = picture; 230 m_Pixmap = picture;
225} 231}
226 232
227void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action) 233void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action)
228{ 234{
229 m_FactoryPresetPressedAction = action; 235 m_FactoryPresetPressedAction = action;
230} 236}
231 237
232 238
233void ODeviceButton::setPressedAction(const OQCopMessage& action) 239void ODeviceButton::setPressedAction(const OQCopMessage& action)
234{ 240{
235 m_PressedAction = action; 241 m_PressedAction = action;
236} 242}
237 243
238void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action) 244void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action)
239{ 245{
240 m_FactoryPresetHeldAction = action; 246 m_FactoryPresetHeldAction = action;
241} 247}
242 248
243void ODeviceButton::setHeldAction(const OQCopMessage& action) 249void ODeviceButton::setHeldAction(const OQCopMessage& action)
244{ 250{
245 m_HeldAction = action; 251 m_HeldAction = action;
246} 252}
253
254}
255}