亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? taskmanagerappview.cpp

?? c++下s60終端對終端傳輸協議
?? CPP
字號:
/*
* ============================================================================
*  Name     : CTaskManagerAppView from TaskManagerAppView.cpp
*  Part of  : TaskManager
*  Created  : 03/13/2005 by Forum Nokia
*  Version  : 1.2
*  Copyright: Nokia Corporation
* ============================================================================
*/

// INCLUDE FILES
#include <coemain.h>
#include <aknlists.h>			// CAknSingleStyleListBox
#include <barsread.h>			// TResourceReader
#include <aknnotewrappers.h>	// CAknInformationNote
#include <HttpTaskManager.rsg>
#include <stringloader.h>
#include <e32std.h>
#include <aknquerydialog.h>
#include "TaskManager.hrh"
#include "TaskManagerAppView.h"
#include "TaskManagerAppUi.h"
#include "Response.h"

// CONSTANTS
#define KListPosition TPoint(0,0)
_LIT(KTab, "\t");
_LIT(KError, "Error: %d");
_LIT(KNoTasks, "No Tasks!");
_LIT(KLoadingTasks, "Loading tasks...");
_LIT(KCompletingTask, "Completing task...");
_LIT(KTaskCompleted, "\n\nTask completed?");
_LIT(KInvalidTask, "Invalid task. Cannot complete.");
_LIT(KTaskFormat, "%d\t%S");
_LIT(KOpeningConnection, "Opening connection...");
const TInt KMaxErrorLength = 30;


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

// constructor
CTaskManagerAppView::CTaskManagerAppView(CTaskManagerAppUi& aAppUi)
	:	iAppUi(aAppUi)
	{
	iStatusText = KNoTasks;
	}

// destructor
CTaskManagerAppView::~CTaskManagerAppView()
	{
	delete iTaskList;
	iTaskList = 0;
	}

// ----------------------------------------------------
// CTaskManagerAppView::NewL()
// Two-phased constructor.
// ----------------------------------------------------
//
CTaskManagerAppView *CTaskManagerAppView::NewL(const TRect& aRect, CTaskManagerAppUi& aAppUi)
	{
    CTaskManagerAppView *self = new(ELeave) CTaskManagerAppView(aAppUi);
    CleanupStack::PushL(self);
    self->ConstructL(aRect);
    CleanupStack::Pop(self);
    return self;
	}

// ----------------------------------------------------
// CTaskManagerAppView::ConstructL()
// Symbian OS default constructor can leave.
// ----------------------------------------------------
//	
void CTaskManagerAppView::ConstructL(const TRect& aRect)
	{
    // Create a window for this application view
    CreateWindowL();
	
	CreateListL();
	
    // Set the windows size
    SetRect(aRect);

    // Activate the window, which makes it ready to be drawn
    ActivateL();
	}

// ----------------------------------------------------
// CTaskManagerAppView::ConstructL()
// Creates a listbox that is used for showing the tasks
// to the user.
// ----------------------------------------------------
//
void CTaskManagerAppView::CreateListL()
	{
	iTaskList = new (ELeave) CAknSingleStyleListBox;
	iTaskList->SetContainerWindowL( *this );
	
	iTaskList->SetListBoxObserver( this );
	
	TResourceReader reader;
	iEikonEnv->CreateResourceReaderLC( reader, R_TASKMANAGER_TASKLIST );
	iTaskList->ConstructFromResourceL( reader );

	iTaskList->MakeVisible( EFalse );
	
	CleanupStack::PopAndDestroy(); // ResourceReader
	}


// ----------------------------------------------------
// CTaskManagerAppView::Draw()
// This function is used for window server-initiated 
// redrawing of controls, and for some 
// application-initiated drawing. Here we show the 
// status text to the user.
// ----------------------------------------------------
//
void CTaskManagerAppView::Draw(const TRect& /*aRect*/) const
	{
    // Get the standard graphics context 
    CWindowGc &gc = SystemGc();
    
    // Gets the control's extent
    TRect rect = Rect();
    
    // Clears the screen
    gc.Clear(rect);
    
    // status text is showed only if iTaskList isn't visible
    if( !iTaskList->IsVisible() )
    	{
   		gc.UseFont( iCoeEnv->NormalFont() );
   		
   		// This is done to center the text
   		TInt pointX = rect.Width() / 2 -
   					  iCoeEnv->NormalFont()->TextWidthInPixels( iStatusText ) / 2;

   		TInt pointY = rect.Height() / 2 -
   					  iCoeEnv->NormalFont()->HeightInPixels() / 2;
   					  
		gc.DrawText( iStatusText, TPoint( pointX, pointY ) );
    	}

	}

// ----------------------------------------------------
// CTaskManagerAppView::HandleListBoxEventL()
// Handles list box events. When enter key is pressed, 
// the selected task is marked completed.
// ----------------------------------------------------
//
void CTaskManagerAppView::HandleListBoxEventL(CEikListBox* aListBox, 
                                              TListBoxEvent aListBoxEvent)
	{
	if( aListBoxEvent == MEikListBoxObserver::EEventEnterKeyPressed )
		{

		const MDesCArray* items = aListBox->Model()->MatchableTextArray();
		
		// We get the currently selected item's text to print it in a query
		TPtrC pointer = items->MdcaPoint( aListBox->CurrentItemIndex() );
		
		TInt tabOffSet = pointer.Find(KTab);
		// id of the task was not found.
		if (tabOffSet == KErrNotFound || tabOffSet == 0)
			{
			CAknInformationNote *informationNote = new(ELeave) CAknInformationNote;
			informationNote->ExecuteLD(KInvalidTask);
			return;
			}
		
		TLex lex(pointer.Left(tabOffSet));
		TInt taskId;
		User::LeaveIfError(lex.Val(taskId));
		
		// (KMaxTaskLength +20) space for task and KTaskCompleted
		TBuf<KMaxTaskLength + 20> message = pointer.Mid(tabOffSet+1);
		message.Append( KTaskCompleted ); 
		
		// A waiting confirmation note
		CAknQueryDialog* note = CAknQueryDialog::NewL(); 
		CleanupStack::PushL(note);
		note->SetPromptL( message );
		CleanupStack::Pop(note);
		
		iAppUi.SetViewBusyL(ETrue);
		
		// The query is shown
		if( note->ExecuteLD( R_TASKMANAGER_TASK_CONFIRMATION_QUERY ) )
			{
			// show 'Completing task' to the user.
			ShowStatus(KCompletingTask);
			
			iAppUi.ShowConnectingCbaL(ETrue);
			iAppUi.Model().MarkTaskDoneL(taskId);
			iTransactionStatus = EMarkingTaskDone;
			}		
		
		iAppUi.SetViewBusyL(EFalse);
		}	
	}

// ----------------------------------------------------
// CTaskManagerAppView::DeleteSelectedTaskL()
// Removes the selected task from the listbox.
// ----------------------------------------------------
//
void CTaskManagerAppView::DeleteSelectedTaskL()
	{
	CTextListBoxModel* model = iTaskList->Model();
	CDesCArray* itemArray = static_cast<CDesCArray*>( model->ItemTextArray() );
	
	TInt currentItem = iTaskList->CurrentItemIndex();
	
	itemArray->Delete( currentItem );
	
	AknListBoxUtils::HandleItemRemovalAndPositionHighlightL( iTaskList,
															 currentItem,
															 ETrue );

	iTaskList->DrawNow();		
	
	// no more tasks, show 'No tasks' to user.													 
	if( model->NumberOfItems() == 0 )
		{
		iTaskList->MakeVisible( EFalse );
		}
	}

