mpxplugins/viewplugins/views/collectionviewhg/inc/mpxcollectionviewhgcontainer.h
branchRCL_3
changeset 53 3de6c4cf6b67
child 66 1f1dad4af8f8
equal deleted inserted replaced
52:14979e23cb5e 53:3de6c4cf6b67
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  MPX Collection view container implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CMPXCOLLECTIONVIEWHGCONTAINER_H
       
    21 #define CMPXCOLLECTIONVIEWHGCONTAINER_H
       
    22 
       
    23 
       
    24 // INCLUDES
       
    25 #include <coecntrl.h>
       
    26 
       
    27 #include <ganes/HgScrollBufferObserverIface.h>
       
    28 #include <ganes/HgSelectionObserverIface.h>
       
    29 #include <ganes/HgVgMediaWallObserverIface.h>
       
    30 #include <ganes/HgItem.h>
       
    31 #include <mpxcommonframeworkdefs.h> // TMPXItemId
       
    32 #include "mpxcollectionviewhgtnloader.h"
       
    33 #include "mpxcommonlistboxarrayobserver.h"
       
    34 #include "mpxcommonlistboxarraybase.h"
       
    35 
       
    36 // FORWARD DECLARATION
       
    37 class CAknContextPane;
       
    38 class CAknIconArray;
       
    39 class CAknsBasicBackgroundControlContext;
       
    40 class CEikMenuPane;
       
    41 class CHgScroller;
       
    42 class CHgScroller;
       
    43 class CHgVgMediaWall;
       
    44 class CMPXCollectionViewHgPlaylistHelper;
       
    45 class CMPXCommonUiHelper;
       
    46 class CMPXMediaArray;
       
    47 class MCoeControlObserver;
       
    48 class MEikCommandObserver;
       
    49 class MEikListBoxObserver;
       
    50 class MMPXCollectionUiHelper;
       
    51 class MMPXCollectionUtility;
       
    52 class MMPXPlaybackUtility;
       
    53 class MMpxCbaHandler;
       
    54 class TAknsItemID;
       
    55 class CAsyncOneShot;
       
    56 class MMPXSelectedAlbumHandler;
       
    57 
       
    58 // CLASS DECLARATION
       
    59 
       
    60 /**
       
    61  *  MPX Collection view container.
       
    62  *
       
    63  *  @lib mpxcollectionviewhg.lib
       
    64  *  @since S60 v5.0
       
    65  */
       
    66 NONSHARABLE_CLASS( CMPXCollectionViewHgContainer )
       
    67     : public CCoeControl
       
    68     , public MCoeControlObserver
       
    69     , public MMPXCommonListBoxArrayObserver
       
    70 	, public MHgScrollBufferObserver
       
    71 	, public MHgSelectionObserver
       
    72     , public MMPXCollectionFindObserver
       
    73     , public MHgVgMediaWallObserver
       
    74     , public MMpxTNLoaderObserver
       
    75     , public MCoeForegroundObserver
       
    76 	{
       
    77 public:
       
    78 
       
    79     /**
       
    80      * Two-phased constructor.
       
    81      *
       
    82      * @since 5.1
       
    83      * @param aView Command observer.
       
    84      * @param aObserver MEikListBoxObserver
       
    85      * @param aIsEmbedded ETrue to indicate that view is embedded
       
    86      * @return Pointer to newly created object.
       
    87      */
       
    88     static CMPXCollectionViewHgContainer* NewL(
       
    89         MEikCommandObserver* aView,
       
    90         MEikListBoxObserver* aObserver,
       
    91         MMPXSelectedAlbumHandler* aSelectedAlbumHandler,
       
    92         TBool aIsEmbedded );
       
    93 
       
    94     /**
       
    95      * Destructor.
       
    96      */
       
    97     virtual ~CMPXCollectionViewHgContainer();
       
    98 
       
    99     /**
       
   100      * Sets playback status with item id
       
   101      *
       
   102      * @param aId item id of the song
       
   103      * @param aStatus status of the song
       
   104      */
       
   105     void SetPlaybackStatusByIdL( TMPXItemId aId, TMPXPlaybackState aStatus, TInt aIndex = 0 );
       
   106 
       
   107     /**
       
   108      * Get current playback index
       
   109      *
       
   110      * @return Current playback index, KErrNotFound if nothing is playing
       
   111      */
       
   112     TInt PlaybackIndex();
       
   113 
       
   114     /**
       
   115      * Activates reorder mode
       
   116      *
       
   117      * @param aEnable ETrue to enable reorder mode, EFalse to disable
       
   118      */
       
   119     void ActivateReorderMode( TBool aEnable );
       
   120 
       
   121     /**
       
   122      * Set reorder mode
       
   123      *
       
   124      * @param aEnable ETrue to enable reorder mode, EFalse to disable reorder mode
       
   125      * @param aIndex current selected index
       
   126      */
       
   127     void SetReorderGrabbedMode( TBool aEnable, TInt aIndex = 0 );
       
   128 
       
   129     /**
       
   130      * Determines if it's currently in reorder mode
       
   131      *
       
   132      * @return ETrue if in reorder mode, EFalse otherwise
       
   133      */
       
   134     TBool IsInReorderMode();
       
   135 
       
   136     /**
       
   137      * Move current reorder index relatively
       
   138      *
       
   139      * @param aDirection +1 to move down, -1 to move up
       
   140      */
       
   141     void MoveReorderIndex( TInt aDirection );
       
   142 
       
   143     /**
       
   144      * Set current reorder index
       
   145      *
       
   146      * @param aIndex current reorder index
       
   147      */
       
   148     void SetReorderIndex( TInt aIndex );
       
   149 
       
   150     /**
       
   151      * Confirm reorder
       
   152      */
       
   153     void ConfirmReorderL();
       
   154 
       
   155     /**
       
   156      * Cancel reorder
       
   157      */
       
   158     void CancelReorder();
       
   159 
       
   160     /**
       
   161      * Gets original index of currently selected item in reorder mode
       
   162      */
       
   163     TInt GetOriginalIndex();
       
   164 
       
   165     /**
       
   166      * Update Titlepane icon to reorder image
       
   167      */
       
   168     void UpdateReorderTitleIconL();
       
   169 
       
   170     /**
       
   171      * Update titlepane to use original icon
       
   172      */
       
   173     void RestoreOriginalTitleIconL();
       
   174 
       
   175     /**
       
   176      * Content is ready
       
   177      */
       
   178     void ContentIsReady( TBool aReady );
       
   179 
       
   180     /**
       
   181      * Returns list box array, ownership not transfered
       
   182      *
       
   183      * @since 3.1
       
   184      * @return A pointer to the list box array
       
   185      */
       
   186     CMPXCommonListBoxArrayBase* ListBoxArray() const;
       
   187 
       
   188     /**
       
   189      * Return number of listbox items shown in the current listbox.
       
   190      *
       
   191      * @since 3.1
       
   192      * @return The number of items shown in the list box
       
   193      */
       
   194     TInt CurrentListItemCount() const;
       
   195 
       
   196     /**
       
   197      * Return total number of listbox items in the listbox.
       
   198      *
       
   199      * @since 3.1
       
   200      * @return Total items in the list box
       
   201      */
       
   202     TInt TotalListItemCount() const;
       
   203 
       
   204     /**
       
   205      * Gets top listbox item index (relative to the original listbox).
       
   206      * @return Top listbox item index
       
   207      *
       
   208      * @since 3.1
       
   209      */
       
   210     TInt TopLbxItemIndex() const;
       
   211     /**
       
   212      * Gets first listbox item index on screen(relative to the original listbox).
       
   213      * @return first listbox item index on screen
       
   214      *
       
   215      * 
       
   216      */
       
   217     TInt FirstIndexOnScreen() const;
       
   218 
       
   219     /**
       
   220      * Gets bottom listbox item index (relative to the original listbox).
       
   221      * @return Bottom listbox item index
       
   222      *
       
   223      * @since 3.1
       
   224      */
       
   225     TInt BottomLbxItemIndex() const;
       
   226 
       
   227     /**
       
   228      * Gets current listbox item index (relative to the original listbox).
       
   229      * @return Current listbox item index
       
   230      *
       
   231      * @since 3.1
       
   232      */
       
   233     TInt CurrentLbxItemIndex() const;
       
   234     
       
   235 	/*
       
   236      * Mark the grabbed item for reordering the playlist.
       
   237      */
       
   238     void MarkGrabedItemL( TInt aIndex ); 
       
   239 
       
   240     /**
       
   241      * Get current selected listbox items indices (relative to the original
       
   242      * listbox). Ownership not transferred.
       
   243      *
       
   244      * @since 3.1
       
   245      * @return Current listbox item indices
       
   246      */
       
   247     const CArrayFix<TInt>* CurrentSelectionIndicesL() const;
       
   248 
       
   249     /**
       
   250      * Sewt current selected listbox items indices
       
   251      *
       
   252      * @since 3.1
       
   253      * @param aIndices Array of selection indices, ownership not transfered
       
   254      */
       
   255     void SetCurrentSelectionIndicesL( CArrayFix<TInt>* aIndices ) const;
       
   256 
       
   257     /**
       
   258      * Set top listbox item index.
       
   259      *
       
   260      * @since 3.1
       
   261      * @param aIndex Actual listbox index.
       
   262      */
       
   263     void SetLbxTopItemIndex( TInt aIndex );
       
   264 
       
   265     /**
       
   266      * Set current listbox item index.
       
   267      *
       
   268      * @since 3.1
       
   269      * @param aIndex Actual listbox index.
       
   270      */
       
   271     void SetLbxCurrentItemIndex( TInt aIndex );
       
   272 
       
   273     /**
       
   274      * Set current listbox item index and highlight it.
       
   275      *
       
   276      * @since 3.1
       
   277      * @param aIndex Actual listbox index.
       
   278      */
       
   279     void SetLbxCurrentItemIndexAndDraw( TInt aIndex );
       
   280 
       
   281     /**
       
   282      * Clear listbox selection.
       
   283      *
       
   284      * @since 3.1
       
   285      */
       
   286     void ClearLbxSelection();
       
   287 
       
   288     /**
       
   289      * Sets list box backround text. This text is visible if the list box
       
   290      * has no items.
       
   291      *
       
   292      * @param aText The text for the empty list box background.
       
   293      * @since 3.2
       
   294      */
       
   295 	void SetLbxEmptyTextL( const TDesC& aText );
       
   296 
       
   297     /**
       
   298      * Draws list box item index
       
   299      *
       
   300      * @since 3.2
       
   301      */
       
   302     void DrawLbxItemL( TInt aIndex );
       
   303 
       
   304     /**
       
   305      * Set Find box's focus.
       
   306      *
       
   307      * @since 3.1
       
   308      * @param aFocus ETrue if set focus on FindBox. Otherwise, EFalse.
       
   309      */
       
   310     void SetFindBoxFocus( TBool aFocus );
       
   311 
       
   312     /**
       
   313      * Handle listbox item addition.
       
   314      *
       
   315      * @since 3.1
       
   316      */
       
   317     void HandleLbxItemAdditionL();
       
   318 
       
   319     /**
       
   320      * Handle listbox item addition, preserving the current display index.
       
   321      *
       
   322      * @since 3.1
       
   323      */
       
   324     void HandleLbxItemAdditionPreserveIndexL();
       
   325 
       
   326     /**
       
   327      * Handle listbox item removal.
       
   328      *
       
   329      * @since 3.1
       
   330      */
       
   331     void HandleLbxItemRemovalL();
       
   332 
       
   333     /**
       
   334      * Show/hide find box
       
   335      *
       
   336      * @since 3.1
       
   337      * @param aIsVisible ETrue to set findbox visible. Otherwise, EFalse
       
   338      */
       
   339     void SetFindBoxVisibilityL( TBool aIsVisible );
       
   340 
       
   341     /**
       
   342      * Determine find box visibility
       
   343      *
       
   344      * @since 3.1
       
   345      * @return ETrue if find box is currently visible, EFalse otherwise
       
   346      */
       
   347     TBool FindBoxVisibility();
       
   348 
       
   349     /**
       
   350      * Restore the PopupCBA of find box
       
   351      */
       
   352     void RestoreFindBoxPopupCBA();
       
   353 
       
   354     /**
       
   355      * Calculate the top index of the visible items
       
   356      *
       
   357      * @since 3.1
       
   358      * @param aBottomIndex the bottom index of the visible items
       
   359      * @return top index
       
   360      */
       
   361     TInt CalculateTopIndex( TInt aBottomIndex );
       
   362 
       
   363 
       
   364     /**
       
   365      * Enable/disable find box
       
   366      *
       
   367      * @since 3.1
       
   368      * @aEnable ETrue to enable find box, EFalse to disable
       
   369      */
       
   370     void EnableFindBox( TBool aEnable );
       
   371 
       
   372     /**
       
   373      * Enable/disable marking
       
   374      *
       
   375      * @since 3.1
       
   376      * @aEnable ETrue to enable marking, EFalse to disable
       
   377      */
       
   378     void EnableMarking( TBool aEnable );
       
   379 
       
   380     /**
       
   381      * Custom handling of commands for markable lists.
       
   382      */
       
   383     void HandleMarkableListProcessCommandL( TInt aCommand );
       
   384 
       
   385     /**
       
   386      * Custom handling of menu pane for markable lists
       
   387      */
       
   388     void HandleMarkableListDynInitMenuPane(
       
   389         TInt aResourceId,
       
   390         CEikMenuPane* aMenuPane );
       
   391 
       
   392 
       
   393 // from base class MMPXViewContainer
       
   394 
       
   395     /**
       
   396      * Handles key events.
       
   397      *
       
   398      * @param aKeyEvent The key event.
       
   399      * @param aType The type of key event.
       
   400      */
       
   401     TKeyResponse HandleKeyEventL(
       
   402         const TKeyEvent& aKeyEvent,
       
   403         TEventCode aType );
       
   404 
       
   405     /**
       
   406      * Handles the retrieval of the view container's help context.
       
   407      *
       
   408      * @param aContext The control's help context.
       
   409      */
       
   410     void HandleHelpContext( TCoeHelpContext& aContext ) const;
       
   411 
       
   412     /**
       
   413      * Returns the indicators for the specified item within the view container
       
   414      *
       
   415      * @param aIndex specified array index
       
   416      * @return Indicator icon indices
       
   417      */
       
   418     RArray<TInt> IndicatorsL( TInt aIndex );
       
   419 
       
   420     void SetCbaHandler( MMpxCbaHandler* aCbaHandler );
       
   421 
       
   422 // from base class CCoeControl
       
   423 
       
   424     /**
       
   425      * From CCoeControl.
       
   426      * Handles key events.
       
   427      *
       
   428      * @param aKeyEvent The key event.
       
   429      * @param aType The type of key event.
       
   430      */
       
   431     TKeyResponse OfferKeyEventL(
       
   432         const TKeyEvent& aKeyEvent,
       
   433         TEventCode aType );
       
   434 
       
   435     /**
       
   436      * From CCoeControl.
       
   437      * Gets the control's help context.
       
   438      *
       
   439      * @param aContext The control's help context.
       
   440      */
       
   441     void GetHelpContext( TCoeHelpContext& aContext ) const;
       
   442 
       
   443     /**
       
   444      * From CoeControl.
       
   445      * Handles a change to the control's resources.
       
   446      *
       
   447      * @param aType A message UID value.
       
   448      */
       
   449     void HandleResourceChange( TInt aType );
       
   450 
       
   451     /**
       
   452      * From CoeControl.
       
   453      * Draw this application's view to the screen
       
   454      *
       
   455      * @param aRect the rectangle of this view that needs updating
       
   456      */
       
   457     void Draw( const TRect& aRect ) const;
       
   458 
       
   459     /**
       
   460      * From CoeControl.
       
   461      * Get the control input capabilities
       
   462      */
       
   463 	TCoeInputCapabilities InputCapabilities() const;
       
   464 
       
   465     TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
       
   466 
       
   467     void HandleGainingForeground();
       
   468     
       
   469     void HandleLosingForeground();
       
   470 
       
   471 // from base class MCoeControlObserver
       
   472 
       
   473     /**
       
   474     * From MCoeControlObserver, Acts upon changes in the hosted control's state.
       
   475     * This class's implementation is trivial and should be able to be safely
       
   476     * re-implemented in directly client-derived classes. For non-base setting
       
   477     * page classes, a call to the base class should be made.
       
   478     * @param aControl Control that caused the event. (not used in default implementation)
       
   479     * @param aEventType Type of the event.
       
   480     */
       
   481     void HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType);
       
   482 
       
   483 
       
   484     /**
       
   485      * From MMPXCommonListBoxArrayObserver.
       
   486      * Handle listbox array events
       
   487      *
       
   488      *  @param aEvent list box event
       
   489      */
       
   490     void HandleListBoxArrayEventL(
       
   491         MMPXCommonListBoxArrayObserver::TMPXCommonListBoxArrayEvents aEvent );
       
   492 
       
   493 
       
   494 // from base class MHgScrollBufferObserver
       
   495 
       
   496     /**
       
   497      * from MHgScrollBufferObserver
       
   498      * Buffer position changed.
       
   499      * The items between the aBufferStart and aBufferEnd should be loaded as soon as possible.
       
   500      *
       
   501      * @param aBufferStart The index of the first item in buffer.
       
   502      * @param aBufferEnd The index of the last item in buffer.
       
   503      * @param aDirection report direction of scrolling
       
   504      */
       
   505     void Request(TInt aBufferStart, TInt aBufferEnd, THgScrollDirection aDirection);
       
   506 
       
   507 // from base class MHgBufferOwner
       
   508 
       
   509     /**
       
   510      * from MHgBufferOwner
       
   511      *
       
   512      *
       
   513      */
       
   514     void Release(TInt aReleaseStart, TInt aReleaseEnd);
       
   515 
       
   516 
       
   517 // from base class MHgSelectionObserver
       
   518 
       
   519     /**
       
   520      * Handle selection.
       
   521      *
       
   522      * @param aIndex Selected item index.
       
   523      */
       
   524     void HandleSelectL( TInt aIndex );
       
   525 
       
   526     void HandleSelectL( TInt aIndex, CCoeControl* aControl );
       
   527     /**
       
   528      * Handle opening.
       
   529      *
       
   530      * @param aIndex Opened item index.
       
   531      */
       
   532     void HandleOpenL( TInt aIndex );
       
   533     void HandleOpenL( TInt aIndex, CCoeControl* aControl );
       
   534 
       
   535 
       
   536     /**
       
   537      *  From MMPXCollectionFindObserver
       
   538      *  Handle callback for "find" operation
       
   539      *
       
   540      *  @param aEntries, CMPXMedia to be returned
       
   541      *  @param aComplete ETrue no more entries. EFalse more entries
       
   542      *                   expected
       
   543      *  @param aError error code
       
   544      */
       
   545     void HandleFindAllL( const CMPXMedia& aResults, TBool aComplete, TInt aError );
       
   546 
       
   547     void TNReadyL(TInt aError, CFbsBitmap* aBitmap, CFbsBitmap* aMask, TInt aIndex);
       
   548 
       
   549     /**
       
   550      * Determines if current selected list item is a song
       
   551      *
       
   552      * @return ETrue if is a song, EFalse otherwise
       
   553      */
       
   554 	TBool IsSelectedItemASong();
       
   555 	
       
   556 	void HandleItemCommandL( TInt aCommand );
       
   557 	
       
   558 	CMPXMedia* SelectedItemMediaL();
       
   559 	
       
   560 	/**
       
   561      * Determines if current view is TBoneview
       
   562      *
       
   563      * @return ETrue if current view is TBoneview, EFalse otherwise
       
   564      */
       
   565 	TBool IsTBoneView();
       
   566 
       
   567 	TBool OfferCommandL(TInt aCommand);
       
   568 
       
   569 	/**
       
   570 	 * Records begin state for the transition animation.
       
   571 	 */
       
   572 	void BeginFullScreenAnimation();
       
   573 
       
   574 	/**
       
   575 	 * Set the previous view Uid
       
   576 	 *
       
   577 	 * @param aViewUid UId of the previous view.
       
   578 	 */
       
   579 	void SetPreviousViewId(TUid aViewUid);
       
   580 
       
   581 	/**
       
   582 	 * Hides container window controls.
       
   583 	 */
       
   584     void HideContainerWindow(); 
       
   585 	
       
   586 private:
       
   587 
       
   588     /**
       
   589      * C++ constructor.
       
   590      */
       
   591     CMPXCollectionViewHgContainer(
       
   592         MEikCommandObserver* aView,
       
   593         MEikListBoxObserver* aObserver,
       
   594         MMPXSelectedAlbumHandler* aSelectedAlbumHandler,
       
   595         TBool aIsEmbedded);
       
   596 
       
   597     /**
       
   598      * Symbian 2nd phase constructor.
       
   599      */
       
   600     void ConstructL();
       
   601 
       
   602     /**
       
   603      * Creates listbox array
       
   604      */
       
   605     CMPXCommonListBoxArrayBase* CreateListBoxArrayL();
       
   606 
       
   607     /**
       
   608      * From MHgVgMediaWallObserver
       
   609      */
       
   610     void HandleMediaWallEvent(TInt aEvent, CHgVgMediaWall* aSender);
       
   611 
       
   612     /**
       
   613      * Creates icon array, populates iIconArray to be used by listbox
       
   614      */
       
   615     void CreateIconArrayL();
       
   616 
       
   617     /**
       
   618      * Sets default icon for HgList
       
   619      */
       
   620     void SetDefaultIconL();
       
   621 
       
   622     /**
       
   623      * Sets default icon for list item
       
   624      */
       
   625     void SetDefaultIconL(TInt aIndex);
       
   626 
       
   627     /*
       
   628 	 * Adds detail to the list item at the specified index
       
   629      */
       
   630     void AddDetailToDisplayedItemL( CHgItem* aVisualItem, CMPXMedia* aMedia, TInt aIndex);
       
   631     void AddThumbnailToDisplayedItemL( CHgItem* aVisualItem, CMPXMedia* aMedia, TInt aIndex);
       
   632     void SetTitleL( CHgItem* aVisualItem, CMPXMedia* aMedia );
       
   633     void SetSongTitleL( CHgItem* aVisualItem, CMPXMedia* aMedia );
       
   634     void SetDetailCountL( CHgItem* aVisualItem, CMPXMedia* aMedia );
       
   635     void SetDetailArtistL( CHgItem* aVisualItem, CMPXMedia* aMedia );
       
   636     void SetDetailAlbumL( CHgItem* aVisualItem, CMPXMedia* aMedia );
       
   637     void SetDetailDurationL( CHgItem* aVisualItem, CMPXMedia* aMedia );
       
   638     void UpdateTimeIndicatorsL( TDes& aBuf, TInt aDuration );
       
   639     void SetDetailIndicatorL( CHgItem* aVisualItem, TInt aIndex );
       
   640     void SetDetailIconL( CHgItem* aVisualItem, TInt aIndex );
       
   641     void SetDetailThumbnailL( CMPXMedia* aMedia, TInt aIndex = 0 );
       
   642 	CGulIcon* DefaultIconL();
       
   643 	void SetDetailIconShuffleL();
       
   644 	TBool SetShuffleItemTextL(CHgItem* aItem, CMPXMedia* aMedia);
       
   645 	void SetShuffleItemToListL( CHgScroller* aList );
       
   646 
       
   647     /**
       
   648      * Set the collection context
       
   649      */
       
   650     void SetCollectionContextL();
       
   651 
       
   652     void ProvideDataL( TInt aStart, TInt aEnd );
       
   653 
       
   654     void SetScrollbarType();
       
   655 
       
   656     void CancelTNRequest();
       
   657 
       
   658     /**
       
   659       * Save the selected album item
       
   660       *
       
   661       */
       
   662     void SaveSelectedAlbumItemL(TInt aIndex);
       
   663 
       
   664     /**
       
   665      * Write the album name, artist name and album art in media data to file
       
   666      *
       
   667      * @param aMedia         the selected media data in Album view
       
   668      */
       
   669     void WriteToStreamFileL( const CMPXMedia* aMedia );
       
   670 
       
   671     /**
       
   672      * Read the album name, artist name and album art from file
       
   673      *
       
   674      * @param aMedia         the media data will be returned
       
   675      */
       
   676     void ReadFromStreamFileL( CMPXMedia* aMedia );
       
   677 
       
   678 	void RestoreSelectedAlbumItemL(const CMPXMediaArray& aMediaArray);
       
   679 
       
   680     /**
       
   681      * Refresh list as needed
       
   682      */
       
   683     void RefreshL(TInt aIndex);
       
   684 
       
   685     /**
       
   686      * Refresh list as needed
       
   687      */
       
   688     void RefreshNoThumbnailL(TInt aIndex);
       
   689 
       
   690 	/**
       
   691 	* Clean AlbumArt request Queue
       
   692 	*/
       
   693     void CleanAlbumArtReqQueue();
       
   694 
       
   695     /**
       
   696      * Handle data providing in requests in visible area
       
   697      * @param aBufferStart  the starting buffer index
       
   698      * @param aBufferEnd  the ending buffer index
       
   699      */
       
   700     void ProvideDataIntersectL(TInt aBufferStart, TInt aBufferEnd);
       
   701 
       
   702     /**
       
   703      * Handle data providing in requests in non visible area
       
   704      * @param aBufferStart  the starting buffer index
       
   705      * @param aBufferEnd  the ending buffer index
       
   706      */
       
   707     void ProvideDataDifferenceL(TInt aBufferStart, TInt aBufferEnd);
       
   708 
       
   709     /**
       
   710      * Provide data without providing thumbnails to list
       
   711      * @param aMediaArray  the media array to pull data from
       
   712      * @param aStartIndex  the starting index index
       
   713      */
       
   714     void ProvideDataWithoutThumbnailsL(const CMPXMediaArray& aMediaArray, TInt aStartIndex = 0);
       
   715 
       
   716     /**
       
   717      * Provide data without providing thumbnails to media wall
       
   718      * @param aMediaArray  the media array to pull data from
       
   719      * @param aStartIndex  the starting index index
       
   720      */
       
   721     void ProvideDataWithoutThumbnailsMwL(const CMPXMediaArray& aMediaArray, TInt aStartIndex = 0);
       
   722 
       
   723     /**
       
   724      * Handle data providing in specified range.
       
   725      * @param aBufferStart  the starting buffer index
       
   726      * @param aBufferEnd  the ending buffer index
       
   727      */
       
   728     void ProvideDataForRangeL( TInt aBufferStart, TInt aBufferEnd );
       
   729 
       
   730     /**
       
   731      * Prepare media wall to be shown
       
   732      * @param aMediaArray  the media array to pull data from
       
   733      * @param aCount  Number of items in media wall
       
   734      */
       
   735 	void PrepareMediaWallL(const CMPXMediaArray& aMediaArray, TInt aCount);
       
   736 
       
   737     /**
       
   738      * Prepare TBone view to be shown
       
   739      * @param aMediaArray  the media array to pull data from
       
   740      * @param aCount  Number of items in media wall portion of tbone.
       
   741      */
       
   742 	void PrepareMediaWallWithListL(const CMPXMediaArray& aMediaArray, TInt aCount);
       
   743 
       
   744     /**
       
   745      * Prepare list to be shown
       
   746      * @param aMediaArray  the media array to pull data from
       
   747      * @param aCount  Number of items in list
       
   748      */
       
   749 	void PrepareListL(const CMPXMediaArray& aMediaArray, TInt aCount);
       
   750 
       
   751     /**
       
   752      * Handle list resizing
       
   753      * @param aMediaArray  the media array to pull data from
       
   754      * @param aCount  Number of items in list
       
   755      */
       
   756 	void ResizeListL(const CMPXMediaArray& aMediaArray, TInt aCount);
       
   757 
       
   758     /**
       
   759      * Get the current list instance
       
   760      * @param aIndex Index from list control
       
   761      * @return Instance of scroller object
       
   762      */
       
   763 	CHgScroller* CurrentListWidget();
       
   764 
       
   765     /**
       
   766      * Resolve the type of view based on current browsing context
       
   767      * @param aCount Count from media array
       
   768      */
       
   769 	void ResolveCurrentViewType(TInt aCount);
       
   770 
       
   771     /**
       
   772      * Clean up the previous view's resources.
       
   773      */
       
   774 	void CleanPrevView();
       
   775 
       
   776     /**
       
   777      * Initiate shuffle play all operation
       
   778      * @return ETrue if shuffle operation is started.
       
   779      */
       
   780 	TBool ShufflePlayAllL(TInt aIndex);
       
   781 
       
   782     /**
       
   783      * Update the collection path and open it to start playback.
       
   784      * @param aIndex The selected media array index to start playing.
       
   785      * @param aSelectAll Indicate if all items should be selected.
       
   786      */
       
   787 	void UpdatePathAndOpenL(TInt aIndex, TBool aSelectAll = EFalse);
       
   788 
       
   789     /**
       
   790      * Construct a collection path with the current selection and
       
   791      * construct a playlist from path to start playback.
       
   792      * @param aResults The media results from find operation.
       
   793      */
       
   794 	void UpdatePathAndOpenPlaylistL( const CMPXMedia& aResults );
       
   795 
       
   796     /**
       
   797      * Find songs belonging to album.
       
   798      * @param aIndex Index in media array of albums
       
   799      */
       
   800 	void FindAlbumSongsL(TInt aIndex);
       
   801 
       
   802     /**
       
   803      * Find songs belonging to playlist.
       
   804      * @param aIndex Index in media array of playlists
       
   805      */
       
   806 	void FindPlaylistSongsL(TInt aIndex);
       
   807 
       
   808     /**
       
   809      * Find songs belonging to genre.
       
   810      * @param aIndex Index in media array of genres
       
   811      */
       
   812 	void FindGenreSongsL(TInt aIndex);
       
   813 
       
   814     /**
       
   815      * Check if the currently playing track is in path
       
   816      * @param aPath Collection path of playlist
       
   817      * @return ETrue if current track is playing
       
   818      */
       
   819 	TBool IsPlayingCurrentIndexL(CMPXCollectionPath* aPath);
       
   820 
       
   821     /**
       
   822      * Show list of songs in an album in a dialog popup.
       
   823      * @param aAlbum Album container with list of songs
       
   824      */
       
   825 	void ShowAlbumSongsDialogL( const CMPXMedia& aAlbum );
       
   826 
       
   827     /**
       
   828      * Show list of songs in an album
       
   829      * @param aAlbum Album container with list of songs
       
   830      */
       
   831     void ShowAlbumSongsL( const CMPXMedia& aAlbum );
       
   832 
       
   833     /**
       
   834      * Open the album to show its contents
       
   835      * @param aIndex Index of the album in media array
       
   836      */
       
   837     void OpenAlbumL(TInt aIndex);
       
   838 
       
   839     /**
       
   840      * Play the album
       
   841      * @param aIndex Index of the album in media array
       
   842      */
       
   843     void PlayAlbumL(TInt aIndex);
       
   844 
       
   845     /**
       
   846      * Play the playlist
       
   847      * @param aIndex Index of the album in media array
       
   848      */
       
   849     void PlayPlaylistL(TInt aIndex);
       
   850 
       
   851     /**
       
   852      * Play the genre
       
   853      * @param aIndex Index of the album in media array
       
   854      */
       
   855     void PlayGenreL(TInt aIndex);
       
   856 
       
   857     static TInt AsyncCallback( TAny* aPtr );
       
   858 
       
   859     /**
       
   860      * Prepare to show the TBone view.
       
   861      */
       
   862 	void PrepareTboneViewL();
       
   863 
       
   864     /**
       
   865      * Check if shuffle item is present in the view.
       
   866      * @return ETrue if shuffle item is present.
       
   867      */
       
   868 	TBool ShuffleItemPresent();
       
   869 
       
   870     /**
       
   871      * Mapping function to convert from list index to media index.
       
   872      * @param aIndex Index from list control
       
   873      * @return media array index
       
   874      */
       
   875 	TInt MediaIndex(TInt aIndex) const;
       
   876 
       
   877 	/**
       
   878      * Load and set empty text.
       
   879      */
       
   880 	void LoadAndSetEmptyTextL();
       
   881 
       
   882     /**
       
   883      * End fullscreen animation effects.
       
   884      */
       
   885     void EndFullScreenAnimation();
       
   886 
       
   887     /**
       
   888      * Resolve popup list rectangle size.
       
   889      */
       
   890     void ResolvePopupListSizeL();
       
   891 
       
   892     /**
       
   893      * Setup transition type
       
   894 	 * @param aType Type of transition to be used.
       
   895 	 * @param aPrevViewWasPlayback ETrue if previous view was playback.
       
   896 	 *     This information used to decide animation direction.
       
   897 	 */
       
   898     void SetupTransitionType( TInt aType, TBool aPrevViewWasPlayback = EFalse );
       
   899 
       
   900 private: // data member
       
   901 
       
   902     /**
       
   903      * Context of collection view. It's the exact location within collection navigation
       
   904      * based on category type + category.
       
   905      */
       
   906     enum TContext
       
   907         {
       
   908         EContextUnknown,
       
   909         EContextGroupCollection,
       
   910         EContextGroupArtist,
       
   911         EContextGroupAlbum,
       
   912         EContextGroupPlaylist,
       
   913         EContextGroupSong,
       
   914         EContextGroupPodcast,
       
   915         EContextGroupGenre,
       
   916         EContextGroupComposer,
       
   917         EContextItemArtist,
       
   918         EContextItemAlbum,
       
   919         EContextItemPlaylist,
       
   920         EContextItemSong,
       
   921         EContextItemPodcast,
       
   922         EContextItemGenre,
       
   923         EContextItemComposer
       
   924         };
       
   925 
       
   926     enum TDefaultIcon
       
   927         {
       
   928         EMPXDefaultIconNotSet = -1,
       
   929         EMPXDefaultIconArtist,
       
   930         EMPXDefaultIconAlbum,
       
   931         EMPXDefaultIconPlaylist,
       
   932         EMPXDefaultIconSongs,
       
   933         EMPXDefaultIconPodcasts,
       
   934         EMPXDefaultIconGenre,
       
   935         EMPXDefaultIconComposer,
       
   936         EMPXDefaultTitleIconPodcasts,
       
   937         EMPXDefaultIconEmpty
       
   938         };
       
   939 
       
   940     enum TViewType
       
   941         {
       
   942         EMPXViewUnknown,
       
   943         EMPXViewMediawall,
       
   944         EMPXViewList,
       
   945         EMPXViewTBone
       
   946         };
       
   947 
       
   948     enum TFindOp
       
   949         {
       
   950         EMPXNoOp,
       
   951         EMPXOpenAlbum,
       
   952         EMPXPlayAlbum,
       
   953         EMPXPlayPlaylist,
       
   954         EMPXPlayGenre
       
   955         };
       
   956 
       
   957     MEikCommandObserver*            iView; // not owned
       
   958     MEikListBoxObserver*            iListBoxObserver; // not owned
       
   959     CAknContextPane*                iContextPane;    // Not owned
       
   960     CMPXCollectionViewListBoxArray* iListBoxArray; // owned
       
   961     CEikImage*                      iNewIcon;  // New context icon, owned
       
   962     CEikImage*                      iOrigIcon;  // New context icon, not owned
       
   963     TBool                           iReorder;
       
   964     TBool                           iReady;
       
   965     TBool                           iIsEmbedded;
       
   966 
       
   967     CAknPopupList* iDialog; // Album tracks dielog. owned.
       
   968     
       
   969     THgScrollDirection iDirection;
       
   970     RArray<TBool> iThumbnailReqMap;
       
   971 
       
   972     HBufC* iAlbumTitle;
       
   973     HBufC* iSongTitle;
       
   974 
       
   975     TBool iPodcastContext;
       
   976     TBool iTitleSet;
       
   977     TDefaultIcon iCurrentDefaultIcon;
       
   978 
       
   979     TFileName iSelectedAlbumItemFileName;
       
   980     CMPXMedia* iSelectedMediaInAlbumView;
       
   981 
       
   982 	CMPXCommonUiHelper*         iCommonUiHelper;        // Owned
       
   983     MMPXCollectionUtility* 		iCollectionUtility;		// Owned
       
   984     MMPXPlaybackUtility* 		iPlaybackUtility;       // Owned
       
   985 
       
   986     CHgScroller* 				iMwListWidget;  		// Owned
       
   987     CHgScroller* 				iListWidget;  		    // Owned
       
   988     CHgVgMediaWall* 			iMediaWall;             // Owned
       
   989     CMpxTNLoader*               iThumbnailManager;      // Owned
       
   990 
       
   991     TContext                    iContext;
       
   992     TContext                    iPrevContext;
       
   993     TInt                        iResourceOffset;        // Must be freed
       
   994     TBool                       iIsMarkingEnabled;
       
   995 	TInt						iTopIndex;
       
   996 	TInt						iBottomIndex;
       
   997 	TSize						iImageSize;
       
   998     CAknsBasicBackgroundControlContext* iBgContext; 	// Owned
       
   999 
       
  1000     CArrayFixFlat<TInt>*        iListSelections;        // Owned
       
  1001     CAknIconArray*              iIconArray;             // Owned
       
  1002 
       
  1003     MMPXCollectionUiHelper* iCollectionUiHelper;
       
  1004     CMPXCollectionPlaylist* iPlaylist;
       
  1005     CMPXCollectionViewHgPlaylistHelper* iPlaylistHelper;
       
  1006 
       
  1007     // List/Media wall management
       
  1008     TInt iLastValidMediaItemIndex;
       
  1009     TInt iRequestStart;
       
  1010     TInt iRequestEnd;
       
  1011     TInt iAlbumIndex; // opened album index in mediawall
       
  1012     TInt iSelectedAlbumIndex; // selected album index in mediawall
       
  1013     TInt iRestoredAlbumIndex; // restored selected album index
       
  1014     MMPXSelectedAlbumHandler* iSelectedAlbumHandler;
       
  1015     TBool iDefaultIconSet;
       
  1016     MMpxCbaHandler* iCbaHandler;
       
  1017     TViewType iCurrentViewType;
       
  1018     TViewType iPrevViewType;
       
  1019     TFindOp iFindOp;
       
  1020     TBool iIsForeground;
       
  1021     TBool iDelayedControlCreation;
       
  1022     CAsyncCallBack* iAsyncCallBack;
       
  1023     TBool iOpenAlbumTracks;
       
  1024     TInt iShuffleItem;
       
  1025     TBool iSetEmptyTextNeeded;
       
  1026     TTransitionType iTranstionType;
       
  1027     TBool iLayoutSwitch;
       
  1028     TRect iPopupListRect;
       
  1029     TUid iPreviousViewId;
       
  1030     TBool iPreviousOrientation;
       
  1031     TBool iDrawBackGround;
       
  1032     TBool iIsNowPlayingView;
       
  1033     };
       
  1034 
       
  1035 #endif  // CMPXCOLLECTIONVIEWHGCONTAINER_H
       
  1036 
       
  1037 // End of File