?? classscheduleappui.cpp
字號:
/*
* ============================================================================
* Name : CClassScheduleAppUi from ClassScheduleAppUi.cpp
* Part of : ClassSchedule
* Created : 2005-8-30 by
* Implementation notes:
* Initial content was generated by Series 60 AppWizard.
* Version :
* Copyright:
* ============================================================================
*/
// INCLUDE FILES
#include "ClassScheduleAppUi.h"
#include "ClassScheduleContainer.h"
#include "ClassScheduleDB.h"
#include "ClassSchedule.hrh"
#include <aknlists.h>
#include <aknPopup.h>
#include <eikbtgpc.h>
#include <ClassSchedule.rsg>
#include <avkon.hrh>
#include <aknquerydialog.h>
#include <aknglobalnote.h>
#include <aknmessagequerydialog.h>
#include <eikmenup.h>
#include <akntitle.h>
_LIT(KColon, ": ");
_LIT(KEnter, "\n");
//-----------------------------------------------
//顯示提示信息
//-----------------------------------------------
void ShowNotify(TDesC &aBuf)
{
TRequestStatus status; //TRequestStatus:當(dāng)操作完成的時候請求的狀態(tài)也隨之完成終結(jié)
CAknGlobalNote* globalNote = CAknGlobalNote::NewLC();
globalNote->ShowNoteL(status, EAknGlobalInformationNote, aBuf ); //顯示提示信息
User::WaitForRequest(status); //等待請求
CleanupStack::PopAndDestroy();
}
// ================= MEMBER FUNCTIONS =======================
//
// ----------------------------------------------------------
// CClassScheduleAppUi::ConstructL()
// ?implementation_description
// ----------------------------------------------------------
void CClassScheduleAppUi::ConstructL()
{
iDB = new(ELeave) CClassScheduleDB(); //給成員變量分配空間
BaseConstructL(); //調(diào)用基類的第二階段構(gòu)造函數(shù)
CEikStatusPane* sp = StatusPane();
iNaviPane = (CAknNavigationControlContainer*)sp->ControlL(
TUid::Uid(EEikStatusPaneUidNavi));
//返回一個CEikStatusPane類型的ID號,強制轉(zhuǎn)換成CAknNavigationControlContainer類型
iDecoratedTabGroup = iNaviPane->ResourceDecorator();
if (iDecoratedTabGroup)
{
iTabGroup = (CAknTabGroup*) iDecoratedTabGroup->DecoratedControl();
//在導(dǎo)航窗格中得到當(dāng)前標(biāo)簽組(控制中的)
}
iTabGroup->SetActiveTabByIndex(iDB->iWeekId); //加亮活躍標(biāo)簽
iAppContainer = new (ELeave) CClassScheduleContainer;
iAppContainer->SetMopParent(this); //設(shè)置父類
iAppContainer->ConstructL( ClientRect(), this);
AddToStackL( iAppContainer );
CheckCurCourse(); //檢查當(dāng)前課程
}
// ----------------------------------------------------
// CClassScheduleAppUi::~CClassScheduleAppUi()
// Destructor
// Frees reserved resources
// ----------------------------------------------------
CClassScheduleAppUi::~CClassScheduleAppUi()
{
delete iDecoratedTabGroup;
if (iAppContainer)
{
RemoveFromStack( iAppContainer );
delete iAppContainer;
}
delete iDB;
}
// ------------------------------------------------------------------------------
// CClassScheduleAppUi::::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
// 這個函數(shù)僅在顯示菜單前被 EIKON 結(jié)構(gòu)調(diào)用。它的默認(rèn)命令空,可以忽略不記。
//應(yīng)用程序可以根據(jù)應(yīng)用程序數(shù)據(jù)的狀態(tài)激活菜單的各個項。
// 包含處理菜單條的亮/ 暗
// ------------------------------------------------------------------------------
void CClassScheduleAppUi::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
{
if(aResourceId==R_CLASSSCHEDULE_MENU)
{
if(iIsSearchStatus)
{
aMenuPane->SetItemDimmed(EClassScheduleCmdAppModify, ETrue);
aMenuPane->SetItemDimmed(EClassScheduleCmdAppDelete, ETrue);
aMenuPane->SetItemDimmed(EClassScheduleCmdAppDeleteAll, ETrue);
aMenuPane->SetItemDimmed(EClassScheduleCmdAppSearch, ETrue);
}
}
}
// ----------------------------------------------------
// CClassScheduleAppUi::HandleKeyEventL(
// const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
// ?implementation_description
// ----------------------------------------------------
TKeyResponse CClassScheduleAppUi::HandleKeyEventL(
const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
{
if ( iTabGroup == NULL )
{
return EKeyWasNotConsumed;
}
TInt active = iTabGroup->ActiveTabIndex(); //返回當(dāng)前活躍標(biāo)簽的索引
TInt count = iTabGroup->TabCount(); //標(biāo)簽數(shù)組中標(biāo)簽的個數(shù)
switch ( aKeyEvent.iCode )
{
case EKeyLeftArrow:
if ( active > 0 )
{
active--;
iTabGroup->SetActiveTabByIndex( active );
}
break;
case EKeyRightArrow:
if( (active + 1) < count )
{
active++;
iTabGroup->SetActiveTabByIndex( active );
}
break;
default:
return EKeyWasNotConsumed;
break;
}
return EKeyWasConsumed;
}
// ----------------------------------------------------
// CClassScheduleAppUi::HandleCommandL(TInt aCommand)
// ?implementation_description
// ----------------------------------------------------
void CClassScheduleAppUi::HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
case EAknSoftkeyExit: //back鍵
if(iIsSearchStatus)
{
iAppContainer->CreateListBoxL();
iAppContainer->SetCurrentItemIndex(0);
CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
TName title;
CAknTitlePane* iTitlePane = (CAknTitlePane *)sp->ControlL(TUid::Uid(EEikStatusPaneUidTitle));
CEikonEnv::Static()->ReadResource(title, R_QTN_APP_CAPTION_STRING);
//從資源文件獲取title的信息
iTitlePane->SetTextL(title);
break;
}
case EEikCmdExit:
Exit();
break;
case EClassScheduleCmdAppDetail:
if(iIsSearchStatus) //查尋詳細(xì)信息
CmdSearchDetail();
else
CmdDetail();
break;
case EClassScheduleCmdAppModify:
CmdModify();
break;
case EClassScheduleCmdAppDelete:
CmdDelete();
break;
case EClassScheduleCmdAppDeleteAll:
CmdDeleteAll();
break;
case EClassScheduleCmdAppSearchForName:
CmdSearchForName();
break;
case EClassScheduleCmdAppSearchForAddr:
CmdSearchForAddr();
break;
case EClassScheduleCmdAppSearchForTime:
CmdSearchForTime();
break;
case EClassScheduleCmdAppSearchForTeacher:
CmdSearchForTeacher();
break;
case EClassScheduleCmdAppSearchForRemark:
CmdSearchForRemark();
break;
default:
break;
}
}
//----------------------------------------------
//向前
//----------------------------------------------
void CClassScheduleAppUi::CmdPrev()
{
TInt active = iTabGroup->ActiveTabIndex(); //返回當(dāng)前活躍標(biāo)簽的索引
TInt count = iTabGroup->TabCount(); //標(biāo)簽數(shù)組中標(biāo)簽的個數(shù)
if(active > 0)
{
active --;
}
else
{
active = count - 1;
}
iTabGroup->SetActiveTabByIndex(active); //加亮活躍標(biāo)簽
iDB->iWeekId = (TWeekId)active; //iweekId TInt 型記錄星期的值
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -