⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filelistcontainer.cpp

📁 Source codes and documents for how to find files in phone memory or mmc card in Symbian OS. Compatib
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CFileListContainer from FileListContainer.h
*  Part of  : FileList
*  Created  : 18.12.2002 by Forum Nokia
*  Implementation notes:
*     Initial content was generated by Nokia Series 60 AppWizard.
*  Version  : 1.0
*  Copyright: Nokia Corporation
* ============================================================================
*/

// INCLUDE FILES
#include "FileListContainer.h"
#include "FileListEngine.h"
#include "Filelist.hrh"

// ================= MEMBER FUNCTIONS =======================

// ---------------------------------------------------------
// CFileListContainer::ConstructL(const TRect& aRect)
// Symbian two phased constructor
// ---------------------------------------------------------
//
void CFileListContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();
  
    iListBox = new (ELeave) CAknDoubleNumberStyleListBox;

	iListBox->SetContainerWindowL( *this );
	iListBox->ConstructL( this, EAknListBoxMarkableList);

	// Create the scroll indicator
	iListBox->CreateScrollBarFrameL(ETrue);
	iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);

    iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );
    iListBox->ActivateL();

    // Create the FileListEngine
    iAppEngine = new (ELeave) CFileListEngine;  

    SetFileList(EFileListPictures, EFileListDate);

    SetRect(aRect);
    ActivateL();
    }

// Destructor
CFileListContainer::~CFileListContainer()
    {
    delete iAppEngine;
    delete iListBox;
    }


// ---------------------------------------------------------
// CFileListContainer::SetFileList(TInt aDirectory, TInt aSizeDate)
// This will set up filelist.
// Directory and Size can be changed. See Filelist.hrh for possible values
// This function is located in the container and not in the engine, because it 
// activates the listbox.
// ---------------------------------------------------------
//
void CFileListContainer::SetFileList(TInt aDirectory, TInt aSizeDate)
    {

    // Set the listbox to use the the file list model
    CDesCArray* items = static_cast<CDesCArray*>(iListBox->Model()->ItemTextArray());

    // If there are items, they will be removed here
    if (iAppEngine->RemoveItems(items)) 
        {
        // This makes changes to the actual listbox
        iListBox->HandleItemRemovalL();  
        }

    // Let's show directory
    iAppEngine->SetDirectory(aDirectory);  
    // Let's decide whether to show file size or modification date
    iAppEngine->SetSizeDate(aSizeDate);     
    // Do preparations for the FileList
    if(iAppEngine->StartFileList() == KErrNone)
        {        
        // Create FileList Items in the ListBox
        iAppEngine->GetFileListItems(items);       
        }
    // Close FileList session
    iAppEngine->EndFileList();                  

    // Refresh the listbox due to model change
	iListBox->HandleItemAdditionL();
    iListBox->SetCurrentItemIndex(0);
    iListBox->DrawNow();
    }

// ---------------------------------------------------------
// CFileListContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CFileListContainer::SizeChanged()
    {
    // control resizing
    iListBox->SetExtent(TPoint(0,0),TSize(176,160));
    }


// ---------------------------------------------------------
// CFileListContainer::OffeKeyEventL()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
TKeyResponse CFileListContainer::OfferKeyEventL(
    const TKeyEvent& aKeyEvent,TEventCode aType)
    {
    // See if we have a selection
    TInt code = aKeyEvent.iCode;
    switch(code)
        {
		// is navigator button pressed
    	case EKeyOK:
            iAppEngine->LaunchCurrent(iListBox->CurrentItemIndex());
            return (EKeyWasConsumed);
            break;

        default:
            // Let Listbox take care of its key handling
            return iListBox->OfferKeyEventL(aKeyEvent, aType);
            break;
        }
    }

// ---------------------------------------------------------
// CFileListContainer::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CFileListContainer::CountComponentControls() const
    {
    // return number of controls inside this container
    return 1; 
    }

// ---------------------------------------------------------
// CFileListContainer::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CFileListContainer::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
        {
        case 0:
            return iListBox;
        default:
            return NULL;
        }
    }

// ---------------------------------------------------------
// CFileListContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CFileListContainer::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    // drawing code 
    gc.SetPenStyle(CGraphicsContext::ENullPen);
    gc.SetBrushColor(KRgbGray);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.DrawRect(aRect);
    }

// ---------------------------------------------------------
// CFileListContainer::HandleControlEventL(
//     CCoeControl* aControl,TCoeEvent aEventType)
// ---------------------------------------------------------
//
void CFileListContainer::HandleControlEventL(
    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
    {
    }

// End of File  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -