summaryrefslogtreecommitdiffabout
path: root/kabc/sound.cpp
Unidiff
Diffstat (limited to 'kabc/sound.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/sound.cpp117
1 files changed, 117 insertions, 0 deletions
diff --git a/kabc/sound.cpp b/kabc/sound.cpp
new file mode 100644
index 0000000..b2e5254
--- a/dev/null
+++ b/kabc/sound.cpp
@@ -0,0 +1,117 @@
1/*
2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/*
22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk changes
24
25$Id$
26*/
27
28#include "sound.h"
29
30#include <qdatastream.h>
31
32using namespace KABC;
33
34Sound::Sound()
35 : mIntern( false )
36{
37}
38
39Sound::Sound( const QString &url )
40 : mUrl( url ), mIntern( false )
41{
42}
43
44Sound::Sound( const QByteArray &data )
45 : mData( data ), mIntern( true )
46{
47}
48
49Sound::~Sound()
50{
51}
52
53bool Sound::operator==( const Sound &s ) const
54{
55 if ( mIntern != s.mIntern ) return false;
56
57 if ( mIntern ) {
58 if ( mData != s.mData )
59 return false;
60 } else {
61 if ( mUrl != s.mUrl )
62 return false;
63 }
64
65 return true;
66}
67
68bool Sound::operator!=( const Sound &s ) const
69{
70 return !( s == *this );
71}
72
73void Sound::setUrl( const QString &url )
74{
75 mUrl = url;
76 mIntern = false;
77}
78
79void Sound::setData( const QByteArray &data )
80{
81 mData = data;
82 mIntern = true;
83}
84
85bool Sound::isIntern() const
86{
87 return mIntern;
88}
89
90QString Sound::url() const
91{
92 return mUrl;
93}
94
95QByteArray Sound::data() const
96{
97 return mData;
98}
99
100QString Sound::asString() const
101{
102 if ( mIntern )
103 return "intern sound";
104 else
105 return mUrl;
106}
107
108QDataStream &KABC::operator<<( QDataStream &s, const Sound &sound )
109{
110 return s << sound.mIntern << sound.mUrl << sound.mData;
111}
112
113QDataStream &KABC::operator>>( QDataStream &s, Sound &sound )
114{
115 s >> sound.mIntern >> sound.mUrl >> sound.mData;
116 return s;
117}