ui/uiengine/medialistwrapper/src/glxmlwrapper_p.cpp
changeset 44 aa2fa096cbfb
parent 43 72396548277c
child 45 863223ea6961
equal deleted inserted replaced
43:72396548277c 44:aa2fa096cbfb
    32 #include <glxmedia.h>
    32 #include <glxmedia.h>
    33 #include <glxerrormanager.h>
    33 #include <glxerrormanager.h>
    34 #include <glxattributecontext.h>
    34 #include <glxattributecontext.h>
    35 #include <glxuistd.h>
    35 #include <glxuistd.h>
    36 #include <glxlistdefs.h>
    36 #include <glxlistdefs.h>
    37 #include <hal.h>
       
    38 #include <hal_data.h>
       
    39 #include <glxmediaid.h>
    37 #include <glxmediaid.h>
    40 #include <caf/caferr.h>
    38 #include <caf/caferr.h>
    41 //internal includes 
    39 //internal includes 
    42 #include "glxmlwrapper_p.h"
    40 #include "glxmlwrapper_p.h"
    43 #include "glxmlgenericobserver.h"
    41 #include "glxmlgenericobserver.h"
    86 // ---------------------------------------------------------------------------
    84 // ---------------------------------------------------------------------------
    87 // C++ default constructor can NOT contain any code, that
    85 // C++ default constructor can NOT contain any code, that
    88 // might leave.
    86 // might leave.
    89 // ---------------------------------------------------------------------------
    87 // ---------------------------------------------------------------------------
    90 //
    88 //
    91 GlxMLWrapperPrivate::GlxMLWrapperPrivate(GlxMLWrapper* aMLWrapper): iMLWrapper(aMLWrapper),
    89 GlxMLWrapperPrivate::GlxMLWrapperPrivate(GlxMLWrapper* aMLWrapper)
    92 								iGridContextActivated(EFalse), iLsFsContextActivated(EFalse),
    90     : iMLWrapper(aMLWrapper),
    93 								iPtFsContextActivated(EFalse), iPtListContextActivated(EFalse),
    91       iGridContextActivated(EFalse), 
    94 								iSelectionListContextActivated(EFalse)
    92       iLsFsContextActivated(EFalse),
    95     {
    93       iPtFsContextActivated(EFalse), 
       
    94       iPtListContextActivated(EFalse),
       
    95       iSelectionListContextActivated(EFalse),
       
    96 	  iDetailsContextActivated(EFalse)
       
    97 {
    96     TRACER("GlxMLWrapperPrivate::GlxMLWrapperPrivate");
    98     TRACER("GlxMLWrapperPrivate::GlxMLWrapperPrivate");
    97 	iGridThumbnailContext = NULL;
    99 	iGridThumbnailContext = NULL;
    98 	iPtFsThumbnailContext = NULL;
   100 	iPtFsThumbnailContext = NULL;
    99 	iLsFsThumbnailContext = NULL;
   101 	iLsFsThumbnailContext = NULL;
   100 	iTitleAttributeContext = NULL;
   102 	iTitleAttributeContext = NULL;
   101 	iSubtitleAttributeContext = NULL;
   103 	iSubtitleAttributeContext = NULL;
   102     iListThumbnailContext = NULL;
   104     iListThumbnailContext = NULL;
   103     iFocusGridThumbnailContext = NULL;
   105     iFocusGridThumbnailContext = NULL;
   104     iFocusFsThumbnailContext = NULL;
   106     iFocusFsThumbnailContext = NULL;
   105     iFilmStripThumbnailContext = NULL;
       
   106     iFavouriteContext = NULL;
   107     iFavouriteContext = NULL;
   107     iTitleFetcher = NULL;
   108     iTitleFetcher = NULL;
   108     iViewTitle = QString();
   109     iViewTitle = QString();
   109     }
   110     }
   110 
   111 
   161 	TInt err = KErrNone;
   162 	TInt err = KErrNone;
   162 	if(aContextMode <= GlxContextPtFs) 
   163 	if(aContextMode <= GlxContextPtFs) 
   163 		{  
   164 		{  
   164 		TRAP(err, SetThumbnailContextL(aContextMode) ); //todo add a trap here
   165 		TRAP(err, SetThumbnailContextL(aContextMode) ); //todo add a trap here
   165 		}
   166 		}
   166 	else if(aContextMode == GlxContextFavorite)
   167     else if(aContextMode == GlxContextFavorite)
       
   168         {
       
   169         TRAP(err,SetFavouriteContextL());
       
   170         }
       
   171 	else if(aContextMode == GlxContextComment)
   167 	    {
   172 	    {
   168 	    TRAP(err,SetFavouriteContextL());
   173 	    TRAP(err,SetDescontextL());
   169 	    }
   174 	    }
   170 	else
   175 	else
   171 		{
   176 		{
   172 		TRAP(err, SetListContextL(aContextMode) );
   177 		TRAP(err, SetListContextL(aContextMode) );
   173 		}
   178 		}
   174 	
   179 	
   175 	GLX_LOG_INFO1("GlxMLWrapperPrivate::SetContextMode error %d", err);
   180 	GLX_LOG_INFO1("GlxMLWrapperPrivate::SetContextMode error %d", err);
   176 	iContextMode = aContextMode;
   181 	iContextMode = aContextMode;
   177 	}
   182 	}
   178 
   183 
       
   184 // ---------------------------------------------------------------------------
       
   185 // RemoveContextMode
       
   186 // ---------------------------------------------------------------------------
       
   187 //
       
   188 void GlxMLWrapperPrivate::RemoveContextMode(GlxContextMode aContextMode)
       
   189 {
       
   190   if(aContextMode == GlxContextComment) 
       
   191       {
       
   192        RemoveDescContext();
       
   193       }
       
   194 }
   179 // ---------------------------------------------------------------------------
   195 // ---------------------------------------------------------------------------
   180 // SetFavouriteContextL
   196 // SetFavouriteContextL
   181 // ---------------------------------------------------------------------------
   197 // ---------------------------------------------------------------------------
   182 //
   198 //
   183 void GlxMLWrapperPrivate::SetFavouriteContextL()
   199 void GlxMLWrapperPrivate::SetFavouriteContextL()
   277             RemoveLsFsContext();
   293             RemoveLsFsContext();
   278         }
   294         }
   279     }
   295     }
   280 	
   296 	
   281 	if(aContextMode == GlxContextLsFs && !iLsFsContextActivated) {
   297 	if(aContextMode == GlxContextLsFs && !iLsFsContextActivated) {
   282 		if(iGridContextActivated) {
   298 	    if(!iGridContextActivated) {
   283             RemoveGridContext();
   299 	        CreateGridContextL();
   284 		}
   300 	    }
   285 		if(iPtFsContextActivated) {
   301 		if(iPtFsContextActivated) {
   286 			RemovePtFsContext();
   302 			RemovePtFsContext();
   287 		}
   303 		}
   288 		CreateLsFsContextL();
   304 		CreateLsFsContextL();
   289 	}
   305 	}
   290 	
   306 	
   291 	if(aContextMode == GlxContextPtFs && !iPtFsContextActivated) {
   307 	if(aContextMode == GlxContextPtFs && !iPtFsContextActivated) {
   292 		if(iGridContextActivated) {
   308         if(!iGridContextActivated) {
   293             RemoveGridContext();
   309             CreateGridContextL();
   294 		}
   310         }
   295 		if(iLsFsContextActivated) {
   311 		if(iLsFsContextActivated) {
   296 			RemoveLsFsContext();
   312 			RemoveLsFsContext();
   297 		}
   313 		}
   298 		CreatePtFsContextL();
   314 		CreatePtFsContextL();
   299 	}
   315 	}
   356             iFocusGridThumbnailContext = CGlxDefaultThumbnailContext::NewL(); // set the thumbnail context for Focus Grid
   372             iFocusGridThumbnailContext = CGlxDefaultThumbnailContext::NewL(); // set the thumbnail context for Focus Grid
   357             iFocusGridThumbnailContext->SetRangeOffsets(0,0);
   373             iFocusGridThumbnailContext->SetRangeOffsets(0,0);
   358             iFocusGridThumbnailContext->SetDefaultSpec( KGridTNWIdth, KGridTNHeight );  //todo get these image sizes from  the layout.
   374             iFocusGridThumbnailContext->SetDefaultSpec( KGridTNWIdth, KGridTNHeight );  //todo get these image sizes from  the layout.
   359             }
   375             }
   360 
   376 
   361         if(!iFilmStripThumbnailContext)
       
   362             {
       
   363             iFilmStripThumbnailContext = CGlxThumbnailContext::NewL( &iBlockyIteratorForFilmStrip ); // set the thumbnail context for Focus Grid
       
   364             iFilmStripThumbnailContext->SetDefaultSpec( KGridTNWIdth, KGridTNHeight );  //todo get these image sizes from  the layout.
       
   365             }
       
   366 
       
   367         // show static items if required
   377         // show static items if required
   368         iMediaList->SetStaticItemsEnabled(EFalse);
   378         iMediaList->SetStaticItemsEnabled(EFalse);
   369         iMediaList->AddContextL(iFocusFsThumbnailContext, 8 );      // Temp will change this number  
   379         iMediaList->AddContextL(iFocusFsThumbnailContext, KGlxFetchContextPriorityNormal );      // Temp will change this number  
   370         iMediaList->AddContextL(iFocusGridThumbnailContext, 9 );    // Temp will change this number
   380         iMediaList->AddContextL(iFocusGridThumbnailContext, KGlxFetchContextPriorityNormal );    // Temp will change this number
   371         iMediaList->AddContextL(iFilmStripThumbnailContext, 7 );    // Temp will change this number 
   381         iMediaList->AddContextL(iLsFsThumbnailContext, KGlxFetchContextPriorityNormal );
   372         iMediaList->AddContextL(iLsFsThumbnailContext, KGlxFetchContextPriorityGridViewFullscreenVisibleThumbnail );
       
   373         iLsFsContextActivated = ETrue;
   382         iLsFsContextActivated = ETrue;
   374         }
   383         }
   375     }
   384     }
   376 
   385 
   377 // ---------------------------------------------------------------------------
   386 // ---------------------------------------------------------------------------
   403             iFocusGridThumbnailContext = CGlxDefaultThumbnailContext::NewL(); // set the thumbnail context for Focus Grid
   412             iFocusGridThumbnailContext = CGlxDefaultThumbnailContext::NewL(); // set the thumbnail context for Focus Grid
   404             iFocusGridThumbnailContext->SetRangeOffsets(0,0);
   413             iFocusGridThumbnailContext->SetRangeOffsets(0,0);
   405             iFocusGridThumbnailContext->SetDefaultSpec( KGridTNWIdth, KGridTNHeight );  //todo get these image sizes from  the layout.
   414             iFocusGridThumbnailContext->SetDefaultSpec( KGridTNWIdth, KGridTNHeight );  //todo get these image sizes from  the layout.
   406             }
   415             }
   407 
   416 
   408         if(!iFilmStripThumbnailContext)
       
   409             {
       
   410             iFilmStripThumbnailContext = CGlxThumbnailContext::NewL( &iBlockyIteratorForFilmStrip ); // set the thumbnail context for Focus Grid
       
   411             iFilmStripThumbnailContext->SetDefaultSpec( KGridTNPTWIdth, KGridTNPTHeight );  //todo get these image sizes from  the layout.
       
   412             }
       
   413 
       
   414         // show static items if required
   417         // show static items if required
   415         iMediaList->SetStaticItemsEnabled(EFalse);
   418         iMediaList->SetStaticItemsEnabled(EFalse);
   416         iMediaList->AddContextL(iFocusFsThumbnailContext, 8 );      // Temp will change this number  
   419         iMediaList->AddContextL(iFocusFsThumbnailContext, KGlxFetchContextPriorityNormal );      // Temp will change this number  
   417         iMediaList->AddContextL(iFocusGridThumbnailContext, 9 );    // Temp will change this number  
   420         iMediaList->AddContextL(iFocusGridThumbnailContext, KGlxFetchContextPriorityNormal );    // Temp will change this number  
   418         iMediaList->AddContextL(iFilmStripThumbnailContext, 7 );    // Temp will change this number 
   421         iMediaList->AddContextL(iPtFsThumbnailContext, KGlxFetchContextPriorityNormal );
   419         iMediaList->AddContextL(iPtFsThumbnailContext, KGlxFetchContextPriorityGridViewFullscreenVisibleThumbnail );
       
   420         iPtFsContextActivated = ETrue;
   422         iPtFsContextActivated = ETrue;
   421         }
   423         }
   422     }
   424     }
   423 
   425 
   424 // ---------------------------------------------------------------------------
   426 // ---------------------------------------------------------------------------
   461 		    {
   463 		    {
   462             iMediaList->RemoveContext(iFocusGridThumbnailContext);
   464             iMediaList->RemoveContext(iFocusGridThumbnailContext);
   463             delete iFocusGridThumbnailContext;
   465             delete iFocusGridThumbnailContext;
   464             iFocusGridThumbnailContext = NULL;
   466             iFocusGridThumbnailContext = NULL;
   465 		    }
   467 		    }
   466 		if(iFilmStripThumbnailContext)
       
   467 		    {
       
   468 		    iMediaList->RemoveContext(iFilmStripThumbnailContext);
       
   469 		    delete iFilmStripThumbnailContext;
       
   470 		    iFilmStripThumbnailContext = NULL;
       
   471 		    }		    
       
   472 	    
   468 	    
   473 		iLsFsContextActivated = EFalse;
   469 		iLsFsContextActivated = EFalse;
   474 		}
   470 		}
   475 	}
   471 	}
   476 
   472 
   496         if(iFocusGridThumbnailContext)
   492         if(iFocusGridThumbnailContext)
   497             {
   493             {
   498             iMediaList->RemoveContext(iFocusGridThumbnailContext);
   494             iMediaList->RemoveContext(iFocusGridThumbnailContext);
   499             delete iFocusGridThumbnailContext;
   495             delete iFocusGridThumbnailContext;
   500             iFocusGridThumbnailContext = NULL;
   496             iFocusGridThumbnailContext = NULL;
   501             }
       
   502         if(iFilmStripThumbnailContext)
       
   503             {
       
   504             iMediaList->RemoveContext(iFilmStripThumbnailContext);
       
   505             delete iFilmStripThumbnailContext;
       
   506             iFilmStripThumbnailContext = NULL;
       
   507             }
   497             }
   508 	        
   498 	        
   509 		iPtFsContextActivated = EFalse;
   499 		iPtFsContextActivated = EFalse;
   510 		}
   500 		}
   511 	}
   501 	}
   798     QString albumSubTitle =  QString::fromUtf16(subTitle.Ptr(), subTitle.Length());
   788     QString albumSubTitle =  QString::fromUtf16(subTitle.Ptr(), subTitle.Length());
   799 	return albumSubTitle;
   789 	return albumSubTitle;
   800 }
   790 }
   801 
   791 
   802 // ---------------------------------------------------------------------------
   792 // ---------------------------------------------------------------------------
       
   793 //  RetrieveListDesc
       
   794 // ---------------------------------------------------------------------------
       
   795 //
       
   796 QString GlxMLWrapperPrivate::RetrieveListDesc(int aItemIndex)
       
   797 {
       
   798     const TGlxMedia& item = iMediaList->Item( aItemIndex );
       
   799     const TDesC &commentstring = item.Comment();
       
   800     QString descstring =  QString::fromUtf16(commentstring.Ptr(), commentstring.Length());
       
   801 	return  descstring;
       
   802 }
       
   803 
       
   804 // ---------------------------------------------------------------------------
   803 //  Retrieve number of image contained by album list
   805 //  Retrieve number of image contained by album list
   804 // ---------------------------------------------------------------------------
   806 // ---------------------------------------------------------------------------
   805 //
   807 //
   806 int GlxMLWrapperPrivate::RetrieveListItemCount(int aItemIndex)
   808 int GlxMLWrapperPrivate::RetrieveListItemCount(int aItemIndex)
   807 {
   809 {
   862     QSize itemSize(size.iWidth,size.iHeight);
   864     QSize itemSize(size.iWidth,size.iHeight);
   863 	return itemSize;
   865 	return itemSize;
   864  }
   866  }
   865 
   867 
   866 // ---------------------------------------------------------------------------
   868 // ---------------------------------------------------------------------------
       
   869 //  RetrieveItemSize
       
   870 // ---------------------------------------------------------------------------
       
   871 //
       
   872 int GlxMLWrapperPrivate::RetrieveItemSize(int aItemIndex)
       
   873 {
       
   874     const TGlxMedia& item = iMediaList->Item( aItemIndex );
       
   875     int itemSize ;
       
   876     item.GetSize(itemSize);
       
   877     return itemSize;
       
   878  }
       
   879 
       
   880 // ---------------------------------------------------------------------------
   867 //  RetrieveItemDate
   881 //  RetrieveItemDate
   868 // ---------------------------------------------------------------------------
   882 // ---------------------------------------------------------------------------
   869 //
   883 //
   870 QDate GlxMLWrapperPrivate::RetrieveItemDate(int index)
   884 QDate GlxMLWrapperPrivate::RetrieveItemDate(int index)
   871     {
   885     {
   880         TDateTime dateTime = dateValue.DateTime();
   894         TDateTime dateTime = dateValue.DateTime();
   881         date = QDate(dateTime.Year(),TInt(dateTime.Month()+1),(dateTime.Day()+1));
   895         date = QDate(dateTime.Year(),TInt(dateTime.Month()+1),(dateTime.Day()+1));
   882         }
   896         }
   883      return date;
   897      return date;
   884     }
   898     }
       
   899 	
       
   900 // ---------------------------------------------------------------------------
       
   901 //  RetrieveItemTime
       
   902 // ---------------------------------------------------------------------------
       
   903 //
       
   904 QTime GlxMLWrapperPrivate::RetrieveItemTime(int index)
       
   905     {
       
   906     GLX_LOG_INFO1("GlxMLWrapperPrivate::RetrieveItemTime %d",index);
       
   907     const TGlxMedia& item = iMediaList->Item( index );
       
   908     TTime TimeValue;
       
   909     QTime time = QTime();
       
   910     TBool returnValue =item.GetDate(TimeValue);
       
   911     
       
   912     if(returnValue)
       
   913         {
       
   914         GLX_LOG_INFO1("GlxMLWrapperPrivate::RetrieveItemDate %d",returnValue);
       
   915         TDateTime dateTime = TimeValue.DateTime();
       
   916         time = QTime(dateTime.Hour(),dateTime.Minute());
       
   917         }
       
   918      return time;
       
   919     }
       
   920 
       
   921 
   885 
   922 
   886 // ---------------------------------------------------------------------------
   923 // ---------------------------------------------------------------------------
   887 //  RetrieveFsBitmap
   924 //  RetrieveFsBitmap
   888 // ---------------------------------------------------------------------------
   925 // ---------------------------------------------------------------------------
   889 //
   926 //
   995 	    CheckPtFsTBAttribute(aItemIndex, aAttributes);
  1032 	    CheckPtFsTBAttribute(aItemIndex, aAttributes);
   996 	if ( iLsFsContextActivated )
  1033 	if ( iLsFsContextActivated )
   997 	    CheckLsFsTBAttribute(aItemIndex, aAttributes);
  1034 	    CheckLsFsTBAttribute(aItemIndex, aAttributes);
   998 	if (iPtListContextActivated || iSelectionListContextActivated)
  1035 	if (iPtListContextActivated || iSelectionListContextActivated)
   999 	    CheckListAttributes(aItemIndex, aAttributes);
  1036 	    CheckListAttributes(aItemIndex, aAttributes);
  1000 	// }
  1037  	if( iDetailsContextActivated && aItemIndex == iMediaList->FocusIndex() )
       
  1038  	   CheckDetailsAttributes(aItemIndex, aAttributes);
       
  1039 	
  1001 	}
  1040 	}
  1002 // ---------------------------------------------------------------------------
  1041 // ---------------------------------------------------------------------------
  1003 // CheckGridTBAttribute
  1042 // CheckGridTBAttribute
  1004 // ---------------------------------------------------------------------------
  1043 // ---------------------------------------------------------------------------
  1005 //
  1044 //
  1126 			searchStatus = KTBAttributeUnavailable;
  1165 			searchStatus = KTBAttributeUnavailable;
  1127 			}
  1166 			}
  1128 		return searchStatus;	
  1167 		return searchStatus;	
  1129 
  1168 
  1130 	 }    
  1169 	 }    
       
  1170 
       
  1171 // ---------------------------------------------------------------------------
       
  1172 // CheckDetailsAttributes
       
  1173 // ---------------------------------------------------------------------------
       
  1174 //
       
  1175 void GlxMLWrapperPrivate::CheckDetailsAttributes(TInt aItemIndex, const RArray<TMPXAttribute>& aAttributes)
       
  1176 {
       
  1177     qDebug("GlxMLWrapperPrivate::CheckDetailsAttributes");
       
  1178     TBool attribPresent = EFalse;
       
  1179     TMPXAttribute titleAttrib(KMPXMediaGeneralComment);
       
  1180     TIdentityRelation< TMPXAttribute > match ( &TMPXAttribute::Match );
       
  1181 
       
  1182     const TGlxMedia& item = iMediaList->Item(aItemIndex);
       
  1183 
       
  1184     if (KErrNotFound != aAttributes.Find(titleAttrib, match))
       
  1185         {
       
  1186         qDebug("GlxMLWrapperPrivate::CheckDetailsAttributes TRUE");
       
  1187         attribPresent = ETrue;
       
  1188         iMLWrapper->handleDetailsItemAvailable(aItemIndex);
       
  1189         GLX_LOG_INFO1("### GlxMLWrapperPrivate::CheckDetailsAttributes title present %d",aItemIndex);
       
  1190         }     
       
  1191 }
       
  1192 
  1131 // ---------------------------------------------------------------------------
  1193 // ---------------------------------------------------------------------------
  1132 // GetItemCount
  1194 // GetItemCount
  1133 // ---------------------------------------------------------------------------
  1195 // ---------------------------------------------------------------------------
  1134 //
  1196 //
  1135 void GlxMLWrapperPrivate::HandleFocusChangedL( NGlxListDefs::TFocusChangeType aType, 
  1197 void GlxMLWrapperPrivate::HandleFocusChangedL( NGlxListDefs::TFocusChangeType aType, 
  1317 bool GlxMLWrapperPrivate::IsPopulated()
  1379 bool GlxMLWrapperPrivate::IsPopulated()
  1318     {
  1380     {
  1319     return iMediaList->IsPopulated();
  1381     return iMediaList->IsPopulated();
  1320     }
  1382     }
  1321 
  1383 
  1322 	 
  1384 // ---------------------------------------------------------------------------
       
  1385 // SetDescontextL
       
  1386 // ---------------------------------------------------------------------------
       
  1387 //
       
  1388 void GlxMLWrapperPrivate::SetDescontextL()
       
  1389      {
       
  1390      iDescContext = CGlxDefaultAttributeContext::NewL();
       
  1391      iDescContext->AddAttributeL( KMPXMediaGeneralComment );
       
  1392      iMediaList->AddContextL( iDescContext, KGlxFetchContextPriorityLow );
       
  1393      iDetailsContextActivated = ETrue;     
       
  1394      }
       
  1395 	
       
  1396 // ---------------------------------------------------------------------------
       
  1397 // RemoveDescContext
       
  1398 // ---------------------------------------------------------------------------
       
  1399 //
       
  1400 void GlxMLWrapperPrivate::RemoveDescContext()
       
  1401     {
       
  1402     if(iDescContext )
       
  1403         {
       
  1404         iMediaList->RemoveContext(iDescContext);
       
  1405         delete iDescContext;
       
  1406         iDescContext = NULL;  
       
  1407         iDetailsContextActivated = EFalse;   
       
  1408         }
       
  1409     }