photosgallery/viewframework/views/listview/src/glxlistviewimp.cpp
changeset 2 7d9067c6fcb1
parent 1 9ba538e329bd
child 3 9a9c174934f5
equal deleted inserted replaced
1:9ba538e329bd 2:7d9067c6fcb1
    40 #include <glxlistviewplugin.rsg>
    40 #include <glxlistviewplugin.rsg>
    41 #include <glxmedialistmulmodelprovider.h>	//CGlxMediaListMulModelProvider
    41 #include <glxmedialistmulmodelprovider.h>	//CGlxMediaListMulModelProvider
    42 #include <aknViewAppUi.h>
    42 #include <aknViewAppUi.h>
    43 #include <StringLoader.h>					//StringLoader		
    43 #include <StringLoader.h>					//StringLoader		
    44 #include <glxsetappstate.h>
    44 #include <glxsetappstate.h>
    45 
    45 #include <glxthumbnailattributeinfo.h>
    46 const TInt KListDataWindowSize(10);
    46 
       
    47 const TInt KListDataWindowSize(25);
       
    48 const TInt KNoOfPages(2);
       
    49 const TInt KBufferTresholdSize(6);
       
    50 const TInt KRecreateListSize(5);
    47 
    51 
    48 // ======== MEMBER FUNCTIONS ========
    52 // ======== MEMBER FUNCTIONS ========
    49 
    53 
    50 // ---------------------------------------------------------------------------
    54 // ---------------------------------------------------------------------------
    51 // C++ default constructor can NOT contain any code that might leave.
    55 // C++ default constructor can NOT contain any code that might leave.
   110         toolbar->DisableToolbarL(ETrue);  
   114         toolbar->DisableToolbarL(ETrue);  
   111         }
   115         }
   112     
   116     
   113     //Register the view to recieve toolbar events. ViewBase handles the events    
   117     //Register the view to recieve toolbar events. ViewBase handles the events    
   114     SetToolbarObserver(this);
   118     SetToolbarObserver(this);
       
   119     
       
   120     iBackwardNavigation = EFalse;
   115     }
   121     }
   116 
   122 
   117 // ---------------------------------------------------------------------------
   123 // ---------------------------------------------------------------------------
   118 // Destructor
   124 // Destructor
   119 // ---------------------------------------------------------------------------
   125 // ---------------------------------------------------------------------------
   196 	iMediaList->AddMediaListObserverL(this);
   202 	iMediaList->AddMediaListObserverL(this);
   197     TRect apRect = iEikonEnv->EikAppUi()->ApplicationRect();
   203     TRect apRect = iEikonEnv->EikAppUi()->ApplicationRect();
   198     iBgContext = CAknsBasicBackgroundControlContext::NewL( 
   204     iBgContext = CAknsBasicBackgroundControlContext::NewL( 
   199             KAknsIIDQsnBgScreen,apRect,ETrue);
   205             KAknsIIDQsnBgScreen,apRect,ETrue);
   200     
   206     
       
   207     if(iUiUtility->ViewNavigationDirection() == EGlxNavigationBackwards )
       
   208         {
       
   209         iBackwardNavigation = ETrue;
       
   210         }
       
   211 
   201     iPreviewTNBinding = CGlxPreviewThumbnailBinding::NewL(*this);
   212     iPreviewTNBinding = CGlxPreviewThumbnailBinding::NewL(*this);
   202     CreateListL();
   213     CreateListL();
   203     if (iPreviewTNBinding)
   214     if (iPreviewTNBinding)
   204         {
   215         {
   205         iPopulateListTNs  = ETrue;
   216         iPopulateListTNs  = ETrue;
   206         CMPXCollectionPath* path = iMediaList->PathLC( 
   217         CMPXCollectionPath* path = iMediaList->PathLC( 
   207                 NGlxListDefs::EPathFocusOrSelection );
   218                 NGlxListDefs::EPathFocusOrSelection );
   208         iPreviewTNBinding->HandleItemChangedL(*path, iPopulateListTNs);
   219         iPreviewTNBinding->HandleItemChangedL(*path, 
       
   220                 iPopulateListTNs, iBackwardNavigation);
   209         CleanupStack::PopAndDestroy( path );        
   221         CleanupStack::PopAndDestroy( path );        
   210         }
   222         }
   211 
   223 
   212     }
   224     }
   213 
   225 
   326     	}
   338     	}
   327     
   339     
   328     return CAknView::MopSupplyObject(aId);
   340     return CAknView::MopSupplyObject(aId);
   329 	}
   341 	}
   330 
   342 
   331 void CGlxListViewImp::Request(TInt /*aRequestStart*/, TInt /*aRequestEnd*/, 
   343 void CGlxListViewImp::Request(TInt aRequestStart, TInt aRequestEnd, 
   332         THgScrollDirection /*aDirection*/)
   344         THgScrollDirection /*aDirection*/)
   333     {
   345     {
   334     TRACER("CGlxListViewImp::Request");
   346     TRACER("CGlxListViewImp::Request");
   335     }
   347     //Doing this to avoid codescanner warning.
       
   348     TRAP_IGNORE(RequestL(aRequestStart, aRequestEnd));    
       
   349     }
       
   350 
       
   351 // ---------------------------------------------------------------------------
       
   352 // RequestL
       
   353 // ---------------------------------------------------------------------------
       
   354 //
       
   355 void CGlxListViewImp::RequestL(TInt aRequestStart, TInt aRequestEnd)
       
   356     {
       
   357     TRACER("CGlxListViewImp::RequestL()");
       
   358     TInt mediaCount = iMediaList->Count();
       
   359     GLX_LOG_INFO1("CGlxListViewImp::RequestL - mediaCount(%d)", mediaCount);
       
   360     if(mediaCount<=0)
       
   361         {
       
   362         return;
       
   363         }
       
   364     
       
   365     TInt visIndex = iList->FirstIndexOnScreen();
       
   366     aRequestStart = (aRequestStart < 0 ? 0 : aRequestStart) ;
       
   367     aRequestEnd = (aRequestEnd >= mediaCount ? (mediaCount-1) : aRequestEnd);
       
   368     GLX_LOG_INFO3("CGlxListViewImp::RequestL - aRequestStart(%d), "
       
   369        "aRequestEnd(%d), visIndex(%d)", aRequestStart, aRequestEnd, visIndex);
       
   370 
       
   371     if (visIndex >= mediaCount )
       
   372         {
       
   373         visIndex = mediaCount-1;
       
   374         }
       
   375     if (visIndex < 0 || mediaCount <= 0)
       
   376         {
       
   377         visIndex = 0;
       
   378         }
       
   379 
       
   380     for (TInt i=aRequestStart; i<= aRequestEnd; i++)
       
   381         {
       
   382         const TGlxMedia& item = iMediaList->Item(i);
       
   383         iList->ItemL(i).SetTitleL(item.Title());
       
   384         iList->ItemL(i).SetTextL(item.SubTitle());
       
   385         }
       
   386     
       
   387     iList->RefreshScreen(visIndex);
       
   388     
       
   389     if ( visIndex != iLastFocusedIndex && !iPopulateListTNs)
       
   390         {
       
   391         GLX_LOG_INFO1("CGlxListViewImp::RequestL - SetFocusL()"
       
   392                 " iPopulateListTNs(%d)", iPopulateListTNs);      
       
   393         GLX_LOG_INFO1("CGlxListViewImp::RequestL - SetFocusL()"
       
   394                 " visIndex(%d)", visIndex);
       
   395         iPopulateListTNs = ETrue;
       
   396         iStartIndex = KErrNotFound;
       
   397         iMediaList->SetFocusL(NGlxListDefs::EAbsolute, visIndex);
       
   398         }
       
   399     }
       
   400 
   336 
   401 
   337 void CGlxListViewImp::Release(TInt /*aBufferStart*/, TInt /*aBufferEnd*/)
   402 void CGlxListViewImp::Release(TInt /*aBufferStart*/, TInt /*aBufferEnd*/)
   338     {
   403     {
   339     TRACER("CGlxListViewImp::Release");
   404     TRACER("CGlxListViewImp::Release");
   340     }
   405     }
   369 
   434 
   370 void CGlxListViewImp::PreviewTNReadyL(CFbsBitmap* aBitmap, CFbsBitmap* 
   435 void CGlxListViewImp::PreviewTNReadyL(CFbsBitmap* aBitmap, CFbsBitmap* 
   371         /*aMask*/, TInt /*aIndex*/)
   436         /*aMask*/, TInt /*aIndex*/)
   372     {
   437     {
   373     TRACER("CGlxListViewImp::PreviewTNReadyL");
   438     TRACER("CGlxListViewImp::PreviewTNReadyL");
   374     
   439 
       
   440     iPreviewTNBinding->StopTimer();
       
   441 
   375 	TInt focusIndex = iMediaList->FocusIndex();
   442 	TInt focusIndex = iMediaList->FocusIndex();
   376     TInt mediaCount = iMediaList->Count();
   443     TInt mediaCount = iMediaList->Count();
   377     
   444     
   378     if (aBitmap)
   445     if (aBitmap)
   379 	    {	
   446 	    {	
   446                  * The callback is not given because the setfocus index is same as the focused index
   513                  * The callback is not given because the setfocus index is same as the focused index
   447                  * in medialist. 
   514                  * in medialist. 
   448                  */
   515                  */
   449                 if(count==1)
   516                 if(count==1)
   450                     {                        
   517                     {                        
   451                     iPreviewTNBinding->StartTimer( iPopulateListTNs );
   518                     CMPXCollectionPath* path = iMediaList->PathLC( 
       
   519                             NGlxListDefs::EPathFocusOrSelection );
       
   520                     iPreviewTNBinding->HandleItemChangedL(*path, 
       
   521                             iPopulateListTNs, iBackwardNavigation);
       
   522                     CleanupStack::PopAndDestroy( path );
   452                     }
   523                     }
   453                 }
   524                 }
   454 			}
   525 			}
   455 		}
   526 		}
   456     }
   527     }
   484 
   555 
   485 	    iList->SetMopParent(this);
   556 	    iList->SetMopParent(this);
   486 	    
   557 	    
   487 		iList->SetSelectionObserver(*this);
   558 		iList->SetSelectionObserver(*this);
   488 		
   559 		
       
   560 	    // Enable Buffer support
       
   561 		iList->EnableScrollBufferL(*this, (KNoOfPages * KBufferTresholdSize),
       
   562 	            KBufferTresholdSize);
       
   563 		
   489         if (iUiUtility->ViewNavigationDirection() == EGlxNavigationBackwards)
   564         if (iUiUtility->ViewNavigationDirection() == EGlxNavigationBackwards)
   490             {
   565             {
   491             GLX_DEBUG1("CGlxListViewImp::CreateListL() - SetEmptyTextL()");			
   566             GLX_DEBUG1("CGlxListViewImp::CreateListL() - SetEmptyTextL()");			
   492             //set the text to be shown if the list is empty.
   567             //set the text to be shown if the list is empty.
   493             HBufC* emptyText = StringLoader::LoadLC(R_LIST_EMPTY_VIEW_TEXT); 
   568             HBufC* emptyText = StringLoader::LoadLC(R_LIST_EMPTY_VIEW_TEXT); 
   494             iList->SetEmptyTextL(*emptyText);
   569             iList->SetEmptyTextL(*emptyText);
   495             CleanupStack::PopAndDestroy(emptyText);
   570             CleanupStack::PopAndDestroy(emptyText);            
   496             iLastFocusedIndex = iMediaList->FocusIndex();
   571             iLastFocusedIndex = iList->FirstIndexOnScreen();            
   497             }		
   572             }		
   498         
   573         
   499 		//Fix for ESLM-7SAHPT::Clear Flag to Disable QWERTY search input in list view
   574 		//Fix for ESLM-7SAHPT::Clear Flag to Disable QWERTY search input in list view
   500 		iList->ClearFlags(CHgScroller::EHgScrollerSearchWithQWERTY ); 
   575 		iList->ClearFlags(CHgScroller::EHgScrollerSearchWithQWERTY ); 
   501 		
   576 		
   520 // ----------------------------------------------------------------------------
   595 // ----------------------------------------------------------------------------
   521 // HandleItemAddedL
   596 // HandleItemAddedL
   522 // ----------------------------------------------------------------------------
   597 // ----------------------------------------------------------------------------
   523 // 
   598 // 
   524 void CGlxListViewImp::HandleItemAddedL( TInt aStartIndex, TInt aEndIndex, 
   599 void CGlxListViewImp::HandleItemAddedL( TInt aStartIndex, TInt aEndIndex, 
   525      MGlxMediaList* /*aList*/ )
   600      MGlxMediaList* aList )
   526 	{
   601     {
   527 	TRACER("CGlxListViewImp::HandleItemAddedL");
   602     TRACER("CGlxListViewImp::HandleItemAddedL");
   528 	
   603     if (iList)
   529 	if (iList)
   604         {
   530 		{
   605         if ((aEndIndex - aStartIndex) >= KRecreateListSize)
   531 		for (TInt i = aStartIndex; i<= aEndIndex; i++)
   606             {
   532 			{
   607             iList->ResizeL(aList->Count());
   533 		   	const TGlxMedia& item = iMediaList->Item(i);
   608             }
   534 			iList->InsertItem(CHgItem::NewL(CHgItem::EHgItemFlagsNone,
   609         else
   535 			        NULL, item.Title(), item.SubTitle()), i);
   610             {
   536 			}
   611             for (TInt i = aStartIndex; i<= aEndIndex; i++)
   537 		
   612                 {
   538 		if(aStartIndex == aEndIndex )
   613                 const TGlxMedia& item = iMediaList->Item(i);
   539 		    {
   614                 iList->InsertItem(CHgItem::NewL(CHgItem::EHgItemFlagsNone,
   540 			iLastFocusedIndex = aStartIndex;
   615                         NULL, item.Title(), item.SubTitle()), i);
   541 	        iPopulateListTNs = EFalse;
   616                 }
   542 	        iMediaList->SetFocusL(NGlxListDefs::EAbsolute, iLastFocusedIndex);			
   617 
   543 		    }
   618             if(aStartIndex == aEndIndex )
   544 
   619                 {
   545 		iList->SetSelectedIndex(iLastFocusedIndex);	
   620                 iLastFocusedIndex = aStartIndex;
   546 		iList->RefreshScreen(iLastFocusedIndex);
   621                 iPopulateListTNs = EFalse;
   547 		}
   622                 iMediaList->SetFocusL(NGlxListDefs::EAbsolute, iLastFocusedIndex);			
   548 	}
   623                 }
       
   624 
       
   625             iList->SetSelectedIndex(iLastFocusedIndex);	
       
   626             iList->RefreshScreen(iLastFocusedIndex);
       
   627             }
       
   628         }
       
   629     }
   549 
   630 
   550 // ----------------------------------------------------------------------------
   631 // ----------------------------------------------------------------------------
   551 // HandleItemRemoved
   632 // HandleItemRemoved
   552 // ----------------------------------------------------------------------------
   633 // ----------------------------------------------------------------------------
   553 //	
   634 //	
   603 			{
   684 			{
   604 			iPopulateListTNs = ETrue;
   685 			iPopulateListTNs = ETrue;
   605 			iStartIndex = KErrNotFound;
   686 			iStartIndex = KErrNotFound;
   606 			CMPXCollectionPath* path = iMediaList->PathLC( 
   687 			CMPXCollectionPath* path = iMediaList->PathLC( 
   607 					NGlxListDefs::EPathFocusOrSelection );
   688 					NGlxListDefs::EPathFocusOrSelection );
   608 			iPreviewTNBinding->HandleItemChangedL(*path, iPopulateListTNs);
   689 	        iPreviewTNBinding->HandleItemChangedL(*path, 
       
   690 	                iPopulateListTNs, iBackwardNavigation);
   609 			CleanupStack::PopAndDestroy( path ); 		
   691 			CleanupStack::PopAndDestroy( path ); 		
   610 			}
   692 			}
   611     	}
   693     	}
   612 	}
   694 	}
   613 	
   695 	
   623 	 
   705 	 
   624 	if (iPreviewTNBinding)
   706 	if (iPreviewTNBinding)
   625 		{
   707 		{
   626 		CMPXCollectionPath* path = iMediaList->PathLC( 
   708 		CMPXCollectionPath* path = iMediaList->PathLC( 
   627 		        NGlxListDefs::EPathFocusOrSelection );
   709 		        NGlxListDefs::EPathFocusOrSelection );
   628 		iPreviewTNBinding->HandleItemChangedL(*path, iPopulateListTNs);
   710         iPreviewTNBinding->HandleItemChangedL(*path, 
       
   711                 iPopulateListTNs, iBackwardNavigation);
   629 		CleanupStack::PopAndDestroy( path );		
   712 		CleanupStack::PopAndDestroy( path );		
   630 		}
   713 		}
   631 	}
   714 	}
   632 
   715 
   633 // ----------------------------------------------------------------------------
   716 // ----------------------------------------------------------------------------