ui/uiengine/model/mediamodel/src/glxmediamodel.cpp
changeset 24 99ad1390cd33
parent 23 74c9f037fd5d
child 26 c499df2dbb33
--- a/ui/uiengine/model/mediamodel/src/glxmediamodel.cpp	Fri Mar 19 09:28:59 2010 +0200
+++ b/ui/uiengine/model/mediamodel/src/glxmediamodel.cpp	Fri Apr 16 14:58:46 2010 +0300
@@ -30,12 +30,16 @@
 //#define GLXPERFORMANCE_LOG  
 #include <glxperformancemacro.h>
 
+#include "glxicondefs.h" //Contains the icon names/Ids
+
 GlxMediaModel::GlxMediaModel(GlxModelParm & modelParm)
 {
 	qDebug("GlxMediaModel::GlxMediaModel");
+	
 	mMLWrapper = new GlxMLWrapper(modelParm.collection(),0,EGlxFilterImage);
-	mMLWrapper->setContextMode(GlxContextGrid);
-	mContextMode = GlxContextGrid;
+	mMLWrapper->setContextMode( modelParm.contextMode() );
+	mContextMode = modelParm.contextMode( ) ; 
+	
 	int err = connect(mMLWrapper, SIGNAL(updateItem(int, GlxTBContextType)), this, SLOT(itemUpdated1(int, GlxTBContextType)));
 	qDebug("updateItem() connection status %d", err);
 	err = connect(mMLWrapper, SIGNAL(itemCorrupted(int)), this, SLOT(itemCorrupted(int)));
@@ -47,14 +51,17 @@
 	err = connect(this, SIGNAL(iconAvailable(int, HbIcon*, GlxTBContextType)), this, SLOT(updateItemIcon(int, HbIcon*, GlxTBContextType)));
 	qDebug("iconAvailable() connection status %d", err);
 	//itemadded.resize(mMLWrapper->getItemCount());
+	
 	itemIconCache.setMaxCost(50);
 	itemFsIconCache.setMaxCost(5);
 	itemExternalIconCache.setMaxCost(0);
+	
 	//todo get this Default icon from some generic path and not directly.
-	m_DefaultIcon = new HbIcon(":/data/All_default.png");
+	m_DefaultIcon = new HbIcon(GLXICON_DEFAULT);
 	mExternalItems = NULL;
 	externalDataCount = 0;
 	mFocusIndex = -1;
+	mSubState = -1;
 }
 
 GlxMediaModel::~GlxMediaModel()
@@ -86,6 +93,10 @@
 		itemFsIconCache.clear();
 		mMLWrapper->setContextMode(contextMode);
 		mContextMode = contextMode;
+		if ( mContextMode == GlxContextLsGrid || mContextMode == GlxContextPtGrid ) {
+            itemIconCache.clear();
+            emit dataChanged( index( 0, 0), index( rowCount() - 1, 0) );
+        }
 	}
 }
 
@@ -162,11 +173,6 @@
     
 //retrieve Data from Media List		
     if (role == Qt::DecorationRole) {
-        // char temp[100];
-        // sprintf(temp, "Thumbnail %d requiest time ", index.row());
-        // WRITE_TIMESTAMP(temp)
-        // sprintf(temp, "Response time of Thumbnail Request %d", index.row());
-        // PERFORMANCE_ADV( d1, temp) {
         itemIcon = GetGridIconItem(itemIndex,GlxTBContextGrid);
         if(itemIcon == NULL || itemIcon->isNull() ){
             itemIcon = m_DefaultIcon;
@@ -225,6 +231,10 @@
     qDebug("GlxMediaModel:: GlxFrameCount ");
     return (mMLWrapper->retrieveItemFrameCount(itemIndex));
     }
+    
+    if ( role == GlxSubStateRole ) {
+        return mSubState;
+    }
 	    
     return QVariant();
 }
@@ -413,6 +423,11 @@
             return TRUE;
         }
     }
+    
+    if ( role == GlxSubStateRole && value.isValid() &&  value.canConvert <int> ()) {
+        mSubState = value.value <int> () ;
+        return TRUE;
+    }
 
     return FALSE;
 }