Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

odevicebutton.cpp

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000-2002 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of the Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 
00021 
00022 #include <qpe/qcopenvelope_qws.h>
00023 #include <opie/odevicebutton.h>
00024 
00025 using namespace Opie;
00026 
00027 
00028 class OQCopMessageData {
00029 public:
00030         QCString m_channel;
00031         QCString m_message;
00032         QByteArray m_data;
00033 };
00034 
00035 
00036 OQCopMessage::OQCopMessage ( )
00037         : d ( 0 )
00038 {
00039         init ( QCString ( ), QCString ( ), QByteArray ( ));
00040 }
00041 
00042 OQCopMessage::OQCopMessage ( const OQCopMessage &copy )
00043         : d ( 0 )
00044 {
00045         init ( copy. channel ( ), copy. message ( ), copy. data ( ));
00046 }
00047 
00048 OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign )
00049 {
00050         init ( assign. channel ( ), assign. message ( ), assign. data ( ));
00051         return *this;
00052 }
00053 
00054 OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg )
00055         : d ( 0 )
00056 {
00057         init ( ch, m, arg );
00058 }
00059 
00060 void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg )
00061 {
00062         if ( !d )
00063                 d = new OQCopMessageData ( );
00064         d-> m_channel = ch;
00065         d-> m_message = m;
00066         d-> m_data = arg;
00067 }
00068 
00069 bool OQCopMessage::send ( )
00070 {
00071         if ( d-> m_channel. isEmpty ( ) || d-> m_message. isEmpty ( ) )
00072                 return false;
00073 
00074         QCopEnvelope e ( d-> m_channel, d-> m_message );
00075 
00076         if ( d-> m_data. size ( ))
00077                 e. writeRawBytes ( d-> m_data. data ( ), d-> m_data. size ( ));
00078 
00079         return true;
00080 }
00081 
00082 QCString OQCopMessage::channel ( ) const
00083 {
00084         return d-> m_channel;
00085 }
00086 
00087 QCString OQCopMessage::message ( ) const
00088 {
00089         return d-> m_message;
00090 }
00091 
00092 QByteArray OQCopMessage::data ( ) const
00093 {
00094         return d-> m_data;
00095 }
00096 
00097 bool OQCopMessage::isNull() const
00098 {
00099         return d-> m_message.isNull() || d-> m_channel.isNull();
00100 }
00101 void OQCopMessage::setChannel ( const QCString &ch )
00102 {
00103         d-> m_channel = ch;
00104 }
00105 
00106 void OQCopMessage::setMessage ( const QCString &m )
00107 {
00108         d-> m_message = m;
00109 }
00110 
00111 void OQCopMessage::setData ( const QByteArray &data )
00112 {
00113         d-> m_data = data;
00114 }
00115 
00129 ODeviceButton::ODeviceButton()
00130 {
00131 }
00132 
00133 ODeviceButton::~ODeviceButton()
00134 {
00135 }
00136 
00140 ushort ODeviceButton::keycode() const
00141 {
00142     return m_Keycode;
00143 }
00144 
00145 
00149 QString ODeviceButton::userText() const
00150 {
00151     return m_UserText;
00152 }
00153 
00158 QPixmap ODeviceButton::pixmap() const
00159 {
00160     return m_Pixmap;
00161 }
00162 
00167 OQCopMessage ODeviceButton::factoryPresetPressedAction() const
00168 {
00169     return m_FactoryPresetPressedAction;
00170 }
00171 
00176 OQCopMessage ODeviceButton::pressedAction() const
00177 {
00178     if (m_PressedAction.channel().isEmpty())
00179         return factoryPresetPressedAction();
00180     return m_PressedAction;
00181 }
00182 
00187 OQCopMessage ODeviceButton::factoryPresetHeldAction() const
00188 {
00189     return m_FactoryPresetHeldAction;
00190 }
00191 
00196 OQCopMessage ODeviceButton::heldAction() const
00197 {
00198     if (m_HeldAction.channel().isEmpty())
00199         return factoryPresetHeldAction();
00200     return m_HeldAction;
00201 }
00202 
00203 void ODeviceButton::setKeycode(ushort keycode)
00204 {
00205     m_Keycode = keycode;
00206 }
00207 
00208 void ODeviceButton::setUserText(const QString& text)
00209 {
00210     m_UserText = text;
00211 }
00212 
00213 void ODeviceButton::setPixmap(const QPixmap& picture)
00214 {
00215     m_Pixmap = picture;
00216 }
00217 
00218 void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action)
00219 {
00220     m_FactoryPresetPressedAction = action;
00221 }
00222 
00223 
00224 void ODeviceButton::setPressedAction(const OQCopMessage& action)
00225 {
00226     m_PressedAction = action;
00227 }
00228 
00229 void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action)
00230 {
00231     m_FactoryPresetHeldAction = action;
00232 }
00233 
00234 void ODeviceButton::setHeldAction(const OQCopMessage& action)
00235 {
00236     m_HeldAction = action;
00237 }

Generated on Sat Nov 5 16:16:06 2005 for OPIE by  doxygen 1.4.2