• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

kabc

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 <QtCore/QDataStream>
00024 #include <QtCore/QSharedData>
00025 
00026 using namespace KABC;
00027 
00028 class Sound::Private : public QSharedData
00029 {
00030   public:
00031     Private()
00032       : mIntern( false )
00033     {
00034     }
00035 
00036     Private( const Private &other )
00037       : QSharedData( other )
00038     {
00039       mUrl = other.mUrl;
00040       mData = other.mData;
00041       mIntern = other.mIntern;
00042     }
00043 
00044     QString mUrl;
00045     QByteArray mData;
00046 
00047     bool mIntern;
00048 };
00049 
00050 Sound::Sound()
00051   : d( new Private )
00052 {
00053 }
00054 
00055 Sound::Sound( const QString &url )
00056   : d( new Private )
00057 {
00058   d->mUrl = url;
00059 }
00060 
00061 Sound::Sound( const QByteArray &data )
00062   : d( new Private )
00063 {
00064   d->mIntern = true;
00065   d->mData = data;
00066 }
00067 
00068 Sound::Sound( const Sound &other )
00069   : d( other.d )
00070 {
00071 }
00072 
00073 Sound::~Sound()
00074 {
00075 }
00076 
00077 Sound &Sound::operator=( const Sound &other )
00078 {
00079   if ( this != &other ) {
00080     d = other.d;
00081   }
00082 
00083   return *this;
00084 }
00085 
00086 bool Sound::operator==( const Sound &other ) const
00087 {
00088   if ( d->mIntern != other.d->mIntern ) {
00089     return false;
00090   }
00091 
00092   if ( d->mIntern ) {
00093     if ( d->mData != other.d->mData ) {
00094       return false;
00095     }
00096   } else {
00097     if ( d->mUrl != other.d->mUrl ) {
00098       return false;
00099     }
00100   }
00101 
00102   return true;
00103 }
00104 
00105 bool Sound::operator!=( const Sound &other ) const
00106 {
00107   return !( other == *this );
00108 }
00109 
00110 void Sound::setUrl( const QString &url )
00111 {
00112   d->mIntern = false;
00113   d->mUrl = url;
00114 }
00115 
00116 void Sound::setData( const QByteArray &data )
00117 {
00118   d->mIntern = true;
00119   d->mData = data;
00120 }
00121 
00122 bool Sound::isIntern() const
00123 {
00124   return d->mIntern;
00125 }
00126 
00127 bool Sound::isEmpty() const
00128 {
00129   return
00130     d->mIntern && d->mData.isEmpty() ||
00131     !d->mIntern && d->mUrl.isEmpty();
00132 }
00133 
00134 QString Sound::url() const
00135 {
00136   return d->mUrl;
00137 }
00138 
00139 QByteArray Sound::data() const
00140 {
00141   return d->mData;
00142 }
00143 
00144 QString Sound::toString() const
00145 {
00146   QString str;
00147 
00148   str += QString( "Sound {\n" );
00149   str += QString( "  IsIntern: %1\n" ).arg( d->mIntern ? "true" : "false" );
00150   if ( d->mIntern ) {
00151     str += QString( "  Data: %1\n" ).arg( QString( d->mData.toBase64() ) );
00152   } else {
00153     str += QString( "  Url: %1\n" ).arg( d->mUrl );
00154   }
00155   str += QString( "}\n" );
00156 
00157   return str;
00158 }
00159 
00160 QDataStream &KABC::operator<<( QDataStream &s, const Sound &sound )
00161 {
00162   return s << sound.d->mIntern << sound.d->mUrl << sound.d->mData;
00163 }
00164 
00165 QDataStream &KABC::operator>>( QDataStream &s, Sound &sound )
00166 {
00167   s >> sound.d->mIntern >> sound.d->mUrl >> sound.d->mData;
00168 
00169   return s;
00170 }

kabc

Skip menu "kabc"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • kabc
  • kblog
  • kcal
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.5
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal