mpx/collectionframework/collectionutility/src/mpxcollectionplaylist.cpp
changeset 32 edd273b3192a
parent 0 a2952bb97e68
child 38 959ca709b049
--- a/mpx/collectionframework/collectionutility/src/mpxcollectionplaylist.cpp	Fri May 14 16:21:14 2010 +0300
+++ b/mpx/collectionframework/collectionutility/src/mpxcollectionplaylist.cpp	Thu May 27 13:19:19 2010 +0300
@@ -1256,6 +1256,19 @@
         if( changeType == EMPXItemDeleted )
             {
             refresh = ETrue;
+            MPX_DEBUG1("CMPXCollectionPlaylist::DoHandleCollectionChangeMessageL -- current item deleted");
+            
+            TBool lastItemDeleted( iItemIndex == 0 && iItemIndexes.Count() == 1 );
+            
+            if ( lastItemDeleted ) // playlist is now empty, notify observer immediately
+                {
+                MPX_DEBUG1("CMPXCollectionPlaylist::DoHandleCollectionChangeMessageL -- last playlist item deleted");
+                Invalidate();
+                if ( iPlObs )
+                    {
+                    iPlObs->HandleCollectionPlaylistChange(KErrEof);
+                    }
+                }
             }
         // Modified
         else if( changeType == EMPXItemModified )
@@ -1333,7 +1346,8 @@
             }
         }
 
-    if (iAutoPlaylist && refresh)
+    // update playlist immediately when item is deleted in order to detect deletion of the last item in the playlist
+    if ( refresh && iItemIndexes.Count() > 0 )
         {
         // For autoplaylist, affected by the event.
         // Path clip will never happen for autoplaylist