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

📄 todolist.cpp

📁 symbian手机上记事本的程序
💻 CPP
字号:
#include"ToDo.h"
#include"ToDoList.h"

CToDoList* CToDoList::NewLC(TInt aGranularity)
	{
	CToDoList* self = new(ELeave)CToDoList(aGranularity);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
	}

CToDoList* CToDoList::NewL(TInt aGranularity)
	{
	CToDoList* self = CToDoList::NewLC(aGranularity);
	CleanupStack::Pop(self);
	return self;
	}

CToDoList::~CToDoList()
	{
	if (iArray !=NULL)
		{
		iArray->ResetAndDestroy();
		delete iArray;
		}
	}

CToDoList::CToDoList(TInt aGranularity):iGranularity(aGranularity)
	{

	}

void CToDoList::ConstructL()
	{
	iArray = new(ELeave)CArrayPtrFlat<CToDo>(iGranularity);
	}

void CToDoList::AddToDoL(CToDo* aToDo )
	{
	iArray->AppendL(aToDo);
	}
TInt CToDoList::Count() const
	{
	return iArray->Count();
	}

void CToDoList::InsertL( TInt aIndex, CToDo* aToDo )
	{
	iArray->InsertL(aIndex, aToDo);
	}

void CToDoList::ModifyL(CToDo* aToDo , TInt aIndex )
	{
	RemoveToDo(aIndex);
	InsertL(aIndex, aToDo);
	}

void CToDoList::RemoveToDo( TInt aIndex )
	{
	CToDo* todo = iArray->At(aIndex);
	if (todo)
		{
		iArray->Delete(aIndex);
	// 	delete todo;局部变量不用删除,出了函数就没有了!
		}

	}

TInt CToDoList::Find(TDesC& aTitle)
	{
	TInt len = iArray->Count();// 比较对象,数组中的每条信息
	for (TInt i = 0; i < len; ++i)
		{
		if((*iArray)[i]->GetSubject().Compare(aTitle))
			return i;
		}
	return -1;
	}

CArrayPtr<CToDo>* CToDoList::ToDoList()
	{
	return iArray;
	}

CToDo* CToDoList::At( TInt aIndex )
	{
	
	return iArray->At(aIndex);
	}

CToDo* CToDoList::operator[](TInt index)
	{
	return (*iArray)[index];
	}

const CToDo* CToDoList::operator[](TInt index) const
	{
	return (*iArray)[index];
	}

void CToDoList::ExternalizeL( RWriteStream& aStream ) const
	{
	TInt32 count = Count();
	aStream << count;

	for (TInt i = 0; i < count; i++)
		{
		aStream << *((*iArray)[i]);
		}
	}

void CToDoList::InternalizeL( RReadStream& aStream )
	{
	if (iArray != NULL)
		{
		iArray->ResetAndDestroy(); 
		}
	else
		{
		iArray = new(ELeave)CArrayPtrFlat<CToDo>(iGranularity);
		}
	TInt32 count = 0;
	aStream >> count;
	for (TInt i = 0; i < count; i++)
		{
		CToDo* thing = CToDo::NewLC(aStream);
		AddToDoL(thing);
		CleanupStack::Pop(thing);
		}

	}

/*void CToDoList::Print() const
	{
	TInt count = Count();
	console->Printf(_L("The count is %d\n\n"), Count());
	for (TInt i = 0; i < count;i++)
		{
		 (*iArray)[i]->Print();//打印每个成员信息
		}
	}
*/

⌨️ 快捷键说明

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