chxavfileviewwindow.h
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:7k
源码类别:

Symbian

开发平台:

C/C++

  1. /************************************************************************
  2.  * chxavfileviewwindow.h
  3.  * ---------------------
  4.  *
  5.  * Synopsis:
  6.  * Contains the declaration of the CHXAvFileViewWindow class.  This class 
  7.  * is instantiates and communicates with the actual controls of the file
  8.  * view.
  9.  *
  10.  * Target:
  11.  * Symbian OS
  12.  *
  13.  *
  14.  * (c) 1995-2003 RealNetworks, Inc. Patents pending. All rights reserved.
  15.  *
  16.  ************************************************************************/
  17. #ifndef _chxavfileviewwindow_h_
  18. #define _chxavfileviewwindow_h_
  19. // Symbian includes...
  20. #include <eiklbo.h> 
  21. #include <aknlists.h>
  22. // Helix includes...
  23. #include "hxlist.h"
  24. // Include from this project...
  25. #include "chxavrefptr.h"
  26. #include "chxavfileui.h"
  27. #include "chxavfilestore.h"
  28. #include "chxavplaylist.h"
  29. #include "chxsmartptr.h"
  30. #include "chxbody.h"
  31. #include "chxavfileviewpageinfo.h"
  32. #include "chxavnamedisplaytrait.h"
  33. #include "chxavcommand.h"
  34. // Forward declarations...
  35. class CHXAvViewBase;
  36. class CHXAvPlayerUI;
  37. class CHXAvFileView;
  38. class CEikColumnListBox;
  39. //class CAknSearchField;
  40. class CSendAppUi;
  41. // CHXAvFileViewWindow 
  42. class CHXAvFileViewWindow 
  43. : public CCoeControl
  44. , public MEikListBoxObserver
  45. , public CHXBody
  46. , private CHXAvNameDisplayTrait
  47. {
  48. public:
  49.     CHXAvFileViewWindow();
  50.     virtual ~CHXAvFileViewWindow();
  51.     void ConstructL(const TRect& rc, CHXAvPlayerUI *playerUI, CHXAvFileView* pFileView, 
  52.                     const refptr<CHXAvFileViewPageInfoVector>& spPageInfo, TInt idxCurrentPage = 0);
  53.     void UpdateTopAndBottomL();
  54.     void UpdateNaviPaneL();
  55.     void SaveCurrentPageInfoL();
  56.     // User commands...
  57.     void UserNewFolderL();
  58.     void UserEditCurrentItemL();
  59.     void UserOpenCurrentItemL();
  60.     void UserSwitchToParentFolderAndRefreshL();
  61.     void UserDeleteSelectedItemsL();
  62.     void UserRenameCurrentItemL();
  63.     void UserMoveSelectedItemsL();
  64.     void UserCopySelectedItemsL();
  65.     void UserMarkL(TInt command);
  66.     void UserSendSelectedItemsL(TInt command, CSendAppUi* pSendAppUi);
  67.     void UserUnlockDriveL();
  68.     //void UserAddSelectedToPinboardL();
  69.     // CCoeControl overrides...
  70.     CCoeControl* ComponentControl( TInt aIndex ) const;
  71.     TInt CountComponentControls() const;
  72.     void GetHelpContext(TCoeHelpContext& aContext) const;
  73.     void SizeChanged();
  74.     TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
  75.     bool IsEmpty() const;
  76.     TInt GetCurrentPageIndex() const;
  77.    
  78.     bool HilightItemIsMarked() const;
  79.     bool IsCreateChildFolderAllowed() const;
  80.     bool HilightItemIsFile() const;
  81.     TInt GetMarkedItemCount() const;
  82.     TInt GetUnmarkedItemCount() const;
  83.     bool HilightItemIsPlaylist() const;
  84.     bool IsAtRoot() const;
  85.     bool IsDriveLocked() const;
  86.     bool HasHilightItem() const;
  87.     const TDesC& GetFullPath() const;
  88.     const CHXAvFileStorePtr& GetStore() const;
  89.     CDesCArray* GetModelTextArray();
  90.     void OnCompleteUnlockAttempt(TInt err);
  91.     // MEikListBoxObserver
  92.     void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
  93. private:
  94.     enum ShiftMarkState
  95.     {
  96.         smNotMarking,
  97.         smShiftMark,
  98.         smShiftUnMark
  99.     };
  100. private:
  101.     
  102.     // XXXLCM new
  103.     void ReloadCurrentPageL();
  104.     void ResetCurrentPageInfoToRootL();
  105.     bool DoUpdateAndCheckDriveStateL();
  106.     void LoadPageL(TInt idxPage);
  107.     void InitFileStoreL();
  108.     void InitEmptyListTextL();
  109.     void BeginWatchingForDriveEventsL();
  110.     void HandlePossibleCurrentFolderChangeL();
  111.     // Helper functions...
  112.     void CreateFileViewListBoxL();
  113.     TInt SwitchToChildFolderAndRefreshL(const TDesC& folder);
  114.     
  115.     void CreateTabsL(TInt idxInitTab);
  116.     void CleanUpTabs();
  117.     TInt GetBestIndex(TInt idxWanted) const;
  118.     void SyncToCurrentPageL();
  119.     void RefreshListBoxL(TInt idxLastCurrentItem = 0, const TDesC& currentItemName = KNullDesC);
  120.     void SetListBoxSelectionAndDrawL(TInt idxLastCurrentItem,const TDesC& currentItemName);
  121.     void AddListItemsForCurrentPathL(CDesCArrayFlat*& pItems) const;
  122.     CDesCArrayFlat* CreateListItemsL() const;
  123.     const CHXAvFile::FileInfo&  GetFileInfoL(TInt idx) const;
  124.     HBufC* AllocFolderItemTextL(const TEntry& entry) const;
  125.     void OnFileSystemEvent();
  126.     void HandleFileSystemEventL();
  127.     HBufC* AllocFileItemTextL(const CHXAvFile::FileInfo& info) const;
  128.     HBufC* AllocPlayListDescriptionL(const CHXAvFile::FileInfo& info) const;
  129.    
  130.     CHXAvPlaylistPtr CreatePlaylist(const TEntry& entry) const;
  131.     
  132.  
  133.     // key handling implementation (OfferKeyEventL() helpers)
  134.     TKeyResponse HandleEventKeyEventL(const TKeyEvent& event);
  135.     TKeyResponse HandleKeyDownEventL(const TKeyEvent& event);
  136.     TKeyResponse HandleKeyUpEventL(const TKeyEvent& event);
  137.     TKeyResponse HandleShiftMarkKeyL(TInt keyCode);
  138.     void CreateAndAddIconsL();
  139. private:
  140.     // Controls...
  141.     CEikFormattedCellListBox* m_pListBox;
  142.     CHXAvFileView* m_pFileView;
  143.     CHXAvPlayerUI* m_playerUI;
  144.     refptr<CHXAvFileViewPageInfoVector> m_spPageInfo;
  145.     CHXAvFileViewPageInfoPtr m_spCurrentPage;
  146.     CHXAvFileStorePtr     m_spStore;
  147.     CHXAvFileUIPtr        m_spFileUI;
  148.     refptr<CAknNavigationDecorator> m_spDecoratedTabGroup;
  149.     CAknNavigationControlContainer *m_wpNaviPane;
  150.     CAknTabGroup *m_wpTabGroup;
  151.     bool m_bHideTabs;
  152.     ShiftMarkState m_shiftMarkState;
  153.     CHXAvCallback m_cbReloadPage;
  154.     CHXAvFileSystemWatcher m_fsWatcher;   
  155. };
  156. typedef CHXSmartPtr<CHXAvFileViewWindow> CHXAvFileViewWindowPtr;
  157. ////////////////////////////////////////////////////
  158. // true if showing contents for root level folder
  159. inline
  160. bool CHXAvFileViewWindow::IsAtRoot() const
  161. {
  162.     return !m_spStore || m_spStore->IsAtRoot();
  163. }
  164. ////////////////////////////////////////////////////////////
  165. // return true if an item is higlighted
  166. inline
  167. bool CHXAvFileViewWindow::HasHilightItem() const
  168. {
  169.     return m_pListBox->CurrentItemIndex() >= 0;
  170. }
  171. ////////////////////////////////////////////////////
  172. // get number of items (files) in selection list
  173. inline
  174. TInt CHXAvFileViewWindow::GetMarkedItemCount() const
  175. {
  176.     return m_pListBox->SelectionIndexes()->Count();
  177. }
  178. ////////////////////////////////////////////////////////////
  179. // return NULL if media folder root not accessible (locked, not there, corrupt, etc.)
  180. inline
  181. const CHXAvFileStorePtr& CHXAvFileViewWindow::GetStore() const
  182. {
  183.     return m_spStore;
  184. }
  185. ////////////////////////////////////////////////////////////
  186. // get array to text items that are displayed in the listbox
  187. inline
  188. CDesCArray* CHXAvFileViewWindow::GetModelTextArray()
  189. {
  190.     // downcast is only way to do it...
  191.     CTextListBoxModel* pModel = m_pListBox->Model();
  192.     return static_cast<CDesCArray*>(pModel->ItemTextArray());
  193. }
  194. ////////////////////////////////////////////////////////////
  195. // return true if the current folder is empty
  196. inline
  197. bool CHXAvFileViewWindow::IsEmpty() const
  198. {
  199.     return !m_spStore || m_spStore->GetEntries().Nelements() == 0;
  200. }
  201. ////////////////////////////////////////////////////////////
  202. //
  203. inline
  204. bool CHXAvFileViewWindow::IsCreateChildFolderAllowed() const
  205. {
  206.     return true;
  207. }
  208. #endif // _chxavfileviewwindow_h_