ui/uiengine/model/mediamodel/src/glxmediamodel.cpp
changeset 24 99ad1390cd33
parent 23 74c9f037fd5d
child 26 c499df2dbb33
equal deleted inserted replaced
23:74c9f037fd5d 24:99ad1390cd33
    28 #include <glxfiltergeneraldefs.h>
    28 #include <glxfiltergeneraldefs.h>
    29 
    29 
    30 //#define GLXPERFORMANCE_LOG  
    30 //#define GLXPERFORMANCE_LOG  
    31 #include <glxperformancemacro.h>
    31 #include <glxperformancemacro.h>
    32 
    32 
       
    33 #include "glxicondefs.h" //Contains the icon names/Ids
       
    34 
    33 GlxMediaModel::GlxMediaModel(GlxModelParm & modelParm)
    35 GlxMediaModel::GlxMediaModel(GlxModelParm & modelParm)
    34 {
    36 {
    35 	qDebug("GlxMediaModel::GlxMediaModel");
    37 	qDebug("GlxMediaModel::GlxMediaModel");
       
    38 	
    36 	mMLWrapper = new GlxMLWrapper(modelParm.collection(),0,EGlxFilterImage);
    39 	mMLWrapper = new GlxMLWrapper(modelParm.collection(),0,EGlxFilterImage);
    37 	mMLWrapper->setContextMode(GlxContextGrid);
    40 	mMLWrapper->setContextMode( modelParm.contextMode() );
    38 	mContextMode = GlxContextGrid;
    41 	mContextMode = modelParm.contextMode( ) ; 
       
    42 	
    39 	int err = connect(mMLWrapper, SIGNAL(updateItem(int, GlxTBContextType)), this, SLOT(itemUpdated1(int, GlxTBContextType)));
    43 	int err = connect(mMLWrapper, SIGNAL(updateItem(int, GlxTBContextType)), this, SLOT(itemUpdated1(int, GlxTBContextType)));
    40 	qDebug("updateItem() connection status %d", err);
    44 	qDebug("updateItem() connection status %d", err);
    41 	err = connect(mMLWrapper, SIGNAL(itemCorrupted(int)), this, SLOT(itemCorrupted(int)));
    45 	err = connect(mMLWrapper, SIGNAL(itemCorrupted(int)), this, SLOT(itemCorrupted(int)));
    42 	qDebug("itemCorrupted() connection status %d", err);
    46 	qDebug("itemCorrupted() connection status %d", err);
    43 	err = connect(mMLWrapper, SIGNAL(insertItems(int, int)), this, SLOT(itemsAdded(int, int)));
    47 	err = connect(mMLWrapper, SIGNAL(insertItems(int, int)), this, SLOT(itemsAdded(int, int)));
    45 	err = connect(mMLWrapper, SIGNAL(removeItems(int, int)), this, SLOT(itemsRemoved(int, int)));
    49 	err = connect(mMLWrapper, SIGNAL(removeItems(int, int)), this, SLOT(itemsRemoved(int, int)));
    46 	qDebug("updateItem() connection status %d", err);
    50 	qDebug("updateItem() connection status %d", err);
    47 	err = connect(this, SIGNAL(iconAvailable(int, HbIcon*, GlxTBContextType)), this, SLOT(updateItemIcon(int, HbIcon*, GlxTBContextType)));
    51 	err = connect(this, SIGNAL(iconAvailable(int, HbIcon*, GlxTBContextType)), this, SLOT(updateItemIcon(int, HbIcon*, GlxTBContextType)));
    48 	qDebug("iconAvailable() connection status %d", err);
    52 	qDebug("iconAvailable() connection status %d", err);
    49 	//itemadded.resize(mMLWrapper->getItemCount());
    53 	//itemadded.resize(mMLWrapper->getItemCount());
       
    54 	
    50 	itemIconCache.setMaxCost(50);
    55 	itemIconCache.setMaxCost(50);
    51 	itemFsIconCache.setMaxCost(5);
    56 	itemFsIconCache.setMaxCost(5);
    52 	itemExternalIconCache.setMaxCost(0);
    57 	itemExternalIconCache.setMaxCost(0);
       
    58 	
    53 	//todo get this Default icon from some generic path and not directly.
    59 	//todo get this Default icon from some generic path and not directly.
    54 	m_DefaultIcon = new HbIcon(":/data/All_default.png");
    60 	m_DefaultIcon = new HbIcon(GLXICON_DEFAULT);
    55 	mExternalItems = NULL;
    61 	mExternalItems = NULL;
    56 	externalDataCount = 0;
    62 	externalDataCount = 0;
    57 	mFocusIndex = -1;
    63 	mFocusIndex = -1;
       
    64 	mSubState = -1;
    58 }
    65 }
    59 
    66 
    60 GlxMediaModel::~GlxMediaModel()
    67 GlxMediaModel::~GlxMediaModel()
    61 {
    68 {
    62     //itemadded.clear();
    69     //itemadded.clear();
    84 {
    91 {
    85 	if(mContextMode != contextMode)	{
    92 	if(mContextMode != contextMode)	{
    86 		itemFsIconCache.clear();
    93 		itemFsIconCache.clear();
    87 		mMLWrapper->setContextMode(contextMode);
    94 		mMLWrapper->setContextMode(contextMode);
    88 		mContextMode = contextMode;
    95 		mContextMode = contextMode;
       
    96 		if ( mContextMode == GlxContextLsGrid || mContextMode == GlxContextPtGrid ) {
       
    97             itemIconCache.clear();
       
    98             emit dataChanged( index( 0, 0), index( rowCount() - 1, 0) );
       
    99         }
    89 	}
   100 	}
    90 }
   101 }
    91 
   102 
    92 //to add external data to the model
   103 //to add external data to the model
    93 void GlxMediaModel::addExternalItems(GlxExternalData* externalItems)
   104 void GlxMediaModel::addExternalItems(GlxExternalData* externalItems)
   160         itemIndex -=  externalDataCount;
   171         itemIndex -=  externalDataCount;
   161     }
   172     }
   162     
   173     
   163 //retrieve Data from Media List		
   174 //retrieve Data from Media List		
   164     if (role == Qt::DecorationRole) {
   175     if (role == Qt::DecorationRole) {
   165         // char temp[100];
       
   166         // sprintf(temp, "Thumbnail %d requiest time ", index.row());
       
   167         // WRITE_TIMESTAMP(temp)
       
   168         // sprintf(temp, "Response time of Thumbnail Request %d", index.row());
       
   169         // PERFORMANCE_ADV( d1, temp) {
       
   170         itemIcon = GetGridIconItem(itemIndex,GlxTBContextGrid);
   176         itemIcon = GetGridIconItem(itemIndex,GlxTBContextGrid);
   171         if(itemIcon == NULL || itemIcon->isNull() ){
   177         if(itemIcon == NULL || itemIcon->isNull() ){
   172             itemIcon = m_DefaultIcon;
   178             itemIcon = m_DefaultIcon;
   173         // }
   179         // }
   174         }
   180         }
   223     
   229     
   224     if (role == GlxFrameCount) {
   230     if (role == GlxFrameCount) {
   225     qDebug("GlxMediaModel:: GlxFrameCount ");
   231     qDebug("GlxMediaModel:: GlxFrameCount ");
   226     return (mMLWrapper->retrieveItemFrameCount(itemIndex));
   232     return (mMLWrapper->retrieveItemFrameCount(itemIndex));
   227     }
   233     }
       
   234     
       
   235     if ( role == GlxSubStateRole ) {
       
   236         return mSubState;
       
   237     }
   228 	    
   238 	    
   229     return QVariant();
   239     return QVariant();
   230 }
   240 }
   231 
   241 
   232 //GetGridIconItem
   242 //GetGridIconItem
   411         qDebug("GlxMediaModel::setData()::GlxSelectedIndexRole%d", idx.row());    
   421         qDebug("GlxMediaModel::setData()::GlxSelectedIndexRole%d", idx.row());    
   412             setSelectedIndex( index( value.value <int> (), 0) );
   422             setSelectedIndex( index( value.value <int> (), 0) );
   413             return TRUE;
   423             return TRUE;
   414         }
   424         }
   415     }
   425     }
       
   426     
       
   427     if ( role == GlxSubStateRole && value.isValid() &&  value.canConvert <int> ()) {
       
   428         mSubState = value.value <int> () ;
       
   429         return TRUE;
       
   430     }
   416 
   431 
   417     return FALSE;
   432     return FALSE;
   418 }
   433 }
   419 
   434 
   420 QModelIndex GlxMediaModel::index(int row, int column, const QModelIndex &parent) const
   435 QModelIndex GlxMediaModel::index(int row, int column, const QModelIndex &parent) const