?? telbookview.cpp
字號:
/*
* ============================================================================
* Name : CTelBookView from CAknView
* Part of : Hello
* Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/
// INCLUDE FILES
#include <aknviewappui.h>
#include <avkon.hrh>
#include <EveryDay.rsg>
#include "EveryDay.hrh"
#include "TelBookView.h"
#include "TelBookContainer.h"
#include "EveryDayAppUi.h"
#include <akntitle.h>
#include <akncontext.h>
#include <eikaufty.h>
#include <eikmenup.h>
#include "BookInfoView.h"
#include "PHKServerBookEngine.h"
#include <EveryDay.mbg>
#include "common.h"
#include "FunGridView.h"
// ================= MEMBER FUNCTIONS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CTelBookView* CTelBookView::NewL(MSendTelphoneInfo* asend)
{
CTelBookView* self = NewLC(asend);
CleanupStack::Pop(self);
return self;
}
CTelBookView* CTelBookView::NewLC(MSendTelphoneInfo* asend)
{
CTelBookView* self = new (ELeave) CTelBookView(asend);
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
CTelBookView::CTelBookView(MSendTelphoneInfo* asend)
{
m_pBookEngine = NULL;
m_pSendinfo = asend;
}
// EPOC default constructor can leave.
void CTelBookView::ConstructL()
{
//BaseConstructL(R_HELLO_VIEW);
BaseConstructL(R_TELBOOK_VIEW);
// m_pBookEngine = CBookEngine::NewL();
}
// Destructor
CTelBookView::~CTelBookView()
{
// MEM_FREE(m_pBookEngine);
// m_pBookInfoArray.ResetAndDestroy();//重置并銷毀
}
// ---------------------------------------------------------
// TUid CTelBookView::Id()
// Returns Id of the view.
// ---------------------------------------------------------
TUid CTelBookView::Id() const
{
return KViewId10;
}
// ---------------------------------------------------------
// CTelBookView::HandleCommandL(TInt aCommand)
// Handles commands
// ---------------------------------------------------------
void CTelBookView::HandleCommandL(TInt aCommand)
{
switch(aCommand)
{
case ENewbookinfo:
{
m_pSendinfo->SendBookInfo(&m_pBookInfoArray, m_pBookInfoArray.Count());
((CBookInfoView*)AppUi()->View(KViewId11))->Setflag(0);
AppUi()->ActivateLocalViewL(KViewId11);
break;
}
case ESigninfo:
{
break;
}
case ELookinfo:
{
TInt listnum;
iContainer->GetListNum(listnum);
m_pSendinfo->SendBookInfo(&m_pBookInfoArray, listnum);
((CBookInfoView*)AppUi()->View(KViewId11))->Setflag(1);
AppUi()->ActivateLocalViewL(KViewId11);
break;
}
case EAmendinfo:
{
TInt listnum;
iContainer->GetListNum(listnum);
m_pSendinfo->SendBookInfo(&m_pBookInfoArray, listnum);
((CBookInfoView*)AppUi()->View(KViewId11))->Setflag(2);
m_pBookEngine->DeleteUserFromBook(m_pBookInfoArray[listnum]->GetItemID());
AppUi()->ActivateLocalViewL(KViewId11);
break;
}
case EDelinfo:
{
TInt nNum = iContainer->GetSelectedIndexL();
if (nNum>=0)
{
DeleteContact();
}
break;
}
case EUpinfo:
{
break;
}
case EDowninfo:
{
break;
}
case EHelpinfo:
{
break;
}
case EAknCmdMark://選擇
{
iContainer->HandleMarkCommandL (aCommand);
break;
}
case EAknCmdUnmark://取消
{
iContainer->HandleMarkCommandL (aCommand);
break;
}
case EAknUnmarkAll://全部取消
{
iContainer->HandleMarkCommandL (aCommand);
break;
}
case EAknMarkAll://全部選定
{
iContainer->HandleMarkCommandL (aCommand);
break;
}
case EAknSoftkeyBack:
{
AppUi()->ActivateLocalViewL(KViewId3);
break;
}
default:
{
AppUi()->HandleCommandL(aCommand);
break;
}
}
}
// ---------------------------------------------------------
// CTelBookView::HandleClientRectChange()
// Handles client rect change.
// ---------------------------------------------------------
void CTelBookView::HandleClientRectChange()
{
if (iContainer)
{
iContainer->SetRect(ClientRect());
}
}
// ---------------------------------------------------------
// CTelBookView::DoActivateL(...)
// Creates the Container class object.
// ---------------------------------------------------------
void CTelBookView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
TUid /*aCustomMessageId*/,
const TDesC8& /*aCustomMessage*/)
{
iContainer = new (ELeave) CTelBookContainer;
iContainer->SetMopParent(this);
TRect rc;
rc.SetRect(ClientRect().iTl, TSize(176, 144));
iContainer->ConstructL(rc);
m_pBookEngine = CBookEngine::NewL();
CreateNewContact();
//更新動態數組中的名片
GetContactFromPB();
iContainer->SetItemToListBox(m_pBookInfoArray);
// CreateNewContact();
//Adds a control to the control stack
AppUi()->AddToStackL(*this, iContainer);
}
// ---------------------------------------------------------
// CTelBookView::DoDeactivate()
// Deletes the Container class object.
// ---------------------------------------------------------
void CTelBookView::DoDeactivate()
{
if (iContainer)
{
AppUi()->RemoveFromStack(iContainer);
delete iContainer;
iContainer = NULL;
}
m_pBookInfoArray.ResetAndDestroy();//重置并銷毀
MEM_FREE(m_pBookEngine);
}
//更新動態數組中的名片
void CTelBookView::GetContactFromPB()
{
m_pBookInfoArray.ResetAndDestroy();
m_pBookEngine->UpdatePhoneBook(0, m_pBookInfoArray);
}
void CTelBookView::CreateNewContact()
{
//更新名片夾
m_pBookEngine->UpdatePhoneBook(1, m_pBookInfoArray);
}
void CTelBookView::DeleteContact()
{
if (m_pBookInfoArray.Count() <=0)
{
return;
}
TInt nResult;
iContainer->GetDeleteResult(nResult);
if (nResult)
{
TInt nIndex = iContainer->m_pListBox->CurrentItemIndex();
if (nIndex >= 0)
{
m_pBookEngine->DeleteUserFromBook(m_pBookInfoArray[nIndex]->GetItemID());
GetContactFromPB();
RefreshListBox(nIndex);
}
}
}
void CTelBookView::RefreshListBox(TInt aIndex)
{
if (m_pBookInfoArray.Count()!=0)
{
iContainer->SetItemToListBox(m_pBookInfoArray);
if (aIndex != 0)
{
iContainer->m_pListBox->SetCurrentItemIndexAndDraw(-1);
}
else
{
iContainer->m_pListBox->SetCurrentItemIndexAndDraw(0);
iContainer->ShowNoCard();
}
}
else
{
iContainer->SetItemToListBox(m_pBookInfoArray);
}
iContainer->m_pListBox->DrawNow();
}
// End of File
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -