• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 API Reference
  • KDE Home
  • Contact Us
 

kabc

  • kabc
sound.cpp
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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#include "sound.h"
22
23#include <QtCore/QDataStream>
24#include <QtCore/QSharedData>
25
26using namespace KABC;
27
28class Sound::Private : public QSharedData
29{
30 public:
31 Private()
32 : mIntern( false )
33 {
34 }
35
36 Private( const Private &other )
37 : QSharedData( other )
38 {
39 mUrl = other.mUrl;
40 mData = other.mData;
41 mIntern = other.mIntern;
42 }
43
44 QString mUrl;
45 QByteArray mData;
46
47 bool mIntern;
48};
49
50Sound::Sound()
51 : d( new Private )
52{
53}
54
55Sound::Sound( const QString &url )
56 : d( new Private )
57{
58 d->mUrl = url;
59}
60
61Sound::Sound( const QByteArray &data )
62 : d( new Private )
63{
64 d->mIntern = true;
65 d->mData = data;
66}
67
68Sound::Sound( const Sound &other )
69 : d( other.d )
70{
71}
72
73Sound::~Sound()
74{
75}
76
77Sound &Sound::operator=( const Sound &other )
78{
79 if ( this != &other ) {
80 d = other.d;
81 }
82
83 return *this;
84}
85
86bool Sound::operator==( const Sound &other ) const
87{
88 if ( d->mIntern != other.d->mIntern ) {
89 return false;
90 }
91
92 if ( d->mIntern ) {
93 if ( d->mData != other.d->mData ) {
94 return false;
95 }
96 } else {
97 if ( d->mUrl != other.d->mUrl ) {
98 return false;
99 }
100 }
101
102 return true;
103}
104
105bool Sound::operator!=( const Sound &other ) const
106{
107 return !( other == *this );
108}
109
110void Sound::setUrl( const QString &url )
111{
112 d->mIntern = false;
113 d->mUrl = url;
114}
115
116void Sound::setData( const QByteArray &data )
117{
118 d->mIntern = true;
119 d->mData = data;
120}
121
122bool Sound::isIntern() const
123{
124 return d->mIntern;
125}
126
127bool Sound::isEmpty() const
128{
129 return
130 ( ( d->mIntern && d->mData.isEmpty() ) || ( !d->mIntern && d->mUrl.isEmpty() ) );
131}
132
133QString Sound::url() const
134{
135 return d->mUrl;
136}
137
138QByteArray Sound::data() const
139{
140 return d->mData;
141}
142
143QString Sound::toString() const
144{
145 QString str;
146
147 str += QLatin1String( "Sound {\n" );
148 str += QString::fromLatin1( " IsIntern: %1\n" ).
149 arg( d->mIntern ? QLatin1String( "true" ) : QLatin1String( "false" ) );
150 if ( d->mIntern ) {
151 str += QString::fromLatin1( " Data: %1\n" ).
152 arg( QString::fromLatin1( d->mData.toBase64() ) );
153 } else {
154 str += QString::fromLatin1( " Url: %1\n" ).arg( d->mUrl );
155 }
156 str += QLatin1String( "}\n" );
157
158 return str;
159}
160
161QDataStream &KABC::operator<<( QDataStream &s, const Sound &sound )
162{
163 return s << sound.d->mIntern << sound.d->mUrl << sound.d->mData;
164}
165
166QDataStream &KABC::operator>>( QDataStream &s, Sound &sound )
167{
168 s >> sound.d->mIntern >> sound.d->mUrl >> sound.d->mData;
169
170 return s;
171}
KABC::Sound
Class that holds a Sound clip for a contact.
Definition sound.h:59
KABC::Sound::~Sound
~Sound()
Destroys the sound object.
Definition sound.cpp:73
KABC::Sound::data
QByteArray data() const
Returns the raw data of this sound.
Definition sound.cpp:138
KABC::Sound::setData
void setData(const QByteArray &data)
Sets the raw data of the sound.
Definition sound.cpp:116
KABC::Sound::operator!=
bool operator!=(const Sound &other) const
Not-Equal operator.
Definition sound.cpp:105
KABC::Sound::Sound
Sound()
Creates an empty sound object.
Definition sound.cpp:50
KABC::Sound::url
QString url() const
Returns the location URL of this sound.
Definition sound.cpp:133
KABC::Sound::toString
QString toString() const
Returns string representation of the sound.
Definition sound.cpp:143
KABC::Sound::setUrl
void setUrl(const QString &url)
Sets a URL for the location of the sound file.
Definition sound.cpp:110
KABC::Sound::isIntern
bool isIntern() const
Returns whether the sound is described by a URL (extern) or by the raw data (intern).
Definition sound.cpp:122
KABC::Sound::operator=
Sound & operator=(const Sound &other)
Assignment operator.
Definition sound.cpp:77
KABC::Sound::operator==
bool operator==(const Sound &other) const
Equality operator.
Definition sound.cpp:86
KABC::Sound::isEmpty
bool isEmpty() const
Returns true, if the sound object is empty.
Definition sound.cpp:127
KABC
Class that holds a Calendar Url (FBURL/CALADRURI/CALURI)
Definition address.h:29
KABC::operator<<
QDataStream & operator<<(QDataStream &stream, const Address &address)
Serializes the address object into the stream.
Definition address.cpp:680
KABC::operator>>
QDataStream & operator>>(QDataStream &stream, Address &address)
Initializes the address object from the stream.
Definition address.cpp:688
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Wed Jan 24 2024 00:00:00 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kabc

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

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal