[Amarok] b53fae0 Revert "Implement metadataChanged() to keep the vi
Bart Cerneels
bart.cerneels at kde.org
Sat Dec 18 19:47:52 CET 2010
commit b53fae0a4273747cefc679caace25baec941339a
branch master
Author: Bart Cerneels <bart.cerneels at kde.org>
Date: Sat Dec 18 19:40:58 2010 +0100
Revert "Implement metadataChanged() to keep the view from resetting"
This reverts commit 9ab7462612680caa5af99285aca0b8b186ac893e.
Seems like it was blocking on metadata update for a lot of people. Most likely in PlaylistBrowserModel::metadataChanged().
This line: while( volatile int position = m_playlists[i]->tracks().indexOf( track, position ) != -1 )
Seemed OK to me, though it can be optimised it should never block.
CCMAIL:amarok-devel at kde.org
diff --git a/src/browsers/playlistbrowser/PlaylistBrowserModel.cpp b/src/browsers/playlistbrowser/PlaylistBrowserModel.cpp
index 3b6f54c..a0f8076 100644
--- a/src/browsers/playlistbrowser/PlaylistBrowserModel.cpp
+++ b/src/browsers/playlistbrowser/PlaylistBrowserModel.cpp
@@ -480,7 +480,6 @@ PlaylistBrowserModel::trackAdded( Playlists::PlaylistPtr playlist, Meta::TrackPt
}
QModelIndex playlistIdx = index( indexNumber, 0, QModelIndex() );
beginInsertRows( playlistIdx, position, position );
- Meta::Observer::subscribeTo( track );
endInsertRows();
}
@@ -499,23 +498,6 @@ PlaylistBrowserModel::trackRemoved( Playlists::PlaylistPtr playlist, int positio
}
void
-PlaylistBrowserModel::metadataChanged( Meta::TrackPtr track )
-{
- //lookup track in all playlists
- //TODO: optimize
- for( int i = 0; i < m_playlists.count(); i++ )
- {
- QModelIndex parentIdx = createIndex( i, 0, i );
- //emit dataChanged for all occurences of track in the playlist
- while( volatile int position = m_playlists[i]->tracks().indexOf( track, position ) != -1 )
- {
- QModelIndex idx = index( position, 0, parentIdx );
- emit dataChanged( idx, idx );
- }
- }
-}
-
-void
PlaylistBrowserModel::slotRenamePlaylist( Playlists::PlaylistPtr playlist )
{
//search index of this Playlist
@@ -541,7 +523,7 @@ PlaylistBrowserModel::slotUpdate()
emit layoutAboutToBeChanged();
foreach( Playlists::PlaylistPtr playlist, m_playlists )
- Playlists::PlaylistObserver::unsubscribeFrom( playlist );
+ unsubscribeFrom( playlist );
m_playlists.clear();
m_playlists = loadPlaylists();
@@ -561,9 +543,7 @@ PlaylistBrowserModel::loadPlaylists()
while( i.hasNext() )
{
Playlists::PlaylistPtr playlist = i.next();
- Playlists::PlaylistObserver::subscribeTo( playlist );
- foreach( Meta::TrackPtr track, playlist->tracks() )
- Meta::Observer::subscribeTo( track );
+ subscribeTo( playlist );
}
qSort( playlists.begin(), playlists.end(), lessThanPlaylistTitles );
@@ -606,7 +586,7 @@ PlaylistBrowserModel::slotPlaylistAdded( Playlists::PlaylistPtr playlist, int ca
if( category != m_playlistCategory )
return;
- Playlists::PlaylistObserver::subscribeTo( playlist );
+ subscribeTo( playlist );
int i;
for( i = 0; i < m_playlists.count(); i++ )
{
diff --git a/src/browsers/playlistbrowser/PlaylistBrowserModel.h b/src/browsers/playlistbrowser/PlaylistBrowserModel.h
index 781e121..feb6551 100644
--- a/src/browsers/playlistbrowser/PlaylistBrowserModel.h
+++ b/src/browsers/playlistbrowser/PlaylistBrowserModel.h
@@ -40,8 +40,7 @@ namespace PlaylistBrowserNS {
@author Bart Cerneels <bart.cerneels at kde.org>
*/
class PlaylistBrowserModel : public QAbstractItemModel,
- public Playlists::PlaylistObserver,
- public Meta::Observer
+ public Playlists::PlaylistObserver
{
Q_OBJECT
public:
@@ -85,9 +84,6 @@ class PlaylistBrowserModel : public QAbstractItemModel,
virtual void trackAdded( Playlists::PlaylistPtr playlist, Meta::TrackPtr track, int position );
virtual void trackRemoved( Playlists::PlaylistPtr playlist, int position );
- /* Meta::MetaObserver methods */
- virtual void metadataChanged( Meta::TrackPtr track );
-
public slots:
void slotRenamePlaylist( Playlists::PlaylistPtr playlist );
void slotUpdate();
diff --git a/src/browsers/playlistbrowser/UserPlaylistModel.cpp b/src/browsers/playlistbrowser/UserPlaylistModel.cpp
index 2061b25..9f00c0c 100644
--- a/src/browsers/playlistbrowser/UserPlaylistModel.cpp
+++ b/src/browsers/playlistbrowser/UserPlaylistModel.cpp
@@ -150,11 +150,11 @@ PlaylistBrowserNS::UserModel::removeRows( int row, int count, const QModelIndex
beginRemoveRows( parent, row, row + count - 1 );
//ignore notifications while removing tracks
- Playlists::PlaylistObserver::unsubscribeFrom( playlist );
+ unsubscribeFrom( playlist );
for( int i = row; i < row + count; i++ )
//deleting a track moves the next track up, so use the same row number each time
playlist->removeTrack( row );
- Playlists::PlaylistObserver::subscribeTo( playlist );
+ subscribeTo( playlist );
endRemoveRows();
return true;
diff --git a/src/core-impl/podcasts/sql/SqlPodcastMeta.cpp b/src/core-impl/podcasts/sql/SqlPodcastMeta.cpp
index 007b381..8ada732 100644
--- a/src/core-impl/podcasts/sql/SqlPodcastMeta.cpp
+++ b/src/core-impl/podcasts/sql/SqlPodcastMeta.cpp
@@ -215,9 +215,9 @@ SqlPodcastEpisode::setLocalUrl( const KUrl &url )
{
//if we had a local file previously it should get deleted by the KSharedPtr.
m_localFile = new MetaFile::Track( m_localUrl );
+ if( m_channel->writeTags() )
+ writeTagsToFile();
}
- //poke PodcastModel to update the download status
- notifyObservers();
}
qint64
diff --git a/src/core-impl/podcasts/sql/SqlPodcastProvider.cpp b/src/core-impl/podcasts/sql/SqlPodcastProvider.cpp
index cac739f..a059dfb 100644
--- a/src/core-impl/podcasts/sql/SqlPodcastProvider.cpp
+++ b/src/core-impl/podcasts/sql/SqlPodcastProvider.cpp
@@ -724,6 +724,7 @@ SqlPodcastProvider::configureChannel( Podcasts::SqlPodcastChannelPtr sqlChannel
.arg( sqlChannel->title() )
.arg( sqlChannel->saveLocation().prettyUrl() );
+ KUrl::List filesToMove;
foreach( Podcasts::SqlPodcastEpisodePtr episode, sqlChannel->sqlEpisodes() )
{
if( !episode->localUrl().isEmpty() )
@@ -1360,6 +1361,7 @@ SqlPodcastProvider::checkEnclosureLocallyAvailable( KIO::Job *job )
// NOTE: we need to emit because the KJobProgressBar relies on it to clean up
job->kill( KJob::EmitResult );
sqlEpisode->setLocalUrl( fileName );
+ emit( updated() ); // repaint icons
return true;
}
@@ -1455,6 +1457,8 @@ SqlPodcastProvider::downloadResult( KJob *job )
if( sqlChannel->writeTags() )
sqlEpisode->writeTagsToFile();
+ //force an update so the icon can be updated in the PlaylistBrowser
+ emit( updated() );
}
else
{
More information about the Amarok-devel
mailing list