// ----------------------------------------------------
// CTaskManagerAppView::ReadTasksL()
// Reads tasks from aResponse and adds them to the listbox.
// ----------------------------------------------------
//
void CTaskManagerAppView::ReadTasksL( const CResponse& aResponse )
	{
	CTextListBoxModel* model = iTaskList->Model();
	
	model->SetOwnershipType( ELbmOwnsItemArray ); // Just to underline the relation
	CDesCArray* itemArray = static_cast<CDesCArray*>( model->ItemTextArray() );
										 
	itemArray->Reset();
	
	TInt taskCount = aResponse.TaskCount();
	// reserve space for task description and for taskid
	TBuf<KMaxTaskLength+10> taskDesc;
	for (TInt i = 0; i < taskCount; i++)
		{
		TBuf<KMaxTaskLength> desc = aResponse.TaskDescription(i);
		taskDesc.Format(KTaskFormat, aResponse.TaskId(i), &desc);
		itemArray->AppendL(taskDesc);
		}
	
	// If there are items in the listbox, make the listbox visible.
	if( model->NumberOfItems() > 0 )
		{
		iTaskList->HandleItemAdditionL();
		iTaskList->DrawNow();
		iTaskList->MakeVisible( ETrue );
		}
	}

// ----------------------------------------------------
// CTaskManagerAppView::CountComponentControls()
// Gets the number of controls contained in a compound 
// control. 
// ----------------------------------------------------
//
TInt CTaskManagerAppView::CountComponentControls() const
	{
	TInt count = 0;
	if (iTaskList)
		{
		count++;
		}
		
	return count;
	}

// ----------------------------------------------------
// CTaskManagerAppView::ComponentControl()
// Gets the specified component of a compound control.
// ----------------------------------------------------
//
CCoeControl* CTaskManagerAppView::ComponentControl( TInt aIndex ) const
	{
	switch( aIndex )
		{
		case 0:
			return iTaskList;
		default:
			return 0;
		};
	}

// ----------------------------------------------------
// CTaskManagerAppView::SizeChanged()
// Responds to size changes to sets the size and 
// position of the contents of this control. 
// ----------------------------------------------------
//	
void CTaskManagerAppView::SizeChanged()
	{
	iTaskList->SetExtent( KListPosition, iTaskList->MinimumSize() );	
	}

// ----------------------------------------------------
// CTaskManagerAppView::OfferKeyEventL()
// When a key event occurs, the control framework calls 
// this function for each control on the control stack, 
// until one of them can process the key event 
// (and returns EKeyWasConsumed).
// ----------------------------------------------------
//	
TKeyResponse CTaskManagerAppView::OfferKeyEventL( const TKeyEvent& aKeyEvent,
												  TEventCode aType )
	{
	if( iTaskList && iTaskList->IsVisible() )
		{
		return iTaskList->OfferKeyEventL( aKeyEvent, aType );
		}
	else
		{
		return EKeyWasNotConsumed;
		}
	}

// ----------------------------------------------------
// CTaskManagerAppView::OpeningConnectionL()
// Called when a GPRS connection is opened.
// ----------------------------------------------------
//	
void CTaskManagerAppView::OpeningConnectionL()
	{
	ShowStatus(KOpeningConnection);
	iAppUi.ShowConnectingCbaL(ETrue);
	}
	
// ----------------------------------------------------
// CTaskManagerAppView::ConnectingL()
// Called when an HTTP transaction is initiated. 
// ----------------------------------------------------
//
void CTaskManagerAppView::ConnectingToServerL(const TBool& aLoadingTasks)
	{
	if (aLoadingTasks)
		{
		ShowStatus(KLoadingTasks);
		}
	else
		{
		ShowStatus(KCompletingTask);
		}

	// show cancel button.
	iAppUi.ShowConnectingCbaL(ETrue);
	}

