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

📄 esimuseritemform.cpp

📁 基于SIP协议的即时消息聊天功能设计,Symbian平台下实现
💻 CPP
字号:
/**
* 
* @brief Definition of CESIMUserItemForm
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/

// INCLUDE FILES

// Class include
#include "ESIMUserItemForm.h"

// System includes
#include <AknPopupFieldText.h> // CAknPopupFieldText
#include <aknnotewrappers.h> 
#include <stringloader.h> 
#include <aknslider.h> // CAknSlider
#include <avkon.hrh> // Commands
#include <avkon.rsg> // R_AVKON_FORM_MENUPANE
#include <eikedwin.h> // CEikEdwin
#include <eikmenup.h> // CEikMenuPane
#include "ESIM.rsg"
#include "ESIM.hrh"

// CONSTANTS
// ================= MEMBER FUNCTIONS =======================

/**
* Symbian OS 2 phase constructor.
* Constructs the CESIMUserItemForm using the NewLC method, popping
* the constructed object from the CleanupStack before returning it.
* 
* @return The newly constructed CESIMUserItemForm
*/
CESIMUserItemForm* CESIMUserItemForm::NewL(CESIMUserItem& aItem, TBool& aSaveState)
{
	CESIMUserItemForm* self = new (ELeave) CESIMUserItemForm(aItem, aSaveState);
	CleanupStack::PushL(self);
	self->ConstructL();
	CleanupStack::Pop(self);
	return self;
}


/**
* Called by the framework whenver the 'Save' menu item is selected, and by the QuerySaveChangesL 
* method when the user answers yes to the save query.
* Saves the data from the forms controls, into the iOpponent.
* @return TBool ETrue if the form data has been saved, EFalse otherwise
*/
TBool CESIMUserItemForm::SaveFormDataL()
{
	iSaveState = EFalse;
	CEikEdwin* nameItem = static_cast <CEikEdwin*> (ControlOrNull(EESIMDlgUserNameEdwin));
	if (nameItem)
	{
		HBufC* name = nameItem->GetTextInHBufL();
		if (name)
		{
			iItem.SetNameL (name->AllocL());
			delete name;
		}
		else
		{
			CAknWarningNote* note = new (ELeave) CAknWarningNote();
			HBufC* text = StringLoader::LoadLC(R_FORM_USERNAME_EMPTY, iCoeEnv);
			note->ExecuteLD(*text);
			CleanupStack::PopAndDestroy(text);
			return EFalse;
		}
	}

	CEikEdwin* sipItem = static_cast <CEikEdwin*> (ControlOrNull(EESIMDlgUserSipAddressEdwin));
	if (sipItem)
	{
		HBufC* sip = sipItem->GetTextInHBufL();
		if (sip)
		{
			iItem.SetSipAddressL (sip->AllocL());
			delete sip;
		}
		else
		{
			CAknWarningNote* note = new (ELeave) CAknWarningNote();
			HBufC* text = StringLoader::LoadLC(R_FORM_USERSIPADDRESS_EMPTY, iCoeEnv);
			note->ExecuteLD(*text);
			CleanupStack::PopAndDestroy(text);
			return EFalse;
		}
	}
	iSaveState = ETrue;
	return ETrue;
}

/**
* Sets the forms contols using the values contained in iOpponent. Called when the form is 
* executed and when the user chooses to discard changes in QuerySaveChangesL (via DoNotSaveFormDataL).
*/
void CESIMUserItemForm::LoadFormValuesFromDataL()
{
	CEikEdwin* nameItem = static_cast <CEikEdwin*> (ControlOrNull(EESIMDlgUserNameEdwin));
	if (nameItem)
	{
		//HBufC* name = iItem.Name().AllocLC();
		//nameItem->SetTextL(name);
		nameItem->SetTextL(iItem.Name());
		//CleanupStack::PopAndDestroy(name);
	}

	CEikEdwin* sipItem = static_cast <CEikEdwin*> (ControlOrNull(EESIMDlgUserSipAddressEdwin));
	if (sipItem)
	{
		//HBufC* name = iItem.Name().AllocLC();
		//nameItem->SetTextL(name);
		sipItem->SetTextL(iItem.SipAddress());
		//CleanupStack::PopAndDestroy(name);
	}
}


/**
* Called by QuerySaveChangeL when the user chooses to discard changes made to the form.
* Loads the form values from iOpponent
*/
void CESIMUserItemForm::DoNotSaveFormDataL()
{
	LoadFormValuesFromDataL();
}

/**
* Called by the framework before the form is initialised
* Loads the form values from iOpponent ready for execution of the form
*/
void CESIMUserItemForm::PreLayoutDynInitL()
{
	CAknForm::PreLayoutDynInitL();
	LoadFormValuesFromDataL();
}


/**
* Called by the framework when a menu is displayed.
* Removes the default items from the options menu of the form for editing a fields label,
* adding a field and deleting a field
*/
void CESIMUserItemForm::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
{
	CAknForm::DynInitMenuPaneL(aResourceId,aMenuPane);

	if (aResourceId == R_AVKON_FORM_MENUPANE)
	{
		aMenuPane->SetItemDimmed(EAknFormCmdLabel, ETrue);
		aMenuPane->SetItemDimmed(EAknFormCmdAdd, ETrue);
		aMenuPane->SetItemDimmed(EAknFormCmdDelete, ETrue);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -