ui/uiengine/model/mediamodel/src/glxmediamodel.cpp
changeset 49 f291796e213d
parent 48 d0b4e67b3a60
child 50 a0f57508af73
child 55 fb37077c270f
equal deleted inserted replaced
48:d0b4e67b3a60 49:f291796e213d
    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 <glxmlwrapper.h>
    26 #include <glxmlwrapper.h>
       
    27 #include"glxdrmutilitywrapper.h"
    27 
    28 
    28 #include <glxfiltergeneraldefs.h>
    29 #include <glxfiltergeneraldefs.h>
    29 
    30 
       
    31 #include <glximageviewermanager.h>
    30 //#define GLXPERFORMANCE_LOG  
    32 //#define GLXPERFORMANCE_LOG  
    31 #include <glxperformancemacro.h>
    33 #include <glxperformancemacro.h>
    32 
    34 
    33 #include "glxicondefs.h" //Contains the icon names/Ids
    35 #include "glxicondefs.h" //Contains the icon names/Ids
       
    36 #include<glxviewids.h>
    34 
    37 
    35 GlxMediaModel::GlxMediaModel(GlxModelParm & modelParm)
    38 GlxMediaModel::GlxMediaModel(GlxModelParm & modelParm)
    36 {
    39 {
    37 	qDebug("GlxMediaModel::GlxMediaModel");
    40 	qDebug("GlxMediaModel::GlxMediaModel");
    38 	
    41 	
    39 	mMLWrapper = new GlxMLWrapper(modelParm.collection(),0,EGlxFilterImage);
    42 	mMLWrapper = new GlxMLWrapper(modelParm.collection(),0,EGlxFilterImage);
    40 	mMLWrapper->setContextMode( modelParm.contextMode() );
    43 	mMLWrapper->setContextMode( modelParm.contextMode() );
    41 	mContextMode = modelParm.contextMode( ) ; 
    44 	mContextMode = modelParm.contextMode( ) ; 
    42 	
    45 	mDRMUtilityWrapper = new GlxDRMUtilityWrapper();
    43 	int err = connect(mMLWrapper, SIGNAL(updateItem(int, GlxTBContextType)), this, SLOT(itemUpdated1(int, GlxTBContextType)));
    46 	int err = connect(mMLWrapper, SIGNAL(updateItem(int, GlxTBContextType)), this, SLOT(itemUpdated1(int, GlxTBContextType)));
    44 	qDebug("updateItem() connection status %d", err);
    47 	qDebug("updateItem() connection status %d", err);
    45 	err = connect(mMLWrapper, SIGNAL(itemCorrupted(int)), this, SLOT(itemCorrupted(int)));
    48 	err = connect(mMLWrapper, SIGNAL(itemCorrupted(int)), this, SLOT(itemCorrupted(int)));
    46 	qDebug("itemCorrupted() connection status %d", err);
    49 	qDebug("itemCorrupted() connection status %d", err);
    47 	err = connect(mMLWrapper, SIGNAL(insertItems(int, int)), this, SLOT(itemsAdded(int, int)));
    50 	err = connect(mMLWrapper, SIGNAL(insertItems(int, int)), this, SLOT(itemsAdded(int, int)));
    63 	m_DefaultIcon = new HbIcon(GLXICON_DEFAULT);
    66 	m_DefaultIcon = new HbIcon(GLXICON_DEFAULT);
    64 	mExternalItems = NULL;
    67 	mExternalItems = NULL;
    65 	externalDataCount = 0;
    68 	externalDataCount = 0;
    66 	mFocusIndex = -1;
    69 	mFocusIndex = -1;
    67 	mSubState = -1;
    70 	mSubState = -1;
       
    71 	mTempVisibleWindowIndex = 0;
    68 }
    72 }
    69 
    73 
    70 GlxMediaModel::~GlxMediaModel()
    74 GlxMediaModel::~GlxMediaModel()
    71 {
    75 {
    72     //itemadded.clear();
    76     //itemadded.clear();
    83 	err = disconnect(this, SIGNAL(iconAvailable(int, HbIcon*, GlxTBContextType)), this, SLOT(updateItemIcon(int, HbIcon*, GlxTBContextType)));
    87 	err = disconnect(this, SIGNAL(iconAvailable(int, HbIcon*, GlxTBContextType)), this, SLOT(updateItemIcon(int, HbIcon*, GlxTBContextType)));
    84 	err = disconnect(mMLWrapper, SIGNAL(updateAlbumTitle(QString)), this, SLOT(albumTitleUpdated(QString)));	    
    88 	err = disconnect(mMLWrapper, SIGNAL(updateAlbumTitle(QString)), this, SLOT(albumTitleUpdated(QString)));	    
    85 	err = disconnect(mMLWrapper, SIGNAL(populated()), this, SLOT(modelpopulated()));
    89 	err = disconnect(mMLWrapper, SIGNAL(populated()), this, SLOT(modelpopulated()));
    86 	err = disconnect(mMLWrapper, SIGNAL(updateDetails()), this, SLOT(updateDetailItems()));
    90 	err = disconnect(mMLWrapper, SIGNAL(updateDetails()), this, SLOT(updateDetailItems()));
    87     delete mMLWrapper;
    91     delete mMLWrapper;
    88 
    92 	delete mDRMUtilityWrapper;
    89 }
    93 }
    90 
    94 
    91 //------------------------------------------------------------------------------------------------------------
    95 //------------------------------------------------------------------------------------------------------------
    92 //setContextMode
    96 //setContextMode
    93 //------------------------------------------------------------------------------------------------------------
    97 //------------------------------------------------------------------------------------------------------------
   358 
   362 
   359 }
   363 }
   360 
   364 
   361 HbIcon* GlxMediaModel::GetFsIconItem(int itemIndex, GlxTBContextType tbContextType) const
   365 HbIcon* GlxMediaModel::GetFsIconItem(int itemIndex, GlxTBContextType tbContextType) const
   362 {
   366 {
   363 	HbIcon* itemIcon = itemFsIconCache[itemIndex];  //Initialize icon from the Cache will be NULL if Item not present
   367 	HbIcon* itemIcon = NULL;  //Initialize icon from the Cache will be NULL if Item not present
   364 	if (!itemIcon) {
   368 
       
   369     bool drmProtected = mMLWrapper->IsDrmProtected(itemIndex);
       
   370     if(drmProtected)
       
   371         {
       
   372         QString imagePath = mMLWrapper->retrieveItemUri(itemIndex);
       
   373 		bool rightValid = mMLWrapper->IsDrmValid(itemIndex);
       
   374         if(!rightValid)
       
   375             {
       
   376             //show error note here
       
   377             if(itemIndex == mFocusIndex )
       
   378                 mDRMUtilityWrapper->ShowRightsInfo(imagePath);
       
   379             return itemIcon;
       
   380             }
       
   381         else
       
   382             {
       
   383             //consumeDrmRights(imagePath);
       
   384             mDRMUtilityWrapper->ConsumeRights(imagePath);
       
   385 			bool rightValid = mDRMUtilityWrapper->ItemRightsValidityCheck(imagePath,true);
       
   386 			mMLWrapper->setDrmValid(itemIndex,rightValid);
       
   387             }
       
   388         }
       
   389     itemIcon = itemFsIconCache[itemIndex];  //Initialize icon from the Cache will be NULL if Item not present
       
   390     if (!itemIcon) {
   365 		itemIcon =  mMLWrapper->retrieveItemIcon(itemIndex, tbContextType);
   391 		itemIcon =  mMLWrapper->retrieveItemIcon(itemIndex, tbContextType);
   366 		if(itemIcon){
   392 		if(itemIcon){
   367             emit iconAvailable(itemIndex,itemIcon, tbContextType);
   393             emit iconAvailable(itemIndex,itemIcon, tbContextType);
   368 		}
   394 		}
   369 		itemIcon = itemFsIconCache[itemIndex];
   395 		itemIcon = itemFsIconCache[itemIndex];
   405 	emit dataChanged(index(itemIndex+externalDataCount,0),index(itemIndex+externalDataCount,0));	
   431 	emit dataChanged(index(itemIndex+externalDataCount,0),index(itemIndex+externalDataCount,0));	
   406 }
   432 }
   407 
   433 
   408 void GlxMediaModel::modelpopulated()
   434 void GlxMediaModel::modelpopulated()
   409 {
   435 {
       
   436     if ( mTempVisibleWindowIndex!=-1) {
       
   437         mMLWrapper->setVisibleWindowIndex(mTempVisibleWindowIndex);
       
   438         mTempVisibleWindowIndex = -1;
       
   439 	}
   410     emit populated();
   440     emit populated();
   411 }
   441 }
   412 
   442 
   413 //------------------------------------------------------------------------------------------------------------
   443 //------------------------------------------------------------------------------------------------------------
   414 //updateDetailItems
   444 //updateDetailItems
   468 
   498 
   469 void GlxMediaModel::setFocusIndex(const QModelIndex &index)
   499 void GlxMediaModel::setFocusIndex(const QModelIndex &index)
   470 {
   500 {
   471 	qDebug("GlxMediaModel::setFocusIndex%d", index.row());
   501 	qDebug("GlxMediaModel::setFocusIndex%d", index.row());
   472 	int itemIndex = index.row();
   502 	int itemIndex = index.row();
   473 	
   503 	int mlIndex = -1;
   474 	if(itemIndex >=externalDataCount)
   504 	if(itemIndex >=externalDataCount)
   475 	{
   505 	{
   476 		int mlIndex = itemIndex - externalDataCount;
   506 		mlIndex = itemIndex - externalDataCount;
   477 		mMLWrapper->setFocusIndex(mlIndex);
   507 		mMLWrapper->setFocusIndex(mlIndex);
   478 		mFocusIndex = -1;
   508 		mFocusIndex = -1;
   479 	}
   509 	}
   480 	else{
   510 	else{
   481 		mFocusIndex = itemIndex;
   511 		mFocusIndex = itemIndex;
   482 		if(rowCount() > externalDataCount) {
   512 		if(rowCount() > externalDataCount) {
   483 			mMLWrapper->setFocusIndex(0);
   513 			mMLWrapper->setFocusIndex(0);
       
   514 			mlIndex = 0;
   484 		}
   515 		}
   485 		
   516 		
   486 	}
   517 	}
   487 
   518 	if(mSubState != IMAGEVIEWER_S ){
       
   519      if( mMLWrapper->IsDrmProtected(mlIndex) && (!mMLWrapper->IsDrmValid(mlIndex)) )
       
   520             {
       
   521             QString imagePath = mMLWrapper->retrieveItemUri(mlIndex);
       
   522             mDRMUtilityWrapper->ShowRightsInfo(imagePath);
       
   523             }
       
   524 	}else {
       
   525         CGlxImageViewerManager* CGlxImageViewerManager = CGlxImageViewerManager::InstanceL();
       
   526         const TDesC& title = CGlxImageViewerManager->ImageUri()->Des();
       
   527         QString imagePath = QString::fromUtf16(title.Ptr(),title.Length());
       
   528         mDRMUtilityWrapper->ShowRightsInfo(imagePath);
       
   529 	}
   488 }
   530 }
   489 
   531 
   490 QModelIndex GlxMediaModel::getFocusIndex() const
   532 QModelIndex GlxMediaModel::getFocusIndex() const
   491 {
   533 {
   492 	int itemIndex = 0;
   534 	int itemIndex = 0;
   552     
   594     
   553     if ( role == GlxSubStateRole && value.isValid() &&  value.canConvert <int> ()) {
   595     if ( role == GlxSubStateRole && value.isValid() &&  value.canConvert <int> ()) {
   554         mSubState = value.value <int> () ;
   596         mSubState = value.value <int> () ;
   555         return TRUE;
   597         return TRUE;
   556     }
   598     }
       
   599     if ( GlxTempVisualWindowIndex == role ) {
       
   600             if ( value.isValid() && value.canConvert<int> () ) {
       
   601             mTempVisibleWindowIndex = value.value <int> (); 
       
   602             return TRUE;
       
   603             }
       
   604     }
   557 
   605 
   558     return FALSE;
   606     return FALSE;
   559 }
   607 }
   560 
   608 
   561 QModelIndex GlxMediaModel::index(int row, int column, const QModelIndex &parent) const
   609 QModelIndex GlxMediaModel::index(int row, int column, const QModelIndex &parent) const