agenda.cpp
来自「在手机操作系统symbina上使用的一个脚本扩展语言的代码实现,可以参考用于自己」· C++ 代码 · 共 2,012 行 · 第 1/4 页
CPP
2,012 行
Day
Hour
Minute
OPL return value:
None
---------------------------------------------------------------------- */
void CAgendaOpx::TdSetDueDateL(OplAPI& aAPI,CAgendaOpx& /*aOpx*/)
{
TInt32 day = aAPI.PopInt32();
TInt32 month = aAPI.PopInt32();
TInt32 year = aAPI.PopInt32();
CAgnTodo* todo = (CAgnTodo*)aAPI.PopInt32();
CheckEntryType(todo, CAgnEntry::ETodo);
if (year==0 && month==0 && day==0)
{
// undated todo
todo->SetDueDate(Time::NullTTime());
}
else
{
if (year<1980 || year>2100 || month<1 || month>12 || day<1 || day>31)
User::Leave(KOplErrInvalidArgs);
todo->SetDueDate(TDateTime(year, (TMonth)(month-1), day-1, 0, 0, 0, 0));
}
aAPI.Push(0.0);
}
/* ----------------------------------------------------------------------
Set the duration of a todo
OPL parameters:
Handle of todo
days
OPL return value:
None
---------------------------------------------------------------------- */
void CAgendaOpx::TdSetDurationL(OplAPI& aAPI,CAgendaOpx& /*aOpx*/)
{
TInt32 days = aAPI.PopInt32();
CAgnTodo* todo = (CAgnTodo*)aAPI.PopInt32();
CheckEntryType(todo, CAgnEntry::ETodo);
if (days<0)
User::Leave(KOplErrInvalidArgs);
todo->SetDuration(TTimeIntervalDays(days));
aAPI.Push(0.0);
}
/* ----------------------------------------------------------------------
Get the list to which a todo belongs
OPL parameters:
Handle of todo
OPL return value:
todo list id
---------------------------------------------------------------------- */
void CAgendaOpx::TdGetListL(OplAPI& aAPI,CAgendaOpx& /*aOpx*/)
{
CAgnTodo* todo = (CAgnTodo*)aAPI.PopInt32();
CheckEntryType(todo, CAgnEntry::ETodo);
aAPI.Push((TInt32)todo->TodoListId().Value());
}
/* ----------------------------------------------------------------------
Set the priority of a todo
OPL parameters:
Handle of todo
OPL return value:
todo priority
---------------------------------------------------------------------- */
void CAgendaOpx::TdGetPriorityL(OplAPI& aAPI,CAgendaOpx& /*aOpx*/)
{
CAgnTodo* todo = (CAgnTodo*)aAPI.PopInt32();
CheckEntryType(todo, CAgnEntry::ETodo);
aAPI.Push((TInt32)todo->Priority());
}
/* ----------------------------------------------------------------------
Get the due date and time of a todo
OPL parameters:
Handle of todo
Year
Month
Day
Hour
Minute
OPL return value:
None
---------------------------------------------------------------------- */
void CAgendaOpx::TdGetDueDateL(OplAPI& aAPI,CAgendaOpx& /*aOpx*/)
{
TAny* day=aAPI.PopPtrInt32();
TAny* month=aAPI.PopPtrInt32();
TAny* year=aAPI.PopPtrInt32();
CAgnTodo* todo = (CAgnTodo*)aAPI.PopInt32();
CheckEntryType(todo, CAgnEntry::ETodo);
if (todo->DueDate()!=Time::NullTTime())
{
TDateTime due = todo->DueDate().DateTime();
aAPI.PutLong(day,due.Day()+1);
aAPI.PutLong(month,due.Month()+1);
aAPI.PutLong(year,due.Year());
}
else
{
aAPI.PutLong(day,0);
aAPI.PutLong(month,0);
aAPI.PutLong(year,0);
}
aAPI.Push(0.0);
}
/* ----------------------------------------------------------------------
Get the duration of a todo
OPL parameters:
Handle of todo
OPL return value:
days
---------------------------------------------------------------------- */
void CAgendaOpx::TdGetDurationL(OplAPI& aAPI,CAgendaOpx& /*aOpx*/)
{
CAgnTodo* todo = (CAgnTodo*)aAPI.PopInt32();
CheckEntryType(todo, CAgnEntry::ETodo);
aAPI.Push((TInt32)todo->Duration().Int());
}
/* ----------------------------------------------------------------------
Set the start time of an event
OPL parameters:
Handle of event
Year
Month
Day
Hour
Minute
OPL return value:
None
---------------------------------------------------------------------- */
void CAgendaOpx::EvSetStartDateL(OplAPI& aAPI,CAgendaOpx& /*aOpx*/)
{
TInt32 day = aAPI.PopInt32();
TInt32 month = aAPI.PopInt32();
TInt32 year = aAPI.PopInt32();
CAgnEvent* event = (CAgnEvent*)aAPI.PopInt32();
CheckEntryType(event, CAgnEntry::EEvent);
if (year<1980 || year>2100 || month<1 || month>12 || day<1 || day>31)
User::Leave(KOplErrInvalidArgs);
TDateTime date(year, (TMonth)(month-1), day-1, 0, 0, 0 ,0);
event->SetStartAndEndDate(date);
aAPI.Push(0.0);
}
/* ----------------------------------------------------------------------
Set the end time of an event
OPL parameters:
Handle of event
Year
Month
Day
Hour
Minute
OPL return value:
None
---------------------------------------------------------------------- */
void CAgendaOpx::EvSetEndDateL(OplAPI& aAPI,CAgendaOpx& /*aOpx*/)
{
TInt32 day = aAPI.PopInt32();
TInt32 month = aAPI.PopInt32();
TInt32 year = aAPI.PopInt32();
CAgnEvent* event = (CAgnEvent*)aAPI.PopInt32();
CheckEntryType(event, CAgnEntry::EEvent);
if (year<1980 || year>2100 || month<1 || month>12 || day<1 || day>31)
User::Leave(KOplErrInvalidArgs);
TDateTime date(year, (TMonth)(month-1), day-1, 0, 0, 0, 0);
if (AgnDateTime::IsLessThan(date, event->StartDate().DateTime()))
event->SetStartAndEndDate(date, date);
else
event->SetStartAndEndDate(event->StartDate(), date);
aAPI.Push(0.0);
}
/* ----------------------------------------------------------------------
Get the start time of an event
OPL parameters:
Handle of event
Year
Month
Day
Hour
Minute
OPL return value:
None
---------------------------------------------------------------------- */
void CAgendaOpx::EvGetStartDateL(OplAPI& aAPI,CAgendaOpx& /*aOpx*/)
{
TAny* day=aAPI.PopPtrInt32();
TAny* month=aAPI.PopPtrInt32();
TAny* year=aAPI.PopPtrInt32();
CAgnEvent* event = (CAgnEvent*)aAPI.PopInt32();
CheckEntryType(event, CAgnEntry::EEvent);
TDateTime d=event->StartDate().DateTime();
aAPI.PutLong(year,d.Year());
aAPI.PutLong(month,d.Month()+1);
aAPI.PutLong(day,d.Day()+1);
aAPI.Push(0.0);
}
/* ----------------------------------------------------------------------
Get the end time of an event
OPL parameters:
Handle of event
Year
Month
Day
Hour
Minute
OPL return value:
None
---------------------------------------------------------------------- */
void CAgendaOpx::EvGetEndDateL(OplAPI& aAPI,CAgendaOpx& /*aOpx*/)
{
TAny* day=aAPI.PopPtrInt32();
TAny* month=aAPI.PopPtrInt32();
TAny* year=aAPI.PopPtrInt32();
CAgnEvent* event = (CAgnEvent*)aAPI.PopInt32();
CheckEntryType(event, CAgnEntry::EEvent);
TDateTime d=event->EndDate().DateTime();
aAPI.PutLong(year,d.Year());
aAPI.PutLong(month,d.Month()+1);
aAPI.PutLong(day,d.Day()+1);
aAPI.Push(0.0);
}
/* ----------------------------------------------------------------------
Set the date of an anniversary
OPL parameters:
Handle of anniversary
Start year
Month
Day
OPL return value:
None
---------------------------------------------------------------------- */
void CAgendaOpx::AnSetDateL(OplAPI& aAPI,CAgendaOpx& /*aOpx*/)
{
TInt32 day = aAPI.PopInt32();
TInt32 month = aAPI.PopInt32();
TInt32 year = aAPI.PopInt32();
CAgnAnniv* anniv = (CAgnAnniv*)aAPI.PopInt32();
CheckEntryType(anniv, CAgnEntry::EAnniv);
if (year<-30000 || year>2100 || month<1 || month>12 || day<1 || day>31)
User::Leave(KOplErrInvalidArgs);
TDateTime date(1980, (TMonth)(month-1), day-1, 0, 0, 0, 0);
//anniv->SetStartAndEndDate(date);
CAgnRptDef *rptDef = CAgnRptDef::NewL();
CleanupStack::PushL(rptDef);
TAgnYearlyByDateRpt rpt;
rpt.SetStartDate(date);
rpt.SetInterval(1);
rpt.SetRepeatForever(ETrue);
rptDef->SetYearlyByDate(rpt);
anniv->SetRptDefL(rptDef);
CleanupStack::PopAndDestroy(); // CAgnRptDef
anniv->SetBaseYear(year);
anniv->SetHasBaseYear(ETrue);
aAPI.Push(0.0);
}
/* ----------------------------------------------------------------------
Set the show type of an anniversary
OPL parameters:
Handle of anniversary
Type:
0=none
1=base year
2=elapsed years
3=both
OPL return value:
None
---------------------------------------------------------------------- */
void CAgendaOpx::AnSetShowL(OplAPI& aAPI,CAgendaOpx& /*aOpx*/)
{
TInt16 type = aAPI.PopInt16();
CAgnAnniv* anniv = (CAgnAnniv*)aAPI.PopInt32();
CheckEntryType(anniv, CAgnEntry::EAnniv);
if (type<0 || type>3)
User::Leave(KOplErrInvalidArgs);
anniv->SetDisplayAs((CAgnAnniv::TDisplayAs)type);
aAPI.Push(0.0);
}
/* ----------------------------------------------------------------------
Get the date of an anniversary
OPL parameters:
Handle of anniversary
Year
Month
Day
OPL return value:
None
---------------------------------------------------------------------- */
void CAgendaOpx::AnGetDateL(OplAPI& aAPI,CAgendaOpx& /*aOpx*/)
{
TAny* day=aAPI.PopPtrInt32();
TAny* month=aAPI.PopPtrInt32();
TAny* year=aAPI.PopPtrInt32();
CAgnAnniv* anniv = (CAgnAnniv*)aAPI.PopInt32();
CheckEntryType(anniv, CAgnEntry::EAnniv);
TDateTime d=anniv->StartDate().DateTime();
if (anniv->HasBaseYear())
aAPI.PutLong(year,anniv->BaseYear().Int());
else
aAPI.PutLong(year,d.Year());
aAPI.PutLong(month,d.Month()+1);
aAPI.PutLong(day,d.Day()+1);
aAPI.Push(0.0);
}
/* ----------------------------------------------------------------------
Get the show type of an anniversary
OPL parameters:
Handle of anniversary
OPL return value:
Type:
0=none
1=base year
2=elapsed years
3=both
---------------------------------------------------------------------- */
void CAgendaOpx::AnGetShowL(OplAPI& aAPI,CAgendaOpx& /*aOpx*/)
{
CAgnAnniv* anniv = (CAgnAnniv*)aAPI.PopInt32();
CheckEntryType(anniv, CAgnEntry::EAnniv);
aAPI.Push((TInt16)anniv->DisplayAs());
}
/* ----------------------------------------------------------------------
Add a new todo list to the file
OPL parameters:
Handle of list
OPL return value:
Entry id
---------------------------------------------------------------------- */
void CAgendaOpx::LiAddL(OplAPI& aAPI,CAgendaOpx& aOpx)
{
CAgnTodoList* list = (CAgnTodoList*)aAPI.PopInt32();
if (list==NULL)
User::Leave(KOplErrInvalidArgs);
TAgnEntryId id = aOpx.iModel->AddTodoListL(list);
aAPI.Push((TInt32)id.Value());
}
/* ----------------------------------------------------------------------
Change the position of a todo list
OPL parameters:
Old position of todo list
New position of todo list
OPL return value:
None
---------------------------------------------------------------------- */
void CAgendaOpx::LiChangePositionL(OplAPI& aAPI,CAgendaOpx& aOpx)
{
TInt newPos = aAPI.PopInt32();
TInt oldPos = aAPI.PopInt32();
if (oldPos<0 || newPos<0 ||
oldPos>aOpx.iModel->TodoListCount() || newPos>aOpx.iModel->TodoListCount())
User::Leave(KOplErrInvalidArgs);
aOpx.iModel->ChangeTodoListOrderL(oldPos, newPos);
aAPI.Push(0.0);
}
/* ----------------------------------------------------------------------
Update a todo list
OPL parameters:
Handle of todo list
OPL return value:
None
---------------------------------------------------------------------- */
void CAgendaOpx::LiModifyL(OplAPI& aAPI,CAgendaOpx& aOpx)
{
CAgnTodoList* list = (CAgnTodoList*)aAPI.PopInt32();
if (list==NULL)
User::Leave(KOplErrInvalidArgs);
aOpx.iModel->UpdateTodoListL(list);
aAPI.Push(0.0);
}
/* ----------------------------------------------------------------------
Delete a todo list
OPL parameters:
Handle of todo list
OPL return value:
None
---------------------------------------------------------------------- */
void CAgendaOpx::LiDeleteL(OplAPI& aAPI,CAgendaOpx& aOpx)
{
CAgnTodoList* list = (CAgnTodoList*)aAPI.PopInt32();
if (list==NULL)
User::Leave(KOplErrInvalidArgs);
aOpx.iModel->DeleteTodoListL(list);
aAPI.Push(0.0);
}
/* ----------------------------------------------------------------------
Fetch an agenda todo list by ID
OPL parameters:
ID of list
OPL return value:
Handle of list
---------------------------------------------------------------------- */
void CAgendaOpx::LiFetchL(OplAPI& aAPI,CAgendaOpx& aOpx)
{
TAgnId id(aAPI.PopInt32());
CAgnTodoList* list = aOpx.iModel->FetchTodoListL(id);
aAPI.Push((TInt32)list);
}
/* ----------------------------------------------------------------------
Create a new todo list
OPL parameters:
None
OPL return value:
Handle to todo list
---------------------------------------------------------------------- */
void CAgendaOpx::LiNewL(OplAPI& aAPI,CAgendaOpx& /*aOpx*/)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?