KContacts::Sound

Search for usage in LXR

KContacts::Sound Class Reference

#include <sound.h>

Public Types

typedef QList< SoundList
 

Public Member Functions

 Sound ()
 
 Sound (const QByteArray &data)
 
 Sound (const QString &url)
 
 Sound (const Sound &other)
 
 ~Sound ()
 
QByteArray data () const
 
bool isEmpty () const
 
bool isIntern () const
 
bool operator!= (const Sound &other) const
 
Soundoperator= (const Sound &other)
 
bool operator== (const Sound &other) const
 
void setData (const QByteArray &data)
 
void setUrl (const QString &url)
 
QString toString () const
 
QString url () const
 

Detailed Description

Class that holds a Sound clip for a contact.

The sound can be played doing something like this:

KTempFile tmp;
if ( sound.isIntern() ) {
tmp.file()->write( sound.data() );
tmp.close();
KAudioPlayer::play( tmp.name() );
} else if( !sound.url().isEmpty() ) {
QString tmpFile;
if ( !KIO::NetAccess::download( QUrl( themeURL.url() ), tmpFile, 0 ) ) {
KIO::NetAccess::lastErrorString(),
i18n( "Failed to download sound file" ),
);
return;
}
KAudioPlayer::play( tmpFile );
}
QString i18n(const char *text, const TYPE &arg...)
void error(QWidget *parent, const QString &text, const QString &title, const KGuiItem &buttonOk, Options options=Notify)

Unfortunately, KAudioPlayer::play is ASync, so to delete the temporary file the best you can really do is set a timer.

Definition at line 45 of file sound.h.

Member Typedef Documentation

◆ List

Definition at line 80 of file sound.h.

Constructor & Destructor Documentation

◆ Sound() [1/4]

Sound::Sound ( )

Creates an empty sound object.

Definition at line 37 of file sound.cpp.

◆ Sound() [2/4]

Sound::Sound ( const QString & url)

Creates a sound object for the given url.

Parameters
urlA url that describes the position of the sound file.

Definition at line 42 of file sound.cpp.

◆ Sound() [3/4]

Sound::Sound ( const QByteArray & data)

Creates a sound object for the given data.

Parameters
dataThe raw data of the sound.

Definition at line 48 of file sound.cpp.

◆ Sound() [4/4]

Sound::Sound ( const Sound & other)

Copy constructor.

Definition at line 55 of file sound.cpp.

◆ ~Sound()

Sound::~Sound ( )

Destroys the sound object.

Definition at line 60 of file sound.cpp.

Member Function Documentation

◆ data()

QByteArray Sound::data ( ) const

Returns the raw data of this sound.

Definition at line 124 of file sound.cpp.

◆ isEmpty()

bool Sound::isEmpty ( ) const

Returns true, if the sound object is empty.

Definition at line 114 of file sound.cpp.

◆ isIntern()

bool Sound::isIntern ( ) const

Returns whether the sound is described by a URL (extern) or by the raw data (intern).

When this method returns 'true' you can use data() to get the raw data. Otherwise you can request the URL of this sound by url() and load the raw data from that location.

Definition at line 109 of file sound.cpp.

◆ operator!=()

bool Sound::operator!= ( const Sound & other) const

Not-Equal operator.

Parameters
otherThe object to compare with
Returns
true if the two objects are not equal, otherwise false

Definition at line 92 of file sound.cpp.

◆ operator=()

Sound & Sound::operator= ( const Sound & other)

Assignment operator.

Parameters
otherThe sound object to assign to this

Definition at line 64 of file sound.cpp.

◆ operator==()

bool Sound::operator== ( const Sound & other) const

Equality operator.

Parameters
otherThe object to compare with
Returns
true if the two objects are equal, otherwise false

Definition at line 73 of file sound.cpp.

◆ setData()

void Sound::setData ( const QByteArray & data)

Sets the raw data of the sound.

When using this function, isIntern() will return 'true' until you use setUrl().

Parameters
dataThe raw data of the sound.

Definition at line 103 of file sound.cpp.

◆ setUrl()

void Sound::setUrl ( const QString & url)

Sets a URL for the location of the sound file.

When using this function, isIntern() will return 'false' until you use setData().

Parameters
urlThe location URL of the sound file.

Definition at line 97 of file sound.cpp.

◆ toString()

QString Sound::toString ( ) const

Returns string representation of the sound.

Definition at line 129 of file sound.cpp.

◆ url()

QString Sound::url ( ) const

Returns the location URL of this sound.

Definition at line 119 of file sound.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:14:08 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.