chxavfileview.cpp
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:12k
- /************************************************************************
- * chxavfileview.cpp
- * -----------------
- *
- * Synopsis:
- * Contains the implementation of the CHXAvFileView class. This class
- * is derived from CHXAvViewBase which is derived from CAknView. This
- * object instantiates and own a control called the CHXAvFileViewWindow.
- * This control owns two component controls, the list box and a find box.
- *
- * Target:
- * Symbian OS
- *
- *
- * (c) 1995-2003 RealNetworks, Inc. Patents pending. All rights reserved.
- *
- ************************************************************************/
- // Symbian includes...
- #include <coeccntx.h>
- #include <eikenv.h>
- #include <eikappui.h>
- #include <eikapp.h>
- #include <eikdoc.h>
- #include <eikmenup.h>
- #include <eikon.hrh>
- #include <aknviewappui.h>
- #include <apchangeobserver.h>
- #include <akniconarray.h>
- #include <aknselectionlist.h>
- #include <SenduiMtmUids.h>
- #include <sendui.h>
- #include <SendNorm.rsg>
- // Includes for this project...
- #include "hxsym_debug.h"
- #include "realplayer.rsg"
- #include "chxavfileviewwindow.h"
- #include "chxavviewbase.h"
- #include "chxavfileview.h"
- #include "realplayer.hrh"
- #include "chxavplayerui.h"
- #include "chxavfileviewpageinfo.h"
- #include "chxavfolderdisplayinfo.h"
- #include "realplayer.mbg"
- namespace
- {
- inline
- bool IsViewAtRoot(CHXAvFileViewWindow* pWin)
- {
- CHXAvFileStorePtr spStore = pWin->GetStore();
- return !spStore || spStore->IsAtRoot();
- }
- }
- /*
- * CHXAvFileView
- * -------------
- * Constructor.
- *
- */
- CHXAvFileView::CHXAvFileView(TInt viewIndex, CHXAvPlayerUI *playerUI)
- : CHXAvViewBase(viewIndex, playerUI)
- , m_idxInitPage(0)
- {
- }
- /*
- * ~CHXAvFileView
- * --------------
- * Destructor.
- *
- */
- CHXAvFileView::~CHXAvFileView()
- {
- }
- /*
- * ConstructL
- * ----------
- * Construction of elements.
- *
- */
- void CHXAvFileView::ConstructL()
- {
- BaseConstructL(R_AVP_FILE_VIEW_INFO);
- m_spPageInfo = new (ELeave) CHXAvFileViewPageInfoVector();
- AppendPageInfoL();
- m_spSendAppUi = CSendAppUi::NewL(ECmdSendVia);
- }
- /*
- * CreatePageInfoL
- * ---------------
- * Create and add to the list all of the page info stuff.
- *
- */
- void
- CHXAvFileView::AppendPageInfoL()
- {
- // Get mmc and local folder information...
- HX_ASSERT(m_playerUI != NULL);
- const CHXAvVector<CHXAvMediaFolderInfoPtr>& spFolderInfo = m_playerUI->GetMediaStoreInfoL(true);
- // Add local tab...
- CHXAvFileViewPageInfoPtr spInfo1 = new (ELeave) CHXAvFileViewPageInfo();
- spInfo1->ConstructL(spFolderInfo[0]->GetRoot(), true, EMbmRealplayerFileview_local_tab, EMbmRealplayerFileview_local_tab_mask);
- CHXAvUtil::Append(*m_spPageInfo, spInfo1);
- if( spFolderInfo.Nelements() > 1 )
- {
- // Add mmc tab
- CHXAvFileViewPageInfoPtr EMbmRealplayer = new (ELeave) CHXAvFileViewPageInfo();
- EMbmRealplayer->ConstructL(spFolderInfo[1]->GetRoot(), false, EMbmRealplayerFileview_mmc_tab, EMbmRealplayerFileview_mmc_tab_mask);
- CHXAvUtil::Append(*m_spPageInfo, EMbmRealplayer);
- }
- }
- /*
- * HandleCommandL
- * --------------
- * Handle commands passed to us by our control and directly.
- *
- */
- void CHXAvFileView::HandleCommandL(TInt command)
- {
- bool bAtRoot = IsViewAtRoot(m_spWindow.raw_ptr());
- switch(command)
- {
- case EAknSoftkeyOk:
- case EOpenFolder:
- case EPlay:
- m_spWindow->UserOpenCurrentItemL();
- break;
- case EAknSoftkeyBack:
- HX_ASSERT(!bAtRoot);
- if( !bAtRoot )
- {
- // go back to root
- m_spWindow->UserSwitchToParentFolderAndRefreshL();
- }
- break;
- case EAknMarkAll:
- case EAknUnmarkAll:
- case EAknCmdUnmark:
- case EAknCmdMark:
- m_spWindow->UserMarkL(command);
- break;
- case EShowDefaultMenu:
- ShowPopupMenuL(R_AVP_FILE_VIEW_MENU_BAR);
- break;
- case EEditPlaylist:
- m_spWindow->UserEditCurrentItemL();
- break;
- case EDelete:
- m_spWindow->UserDeleteSelectedItemsL();
- break;
- case EMoveToFolder:
- m_spWindow->UserMoveSelectedItemsL();
- break;
- case ECopyToFolder:
- m_spWindow->UserCopySelectedItemsL();
- break;
- case ENewFolder:
- m_spWindow->UserNewFolderL();
- break;
- case ERename:
- m_spWindow->UserRenameCurrentItemL();
- break;
- /*
- case EAknCmdAddToPinboard:
- m_spWindow->UserAddSelectedToPinboardL();
- break;*/
- case ECmdSendVia:
- case ECmdSendCmd1:
- case ECmdSendCmd2:
- case ECmdSendCmd3:
- case ECmdSendCmd4:
- case ECmdSendCmd5:
- case ECmdSendCmd6:
- m_spWindow->UserSendSelectedItemsL(command, m_spSendAppUi.Ptr());
- break;
- case EUnlockDrive:
- m_spWindow->UserUnlockDriveL();
- break;
- default:
- m_playerUI->HandleCommandL(command);
- break;
- }
- }
- /*
- * UpdateViewStateL
- * ----------------
- *
- */
- ////////////////////////////////////////////////////////
- // make sure view state (everything but window area) appropriately
- // reflects state of the file view window; updates menu bar commands
- // and title text
- void CHXAvFileView::UpdateViewStateL()
- {
- if(IsViewAtRoot(m_spWindow.raw_ptr()))
- {
- Cba()->SetCommandSetL(R_AVKON_SOFTKEYS_OPTIONS_EXIT);
- // use long caption from caption resource; initially overridden app title is shown
- SetDefaultAppTitleL();
- }
- else
- {
- Cba()->SetCommandSetL(R_AVKON_SOFTKEYS_OPTIONS_BACK);
- CHXAvFolderDisplayInfo info;
- info.SetFolderPathL(m_spWindow->GetFullPath());
- // in case folder name has weird control characters
- HBufC* pFixedText = CHXAvMisc::AllocDisplayFriendlyStringL(info.GetDisplayText());
- AUTO_PUSH_POP_DEL(pFixedText);
- m_titlePane->SetTextL(*pFixedText);
- }
- UpdateMenuBar();
- Cba()->DrawNow();
- m_spWindow->UpdateTopAndBottomL();
- }
- /////////////////////////////////////
- // set menu bar, depending on whether or not current window
- // view represents a valid (accessible) drive or not
- void CHXAvFileView::UpdateMenuBar()
- {
- TInt idMenuBar = m_spWindow->GetStore() ? R_AVP_FILE_VIEW_MENU_BAR : R_AVP_FILE_VIEW_NODRIVE_MENU_BAR;
- MenuBar()->SetMenuTitleResourceId(idMenuBar);
- }
- /*
- * CreateViewWindowForActivatingViewL
- * -------------------
- * Construct view window needed for active view
- *
- */
- CCoeControl* CHXAvFileView::CreateViewWindowForActivatingViewL()
- {
- DPRINTF(SYMP_INFO, ("CHXAvFileView::CreateViewWindowForActivatingViewL()n"));
- if (!m_spWindow)
- {
- m_spWindow = new (ELeave) CHXAvFileViewWindow();
- HX_ASSERT(m_spPageInfo);
- m_spWindow->ConstructL(ClientRect(), m_playerUI, this, m_spPageInfo, m_idxInitPage);
- }
- return m_spWindow.raw_ptr();
- }
- /*
- * FinishViewDeactivateL
- * ---------------------
- *
- */
- void CHXAvFileView::FinishViewDeactivateL()
- {
- DPRINTF(SYMP_INFO, ("CHXAvFileView::FinishViewDeactivateL()n"));
- if( m_spWindow )
- {
- // remember the index of the page that is currently visible
- m_idxInitPage = m_spWindow->GetCurrentPageIndex();
- HX_ASSERT(m_idxInitPage >= 0);
- m_spWindow->SaveCurrentPageInfoL();
- m_spWindow = 0;
- }
- }
-
- /*
- * DynInitMenuPaneL
- * ----------------
- * Called when a menu pane is about to be displayed.
- *
- */
- void
- CHXAvFileView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
- {
- HX_ASSERT(m_spWindow);
- switch (aResourceId)
- {
- case R_AVP_FILE_VIEW_MENU_PANE:
- InitMainMenuPaneL(aMenuPane);
- break;
- case R_AVP_MARK_MENU_PANE:
- InitMarkMenuPaneL(aMenuPane);
- break;
- case R_AVP_OPEN_MENU_PANE:
- InitOpenMenuPaneL(aMenuPane);
- break;
- case R_SENDUI_MENU:
- m_spSendAppUi->DisplaySendCascadeMenuL(*aMenuPane);
- break;
- case R_AVP_FILE_VIEW_NODRIVE_MENU_PANE:
- aMenuPane->SetItemDimmed(EUnlockDrive, !m_spWindow->IsDriveLocked());
- CHXAvMisc::InitDebugMenuItemsL(aMenuPane);
- CHXAvMisc::InitHelpMenuItem(aMenuPane);
- break;
- default:
- break;
- }
- }
- /*
- * InitMainMenuPaneL
- * -----------------
- * Main menu is set up here.
- *
- */
- void
- CHXAvFileView::InitMainMenuPaneL(CEikMenuPane* pPane)
- {
- HX_ASSERT(m_spSendAppUi);
- //
- // note:
- //
- // only files can be marked
- // any items marked -> selection applies to marks
- // no items marked -> selection applies to hilight item
- //
- bool bItemsAreMarked = m_spWindow->GetMarkedItemCount() > 0;
- bool bAtLeastOneItemSelected = bItemsAreMarked || m_spWindow->HasHilightItem();
- bool bSingleItemSelected = m_spWindow->HasHilightItem() && !bItemsAreMarked;
- bool bSingleFileSelected = bSingleItemSelected && m_spWindow->HilightItemIsFile();
- bool bSingleFolderSelected = bSingleItemSelected && !m_spWindow->HilightItemIsFile();
- bool bOneOrMoreFilesSelected = bItemsAreMarked || bSingleFileSelected;
- bool bAtLeastOneFileInView = !m_spWindow->IsEmpty() && (m_spWindow->GetUnmarkedItemCount() + m_spWindow->GetMarkedItemCount() > 0);
- bool bPlaylistItemSelected = bSingleFileSelected && m_spWindow->HilightItemIsPlaylist();
-
-
- pPane->SetItemDimmed(EPlay, !bSingleFileSelected);
- pPane->SetItemDimmed(EOpenFolder, !bSingleFolderSelected);
- pPane->SetItemDimmed(EDelete, !bAtLeastOneItemSelected);
- pPane->SetItemDimmed(EMarkCascade, !bAtLeastOneFileInView);
- pPane->SetItemDimmed(ERename, !bSingleItemSelected);
- pPane->SetItemDimmed(EMoveToFolder, !bOneOrMoreFilesSelected);
- pPane->SetItemDimmed(ECopyToFolder, true /*!bOneOrMoreFilesSelected*/); //XXXLCM
- pPane->SetItemDimmed(EEditPlaylist, !bPlaylistItemSelected);
- //pPane->SetItemDimmed(EViewInfo, !bSingleFileSelected);
- // enable create folder item only if page allows it at current level
- pPane->SetItemDimmed(ENewFolder, !m_spWindow->IsCreateChildFolderAllowed());
- if (bOneOrMoreFilesSelected)
- {
- // send
- TSendingCapabilities caps(0, 1024,
- TSendingCapabilities::ESupportsAttachments );
- TInt pos = 0;
- pPane->ItemAndPos(EMarkCascade, pos);
- m_spSendAppUi->DisplaySendMenuItemL(*pPane, pos + 1, caps);
- // add to pinboard
- //m_playerUI->PinbModel().AddLinkMenuItemL(*pPane, ECmdSendVia);
- }
- CHXAvMisc::InitDebugMenuItemsL(pPane);
- CHXAvMisc::InitHelpMenuItem(pPane);
-
- }
- /*
- * InitMarkMenuPaneL
- * -----------------
- * Marked items menu.
- *
- */
- void
- CHXAvFileView::InitMarkMenuPaneL(CEikMenuPane* pPane)
- {
- HX_ASSERT(!m_spWindow->IsEmpty());
- // we can unmark the hilight item if it is marked
- pPane->SetItemDimmed(EAknCmdUnmark, !m_spWindow->HilightItemIsMarked());
- // we can mark the hilight item if it is a file (and unmarked)
- TBool bMarkable = !m_spWindow->HilightItemIsMarked() &&
- m_spWindow->HilightItemIsFile();
- pPane->SetItemDimmed(EAknCmdMark, !bMarkable);
- TBool bHasMarkedItems = m_spWindow->GetMarkedItemCount() > 0;
- TBool bHasUnMarkedMarkableItems = m_spWindow->GetUnmarkedItemCount() > 0;
- pPane->SetItemDimmed(EAknMarkAll, !bHasUnMarkedMarkableItems);
- pPane->SetItemDimmed(EAknUnmarkAll, !bHasMarkedItems);
- }
- /*
- * InitOpenMenuPaneL
- * -----------------
- * Open menu items.
- *
- */
- void
- CHXAvFileView::InitOpenMenuPaneL(CEikMenuPane* pPane)
- {
- // see if the guide exists
- const TDesC& guide = m_playerUI->GetGuideUrlL(true);
- bool bGuideExists = (guide.Length() > 0);
- // only show 'open guide' if guide home page exists
- pPane->SetItemDimmed(EOpenGuide, !bGuideExists);
- // only show 'open recent' if at least one recent clip exists
- pPane->SetItemDimmed(EOpenRecentDialog, (m_playerUI->GetRecentClipCount() == 0));
- }