diff --git a/src/libtomahawk/playlist/PlaylistModel.cpp b/src/libtomahawk/playlist/PlaylistModel.cpp index a8e16155b..bb0462249 100644 --- a/src/libtomahawk/playlist/PlaylistModel.cpp +++ b/src/libtomahawk/playlist/PlaylistModel.cpp @@ -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() { diff --git a/src/libtomahawk/playlist/PlaylistModel.h b/src/libtomahawk/playlist/PlaylistModel.h index 989f64b42..3bc92478a 100644 --- a/src/libtomahawk/playlist/PlaylistModel.h +++ b/src/libtomahawk/playlist/PlaylistModel.h @@ -80,10 +80,12 @@ protected: void removeFromWaitList( const QString& revisionguid ) { m_waitForRevision.removeAll( revisionguid ); } QList playlistEntries() const; + private slots: void onRevisionLoaded( Tomahawk::PlaylistRevision revision ); void parsedDroppedTracks( QList ); void trackResolved( bool ); + void onPlaylistChanged(); private: void beginPlaylistChanges();