📄 calendarapiexamplesearchview.cpp
字号:
/*
* ============================================================================
* Name : CCalendarAPIexampleSearchView from CalendarAPIexampleSearchView.h
* Part of : CalendarAPIexample
* Created : 02/22/2005 by Forum Nokia
* Version : 1.0
* Copyright: Nokia Corporation
* ============================================================================
*/
// INCLUDE FILES
#include <avkon.hrh>
#include <aknviewappui.h>
#include <aknnotewrappers.h> //CAknInformationNote
#include <CalendarAPIexample.rsg>
#include <aknglobalnote.h>
#include "CalendarAPIexampleSearchView.h"
#include "CalendarAPIexampleSearchContainer.h"
#include "CalendarAPIexample.hrh"
#include "CalendarAPIexampleEntryView.h"
#include "CalendarAPIexampleGridView.h" /*YC inclusion calendrier*/
#include "CalendarAPIexampleEntriesView.h"
#include "CalendarAPIexampleDocument.h"
// ================= MEMBER FUNCTIONS =======================
// destructor
CCalendarAPIexampleSearchView::~CCalendarAPIexampleSearchView()
{
if (iContainer)
{
// Removes Container from View control stack.
AppUi()->RemoveFromViewStack(*this, iContainer);
}
delete iContainer;
iContainer = NULL;
}
// Symbian OS default constructor can leave.
void CCalendarAPIexampleSearchView::ConstructL()
{
BaseConstructL(R_CALENDARAPIEXAMPLE_SEARCH_VIEW);
iDocument = static_cast<CCalendarAPIexampleDocument*>(AppUi()->Document());
}
// ----------------------------------------------------
// CCalendarAPIexampleSearchView::Id()
// Returns ID of View
// ----------------------------------------------------
//
TUid CCalendarAPIexampleSearchView::Id() const
{
return KSearchViewId;
}
// ----------------------------------------------------
// CCalendarAPIexampleSearchView::HandleCommandL()
// Takes care of command handling
// ----------------------------------------------------
//
void CCalendarAPIexampleSearchView::HandleCommandL( TInt aCommand )
{
switch (aCommand)
{
case EAknSoftkeyExit:
AppUi()->ProcessCommandL(EAknCmdExit);
break;
case ECalendarAPIexampleCmdPropos:
{
_LIT(message,"MyAgenda v1.3\nDevelopped By:\nSpawn Te@M\nVisit :\nwww.spawnrider.net");
CAknInformationNote *informationNote = new(ELeave) CAknInformationNote;
informationNote->ExecuteLD(message);
}
break;
case ECalendarAPIexampleCmdAdd:
DoAddL();
break;
case ECalendarAPIexampleCmdSearch:
DoSearchL();
break;
case ECalendarAPIexampleCmdGrid:
AppUi()->ActivateLocalViewL(KGridViewId);
break;
case ECalendarAPIexampleCmdCountMsg:
DoCountL();
break;
default:
break;
}
}
// ----------------------------------------------------
// CCalendarAPIexampleSearchView::DoActivateL()
// Gets called when the view is activated. Creates
// the search container, adds it to view control stack
// and sets it visible.
// ----------------------------------------------------
//
void CCalendarAPIexampleSearchView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
TUid /*aCustomMessageId*/,
const TDesC8& /*aCustomMessage*/ )
{
if ( !iContainer )
{
iContainer = CCalendarAPIexampleSearchContainer::NewL(ClientRect(),*this);
iContainer->SetMopParent(this);
// Adds Container to View control stack.
AppUi()->AddToStackL( *this, iContainer );
// Requires to display the default screen.
iContainer->MakeVisible( ETrue );
}
}
// ----------------------------------------------------
// CCalendarAPIexampleSearchView::DoDeactivate()
// Gets called when the view is deactivated. Removes
// the search container from view control stack and
// deletes it.
// ----------------------------------------------------
//
void CCalendarAPIexampleSearchView::DoDeactivate()
{
if ( iContainer )
{
// Removes Container from View control stack.
AppUi()->RemoveFromViewStack(*this, iContainer );
}
delete iContainer;
iContainer = NULL;
}
// ----------------------------------------------------
// CCalendarAPIexampleSearchView::DoSearchL()
// Requests the model to do an entry search. If no
// entries were found, an information note about it is
// displayed. If entries were found, entries view is
// activated.
// ----------------------------------------------------
//
void CCalendarAPIexampleSearchView::DoSearchL()
{
TSearchType type = iContainer->SearchType();
iDocument->DoSearchL(type, iContainer);
// No entries found, display information note.
if (0 >= iDocument->EntryCount())
{
CAknInformationNote* note = new (ELeave) CAknInformationNote;
HBufC* errorMsg = CCoeEnv::Static()->AllocReadResourceLC(R_CALENDARAPIEXAMPLE_NO_ENTRIES_FOUND);
note->ExecuteLD(*errorMsg);
CleanupStack::PopAndDestroy(errorMsg);
}
// Entries found, activate entries view
else
{
AppUi()->ActivateLocalViewL(KEntriesViewId);
}
}
//***************************************************
// YC DISPLAY NOTE INFORMATION
// Display the Task Number in a globalNoteInformation
//***************************************************
void CCalendarAPIexampleSearchView::DoCountL(){
TSearchType type = iContainer->SearchType();
iDocument->DoSearchL(type, iContainer);
// No entries found, display information note.
if (0 >= iDocument->EntryCount())
{
CAknInformationNote* note = new (ELeave) CAknInformationNote;
HBufC* errorMsg = CCoeEnv::Static()->AllocReadResourceLC(R_CALENDARAPIEXAMPLE_NO_ENTRIES_FOUND);
note->ExecuteLD(*errorMsg);
CleanupStack::PopAndDestroy(errorMsg);
}
// Entries found, activate entries view
else
{
// iDocument->EntryCount()
CAknInformationNote* dlg = new(ELeave)CAknInformationNote();
_LIT(aDes,"Nombre de Rendez-vous :\n");
TBuf16<50> tgt(aDes);
tgt.AppendNum(iDocument->EntryCount());
//TBuf<64> aDes;
//CEikonEnv::Static()->ReadResource(aDes, R_MYAGENDA_COUNT_MSG);
dlg->ExecuteLD(tgt);
}
}
// ----------------------------------------------------
// CCalendarAPIexampleSearchView::DoAddL()
// Resets models modify index, so that next call to
// models EntryForModifycation will create a new entry.
// Activates the entry view.
// ----------------------------------------------------
//
void CCalendarAPIexampleSearchView::DoAddL()
{
iDocument->ResetModifyIndex();
AppUi()->ActivateLocalViewL(KEntryViewId);
}
// End of file
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -