API cleanup

svn path=/trunk/playground/graphics/okular/; revision=608230
remotes/origin/KDE/4.0
Tobias Koenig 20 years ago
parent 1cea7cb777
commit 25f836351f
  1. 119
      core/pagetransition.cpp
  2. 138
      core/pagetransition.h
  3. 82
      core/sound.cpp
  4. 94
      core/sound.h

@ -14,17 +14,122 @@ using namespace Okular;
/** class Okular::PageTransition **/ /** 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 ) PageTransition::PageTransition( Type type )
: m_type( type ), : d( new Private( type ) )
m_duration( 1 ), {
m_alignment( Horizontal ), }
m_direction( Inward ),
m_angle( 0 ), PageTransition::PageTransition( const PageTransition &other )
m_scale( 1.0 ), : d( new Private( Replace ) )
m_rectangular( false ) {
*d = *other.d;
}
PageTransition& PageTransition::operator=( const PageTransition &other )
{ {
if ( this == &other )
return *this;
*d = *other.d;
return *this;
} }
PageTransition::~PageTransition() 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. * * (at your option) any later version. *
***************************************************************************/ ***************************************************************************/
#ifndef _OKULAR_PAGE_TRANSITION_H_ #ifndef _OKULAR_PAGETRANSITION_H_
#define _OKULAR_PAGE_TRANSITION_H_ #define _OKULAR_PAGETRANSITION_H_
#include "okular_export.h" #include "okular_export.h"
@ -16,10 +16,17 @@ namespace Okular {
/** /**
* @short Information object for the transition effect of a page. * @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 class OKULAR_EXPORT PageTransition
{ {
public: public:
/**
* Describes the type of transition effect.
*/
enum Type { enum Type {
Replace, Replace,
Split, Split,
@ -35,56 +42,115 @@ class OKULAR_EXPORT PageTransition
Fade Fade
}; };
/**
* Describes the alignment that is applied to the @see Type
* of transition effect.
*/
enum Alignment { enum Alignment {
Horizontal, Horizontal,
Vertical Vertical
}; };
/**
* Describes the direction that is applied to the @see Type
* of transition effect.
*/
enum Direction { enum Direction {
Inward, Inward,
Outward 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( 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; } * Destroys the page transition.
*/
// Get starting or ending scale. (Fly only) ~PageTransition();
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; }
inline void setType( Type type ) { m_type = type; } /**
inline void setDuration( int duration ) { m_duration = duration; } * Returns the type of the transition.
inline void setAlignment( Alignment alignment ) { m_alignment = alignment; } */
inline void setDirection( Direction direction ) { m_direction = direction; } Type type() const;
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 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: private:
Type m_type; class Private;
int m_duration; Private* const d;
Alignment m_alignment;
Direction m_direction;
int m_angle;
double m_scale;
bool m_rectangular;
}; };
} }

@ -7,88 +7,112 @@
* (at your option) any later version. * * (at your option) any later version. *
***************************************************************************/ ***************************************************************************/
#include <QtCore/QVariant>
// local includes // local includes
#include "sound.h" #include "sound.h"
using namespace Okular; using namespace Okular;
Sound::Sound( const QByteArray& data ) class Sound::Private
{ {
m_type = Sound::Embedded; public:
m_data = QVariant( data ); Private( const QByteArray &data )
init(); : 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() Sound::~Sound()
{ {
delete d;
} }
Sound::SoundType Sound::soundType() const Sound::SoundType Sound::soundType() const
{ {
return m_type; return d->m_type;
} }
QString Sound::url() const 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 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 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 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 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 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/QByteArray>
#include <QtCore/QString> #include <QtCore/QString>
#include <QtCore/QVariant>
namespace Okular { 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 class OKULAR_EXPORT Sound
{ {
public: public:
/**
* Describes where the sound is stored.
*/
enum SoundType { enum SoundType {
External, External, ///< Is stored at external resource (e.g. url)
Embedded Embedded ///< Is stored embedded in the document
}; };
/**
* Describes the encoding of the sound data.
*/
enum SoundEncoding { enum SoundEncoding {
Raw, Raw, ///< Is not encoded
Signed, Signed, ///< Is encoded with twos-complement values
muLaw, muLaw, ///< Is µ-law encoded
ALaw ALaw ///< Is A-law encoded
}; };
/**
* Creates a new sound object with the given embedded
* sound @p data.
*/
Sound( const QByteArray& 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(); ~Sound();
/**
* Returns the type of the sound object.
*/
SoundType soundType() const; SoundType soundType() const;
/**
* Returns the external storage url of the sound data.
*/
QString url() const; QString url() const;
/**
* Returns the embedded sound data.
*/
QByteArray data() const; QByteArray data() const;
/**
* Sets the sampling @p rate.
*/
void setSamplingRate( double rate );
/**
* Returns the sampling rate.
*/
double samplingRate() const; 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; 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; 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; SoundEncoding soundEncoding() const;
void setSoundEncoding( SoundEncoding se );
private: private:
void init(); class Private;
Private* const d;
QVariant m_data;
Sound::SoundType m_type; Q_DISABLE_COPY( Sound )
double m_samplingRate;
int m_channels;
int m_bitsPerSample;
SoundEncoding m_soundEncoding;
}; };
} }

Loading…
Cancel
Save