Commit 25f83635 authored by Tobias Koenig's avatar Tobias Koenig

API cleanup

svn path=/trunk/playground/graphics/okular/; revision=608230
parent 1cea7cb7
......@@ -14,17 +14,122 @@ using namespace Okular;
/** class Okular::PageTransition **/
class PageTransition::Private
{
public:
Private( Type type )
: m_type( type ),
m_duration( 1 ),
m_alignment( Horizontal ),
m_direction( Inward ),
m_angle( 0 ),
m_scale( 1.0 ),
m_rectangular( false )
{
}
Type m_type;
int m_duration;
Alignment m_alignment;
Direction m_direction;
int m_angle;
double m_scale;
bool m_rectangular;
};
PageTransition::PageTransition( Type type )
: m_type( type ),
m_duration( 1 ),
m_alignment( Horizontal ),
m_direction( Inward ),
m_angle( 0 ),
m_scale( 1.0 ),
m_rectangular( false )
: d( new Private( type ) )
{
}
PageTransition::PageTransition( const PageTransition &other )
: d( new Private( Replace ) )
{
*d = *other.d;
}
PageTransition& PageTransition::operator=( const PageTransition &other )
{
if ( this == &other )
return *this;
*d = *other.d;
return *this;
}
PageTransition::~PageTransition()
{
delete d;
}
PageTransition::Type PageTransition::type() const
{
return d->m_type;
}
int PageTransition::duration() const
{
return d->m_duration;
}
PageTransition::Alignment PageTransition::alignment() const
{
return d->m_alignment;
}
PageTransition::Direction PageTransition::direction() const
{
return d->m_direction;
}
int PageTransition::angle() const
{
return d->m_angle;
}
double PageTransition::scale() const
{
return d->m_scale;
}
bool PageTransition::isRectangular() const
{
return d->m_rectangular;
}
void PageTransition::setType( Type type )
{
d->m_type = type;
}
void PageTransition::setDuration( int duration )
{
d->m_duration = duration;
}
void PageTransition::setAlignment( Alignment alignment )
{
d->m_alignment = alignment;
}
void PageTransition::setDirection( Direction direction )
{
d->m_direction = direction;
}
void PageTransition::setAngle( int angle )
{
d->m_angle = angle;
}
void PageTransition::setScale( double scale )
{
d->m_scale = scale;
}
void PageTransition::setIsRectangular( bool rectangular )
{
d->m_rectangular = rectangular;
}
......@@ -7,8 +7,8 @@
* (at your option) any later version. *
***************************************************************************/
#ifndef _OKULAR_PAGE_TRANSITION_H_
#define _OKULAR_PAGE_TRANSITION_H_
#ifndef _OKULAR_PAGETRANSITION_H_
#define _OKULAR_PAGETRANSITION_H_
#include "okular_export.h"
......@@ -16,10 +16,17 @@ namespace Okular {
/**
* @short Information object for the transition effect of a page.
*
* This class encapsulates the information about the effect of
* a page transition. It supports mainly the transition effects as
* defined in PDF specification 1.6.
*/
class OKULAR_EXPORT PageTransition
{
public:
/**
* Describes the type of transition effect.
*/
enum Type {
Replace,
Split,
......@@ -35,56 +42,115 @@ class OKULAR_EXPORT PageTransition
Fade
};
/**
* Describes the alignment that is applied to the @see Type
* of transition effect.
*/
enum Alignment {
Horizontal,
Vertical
};
/**
* Describes the direction that is applied to the @see Type
* of transition effect.
*/
enum Direction {
Inward,
Outward
};
/**
* Creates a new page transition of the given @p type.
*
* If no type is given, the normal @see Replace transition is used.
*/
PageTransition( Type type = Replace );
~PageTransition();
// Get type of the transition.
inline Type type() const { return m_type; }
// Get duration of the transition in seconds.
inline int duration() const { return m_duration; }
// Get dimension in which the transition effect occurs.
inline Alignment alignment() const { return m_alignment; }
// Get direction of motion of the transition effect.
inline Direction direction() const { return m_direction; }
/**
* Creates a new page transition from an @p other.
*/
PageTransition( const PageTransition &other );
PageTransition& operator=( const PageTransition &other );
// Get direction in which the transition effect moves.
inline int angle() const { return m_angle; }
// Get starting or ending scale. (Fly only)
inline double scale() const { return m_scale; }
// Returns true if the area to be flown is rectangular and opaque. (Fly only)
inline bool isRectangular() const { return m_rectangular; }
/**
* Destroys the page transition.
*/
~PageTransition();
inline void setType( Type type ) { m_type = type; }
inline void setDuration( int duration ) { m_duration = duration; }
inline void setAlignment( Alignment alignment ) { m_alignment = alignment; }
inline void setDirection( Direction direction ) { m_direction = direction; }
inline void setAngle( int angle ) { m_angle = angle; }
inline void setScale( double scale ) { m_scale = scale; }
inline void setIsRectangular( bool rectangular ) { m_rectangular = rectangular; }
/**
* Returns the type of the transition.
*/
Type type() const;
/**
* Returns the duration of the transition in seconds.
*/
int duration() const;
/**
* Returns the alignment of the transition.
*/
Alignment alignment() const;
/**
* Returns the direction of motion of the transition.
*/
Direction direction() const;
/**
* Returns the angle of rotation of the transition.
*/
int angle() const;
/**
* Returns the starting or ending scale (Only if type == 'Fly').
*/
double scale() const;
/**
* Returns true if the area to be flown is rectangular and opaque (Only if type == 'Fly').
*/
bool isRectangular() const;
/**
* Sets the @p type of the transition (@see Type).
*/
void setType( Type type );
/**
* Sets the @p duration in seconds for the transition.
*/
void setDuration( int duration );
/**
* Sets the @p alignment of the transition (@see Alignment).
*/
void setAlignment( Alignment alignment );
/**
* Sets the @p direction of the transition (@see Direction).
*/
void setDirection( Direction direction );
/**
* Sets the moving @p angle of the transition.
*/
void setAngle( int angle );
/**
* Sets the starting or ending scale of the transition (Only if type == 'Fly').
*/
void setScale( double scale );
/**
* Sets whether the area to be flown is rectangular and opaque (Only if type == 'Fly').
*/
void setIsRectangular( bool rectangular );
private:
Type m_type;
int m_duration;
Alignment m_alignment;
Direction m_direction;
int m_angle;
double m_scale;
bool m_rectangular;
class Private;
Private* const d;
};
}
......
......@@ -7,88 +7,112 @@
* (at your option) any later version. *
***************************************************************************/
#include <QtCore/QVariant>
// local includes
#include "sound.h"
using namespace Okular;
Sound::Sound( const QByteArray& data )
class Sound::Private
{
m_type = Sound::Embedded;
m_data = QVariant( data );
init();
}
public:
Private( const QByteArray &data )
: m_data( QVariant( data ) ),
m_type( Sound::Embedded )
{
init();
}
Private( const QString &url )
: m_data( QVariant( url ) ),
m_type( Sound::External )
{
init();
}
void init()
{
m_samplingRate = 44100.0;
m_channels = 1;
m_bitsPerSample = 8;
m_soundEncoding = Sound::Raw;
}
QVariant m_data;
Sound::SoundType m_type;
double m_samplingRate;
int m_channels;
int m_bitsPerSample;
SoundEncoding m_soundEncoding;
};
Sound::Sound( const QString& file )
Sound::Sound( const QByteArray& data )
: d( new Private( data ) )
{
m_type = Sound::External;
m_data = QVariant( file );
init();
}
void Sound::init()
Sound::Sound( const QString& url )
: d( new Private( url ) )
{
m_samplingRate = 44100.0;
m_channels = 1;
m_bitsPerSample = 8;
m_soundEncoding = Sound::Raw;
}
Sound::~Sound()
{
delete d;
}
Sound::SoundType Sound::soundType() const
{
return m_type;
return d->m_type;
}
QString Sound::url() const
{
return m_type == Sound::External ? m_data.toString() : QString();
return d->m_type == Sound::External ? d->m_data.toString() : QString();
}
QByteArray Sound::data() const
{
return m_type == Sound::Embedded ? m_data.toByteArray() : QByteArray();
return d->m_type == Sound::Embedded ? d->m_data.toByteArray() : QByteArray();
}
double Sound::samplingRate() const
{
return m_samplingRate;
return d->m_samplingRate;
}
void Sound::setSamplingRate( double sr )
void Sound::setSamplingRate( double samplingRate )
{
m_samplingRate = sr;
d->m_samplingRate = samplingRate;
}
int Sound::channels() const
{
return m_channels;
return d->m_channels;
}
void Sound::setChannels( int ch )
void Sound::setChannels( int channels )
{
m_channels = ch;
d->m_channels = channels;
}
int Sound::bitsPerSample() const
{
return m_bitsPerSample;
return d->m_bitsPerSample;
}
void Sound::setBitsPerSample( int bps )
void Sound::setBitsPerSample( int bitsPerSample )
{
m_bitsPerSample = bps;
d->m_bitsPerSample = bitsPerSample;
}
Sound::SoundEncoding Sound::soundEncoding() const
{
return m_soundEncoding;
return d->m_soundEncoding;
}
void Sound::setSoundEncoding( Sound::SoundEncoding se )
void Sound::setSoundEncoding( Sound::SoundEncoding soundEncoding )
{
m_soundEncoding = se;
d->m_soundEncoding = soundEncoding;
}
......@@ -14,62 +14,112 @@
#include <QtCore/QByteArray>
#include <QtCore/QString>
#include <QtCore/QVariant>
namespace Okular {
/**
* @short A sound.
* @short Contains information about a sound object.
*
* ...
* This class encapsulates the information about a sound object
* which is used for links on enter/leave page event.
*/
class OKULAR_EXPORT Sound
{
public:
/**
* Describes where the sound is stored.
*/
enum SoundType {
External,
Embedded
External, ///< Is stored at external resource (e.g. url)
Embedded ///< Is stored embedded in the document
};
/**
* Describes the encoding of the sound data.
*/
enum SoundEncoding {
Raw,
Signed,
muLaw,
ALaw
Raw, ///< Is not encoded
Signed, ///< Is encoded with twos-complement values
muLaw, ///< Is µ-law encoded
ALaw ///< Is A-law encoded
};
/**
* Creates a new sound object with the given embedded
* sound @p data.
*/
Sound( const QByteArray& data );
Sound( const QString& data );
/**
* Creates a new sound object with the given external @p filename.
*/
Sound( const QString& filename );
/**
* Destroys the sound object.
*/
~Sound();
/**
* Returns the type of the sound object.
*/
SoundType soundType() const;
/**
* Returns the external storage url of the sound data.
*/
QString url() const;
/**
* Returns the embedded sound data.
*/
QByteArray data() const;
/**
* Sets the sampling @p rate.
*/
void setSamplingRate( double rate );
/**
* Returns the sampling rate.
*/
double samplingRate() const;
void setSamplingRate( double sr );
/**
* Sets the number of @p channels.
*/
void setChannels( int channels );
/**
* Returns the number of channels.
*/
int channels() const;
void setChannels( int ch );
/**
* Sets the bits per sample @rate.
*/
void setBitsPerSample( int rate );
/**
* Returns the bits per sample rate.
*/
int bitsPerSample() const;
void setBitsPerSample( int bps );
/**
* Sets the type of sound @p encoding.
*/
void setSoundEncoding( SoundEncoding encoding );
/**
* Returns the sound encoding.
*/
SoundEncoding soundEncoding() const;
void setSoundEncoding( SoundEncoding se );
private:
void init();
QVariant m_data;
Sound::SoundType m_type;
double m_samplingRate;
int m_channels;
int m_bitsPerSample;
SoundEncoding m_soundEncoding;
class Private;
Private* const d;
Q_DISABLE_COPY( Sound )
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment