Commit f1475a10 authored by Matěj Laitl's avatar Matěj Laitl
Browse files

MetaProxy: implement more Track and Album methods

BUGFIXES:
 * Lyrics, labels and album actions are correctly displayed for tracks
   from main and saved playlists on Amarok startup

BUG: 299150
FIXED-IN: 2.6
DIGEST: bugfix
parent 9a31c35d
......@@ -86,6 +86,8 @@ VERSION 2.6-Beta 1
"1.2 GB free" is shown instead of "85% used"; thicker capacity bar.
BUGFIXES:
* Lyrics, labels and album actions are correctly displayed for tracks
from main and saved playlists on Amarok startup. (BR 299150)
* Lyrics applet scrolls more intelligently. Patch by Alexander Potashev.
(BR 283601)
* Fix crash on startup related to ContextView. (BR 258741)
......
......@@ -109,11 +109,10 @@ MetaProxy::Track::~Track()
QString
MetaProxy::Track::name() const
{
if( d->realTrack ) {
QString name = d->realTrack->name();
return name;
}
return d->cachedName;
if( d->realTrack )
return d->realTrack->name();
else
return d->cachedName;
}
void
......@@ -125,31 +124,37 @@ MetaProxy::Track::setName( const QString &name )
QString
MetaProxy::Track::prettyName() const
{
if( d->realTrack ) {
QString prettyName = d->realTrack->prettyName();
return prettyName;
}
return d->cachedName; //TODO maybe change this?
if( d->realTrack )
return d->realTrack->prettyName();
else
return d->cachedName;
}
QString
MetaProxy::Track::fullPrettyName() const
{
if( d->realTrack ) {
QString fullPrettyName = d->realTrack->fullPrettyName();
return fullPrettyName;
}
return d->cachedName; //TODO maybe change this??
if( d->realTrack )
return d->realTrack->fullPrettyName();
else
return d->cachedName;
}
QString
MetaProxy::Track::sortableName() const
{
if( d->realTrack ) {
QString sortableName = d->realTrack->sortableName();
return sortableName;
}
return d->cachedName; //TODO maybe change this??
if( d->realTrack )
return d->realTrack->sortableName();
else
return d->cachedName;
}
QString
Track::fixedName() const
{
if( d->realTrack )
return d->realTrack->fixedName();
else
return d->cachedName;
}
KUrl
......@@ -259,6 +264,15 @@ MetaProxy::Track::setYear( int year )
d->cachedYear = year;
}
Meta::LabelList
Track::labels() const
{
if( d->realTrack )
return d->realTrack->labels();
else
return Meta::Track::labels();
}
qreal
MetaProxy::Track::bpm() const
{
......@@ -384,7 +398,15 @@ MetaProxy::Track::createDate() const
{
if( d->realTrack )
return d->realTrack->createDate();
return QDateTime();
return Meta::Track::createDate();
}
QDateTime
Track::modifyDate() const
{
if( d->realTrack )
return d->realTrack->modifyDate();
return Meta::Track::modifyDate();
}
QDateTime
......@@ -411,6 +433,14 @@ MetaProxy::Track::playCount() const
return 0;
}
qreal
Track::replayGain( Meta::ReplayGainTag mode ) const
{
if( d->realTrack )
return d->realTrack->replayGain( mode );
return Meta::Track::replayGain( mode );
}
QString
MetaProxy::Track::type() const
{
......@@ -419,6 +449,13 @@ MetaProxy::Track::type() const
return QString(); //TODO cache type??
}
void
Track::prepareToPlay()
{
if( d->realTrack )
d->realTrack->prepareToPlay();
}
void
MetaProxy::Track::finishedPlaying( double playedFraction )
{
......@@ -443,6 +480,51 @@ MetaProxy::Track::collection() const
return 0;
}
QString
Track::cachedLyrics() const
{
if( d->realTrack )
return d->realTrack->cachedLyrics();
else
return Meta::Track::cachedLyrics();
}
void
Track::setCachedLyrics(const QString& lyrics)
{
if( d->realTrack )
d->realTrack->setCachedLyrics( lyrics );
else
Meta::Track::setCachedLyrics( lyrics );
}
void
Track::addLabel( const QString &label )
{
if( d->realTrack )
d->realTrack->addLabel( label );
else
Meta::Track::addLabel( label );
}
void
Track::addLabel( const Meta::LabelPtr &label )
{
if( d->realTrack )
d->realTrack->addLabel( label );
else
Meta::Track::addLabel( label );
}
void
Track::removeLabel( const Meta::LabelPtr &label )
{
if( d->realTrack )
d->realTrack->removeLabel( label );
else
Meta::Track::removeLabel( label );
}
void
MetaProxy::Track::subscribe( Meta::Observer *observer )
{
......
......@@ -41,75 +41,82 @@ namespace MetaProxy
Track( const KUrl &url );
virtual ~Track();
//methods inherited from Meta::MetaBase
// methods inherited from Meta::MetaCapability
virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const;
virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type );
// methods inherited from Meta::MetaBase
virtual QString name() const;
virtual void setName( const QString &name );
virtual QString prettyName() const;
virtual QString fullPrettyName() const;
virtual QString sortableName() const;
virtual QString fixedName() const;
virtual void subscribe( Meta::Observer *observer );
virtual void unsubscribe( Meta::Observer *observer );
//methods inherited from Meta::Track
// methods inherited from Meta::Track
virtual KUrl playableUrl() const;
virtual QString prettyUrl() const;
virtual QString uidUrl() const;
virtual bool isPlayable() const;
virtual Meta::AlbumPtr album() const;
virtual void setAlbum( const QString &album );
virtual void setAlbumArtist( const QString &artist );
virtual Meta::ArtistPtr artist() const;
virtual void setArtist( const QString &artist );
virtual Meta::GenrePtr genre() const;
virtual void setGenre( const QString &genre );
virtual Meta::ComposerPtr composer() const;
virtual void setComposer( const QString &composer );
virtual Meta::YearPtr year() const;
virtual void setYear( int year );
virtual Meta::LabelList labels() const;
virtual qreal bpm() const;
virtual void setBpm( const qreal bpm );
virtual QString comment() const;
virtual double score() const;
virtual void setScore( double newScore );
virtual int rating() const;
virtual void setRating( int newRating );
virtual int trackNumber() const;
virtual void setTrackNumber( int number );
virtual int discNumber() const;
virtual void setDiscNumber( int discNumber );
virtual qint64 length() const;
virtual void setLength( qint64 length );
virtual int filesize() const;
virtual int sampleRate() const;
virtual int bitrate() const;
virtual QDateTime createDate() const;
virtual QDateTime firstPlayed() const;
virtual QDateTime modifyDate() const;
virtual int trackNumber() const;
virtual int discNumber() const;
virtual QDateTime lastPlayed() const;
virtual QDateTime firstPlayed() const;
virtual int playCount() const;
virtual qreal replayGain( Meta::ReplayGainTag mode ) const;
virtual QString type() const;
virtual void prepareToPlay();
virtual void finishedPlaying( double playedFraction );
virtual bool inCollection() const;
virtual Collections::Collection *collection() const;
virtual void subscribe( Meta::Observer *observer );
virtual void unsubscribe( Meta::Observer *observer );
virtual QString cachedLyrics() const;
virtual void setCachedLyrics( const QString &lyrics );
virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const;
virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type );
virtual void addLabel( const QString &label );
virtual void addLabel( const Meta::LabelPtr &label );
virtual void removeLabel( const Meta::LabelPtr &label );
virtual bool operator==( const Meta::Track &track ) const;
// custom MetaProxy methods
virtual void setName( const QString &name );
virtual void setAlbum( const QString &album );
virtual void setAlbumArtist( const QString &artist );
virtual void setArtist( const QString &artist );
virtual void setGenre( const QString &genre );
virtual void setComposer( const QString &composer );
virtual void setYear( int year );
virtual void setBpm( const qreal bpm );
virtual void setTrackNumber( int number );
virtual void setDiscNumber( int discNumber );
virtual void setLength( qint64 length );
/**
* allows subclasses to create an instance of trackprovider which will only check the TrackProvider
* passed to lookupTrack(TrackProvider*) for the real track.
......
......@@ -157,14 +157,44 @@ public:
, d( dptr )
{}
bool hasCapabilityInterface( Capabilities::Capability::Type type ) const
{
if( d && d->realTrack && d->realTrack->album() )
return d->realTrack->album()->hasCapabilityInterface( type );
else
return Meta::Album::hasCapabilityInterface( type );
}
Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type )
{
if( d && d->realTrack && d->realTrack->album() )
return d->realTrack->album()->createCapabilityInterface( type );
else
return Meta::Album::createCapabilityInterface( type );
}
bool isCompilation() const
{
if( d && d->realTrack )
if( d && d->realTrack && d->realTrack->album() )
return d->realTrack->album()->isCompilation();
else
return false;
}
bool canUpdateCompilation() const
{
if( d && d->realTrack && d->realTrack->album() )
return d->realTrack->album()->canUpdateCompilation();
else
return Meta::Album::canUpdateCompilation();
}
void setCompilation( bool isCompilation )
{
if( d && d->realTrack && d->realTrack->album() )
return d->realTrack->album()->setCompilation( isCompilation );
}
bool hasAlbumArtist() const
{
if( d && d->realTrack && d->realTrack->album() )
......@@ -183,7 +213,7 @@ public:
Meta::TrackList tracks()
{
if( d && d->realTrack )
if( d && d->realTrack && d->realTrack->album() )
return d->realTrack->album()->tracks();
else
return Meta::TrackList();
......@@ -213,34 +243,48 @@ public:
QImage image( int size ) const
{
if( d && d->realTrack ) {
if ( d->realTrack->album() )
return d->realTrack->album()->image( size );
return Meta::Album::image( size );
} else
if( d && d->realTrack && d->realTrack->album() )
return d->realTrack->album()->image( size );
else
return Meta::Album::image( size );
}
bool hasImage( int size ) const
{
if( d && d->realTrack ) {
if ( d->realTrack->album() )
return d->realTrack->album()->hasImage( size );
return Meta::Album::hasImage( size );
} else
if( d && d->realTrack && d->realTrack->album() )
return d->realTrack->album()->hasImage( size );
else
return Meta::Album::hasImage( size );
}
KUrl imageLocation( int size = 0 )
{
if( d && d->realTrack ) {
if ( d->realTrack->album() )
return d->realTrack->album()->imageLocation( size );
return Meta::Album::imageLocation( size );
} else
if( d && d->realTrack && d->realTrack->album() )
return d->realTrack->album()->imageLocation( size );
else
return Meta::Album::imageLocation( size );
}
bool canUpdateImage() const
{
if( d && d->realTrack && d->realTrack->album() )
return d->realTrack->album()->canUpdateImage();
else
return Meta::Album::canUpdateImage();
}
void setImage( const QImage &image )
{
if( d && d->realTrack && d->realTrack->album() )
return d->realTrack->album()->setImage( image );
}
void removeImage()
{
if( d && d->realTrack && d->realTrack->album() )
return d->realTrack->album()->removeImage();
}
virtual bool operator==( const Meta::Album &album ) const
{
const ProxyAlbum *proxy = dynamic_cast<const ProxyAlbum*>( &album );
......
Supports Markdown
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