⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 esimgroupuserview.cpp

📁 基于SIP协议的即时消息聊天功能设计,Symbian平台下实现
💻 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 + -