// ----------------------------------------------------
// CTaskManagerAppView::SuccessL()
// Called when the HTTP transaction is successfully 
// finished. 
// ----------------------------------------------------
//	
void CTaskManagerAppView::SuccessL(const CResponse& aResponse)
	{
	// even though HTTP transaction was successful, errors might have occurred
	// in the server database.
	if (aResponse.HasError())
		{
		CAknInformationNote *informationNote = new(ELeave) CAknInformationNote;
		informationNote->ExecuteLD(aResponse.Error());
		}
	// no errors.
	else
		{
		// we were completing a task, remove it from the listbox.
		if (iTransactionStatus == EMarkingTaskDone)
			{
			iTransactionStatus = EFetchingTasks;
			DeleteSelectedTaskL();
			}
		// we were loading tasks, show them in the listbox.
		else
			{
			ReadTasksL(aResponse);
			}
		}
	
	// will show 'No tasks' or if tasks exist, a list of tasks is shown.
	ShowStatus(KNoTasks);
	
	iAppUi.ShowConnectingCbaL(EFalse);
	}

// ----------------------------------------------------
// CTaskManagerAppView::FailedL()
// Called when the HTTP transaction failed. 
// ----------------------------------------------------
//	
void CTaskManagerAppView::FailedL(const TInt& aError)
	{
	TBuf<KMaxErrorLength> error;
	error.Format(KError, aError);
	CAknInformationNote *informationNote = new(ELeave) CAknInformationNote;
	informationNote->ExecuteLD(error);
	
	// will show 'No tasks' or if tasks exist, a list of tasks is shown.
	ShowStatus(KNoTasks);

	iAppUi.ShowConnectingCbaL(EFalse);
	}
	
// ----------------------------------------------------
// CTaskManagerAppView::CancelledL()
// Called when the HTTP transaction was cancelled by 
// the user. 
// ----------------------------------------------------
//	
void CTaskManagerAppView::CancelledL()
	{
	// will show 'No tasks' or if tasks exist, a list of tasks is shown.
	ShowStatus(KNoTasks);

	iAppUi.ShowConnectingCbaL(EFalse);
	}

// ----------------------------------------------------
// CTaskManagerAppView::ErrorL()
// Called when connection settings are invalid and the 
// HTTP transaction cannot be initiated. This occurs 
// e.g. when username and/or password is not set.
// ----------------------------------------------------
//	
void CTaskManagerAppView::ErrorL(const TDesC& aErrorMsg)
	{
	CAknInformationNote *informationNote = new(ELeave) CAknInformationNote;
	informationNote->ExecuteLD(aErrorMsg);
	
	// will show 'No tasks' or if tasks exist, a list of tasks is shown.
	ShowStatus(KNoTasks);

	iAppUi.ShowConnectingCbaL(EFalse);
	}

// ----------------------------------------------------
// CTaskManagerAppView::QueryIapL()
// Opens up a querylist dialog containing all IAPs. User 
// selects from the list the IAP that he/she wants to use.
// ----------------------------------------------------
//	
	
TBool CTaskManagerAppView::QueryIapL(TUint32& aId, const TUint32& aDefaultId)
	{
	TBool retval = EFalse;
	RArray<TIap>& iaps = iAppUi.Model().Iaps();
	TInt iapCount = iaps.Count();
	
	CDesCArrayFlat* iapArray = new (ELeave) CDesCArrayFlat(iapCount);
	CleanupStack::PushL(iapArray);
	
	TInt selectedIndex = 0;
	
	// Load all IAPs to the list.
	for (TInt i = 0; i < iapCount; i++)
		{
		if (iaps[i].iId == aDefaultId)
			{
			selectedIndex = i;
			}			
		iapArray->AppendL(iaps[i].iName);
		}
		
	TInt index(0);
	CAknListQueryDialog* query = new (ELeave) CAknListQueryDialog(&index);
	query->PrepareLC(R_TASKMANAGER_IAP_LIST_QUERY);
	query->SetItemTextArray(iapArray);
	query->SetOwnershipType(ELbmDoesNotOwnItemArray);
	query->ListBox()->SetCurrentItemIndex(selectedIndex);
	if (query->RunLD())
		{
		aId = iaps[index].iId;
		retval = ETrue;
		}
		
	CleanupStack::PopAndDestroy(iapArray);	
	return retval;
	}

// ----------------------------------------------------
// CTaskManagerAppView::ShowStatus()
// Shows proper status text to the user.
// ----------------------------------------------------
//	
void CTaskManagerAppView::ShowStatus(const TDesC& aStatus)
	{
	iStatusText = aStatus;
	
	// Show 'No tasks' or if tasks exist, show list of tasks.
	if (aStatus == KNoTasks)
		{
		if (iTaskList->Model()->NumberOfItems() > 0)
			{
			iTaskList->MakeVisible(ETrue);
			}
		}
	// Show only status text.
	else
		{
		iTaskList->MakeVisible(EFalse);
		}
		
	DrawNow();
	}
	
// End of file

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
洋洋成人永久网站入口| 亚洲gay无套男同| 天使萌一区二区三区免费观看| 久久国产精品99久久久久久老狼| 成人在线综合网| 日韩欧美在线综合网| 亚洲人成精品久久久久| 九九**精品视频免费播放| 91久久久免费一区二区| 久久先锋影音av鲁色资源| 亚洲国产日韩精品| 成人性生交大片免费看中文| 日韩精品资源二区在线| 天堂蜜桃一区二区三区| 色悠久久久久综合欧美99| 国产人伦精品一区二区| 精品一区二区国语对白| 日韩一卡二卡三卡四卡| 亚洲国产aⅴ成人精品无吗| 99视频精品免费视频| 国产午夜精品一区二区三区嫩草 | 国产精品久久久久一区二区三区共| 日韩电影在线一区二区| 欧美羞羞免费网站| 自拍偷拍欧美激情| 91蝌蚪国产九色| 亚洲欧美一区二区三区国产精品| 久久99精品一区二区三区三区| 日韩色视频在线观看| 国产一区视频导航| 91精品国产黑色紧身裤美女| 天天综合色天天| 91精品婷婷国产综合久久性色| 亚洲成av人综合在线观看| 欧美无砖专区一中文字| 亚洲成av人片一区二区三区 | 国产精品66部| 久久久不卡网国产精品二区| 国产麻豆9l精品三级站| 国产女人18水真多18精品一级做 | 久久成人综合网| 2023国产精品视频| 国产成人高清视频| 亚洲图片激情小说| 欧美午夜宅男影院| 日韩精品三区四区| 精品国产91亚洲一区二区三区婷婷| 美女国产一区二区| 国产校园另类小说区| 91社区在线播放| 日日摸夜夜添夜夜添亚洲女人| 91精品国产aⅴ一区二区| 国内精品写真在线观看 | 精品乱人伦一区二区三区| 国产精品影音先锋| 日韩毛片视频在线看| 欧美日韩在线观看一区二区 | 亚洲综合一二区| 91精品一区二区三区久久久久久 | 日本道免费精品一区二区三区| 亚洲亚洲人成综合网络| 精品久久久网站| 9l国产精品久久久久麻豆| 日韩有码一区二区三区| 久久综合色8888| 日本高清免费不卡视频| 另类小说色综合网站| 亚洲丝袜精品丝袜在线| 91精品国产综合久久精品图片| 另类小说一区二区三区| 亚洲免费观看高清完整版在线观看熊| 欧美日韩的一区二区| 岛国av在线一区| 日韩电影一二三区| 国产精品国产三级国产aⅴ无密码| 欧美日韩亚洲综合一区二区三区| 九一九一国产精品| 亚洲成人一区在线| 综合自拍亚洲综合图不卡区| 91.com视频| 91精品福利在线| 国产91精品久久久久久久网曝门| 亚洲成av人片在线观看无码| 国产精品理伦片| 精品福利av导航| 91麻豆精品国产91久久久久久| 91在线视频免费观看| 韩国欧美一区二区| 午夜精品福利一区二区三区蜜桃| 国产精品午夜在线观看| 久久综合色一综合色88| 日韩三区在线观看| 欧美日韩激情在线| 91国内精品野花午夜精品| 粉嫩一区二区三区性色av| 男人的天堂亚洲一区| 亚洲成a人片在线不卡一二三区| 国产精品三级av| 国产色婷婷亚洲99精品小说| 日韩精品一区在线观看| 在线播放中文一区| 日本道精品一区二区三区| 97久久超碰国产精品| 成人av中文字幕| 成人丝袜18视频在线观看| 九九在线精品视频| 国内久久精品视频| 精品午夜久久福利影院| 美女在线一区二区| 精品在线播放免费| 毛片av一区二区三区| 美腿丝袜亚洲综合| 九九视频精品免费| 激情欧美一区二区| 激情六月婷婷久久| 国产麻豆日韩欧美久久| 久久66热re国产| 狠狠色丁香婷婷综合久久片| 国内精品视频666| 国产成+人+日韩+欧美+亚洲| 国产精品888| www.日韩精品| 欧美性xxxxxx少妇| 欧美一区二区免费| 久久精品夜色噜噜亚洲a∨| www国产精品av| 国产视频一区在线播放| 中文字幕一区二区三区av| 亚洲女厕所小便bbb| 亚洲午夜久久久久中文字幕久| 亚洲图片欧美视频| 日韩不卡一区二区三区| 韩国三级电影一区二区| 成人激情午夜影院| 色香色香欲天天天影视综合网| 91九色02白丝porn| 日韩欧美的一区| 亚洲国产精品成人综合| 亚洲综合免费观看高清完整版在线| 一区二区三区中文字幕在线观看| 亚洲一卡二卡三卡四卡无卡久久| 日韩专区一卡二卡| 国产成人精品免费在线| 91婷婷韩国欧美一区二区| 欧美日韩精品欧美日韩精品一| 日韩欧美在线综合网| 国产精品成人网| 图片区小说区国产精品视频| 国产一区二区三区免费看| 99久久精品免费看国产| 91精品婷婷国产综合久久性色 | 国产99精品国产| 欧美主播一区二区三区| 日韩精品一区二区三区三区免费| 日本一区二区三区四区在线视频 | 亚洲视频 欧洲视频| 丝袜美腿亚洲综合| 成人午夜激情片| 欧美一区二区在线免费播放| 中文字幕免费不卡在线| 美女爽到高潮91| 色欧美乱欧美15图片| 久久久久久毛片| 日韩黄色小视频| aaa欧美色吧激情视频| 欧美大黄免费观看| 亚洲与欧洲av电影| 懂色av一区二区三区蜜臀| 7777精品伊人久久久大香线蕉经典版下载 | 一二三四区精品视频| 国产精品18久久久久久久久久久久 | 国产91在线观看| 欧美高清一级片在线| 中文字幕在线不卡视频| 精彩视频一区二区三区| 欧美日韩精品欧美日韩精品一综合| 国产调教视频一区| 久久精品久久精品| 在线播放视频一区| 亚洲午夜免费视频| 在线影院国内精品| 亚洲婷婷综合久久一本伊一区| 国产精选一区二区三区| 精品久久久久久无| 美国毛片一区二区三区| 欧美电影在哪看比较好| 亚洲综合小说图片| 97se亚洲国产综合自在线不卡| 久久亚洲影视婷婷| 另类调教123区| 精品日韩99亚洲| 麻豆91精品91久久久的内涵| 9191久久久久久久久久久| 婷婷久久综合九色国产成人| 欧美色偷偷大香| 香蕉乱码成人久久天堂爱免费| 欧美日韩国产片| 肉色丝袜一区二区| 日韩一区二区三区四区| 日韩电影免费一区|