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

📄 logexeventform.cpp

📁 Log Engine的使用
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CLogExEventForm from LogExEventForm.h
*  Part of  : LogExample
*  Created  : 26.05.2005 by Forum Nokia  
*  Implementation notes:
*  Version  : 1.0
*  Copyright: Nokia Corporation
* ============================================================================*/


//INCLUDE FILES
#include "LogExEventForm.h"
#include <logexample.rsg>
#include <eikedwin.h> // CEikEdwin

#include "logexample.hrh"

//CONSTANTS
_LIT(KNoData,"No data");

// ================= PUBLIC =======================

// ----------------------------------------------------------
// CLogExEventForm::NewL(CLogEvent& aLogEvent)
// Two phased constructor
// ----------------------------------------------------------
//
CLogExEventForm* CLogExEventForm::NewL(CLogEvent& aLogEvent)
	{

    CLogExEventForm* self = new (ELeave) CLogExEventForm(aLogEvent);
    CleanupStack::PushL(self);
    self->ConstructL();
    CleanupStack::Pop(self);
    return self;
	
	}

// ================= PRIVATE =======================

// ----------------------------------------------------------
// CLogExEventForm::CLogExEventForm(CLogEvent& aLogEvent):iLogEvent(aLogEvent)
// Default constructor
// ----------------------------------------------------------
//
CLogExEventForm::CLogExEventForm(CLogEvent& aLogEvent):iLogEvent(aLogEvent)
	{
	}

// ----------------------------------------------------------
// CLogExEventForm::PreLayoutDynInitL()
// Initializes the form from the base class
// ----------------------------------------------------------
//
void CLogExEventForm::PreLayoutDynInitL()
	{

	CAknForm::PreLayoutDynInitL();
	
	CEikEdwin* formField1 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin01));
	if (formField1)
		{
		HBufC* name = iLogEvent.Direction().AllocLC(); // Direction field
		formField1->SetTextL(name);
		CleanupStack::PopAndDestroy(name);
		}
	
	CEikEdwin* formField2 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin02));
	if (formField2)
		{
		HBufC* name = iLogEvent.Description().AllocLC(); // Description field
		formField2->SetTextL(name);
		CleanupStack::PopAndDestroy(name);
		}
	
	CEikEdwin* formField3 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin03));
	if (formField3)
		{
		TBuf<KMaxTimeFormatSpec> buffer;
		iLogEvent.Time().FormatL(buffer, TTimeFormatSpec()); // Time field
		HBufC* name = buffer.AllocLC();
		formField3->SetTextL(name);
		CleanupStack::PopAndDestroy(name);
		}
	
	CEikEdwin* formField4 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin04));
	if (formField4)
		{
		TBuf<KMaxShortDateFormatSpec> buffer;
		iLogEvent.Time().FormatL(buffer, TShortDateFormatSpec()); // Date field
		HBufC* name = buffer.AllocLC();
		formField4->SetTextL(name);
		CleanupStack::PopAndDestroy(name);
		}
	
	CEikEdwin* formField5 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin05));
	if (formField5)
		{
		HBufC* name = iLogEvent.RemoteParty().AllocLC(); // RemoteParty field
		formField5->SetTextL(name);
		CleanupStack::PopAndDestroy(name);
		}
	
	CEikEdwin* formField6 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin06));
	if (formField6)
		{
		HBufC* name = iLogEvent.Number().AllocLC(); // Number field
		formField6->SetTextL(name);
		CleanupStack::PopAndDestroy(name);
		}
	
	CEikEdwin* formField7 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin07));
	if (formField7)
		{
		HBufC* name = iLogEvent.Subject().AllocLC(); // Subject field
		formField7->SetTextL(name);
		CleanupStack::PopAndDestroy(name);
		}
	
	CEikEdwin* formField8 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin08));
	if (formField8)
		{
		TBuf<32> buffer;
		buffer.AppendNum(iLogEvent.Duration(),32); // Duration field
		HBufC* name = buffer.AllocLC();
		formField8->SetTextL(name);
		CleanupStack::PopAndDestroy(name);
		}
	
	CEikEdwin* formField9 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin09));
	if (formField9)
		{
		TBuf<32> buffer;
		buffer.AppendNum(iLogEvent.DurationType(),32); // DurationType field
		HBufC* name = buffer.AllocLC(); 
		formField9->SetTextL(name);
		CleanupStack::PopAndDestroy(name);	
		}
	
	CEikEdwin* formField10 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin10));
	if (formField10)
		{
		TBuf<32> buffer;
		buffer.AppendNum(iLogEvent.Id(),32); // Id field
		HBufC* name = buffer.AllocLC(); 
		formField10->SetTextL(name);
		CleanupStack::PopAndDestroy(name);
		}
	
	
	CEikEdwin* formField11 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin11));
	if (formField11)
		{
		TBuf<32> buffer;
		buffer.AppendNum(iLogEvent.Link(),32); // Link field
		HBufC* name = buffer.AllocLC(); 
		formField11->SetTextL(name);
		CleanupStack::PopAndDestroy(name);
		}
	
	CEikEdwin* formField12 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin12));
	if (formField12)
		{
		TBuf<32> buffer;
		buffer.AppendNum(iLogEvent.Contact(),32); // Contact field
		HBufC* name = buffer.AllocLC();
		formField12->SetTextL(name);
		CleanupStack::PopAndDestroy(name);
		}
	
	CEikEdwin* formField13 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin13));
	if (formField13)
		{
		HBufC* name = iLogEvent.Status().AllocLC(); // Status field
		formField13->SetTextL(name);
		CleanupStack::PopAndDestroy(name);
		}
	
	CEikEdwin* formField14 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin14));
	if (formField14)
		{
		HBufC* name = iLogEvent.EventType().Name().AllocLC(); // EventType field
		formField14->SetTextL(name);
		CleanupStack::PopAndDestroy(name);
		}
	
	CEikEdwin* formField15 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin15));
	if (formField15)
		{
		
		// This conversion is done just to show the data field for the user 
		// if there is anything
		if(iLogEvent.Data() != KNullDesC8) 
			{ 
			TBuf8<32> name8 = iLogEvent.Data(); // Data field
			TBuf16<32> name16;
			name8.Copy(name16); 
			HBufC* name = name16.AllocLC();
			formField15->SetTextL(name);
			CleanupStack::PopAndDestroy(name);
			}
		else
			{
			TBuf<32> nodata;
			nodata.Copy(KNoData);
			HBufC* name = nodata.AllocLC();
			formField15->SetTextL(name);
			CleanupStack::PopAndDestroy(name);
			} 

		}
	}

//End of file

⌨️ 快捷键说明

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