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

📄 shoppinglistdocument.cpp

📁 为symbian7.0c操作系统series60系列开发的购物软件
💻 CPP
字号:
/* Copyright (c) 2003, Nokia. All rights reserved */

#include "ShoppingListDocument.h"
#include "ShoppingListAppUi.h"
#include "ShoppingItem.h"

CShoppingListDocument* CShoppingListDocument::NewL(CEikApplication& aApp)
    {
    CShoppingListDocument* self = NewLC(aApp);
    CleanupStack::Pop(self);
    return self;
    }

CShoppingListDocument* CShoppingListDocument::NewLC(CEikApplication& aApp)
    {
    CShoppingListDocument* self = new (ELeave) CShoppingListDocument(aApp);
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
    }

void CShoppingListDocument::ConstructL()
    {
	//	No implementation required
    }    

CShoppingListDocument::CShoppingListDocument(CEikApplication& aApp) : CAknDocument(aApp) 
    {
	//	No implementation required
    }

CShoppingListDocument::~CShoppingListDocument()
    {
	iItemList.ResetAndDestroy();
    }

CEikAppUi* CShoppingListDocument::CreateAppUiL()
    {
	return (static_cast <CEikAppUi*> (new (ELeave) CShoppingListAppUi)); 
    }

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
    }


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
    }

CFileStore* CShoppingListDocument::OpenFileL(TBool aDoOpen,const TDesC& aFilename,RFs& aFs)
	{
	return 	CEikDocument::OpenFileL( aDoOpen, aFilename, aFs);
	}


CShoppingItem* CShoppingListDocument::Item(TInt aIndex)
	{
	CShoppingItem* item = static_cast<CShoppingItem*> (iItemList[aIndex]);
	return item;
	}


void CShoppingListDocument::InsertItemL(CShoppingItem* aItem, TInt aIndex)
	{
	User::LeaveIfError( iItemList.Insert( aItem, aIndex)  );
	}


void CShoppingListDocument::RemoveItem(TInt aIndex)
	{
	CShoppingItem* item = static_cast<CShoppingItem*> (iItemList[aIndex]);
	iItemList.Remove( aIndex );
	delete item;
	}


TInt CShoppingListDocument::ItemCount()
	{
	return iItemList.Count();
	}














⌨️ 快捷键说明

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