?? shoppinglistdocument.cpp
字號:
/* Copyright (c) 2004, Nokia. All rights reserved */
// INCLUDE FILES
#include "ShoppingListDocument.h"
#include "ShoppingListAppUi.h"
#include "ShoppingItem.h"
// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CShoppingListDocument::NewL()
// ---------------------------------------------------------
//
CShoppingListDocument* CShoppingListDocument::NewL( CEikApplication& aApp )
{
CShoppingListDocument* self = NewLC( aApp );
CleanupStack::Pop( self );
return self;
}
// ---------------------------------------------------------
// CShoppingListDocument::NewLC()
// ---------------------------------------------------------
//
CShoppingListDocument* CShoppingListDocument::NewLC( CEikApplication& aApp )
{
CShoppingListDocument* self = new ( ELeave ) CShoppingListDocument( aApp );
CleanupStack::PushL( self );
self->ConstructL();
return self;
}
// ---------------------------------------------------------
// CShoppingListDocument::ConstructL()
// 2nd phase constructor.
// ---------------------------------------------------------
//
void CShoppingListDocument::ConstructL()
{
// No implementation required
}
// ---------------------------------------------------------
// CShoppingListDocument::CShoppingListDocument()
// Constructor
// ---------------------------------------------------------
//
CShoppingListDocument::CShoppingListDocument( CEikApplication& aApp )
: CAknDocument( aApp )
{
// No implementation required
}
// ---------------------------------------------------------
// CShoppingListDocument::~CShoppingListDocument()
// Destructor
// ---------------------------------------------------------
//
CShoppingListDocument::~CShoppingListDocument()
{
iItemList.ResetAndDestroy();
}
// ---------------------------------------------------------
// CShoppingListDocument::CreateAppUiL()
// ---------------------------------------------------------
//
CEikAppUi* CShoppingListDocument::CreateAppUiL()
{
return ( static_cast <CEikAppUi*>( new ( ELeave ) CShoppingListAppUi ) );
}
// ---------------------------------------------------------
// CShoppingListDocument::StoreL()
// ---------------------------------------------------------
//
void CShoppingListDocument::StoreL( CStreamStore& aStore,
CStreamDictionary& aStreamDic ) const
{
RStoreWriteStream stream;
TStreamId id = stream.CreateLC( aStore );
TInt count = iItemList.Count();
stream.WriteInt16L( static_cast<TInt16>( count ) );
for ( TInt index = 0; index < count; ++index )
{
( static_cast<CShoppingItem*>( iItemList[index] ) )->
ExternalizeL( stream );
}
stream.CommitL();
aStreamDic.AssignL( Application()->AppDllUid(), id );
CleanupStack::PopAndDestroy(); // stream
}
// ---------------------------------------------------------
// CShoppingListDocument::RestoreL()
// ---------------------------------------------------------
//
void CShoppingListDocument::RestoreL( const CStreamStore& aStore,
const CStreamDictionary& aStreamDic )
{
TStreamId id = aStreamDic.At( Application()->AppDllUid() );
RStoreReadStream stream;
stream.OpenLC( aStore, id );
TInt count = stream.ReadInt16L();
for ( TInt index = 0; index < count; ++index )
{
CShoppingItem* item = CShoppingItem::NewL();
CleanupStack::PushL( item );
item->InternalizeL( stream );
User::LeaveIfError( iItemList.Append( item ) );
CleanupStack::Pop( item );
}
CleanupStack::PopAndDestroy(); // stream
}
// ---------------------------------------------------------
// CShoppingListDocument::OpenFileL()
// ---------------------------------------------------------
//
CFileStore* CShoppingListDocument::OpenFileL( TBool aDoOpen,
const TDesC& aFilename, RFs& aFs )
{
return CEikDocument::OpenFileL( aDoOpen, aFilename, aFs );
}
// ---------------------------------------------------------
// CShoppingListDocument::Item()
// ---------------------------------------------------------
//
CShoppingItem* CShoppingListDocument::Item( TInt aIndex )
{
CShoppingItem* item = static_cast<CShoppingItem*>( iItemList[aIndex] );
return item;
}
// ---------------------------------------------------------
// CShoppingListDocument::InsertItemL()
// ---------------------------------------------------------
//
void CShoppingListDocument::InsertItemL( CShoppingItem* aItem, TInt aIndex )
{
User::LeaveIfError( iItemList.Insert( aItem, aIndex ) );
}
// ---------------------------------------------------------
// CShoppingListDocument::RemoveItem()
// ---------------------------------------------------------
//
void CShoppingListDocument::RemoveItem( TInt aIndex )
{
CShoppingItem* item = static_cast<CShoppingItem*>( iItemList[aIndex] );
iItemList.Remove( aIndex );
delete item;
}
// ---------------------------------------------------------
// CShoppingListDocument::ItemCount()
// ---------------------------------------------------------
//
TInt CShoppingListDocument::ItemCount()
{
return iItemList.Count();
}
// End of File
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -