ui/uiengine/model/mediamodel/src/glxmediamodel.cpp
changeset 44 aa2fa096cbfb
parent 43 72396548277c
child 45 863223ea6961
equal deleted inserted replaced
43:72396548277c 44:aa2fa096cbfb
    21 #include <hbicon.h>
    21 #include <hbicon.h>
    22 #include <qimage.h>
    22 #include <qimage.h>
    23 #include <glxmodelparm.h>
    23 #include <glxmodelparm.h>
    24 #include <QCache>
    24 #include <QCache>
    25 #include <QDebug>
    25 #include <QDebug>
    26 #include <hal.h>
       
    27 #include <hal_data.h>
       
    28 #include <glxmlwrapper.h>
    26 #include <glxmlwrapper.h>
    29 
    27 
    30 #include <glxfiltergeneraldefs.h>
    28 #include <glxfiltergeneraldefs.h>
    31 
    29 
    32 //#define GLXPERFORMANCE_LOG  
    30 //#define GLXPERFORMANCE_LOG  
    53 	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)));
    54 	qDebug("iconAvailable() connection status %d", err);
    52 	qDebug("iconAvailable() connection status %d", err);
    55 	err = connect( mMLWrapper, SIGNAL(updateAlbumTitle(QString)), this, SLOT(albumTitleUpdated(QString)));
    53 	err = connect( mMLWrapper, SIGNAL(updateAlbumTitle(QString)), this, SLOT(albumTitleUpdated(QString)));
    56 	qDebug("updateAlbumTitle() connection status %d", err);
    54 	qDebug("updateAlbumTitle() connection status %d", err);
    57 	err = connect(mMLWrapper, SIGNAL(populated()), this, SLOT(modelpopulated()));
    55 	err = connect(mMLWrapper, SIGNAL(populated()), this, SLOT(modelpopulated()));
    58 	//itemadded.resize(mMLWrapper->getItemCount());
    56 	err = connect(mMLWrapper, SIGNAL(updateDetails()), this, SLOT(updateDetailItems()));
    59 	
    57 	
    60 	itemIconCache.setMaxCost(20);  //Changed While Doing Media Wall
    58 	itemIconCache.setMaxCost(20);  //Changed While Doing Media Wall
    61 	itemFsIconCache.setMaxCost(5);
    59 	itemFsIconCache.setMaxCost(5);
    62 	itemExternalIconCache.setMaxCost(0);
    60 	itemExternalIconCache.setMaxCost(0);
    63 	
    61 	
    71 
    69 
    72 GlxMediaModel::~GlxMediaModel()
    70 GlxMediaModel::~GlxMediaModel()
    73 {
    71 {
    74     //itemadded.clear();
    72     //itemadded.clear();
    75 	qDebug("GlxMediaModel::~GlxMediaModel");
    73 	qDebug("GlxMediaModel::~GlxMediaModel");
    76 	int freeMemory = 0;
       
    77 	int err1 = HAL::Get( HALData::EMemoryRAMFree, freeMemory );
       
    78 	qDebug("####mediaModel : Memory available before cache cleanup  = %d and error is = %d ", freeMemory , err1 );
       
    79 	itemIconCache.clear();
    74 	itemIconCache.clear();
    80 	itemFsIconCache.clear();
    75 	itemFsIconCache.clear();
    81 	delete m_DefaultIcon;
    76 	delete m_DefaultIcon;
    82 	m_DefaultIcon = NULL;
    77 	m_DefaultIcon = NULL;
    83 	clearExternalItems();
    78 	clearExternalItems();
    84 	err1 = HAL::Get( HALData::EMemoryRAMFree, freeMemory );
    79   int err = disconnect(mMLWrapper, SIGNAL(updateItem(int, GlxTBContextType)), this, SLOT(itemUpdated1(int, GlxTBContextType)));
    85 	qDebug("####mediaModel : Memory available after cache cleanup  = %d and error is = %d ", freeMemory , err1 );
       
    86     int err = disconnect(mMLWrapper, SIGNAL(updateItem(int, GlxTBContextType)), this, SLOT(itemUpdated1(int, GlxTBContextType)));
       
    87 	err = disconnect(mMLWrapper, SIGNAL(itemCorrupted(int)), this, SLOT(itemCorrupted(int)));
    80 	err = disconnect(mMLWrapper, SIGNAL(itemCorrupted(int)), this, SLOT(itemCorrupted(int)));
    88 	err = disconnect(mMLWrapper, SIGNAL(insertItems(int, int)), this, SLOT(itemsAdded(int, int)));
    81 	err = disconnect(mMLWrapper, SIGNAL(insertItems(int, int)), this, SLOT(itemsAdded(int, int)));
    89 	err = disconnect(mMLWrapper, SIGNAL(removeItems(int, int)), this, SLOT(itemsRemoved(int, int)));
    82 	err = disconnect(mMLWrapper, SIGNAL(removeItems(int, int)), this, SLOT(itemsRemoved(int, int)));
    90 	err = disconnect(this, SIGNAL(iconAvailable(int, HbIcon*, GlxTBContextType)), this, SLOT(updateItemIcon(int, HbIcon*, GlxTBContextType)));
    83 	err = disconnect(this, SIGNAL(iconAvailable(int, HbIcon*, GlxTBContextType)), this, SLOT(updateItemIcon(int, HbIcon*, GlxTBContextType)));
    91 	err = disconnect(mMLWrapper, SIGNAL(updateAlbumTitle(QString)), this, SLOT(albumTitleUpdated(QString)));	    
    84 	err = disconnect(mMLWrapper, SIGNAL(updateAlbumTitle(QString)), this, SLOT(albumTitleUpdated(QString)));	    
    92 	err = disconnect(mMLWrapper, SIGNAL(populated()), this, SLOT(modelpopulated()));
    85 	err = disconnect(mMLWrapper, SIGNAL(populated()), this, SLOT(modelpopulated()));
       
    86 	err = disconnect(mMLWrapper, SIGNAL(updateDetails()), this, SLOT(updateDetailItems()));
    93     delete mMLWrapper;
    87     delete mMLWrapper;
    94 
    88 
    95 }
    89 }
    96 
    90 
       
    91 //------------------------------------------------------------------------------------------------------------
       
    92 //setContextMode
       
    93 //------------------------------------------------------------------------------------------------------------
    97 void GlxMediaModel::setContextMode(GlxContextMode contextMode)
    94 void GlxMediaModel::setContextMode(GlxContextMode contextMode)
    98 {
    95 {
    99 	if(mContextMode != contextMode)	{
    96     if(contextMode == GlxContextComment)
       
    97         {
       
    98            mMLWrapper->setContextMode(contextMode);
       
    99         }
       
   100     else 
       
   101         {
       
   102       if(mContextMode != contextMode)	{
       
   103         
   100 		itemFsIconCache.clear();
   104 		itemFsIconCache.clear();
   101 		mMLWrapper->setContextMode(contextMode);
   105 		mMLWrapper->setContextMode(contextMode);
   102 		mContextMode = contextMode;
   106 		mContextMode = contextMode;
   103 		if ( mContextMode == GlxContextLsGrid || mContextMode == GlxContextPtGrid ) {
   107 		if ( mContextMode == GlxContextLsGrid || mContextMode == GlxContextPtGrid ) {
   104             itemIconCache.clear();
   108             itemIconCache.clear();
   105             //emit dataChanged( index( 0, 0), index( rowCount() - 1, 0) );  // Not Needed for HgWidget
   109             //emit dataChanged( index( 0, 0), index( rowCount() - 1, 0) );  // Not Needed for HgWidget
   106         }
   110        }
   107 	}
   111 	  }
   108 }
   112      }
       
   113 }
       
   114 
       
   115 //------------------------------------------------------------------------------------------------------------
       
   116 //removeContextMode
       
   117 //------------------------------------------------------------------------------------------------------------
       
   118 void GlxMediaModel::removeContextMode(GlxContextMode contextMode)
       
   119     {
       
   120      mMLWrapper->removeContextMode(contextMode);
       
   121     }
   109 
   122 
   110 //to add external data to the model
   123 //to add external data to the model
   111 void GlxMediaModel::addExternalItems(GlxExternalData* externalItems)
   124 void GlxMediaModel::addExternalItems(GlxExternalData* externalItems)
   112 {
   125 {
   113 	externalDataCount = externalItems->count();
   126 	externalDataCount = externalItems->count();
   312     }
   325     }
   313     
   326     
   314     if (role == GlxHdmiBitmap) {
   327     if (role == GlxHdmiBitmap) {
   315         return mMLWrapper->RetrieveBitmap(itemIndex);
   328         return mMLWrapper->RetrieveBitmap(itemIndex);
   316     }
   329     }
   317 	    
   330     
       
   331     if (role == GlxTimeRole) {
       
   332         return mMLWrapper->retrieveItemTime(itemIndex);
       
   333     }
       
   334 	
       
   335     if (role == GlxSizeRole) {
       
   336             return mMLWrapper->retrieveItemSize(itemIndex);
       
   337         }
       
   338     
       
   339     if (role == GlxDescRole) {
       
   340               return mMLWrapper->retrieveListDesc(itemIndex);
       
   341           }
   318     return QVariant();
   342     return QVariant();
   319 }
   343 }
   320 
   344 
   321 //GetGridIconItem
   345 //GetGridIconItem
   322 HbIcon* GlxMediaModel::GetGridIconItem(int itemIndex, GlxTBContextType tbContextType) const
   346 HbIcon* GlxMediaModel::GetGridIconItem(int itemIndex, GlxTBContextType tbContextType) const
   382 }
   406 }
   383 
   407 
   384 void GlxMediaModel::modelpopulated()
   408 void GlxMediaModel::modelpopulated()
   385 {
   409 {
   386     emit populated();
   410     emit populated();
       
   411 }
       
   412 
       
   413 //------------------------------------------------------------------------------------------------------------
       
   414 //updateDetailItems
       
   415 //------------------------------------------------------------------------------------------------------------
       
   416 void GlxMediaModel::updateDetailItems()
       
   417 {
       
   418     qDebug("GlxMediaModel::updateDetailItems");
       
   419     emit updateDetailsView();
   387 }
   420 }
   388 
   421 
   389 void GlxMediaModel::itemsAdded(int startIndex, int endIndex)
   422 void GlxMediaModel::itemsAdded(int startIndex, int endIndex)
   390 {
   423 {
   391 	qDebug("GlxMediaModel::itemsAdded %d %d", startIndex, endIndex);
   424 	qDebug("GlxMediaModel::itemsAdded %d %d", startIndex, endIndex);
   484             setContextMode( (GlxContextMode) value.value <int> () );
   517             setContextMode( (GlxContextMode) value.value <int> () );
   485             return TRUE;
   518             return TRUE;
   486         }
   519         }
   487     }
   520     }
   488     
   521     
       
   522     if ( GlxRemoveContextRole == role ) {
       
   523             if ( value.isValid() &&  value.canConvert <int> () ) {
       
   524                 removeContextMode( (GlxContextMode) value.value <int> () );
       
   525                 return TRUE;
       
   526             }
       
   527         }
       
   528     
       
   529     
   489     if ( GlxFocusIndexRole == role ) {
   530     if ( GlxFocusIndexRole == role ) {
   490         if ( value.isValid() &&  value.canConvert <int> () ) {
   531         if ( value.isValid() &&  value.canConvert <int> () ) {
   491             setFocusIndex( index( value.value <int> (), 0) );
   532             setFocusIndex( index( value.value <int> (), 0) );
   492             return TRUE;
   533             return TRUE;
   493         }
   534         }