sound.cpp
00001 /* 00002 This file is part of libkabc. 00003 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #include "sound.h" 00022 00023 #include <qdatastream.h> 00024 00025 using namespace KABC; 00026 00027 Sound::Sound() 00028 : mIntern( false ) 00029 { 00030 } 00031 00032 Sound::Sound( const QString &url ) 00033 : mUrl( url ), mIntern( false ) 00034 { 00035 } 00036 00037 Sound::Sound( const QByteArray &data ) 00038 : mData( data ), mIntern( true ) 00039 { 00040 } 00041 00042 Sound::~Sound() 00043 { 00044 } 00045 00046 bool Sound::operator==( const Sound &s ) const 00047 { 00048 if ( mIntern != s.mIntern ) return false; 00049 00050 if ( mIntern ) { 00051 if ( mData != s.mData ) 00052 return false; 00053 } else { 00054 if ( mUrl != s.mUrl ) 00055 return false; 00056 } 00057 00058 return true; 00059 } 00060 00061 bool Sound::operator!=( const Sound &s ) const 00062 { 00063 return !( s == *this ); 00064 } 00065 00066 void Sound::setUrl( const QString &url ) 00067 { 00068 mUrl = url; 00069 mIntern = false; 00070 } 00071 00072 void Sound::setData( const QByteArray &data ) 00073 { 00074 mData = data; 00075 mIntern = true; 00076 } 00077 00078 bool Sound::isIntern() const 00079 { 00080 return mIntern; 00081 } 00082 00083 bool Sound::isEmpty() const 00084 { 00085 return (!mIntern) && mUrl.isEmpty(); 00086 00087 } 00088 00089 QString Sound::url() const 00090 { 00091 return mUrl; 00092 } 00093 00094 QByteArray Sound::data() const 00095 { 00096 return mData; 00097 } 00098 00099 QString Sound::asString() const 00100 { 00101 if ( mIntern ) 00102 return "intern sound"; 00103 else 00104 return mUrl; 00105 } 00106 00107 QDataStream &KABC::operator<<( QDataStream &s, const Sound &sound ) 00108 { 00109 return s << sound.mIntern << sound.mUrl; 00110 // return s << sound.mIntern << sound.mUrl << sound.mData; 00111 } 00112 00113 QDataStream &KABC::operator>>( QDataStream &s, Sound &sound ) 00114 { 00115 s >> sound.mIntern >> sound.mUrl; 00116 // s >> sound.mIntern >> sound.mUrl >> sound.mData; 00117 return s; 00118 }