ui/uiengine/medialists/src/glxmedialist.cpp
changeset 52 a3a4c0de738e
parent 42 5e1df1b52eb3
--- a/ui/uiengine/medialists/src/glxmedialist.cpp	Sat Jul 10 00:59:39 2010 +0530
+++ b/ui/uiengine/medialists/src/glxmedialist.cpp	Fri Jul 23 20:41:04 2010 +0530
@@ -39,6 +39,16 @@
 #include "mglxmedialistobserver.h"
 #include "glxmediastaticitemdefs.h"
 
+/**
+ * Min & Max wait interval for a modify event, in microseconds
+ * This is to allow thumbnail manager to procees the event first.
+ */
+const TInt KModifyEventMinWaitInterval = 2000000;
+const TInt KModifyEventMaxWaitInterval = 3000000;
+/**
+ * Maximum items count for minimum wait interval.
+ */
+const TInt KMaxItemsCount = 500;
 namespace NGlxMediaList
     {
     /**
@@ -1327,7 +1337,7 @@
     for (TInt level = 0; level < levels; level++) 
         {
         TGlxMediaId id(aPath.Id(level));
-        iPath.Append(id); 
+        iPath.AppendL(id); 
         }
 
     
@@ -1530,6 +1540,28 @@
             }
 
         CleanupStack::PopAndDestroy(&itemIndices);
+        RPointerArray<CGlxMediaList>& mediaLists = iMediaListArray->Array();
+        TInt listCount = mediaLists.Count();
+        GLX_DEBUG2("ML:HandleItemModifiedL listCount=%d", listCount);
+        if (listCount > 0)
+            {
+            CGlxMediaList* mediaList = mediaLists[listCount-1];
+            if (mediaList == this)
+                {
+                GLX_DEBUG3("ML:HandleItemModifiedL(wait) listCount=%d, Id=%d",
+                                                  listCount, id.Value());
+                TTimeIntervalMicroSeconds32 timeout;
+                timeout = (mediaList->Count() > KMaxItemsCount ?
+                  KModifyEventMaxWaitInterval : KModifyEventMinWaitInterval );
+                RTimer timer;
+                CleanupClosePushL(timer);
+                TRequestStatus status;
+                timer.CreateLocal();
+                timer.After(status, timeout);
+                User::WaitForRequest(status);
+                CleanupStack::PopAndDestroy(&timer);
+                }
+            }
         }
     }
 
@@ -1757,6 +1789,7 @@
     TRACER("CGlxMediaList::UpdateMedia");
     
     TInt count = iItemList->Count();
+    GLX_DEBUG2("CGlxMediaList::UpdateMedia() count=%d", count);    
     for (TInt i = 0; i < count; ++i)
         {
         TGlxMedia& item = iItemList->Item( i );
@@ -1859,15 +1892,8 @@
 	{
 	TRACER("CGlxMediaList::CancelPreviousRequests");	
 	
-	TInt focusIndex = FocusIndex();
 	
-	if(focusIndex >= KErrNone)
-		{	
-		if(!Item(focusIndex).Properties())
-			{
 			// If media is NULL, cancel the previous pending request.
 			// Place a new request for the item in focus, to fetch the media attributes
 			iManager->CancelPreviousRequest();		
 			}
-		}
-	}