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

📄 calendarapiexampleentryview.cpp

📁 该源码实现个人日程管理以及备忘功能
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CCalendarAPIexampleEntryView from CalendarAPIexampleEntryView.h
*  Part of  : CalendarAPIexample
*  Created  : 02/22/2005 by Forum Nokia
*  Version  : 1.0
*  Copyright: Nokia Corporation
* ============================================================================
*/

// INCLUDE FILES
#include <aknviewappui.h>
#include <aknnotewrappers.h> 
#include <CalendarAPIexample.rsg>
#include "CalendarAPIexampleEntryView.h"
#include "CalendarAPIexampleEntryContainer.h"
#include "CalendarAPIexampleEntriesView.h"
#include "CalendarAPIexampleSearchView.h"
#include "CalendarAPIexampleDocument.h"

// CONSTANTS
_LIT(KDeleteConfirmation, "Supprimer cette entr閑 ?");


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

// destructor
CCalendarAPIexampleEntryView::~CCalendarAPIexampleEntryView()
	{
	if (iContainer)
    	{
        // Removes Container from View control stack.
        AppUi()->RemoveFromViewStack(*this, iContainer);
        }

    delete iContainer;
    iContainer = NULL;
   	}
	
// Symbian OS default constructor can leave.
void CCalendarAPIexampleEntryView::ConstructL()
	{
	BaseConstructL(R_CALENDARAPIEXAMPLE_ENTRY_VIEW);
	iDocument = static_cast<CCalendarAPIexampleDocument*>(AppUi()->Document());
	}
	
// ----------------------------------------------------
// CCalendarAPIexampleEntryView::Id()
// Returns ID of View
// ----------------------------------------------------
//	
TUid CCalendarAPIexampleEntryView::Id() const
	{
	return KEntryViewId;
	}
	
// ----------------------------------------------------
// CCalendarAPIexampleEntryView::HandleCommandL()
// Takes care of command handling
// ----------------------------------------------------
//			
void CCalendarAPIexampleEntryView::HandleCommandL( TInt aCommand )
    {
    switch (aCommand)
    	{
    	case ECalendarAPIexampleCmdDelete:
    		DoDeleteL();
    		break;
    	case EAknSoftkeyDone:
    		DoSaveL();
    		break;
        default:
			break;
		}
    }

// ----------------------------------------------------
// CCalendarAPIexampleEntryView::HandleClientRectChange()
// Handles client rect change
// ----------------------------------------------------
//     
void CCalendarAPIexampleEntryView::HandleClientRectChange()
    {
	if ( iContainer )
		{
		iContainer->SetRect( ClientRect() );
		}
	}

// ----------------------------------------------------
// CCalendarAPIexampleEntryView::DoActivateL()
// Gets called when the view is activated. Creates 
// the entry container, adds it to view control stack
// and sets it visible.
// ----------------------------------------------------
// 		
void CCalendarAPIexampleEntryView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
												TUid /*aCustomMessageId*/,
												const TDesC8& /*aCustomMessage*/ )
	{
    if ( !iContainer )
        {
        
        iContainer = CCalendarAPIexampleEntryContainer::NewL(	ClientRect(), 
        														iDocument->EntryForModificationL(iModify));
		iContainer->SetMopParent(this);

		// Adds Container to View control stack.
		AppUi()->AddToStackL( *this, iContainer );

		// Requires to display the default screen.
		iContainer->MakeVisible( ETrue );        
		}    	
	}

// ----------------------------------------------------
// CCalendarAPIexampleEntryView::DoDeactivate()
// Gets called when the view is deactivated. Removes
// the entry container from view control stack and
// deletes it.
// ----------------------------------------------------
// 		
void CCalendarAPIexampleEntryView::DoDeactivate()
	{
    if ( iContainer )
        {
        // Removes Container from View control stack.
        AppUi()->RemoveFromViewStack(*this, iContainer );
        }

    delete iContainer;
    iContainer = NULL;
	
	}

// ----------------------------------------------------
// CCalendarAPIexampleEntryView::DoSaveL()
// Requests the model to save the current entry. If user
// input is invalid, an information note about it is 
// shown. Otherwise a proper view is activated.
// ----------------------------------------------------
// 		
void CCalendarAPIexampleEntryView::DoSaveL()
	{
	// User input invalid, show an information note about it.
	if (!iContainer->SaveL())
		{
		CAknInformationNote* note = new (ELeave) CAknInformationNote;
		HBufC* errorMsg = CCoeEnv::Static()->AllocReadResourceLC(R_CALENDARAPIEXAMPLE_INVALID_DATA);
		note->ExecuteLD(*errorMsg);
		CleanupStack::PopAndDestroy(errorMsg);
		}
	// User input valid.
	else
		{
		iDocument->SaveL();
		// We were modifying entry, activate entries view or search view
		if (iModify)
			{
			// After modification, entries still exist in the given search range, activate entries view.
			if (iDocument->EntryCount() > 0)
				{
				AppUi()->ActivateLocalViewL(KEntriesViewId);
				}
			// After modification, no entries exist anymore in the given search range, activate search view.
			else
				{
    			AppUi()->ActivateLocalViewL(KSearchViewId);    				
				}
			}
		// We were adding an entry, activate search view.
		else
			{
			AppUi()->ActivateLocalViewL(KSearchViewId);
			}
		}
	}

// ----------------------------------------------------
// CCalendarAPIexampleEntryView::DoDeleteL()
// Deletes the entry and activates a proper view.
// ----------------------------------------------------
// 		
void CCalendarAPIexampleEntryView::DoDeleteL()
	{
	CAknQueryDialog* query = CAknQueryDialog::NewL();
	CleanupStack::PushL(query);
	query->SetPromptL(KDeleteConfirmation);
	CleanupStack::Pop(query);
	if (query->ExecuteLD(R_CALENDARAPIEXAMPLE_CONFIRMATION_QUERY))
		{
		// if we are modifying an entry, delete it and open a proper view
		if (iModify)
			{
			iDocument->DeleteEntryL(iDocument->ModifyIndex());
			// If no more entries exist in the listbox, activate search view.
			if (iDocument->EntryCount() == 0)
				{
				AppUi()->ActivateLocalViewL(KSearchViewId);
				}
			// activate entries view
			else
				{
				AppUi()->ActivateLocalViewL(KEntriesViewId);
				}
			}
		// no need for deletion, because the new entry is not yet saved.
		else
			{
			AppUi()->ActivateLocalViewL(KSearchViewId);
			}
		}
	}
	

⌨️ 快捷键说明

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