📄 createcardview.cpp
字号:
#include <aknviewappui.h>
#include <avkon.hrh>
#include <FrMes.rsg>
#include "FrMes.hrh"
#include "CreateCardView.h"
#include "CreateCardContainer.h"
#include "CardClipview.h"
#include <akntitle.h>
#include "FrMesAppUi.h"
#include "BookEngine.h"
// ================= MEMBER FUNCTIONS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CCreateCardView* CCreateCardView::NewL()
{
CCreateCardView* self = CCreateCardView::NewLC();
CleanupStack::Pop(self);
return self;
}
CCreateCardView* CCreateCardView::NewLC()
{
CCreateCardView* self = new(ELeave)CCreateCardView();
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
CCreateCardView::CCreateCardView()
{
}
// EPOC default constructor can leave.
void CCreateCardView::ConstructL()
{
BaseConstructL(R_CREATECARD_VIEW);
}
// Destructor
CCreateCardView::~CCreateCardView()
{
if (iContainer)
{
AppUi()->RemoveFromStack(iContainer);
}
delete iContainer;
iContainer = NULL;
}
// ---------------------------------------------------------
// TUid CCreateCardView::Id()
// Returns Id of the view.
// ---------------------------------------------------------
TUid CCreateCardView::Id() const
{
return KCreateViewId;
}
// ---------------------------------------------------------
// CCreateCardView::HandleCommandL(TInt aCommand)
// Handles commands
// ---------------------------------------------------------
void CCreateCardView::HandleCommandL(TInt aCommand)
{
switch(aCommand)
{
case EFrMesCommandconfirm:
{
TBuf<8> aFamilyName;
TBuf<8> aFristName;
TBuf<16> aTelephone;
aFamilyName.Zero();
aFristName.Zero();
aTelephone.Zero();
iContainer->GetInputFamilyName(aFamilyName);
iContainer->GetInputFirstName(aFristName);
iContainer->GetInputTelephone(aTelephone);
CFrMesAppUi* pApp = (CFrMesAppUi*)CEikonEnv::Static()->AppUi();
if ((aFamilyName.Length()==0)&&(aFristName.Length()==0)&&(aTelephone.Length()!=0))
{
_LIT(KName, "(未命名)");//待修改,读资源
aFamilyName.Append(KName);
}
if ((aTelephone.Length()==0)&&(aFamilyName.Length()!=0)&&(aFristName.Length()!=0))
{
_LIT(KTelephone, "(无名片详情)");
aTelephone.Append(KTelephone);
}
if ((aTelephone.Length()==0)&&(aFamilyName.Length()==0)&&(aFristName.Length()==0))
{
AppUi()->ActivateLocalViewL(KCardClipViewId);
return;
}
CBookInfo * aBookInfo = CBookInfo::NewL();
aBookInfo->SetLastName(aFamilyName);
aBookInfo->SetFirstName(aFristName);
aBookInfo->SetTelephone(aTelephone);
aBookInfo->SetItemID(-1);
pApp->iPhoneBookArray->AppendL(aBookInfo);
pApp->iBookEngine->UpdatePhoneBook(1,*(pApp->iPhoneBookArray));
AppUi()->ActivateLocalViewL(KCardClipViewId);
}
break;
case EFrMesCommandcancel:
{
AppUi()->ActivateLocalViewL(KCardClipViewId);
}
break;
default:
break;
}
}
// ---------------------------------------------------------
// CCreateCardView::HandleClientRectChange()
// Handles client rect change.
// ---------------------------------------------------------
void CCreateCardView::HandleClientRectChange()
{
if (iContainer)
{
iContainer->SetRect(ClientRect());
}
}
// ---------------------------------------------------------
// CCreateCardView::DoActivateL(...)
// Creates the Container class object.
// ---------------------------------------------------------
void CCreateCardView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
TUid /*aCustomMessageId*/,
const TDesC8& /*aCustomMessage*/)
{
iContainer = new (ELeave) CCreateCardContainer;
iContainer->SetMopParent(this);
TRect rc;
rc.SetRect(ClientRect().iTl, TSize(176, 144));
iContainer->ConstructL(rc/*ClientRect()*/);
AppUi()->AddToStackL(*this, iContainer);
//标题
CEikStatusPane* statusPane = StatusPane();
TBuf<32> sTmpTitle;
CEikonEnv::Static()->ReadResource(sTmpTitle, R_FRMES_VIEW_TITLE_CREATECARD);
CAknTitlePane* titlePane = (CAknTitlePane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle));
titlePane->SetTextL(sTmpTitle);
}
// ---------------------------------------------------------
// CCreateCardView::DoDeactivate()
// Deletes the Container class object.
// ---------------------------------------------------------
void CCreateCardView::DoDeactivate()
{
if (iContainer)
{
AppUi()->RemoveFromStack(iContainer);
}
delete iContainer;
iContainer = NULL;
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -