kabc Library API Documentation

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., 59 Temple Place - Suite 330,
00018     Boston, MA 02111-1307, USA.
00019 */
00020 
00021 #include "sound.h"
00022 
00023 #include <qdatastream.h>
00024 
00025 using namespace KABC;
00026 
00027 Sound::Sound()
00028   : mIntern( true )
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 QString Sound::url() const
00084 {
00085   return mUrl;
00086 }
00087 
00088 QByteArray Sound::data() const
00089 {
00090   return mData;
00091 }
00092 
00093 QString Sound::asString() const
00094 {
00095   if ( mIntern )
00096     return "intern sound";
00097   else
00098     return mUrl;
00099 }
00100 
00101 QDataStream &KABC::operator<<( QDataStream &s, const Sound &sound )
00102 {
00103   return s << sound.mIntern << sound.mUrl;
00104 }
00105 
00106 QDataStream &KABC::operator>>( QDataStream &s, Sound &sound )
00107 {
00108   s >> sound.mIntern >> sound.mUrl;
00109   return s;
00110 }
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:22:08 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001