1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 19:30:21 +02:00

* Reset the name and description of PlaylistModel when the underlying playlist changes.

This commit is contained in:
Christian Muehlhaeuser
2012-11-16 09:00:59 +01:00
parent adec0b4657
commit 8328a0b2a9
2 changed files with 40 additions and 30 deletions

View File

@@ -78,7 +78,7 @@ PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEn
{
disconnect( m_playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), this, SLOT( onRevisionLoaded( Tomahawk::PlaylistRevision ) ) );
disconnect( m_playlist.data(), SIGNAL( deleted( Tomahawk::playlist_ptr ) ), this, SIGNAL( playlistDeleted() ) );
disconnect( m_playlist.data(), SIGNAL( changed() ), this, SIGNAL( playlistChanged() ) );
disconnect( m_playlist.data(), SIGNAL( changed() ), this, SLOT( onPlaylistChanged() ) );
}
m_isLoading = true;
@@ -88,38 +88,13 @@ PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEn
m_playlist = playlist;
connect( playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), SLOT( onRevisionLoaded( Tomahawk::PlaylistRevision ) ) );
connect( playlist.data(), SIGNAL( deleted( Tomahawk::playlist_ptr ) ), this, SIGNAL( playlistDeleted() ) );
connect( playlist.data(), SIGNAL( changed() ), this, SIGNAL( playlistChanged() ) );
connect( playlist.data(), SIGNAL( deleted( Tomahawk::playlist_ptr ) ), SIGNAL( playlistDeleted() ) );
connect( playlist.data(), SIGNAL( changed() ), SLOT( onPlaylistChanged() ) );
setReadOnly( !m_playlist->author()->isLocal() );
setTitle( playlist->title() );
QString age = TomahawkUtils::ageToString( QDateTime::fromTime_t( playlist->createdOn() ), true );
QString desc;
if ( playlist->creator().isEmpty() )
{
if ( playlist->author()->isLocal() )
{
desc = tr( "A playlist you created %1." )
.arg( age );
}
else
{
desc = tr( "A playlist by %1, created %2." )
.arg( playlist->author()->friendlyName() )
.arg( age );
}
}
else
{
desc = tr( "A playlist by %1, created %2." )
.arg( playlist->creator() )
.arg( age );
}
setDescription( desc );
m_isTemporary = false;
emit playlistChanged();
onPlaylistChanged();
if ( !loadEntries )
{
@@ -137,6 +112,39 @@ PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEn
}
void
PlaylistModel::onPlaylistChanged()
{
QString age = TomahawkUtils::ageToString( QDateTime::fromTime_t( m_playlist->createdOn() ), true );
QString desc;
if ( m_playlist->creator().isEmpty() )
{
if ( m_playlist->author()->isLocal() )
{
desc = tr( "A playlist you created %1." )
.arg( age );
}
else
{
desc = tr( "A playlist by %1, created %2." )
.arg( m_playlist->author()->friendlyName() )
.arg( age );
}
}
else
{
desc = tr( "A playlist by %1, created %2." )
.arg( m_playlist->creator() )
.arg( age );
}
setTitle( m_playlist->title() );
setDescription( desc );
emit playlistChanged();
}
void
PlaylistModel::clear()
{

View File

@@ -80,10 +80,12 @@ protected:
void removeFromWaitList( const QString& revisionguid ) { m_waitForRevision.removeAll( revisionguid ); }
QList<Tomahawk::plentry_ptr> playlistEntries() const;
private slots:
void onRevisionLoaded( Tomahawk::PlaylistRevision revision );
void parsedDroppedTracks( QList<Tomahawk::query_ptr> );
void trackResolved( bool );
void onPlaylistChanged();
private:
void beginPlaylistChanges();