ui/uiengine/model/mediamodel/src/glxmediamodel.cpp
changeset 42 5e1df1b52eb3
parent 40 112f0ac2d1f0
child 36 6481344a6d67
equal deleted inserted replaced
41:ae07d189b490 42:5e1df1b52eb3
    50 	qDebug("updateItem() connection status %d", err);
    50 	qDebug("updateItem() connection status %d", err);
    51 	err = connect(mMLWrapper, SIGNAL(removeItems(int, int)), this, SLOT(itemsRemoved(int, int)));
    51 	err = connect(mMLWrapper, SIGNAL(removeItems(int, int)), this, SLOT(itemsRemoved(int, int)));
    52 	qDebug("updateItem() connection status %d", err);
    52 	qDebug("updateItem() connection status %d", err);
    53 	err = connect(this, SIGNAL(iconAvailable(int, HbIcon*, GlxTBContextType)), this, SLOT(updateItemIcon(int, HbIcon*, GlxTBContextType)));
    53 	err = connect(this, SIGNAL(iconAvailable(int, HbIcon*, GlxTBContextType)), this, SLOT(updateItemIcon(int, HbIcon*, GlxTBContextType)));
    54 	qDebug("iconAvailable() connection status %d", err);
    54 	qDebug("iconAvailable() connection status %d", err);
       
    55 	err = connect( mMLWrapper, SIGNAL(updateAlbumTitle(QString)), this, SLOT(albumTitleUpdated(QString)));
       
    56 	qDebug("updateAlbumTitle() connection status %d", err);
       
    57 	err = connect(mMLWrapper, SIGNAL(populated()), this, SLOT(modelpopulated()));
    55 	//itemadded.resize(mMLWrapper->getItemCount());
    58 	//itemadded.resize(mMLWrapper->getItemCount());
    56 	
    59 	
    57 	itemIconCache.setMaxCost(20);  //Changed While Doing Media Wall
    60 	itemIconCache.setMaxCost(20);  //Changed While Doing Media Wall
    58 	itemFsIconCache.setMaxCost(5);
    61 	itemFsIconCache.setMaxCost(5);
    59 	itemExternalIconCache.setMaxCost(0);
    62 	itemExternalIconCache.setMaxCost(0);
    83     int err = disconnect(mMLWrapper, SIGNAL(updateIcon(int, HbIcon*)), this, SLOT(itemUpdated1(int, HbIcon*)));
    86     int err = disconnect(mMLWrapper, SIGNAL(updateIcon(int, HbIcon*)), this, SLOT(itemUpdated1(int, HbIcon*)));
    84 	err = disconnect(mMLWrapper, SIGNAL(itemCorrupted(int)), this, SLOT(itemCorrupted(int)));
    87 	err = disconnect(mMLWrapper, SIGNAL(itemCorrupted(int)), this, SLOT(itemCorrupted(int)));
    85 	err = disconnect(mMLWrapper, SIGNAL(insertItems(int, int)), this, SLOT(itemsAdded(int, int)));
    88 	err = disconnect(mMLWrapper, SIGNAL(insertItems(int, int)), this, SLOT(itemsAdded(int, int)));
    86 	err = disconnect(mMLWrapper, SIGNAL(removeItems(int, int)), this, SLOT(itemsRemoved(int, int)));
    89 	err = disconnect(mMLWrapper, SIGNAL(removeItems(int, int)), this, SLOT(itemsRemoved(int, int)));
    87 	err = disconnect(this, SIGNAL(iconAvailable(int, HbIcon*, GlxTBContextType)), this, SLOT(updateItemIcon(int, HbIcon*, GlxTBContextType)));
    90 	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)));	    
       
    92 	err = disconnect(mMLWrapper, SIGNAL(populated()), this, SLOT(modelpopulated()));
    88     delete mMLWrapper;
    93     delete mMLWrapper;
    89 
    94 
    90 }
    95 }
    91 
    96 
    92 void GlxMediaModel::setContextMode(GlxContextMode contextMode)
    97 void GlxMediaModel::setContextMode(GlxContextMode contextMode)
   155 
   160 
   156 
   161 
   157 //todo refactor this whole function ... too many return statements are not good
   162 //todo refactor this whole function ... too many return statements are not good
   158 QVariant GlxMediaModel::data(const QModelIndex &index, int role) const
   163 QVariant GlxMediaModel::data(const QModelIndex &index, int role) const
   159 {
   164 {
       
   165     if (role == GlxViewTitle)
       
   166         {
       
   167         return mMLWrapper->retrieveViewTitle();
       
   168         }
       
   169 
       
   170     if(role == GlxPopulated) {
       
   171         return mMLWrapper->IsPopulated();
       
   172     }
       
   173 
   160     if ( role == GlxSubStateRole ) {
   174     if ( role == GlxSubStateRole ) {
   161         return mSubState;
   175         return mSubState;
   162     }
   176     }
   163 
   177 
   164     if ( role == GlxHgVisibilityRole ) {
   178     if ( role == GlxHgVisibilityRole ) {
   168     if ( role == Qt::DisplayRole ) {
   182     if ( role == Qt::DisplayRole ) {
   169         return QVariant();
   183         return QVariant();
   170     }
   184     }
   171     
   185     
   172     if ( role == GlxDefaultImage ) {
   186     if ( role == GlxDefaultImage ) {
       
   187         if(!m_DefaultIcon->isNull()) {
       
   188             // this image Creation is Slow. 
       
   189             // But what to do, Q class's Does not undersatnd our Localised File names
   173         return m_DefaultIcon->pixmap().toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
   190         return m_DefaultIcon->pixmap().toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
       
   191     }
       
   192         else {
       
   193             return QImage();
       
   194         }
       
   195             
   174     }
   196     }
   175 
   197 
   176     HbIcon* itemIcon = NULL;
   198     HbIcon* itemIcon = NULL;
   177     QImage itemImage;
   199     QImage itemImage;
   178     int itemIndex = index.row();
   200     int itemIndex = index.row();
   357 {
   379 {
   358 	qDebug("GlxMediaModel::itemCorrupted %d", itemIndex);
   380 	qDebug("GlxMediaModel::itemCorrupted %d", itemIndex);
   359 	emit dataChanged(index(itemIndex+externalDataCount,0),index(itemIndex+externalDataCount,0));	
   381 	emit dataChanged(index(itemIndex+externalDataCount,0),index(itemIndex+externalDataCount,0));	
   360 }
   382 }
   361 
   383 
       
   384 void GlxMediaModel::modelpopulated()
       
   385 {
       
   386     emit populated();
       
   387 }
       
   388 
   362 void GlxMediaModel::itemsAdded(int startIndex, int endIndex)
   389 void GlxMediaModel::itemsAdded(int startIndex, int endIndex)
   363 {
   390 {
   364 	qDebug("GlxMediaModel::itemsAdded %d %d", startIndex, endIndex);
   391 	qDebug("GlxMediaModel::itemsAdded %d %d", startIndex, endIndex);
   365 	mFocusIndex = -1;
   392 	mFocusIndex = -1;
   366 	//emit rowsAboutToBeInserted(index(startIndex,0), startIndex, endIndex );
   393 	//emit rowsAboutToBeInserted(index(startIndex,0), startIndex, endIndex );
   399 	else if (tbContextType == GlxTBContextExternal){
   426 	else if (tbContextType == GlxTBContextExternal){
   400 		itemExternalIconCache.insert(itemIndex, itemIcon);	
   427 		itemExternalIconCache.insert(itemIndex, itemIcon);	
   401 	}
   428 	}
   402 }
   429 }
   403 
   430 
       
   431 void GlxMediaModel::albumTitleUpdated(QString aTitle)
       
   432 {
       
   433     emit albumTitleAvailable(aTitle);
       
   434 }
   404 
   435 
   405 void GlxMediaModel::setFocusIndex(const QModelIndex &index)
   436 void GlxMediaModel::setFocusIndex(const QModelIndex &index)
   406 {
   437 {
   407 	qDebug("GlxMediaModel::setFocusIndex%d", index.row());
   438 	qDebug("GlxMediaModel::setFocusIndex%d", index.row());
   408 	int itemIndex = index.row();
   439 	int itemIndex = index.row();