?? esimgroupuserview.cpp
字號:
/*
============================================================================
Name : CESIMGroupUserView from ESIMView.h
Author :
Version :
Copyright : Your copyright notice
Description : CESIMGroupUserView implementation
============================================================================
*/
// INCLUDE FILES
#include <aknviewappui.h>
#include <avkon.hrh>
#include <ESIM.rsg>
#include "ESIM.hrh"
#include "ESIMGroupUserView.h"
#include "ESIMGroupUserContainer.h"
#include "ESIMUserItem.h"
#include <eikspane.h>
#include <aknappui.h>
#include <avkon.rsg>
#include <stringloader.h>
#include <aknnavi.h>
#include <akntabgrp.h>
#include <aknnavide.h>
#include <barsread.h>
#include <eikmobs.h>
#include <eikmenup.h>
#include <stringloader.h>
#include <aknlists.h>
#include <aknpopup.h>
#include "ESIMItemEngine.h"
#include "ESIMGroupContainer.h"
// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CESIMGroupUserView::ConstructL(const TRect& aRect)
// EPOC two-phased constructor
// ---------------------------------------------------------
//
void CESIMGroupUserView::ConstructL()
{
BaseConstructL( R_ESIM_GROUP_USER_VIEW );
//設置標簽
/*CEikStatusPane *sp =((CAknAppUi*)iEikonEnv->EikAppUi())->StatusPane();
iNaviPane =(CAknNavigationControlContainer*)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
iNaviDecorator=iNaviPane->CreateNavigationLabelL(_L("Setting"));
iNaviPane->PushL(*iNaviDecorator);*/
}
// ---------------------------------------------------------
// CESIMGroupUserView::~CESIMGroupUserView()
// destructor
// ---------------------------------------------------------
//
CESIMGroupUserView::~CESIMGroupUserView()
{
/*iNaviPane->Pop(iNaviDecorator);
if(NULL!=iNaviDecorator)
{
delete iNaviDecorator;
iNaviDecorator=NULL;
}*/
if ( iContainer )
{
AppUi()->RemoveFromViewStack( *this, iContainer );
}
delete iContainer;
//delete iNaviDecorator;
}
// ---------------------------------------------------------
// TUid CESIMGroupUserView::Id()
//
// ---------------------------------------------------------
//
TUid CESIMGroupUserView::Id() const
{
return KGroupUserViewId;
}
// ---------------------------------------------------------
// CESIMGroupUserView::HandleCommandL(TInt aCommand)
// takes care of view command handling
// ---------------------------------------------------------
//
void CESIMGroupUserView::HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
case EAknSoftkeyBack:
{
AppUi()->HandleCommandL(EESIMCmdActiveGroupView);
break;
}
case EESIMGroupUserCmdDelete:
{
iContainer->DeleteSelectedL();
iContainer->RefreshListL();
break;
}
case EESIMGroupCmdAddToGroup:
{
AddUserToGroup();
iContainer->RefreshListL();
break;
}
default:
{
AppUi()->HandleCommandL( aCommand );
break;
}
}
}
// ---------------------------------------------------------
// CESIMGroupUserView::HandleClientRectChange()
// ---------------------------------------------------------
//
void CESIMGroupUserView::HandleClientRectChange()
{
if ( iContainer )
{
iContainer->SetRect( ClientRect() );
}
}
// ---------------------------------------------------------
// CESIMGroupUserView::DoActivateL(...)
//
// ---------------------------------------------------------
//
void CESIMGroupUserView::DoActivateL(
const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
const TDesC8& /*aCustomMessage*/)
{
if (!iContainer)
{
iContainer = new (ELeave) CESIMGroupUserContainer(iEngine);
iContainer->SetMopParent(this);
iContainer->ConstructL( ClientRect(),this);
AppUi()->AddToStackL( *this, iContainer );
}
}
// ---------------------------------------------------------
// CESIMGroupUserView::DoDeactivate()
//
// ---------------------------------------------------------
//
void CESIMGroupUserView::DoDeactivate()
{
if ( iContainer )
{
AppUi()->RemoveFromViewStack( *this, iContainer );
}
delete iContainer;
iContainer = NULL;
}
void CESIMGroupUserView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
{
if (aResourceId == R_ESIM_GROUP_USER_VIEW_MENU)
{
aMenuPane->SetItemDimmed(EESIMGroupUserCmdDelete,iContainer->IsContactsOnListBox());
}
}
void CESIMGroupUserView::AddUserToGroup()
{
// First phase construction of menu list
CAknSinglePopupMenuStyleListBox* savedGameMenuList =
new (ELeave) CAknSinglePopupMenuStyleListBox;
CleanupStack::PushL(savedGameMenuList);
// Create a popuplist to show the menu list in
CAknPopupList* popupList = CAknPopupList::NewL(
savedGameMenuList,
R_AVKON_SOFTKEYS_OK_BACK);
CleanupStack::PushL(popupList);
// Second phase construction of menulist
savedGameMenuList->ConstructL(popupList,EAknListBoxMenuList);
// Set up scroll bars
SetupScrollBarsL (*savedGameMenuList);
// Set up menu items
CTextListBoxModel* model = savedGameMenuList->Model(); // not taking ownership
model->SetOwnershipType (ELbmOwnsItemArray);
CDesCArray* savedGameMenuListArray = STATIC_CAST(CDesCArray*, model->ItemTextArray());
//CDesCArray *groups = iEngine->GetContactGroupsL();
_LIT (KStringHeader, "%S");
TBuf <16> aString;
for (TInt i = 0; i< iEngine->UserItemCount(); i++)
{
TPtrC ptr = ((iEngine->UserItem(i))->Name())->Des();
aString.Format(KStringHeader(), &ptr);
savedGameMenuListArray->AppendL (aString);
}
// Set title
HBufC* title;
title = StringLoader::LoadLC(R_SAVED_GAME_MENU_LIST_TITLE); // Pushes title onto the Cleanup Stack.
popupList->SetTitleL(*title);
CleanupStack::PopAndDestroy(title);
// Show the menu in the popup list
TInt popupOk = popupList->ExecuteLD();
CleanupStack::Pop(popupList);
// if the user selected a level to play, play the game at that level
if (popupOk)
{
//TDesC level = (*savedGameMenuListArray)[savedGameMenuList->CurrentItemIndex()];
TInt userIndex = savedGameMenuList->CurrentItemIndex();
//TDesC level = (*savedGameMenuListArray)[index];
/*iEngine->GetSelectedContactL(iContainer->ListBox());
iEngine->GetSelectedContactGroupL(groupIndex);*/
// TInt t = iContainer->ListBox()->CurrentItemIndex();
TInt t = iEngine->GetCurrentGrouuIndex();
iEngine->AddUserToGroupL(userIndex, iEngine->GetCurrentGrouuIndex());
CleanupStack::PopAndDestroy(savedGameMenuList);
//PlayGame (aSavedGameName, level);
}
// otherwise return to the saved game list
else
CleanupStack::PopAndDestroy(savedGameMenuList);
}
/**
* Creates vertical scrollbars for the list, which appear automatically when required.
*
*/
void CESIMGroupUserView::SetupScrollBarsL(CEikListBox& aListBox)
{
aListBox.CreateScrollBarFrameL(ETrue);
aListBox.ScrollBarFrame()->SetScrollBarVisibilityL(
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -