📄 vrexlistcontainer.cpp
字号:
/*
* ============================================================================
* Name : CVRexListContainer from VRexListContainer.cpp
* Part of : Video Example
* Created : 30/08/2006 by Forum Nokia
* Implementation notes:
* Version : 2.0
* Copyright: Nokia Corporation, 2006
* ============================================================================
*/
// INCLUDE FILES
#include <avkon.hrh>
#include <aknlists.h>
#include "VRexListContainer.h"
#include "VRexApp.h"
#include "VRexListView.h"
#include "VRexFileDetailsDialog.h"
// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CVRexListContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CVRexListContainer::ConstructL(const TRect& aRect, CVRexListView* aView,
CVRexEngine* aEngine)
{
iEngine = aEngine;
iView = aView;
CreateWindowL();
iListBox = new( ELeave ) CAknDoubleNumberStyleListBox();
iListBox->SetContainerWindowL(*this);
iListBox->ConstructL(this, EAknListBoxMarkableList);
iListBox->CreateScrollBarFrameL(ETrue);
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,
CEikScrollBarFrame::EAuto);
iListBox->Model()->SetOwnershipType(ELbmOwnsItemArray);
iListBox->SetListBoxObserver(this);
iListBox->ActivateL();
iAvkonAppUi->AddToStackL(iListBox);
// Get the file list of clips in video gallery
UpdateFileListL();
SetRect(aRect);
ActivateL();
}
// Destructor
CVRexListContainer::~CVRexListContainer()
{
if(iListBox)
{
iAvkonAppUi->RemoveFromStack(iListBox);
delete iListBox;
iListBox = NULL;
}
}
/*
-----------------------------------------------------------------------------
void CVRexListContainer::UpdateFileListL()
Description: This method updates file list in list box.
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CVRexListContainer::UpdateFileListL()
{
SetFileListL(EFileListVideos, EFileListDate);
}
// ---------------------------------------------------------
// CVRexListContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CVRexListContainer::SizeChanged()
{
if(iListBox)
{
iListBox->SetRect(Rect());
}
}
// ---------------------------------------------------------
// CVRexListContainer::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CVRexListContainer::CountComponentControls() const
{
if(iListBox)
return 1;
else
return 0;
}
// ---------------------------------------------------------
// CVRexListContainer::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CVRexListContainer::ComponentControl(TInt aIndex) const
{
switch(aIndex)
{
case 0:
return iListBox;
default:
return NULL;
}
}
// ---------------------------------------------------------
// CVRexListContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CVRexListContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle( CGraphicsContext::ENullPen );
gc.SetBrushColor( KRgbGray );
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
gc.DrawRect( aRect );
}
// ---------------------------------------------------------
// CVRexListContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// ---------------------------------------------------------
//
void CVRexListContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
// Add your control event handler code here
}
/*
-----------------------------------------------------------------------------
void CVRexListContainer::SetFileListL(TInt aDirectory, TInt aSizeDate)
Description: This method sets directory listing to list box.
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CVRexListContainer::SetFileListL(TInt aDirectory, TInt aSizeDate)
{
// Set the listbox to use the the file list model
CDesCArray* items =
static_cast<CDesCArray*>(iListBox->Model()->ItemTextArray());
// Let's show directory
iEngine->SetDirectory(aDirectory);
// Let's decide whether to show file size or modification date
iEngine->SetSizeDate(aSizeDate);
// Do preparations for the file list
if(iEngine->StartFileList() == KErrNone)
{
// Create file list items in the list box
iEngine->GetFileListItemsL(items);
}
// Close file server session
iEngine->EndFileList();
// Refresh the list box due to model change
iListBox->HandleItemAdditionL();
iListBox->SetCurrentItemIndex(0);
iListBox->DrawNow();
}
/*
-----------------------------------------------------------------------------
TKeyResponse CVRexListContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,
TEventCode aType)
Description: This method handles key events.
Comments :
Return values: TKeyResponse
-----------------------------------------------------------------------------
*/
TKeyResponse CVRexListContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent,TEventCode aType)
{
// See if we have a selection
TInt code = aKeyEvent.iCode;
switch(code)
{
case EKeyUpArrow:
case EKeyDownArrow:
{
// Let list box take care of its key handling
return iListBox->OfferKeyEventL(aKeyEvent, aType);
}
default:
break;
}
return EKeyWasNotConsumed;
}
// ---------------------------------------------------------
// CVRexListContainer::HandleListBoxEventL(CEikListBox *aListBox,
// TListBoxEvent aEventType)
// ---------------------------------------------------------
//
void CVRexListContainer::HandleListBoxEventL(CEikListBox */*aListBox*/,
TListBoxEvent aEventType)
{
if (GetNumOfItemsInListBox()==0)
return;
if(aEventType == EEventEnterKeyPressed)
{
iView->HandleCommandL(EVRexCmdAppPlay);
}
}
/*
-----------------------------------------------------------------------------
void CVRexListContainer::GetCurrentVideoFileNameL(TDes &aFileName)
Description: This method gets the current video file name.
Comments :
Return values: N/A
-----------------------------------------------------------------------------
*/
void CVRexListContainer::GetCurrentVideoFileNameL(TDes &aFileName)
{
iEngine->GetVideoFilePathAndNameAtPosition(iListBox->CurrentItemIndex(),
aFileName);
}
/*
-----------------------------------------------------------------------------
TInt CVRexListContainer::GetNumOfItemsInListBox()
Description: This method gets the total number of items in the list box.
Comments :
Return values: Number of items
-----------------------------------------------------------------------------
*/
TInt CVRexListContainer::GetNumOfItemsInListBox()
{
// Set the list box to use the the file list model
CDesCArray* items =
static_cast<CDesCArray*>(iListBox->Model()->ItemTextArray());
return items->Count();
}
// End of file
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -