00001 /* 00002 * Copyright © 2008 Nokia Corporation. 00003 */ 00004 00005 00006 // INCLUDE FILES 00007 #include <avkon.hrh> 00008 #include <aknviewappui.h> 00009 #include <aknnotewrappers.h> //CAknInformationNote 00010 #include <CalendarAPIexample.rsg> 00011 #include "CalendarAPIexampleSearchView.h" 00012 #include "CalendarAPIexampleSearchContainer.h" 00013 #include "CalendarAPIexample.hrh" 00014 #include "CalendarAPIexampleEntryView.h" 00015 #include "CalendarAPIexampleEntriesView.h" 00016 #include "CalendarAPIexampleDocument.h" 00017 00018 // ================= MEMBER FUNCTIONS ======================= 00019 00020 // Two-phased constructor. 00021 CCalendarAPIexampleSearchView* CCalendarAPIexampleSearchView::NewL(MCalendarEngineCommandsInterface& aEngine) 00022 { 00023 CCalendarAPIexampleSearchView* self = CCalendarAPIexampleSearchView::NewLC(aEngine); 00024 CleanupStack::Pop(self); 00025 return self; 00026 } 00027 00028 // Two-phased constructor. 00029 CCalendarAPIexampleSearchView* CCalendarAPIexampleSearchView::NewLC(MCalendarEngineCommandsInterface& aEngine) 00030 { 00031 CCalendarAPIexampleSearchView* self = new (ELeave) CCalendarAPIexampleSearchView(aEngine); 00032 CleanupStack::PushL(self); 00033 self->ConstructL(); 00034 return self; 00035 } 00036 00037 // destructor 00038 CCalendarAPIexampleSearchView::~CCalendarAPIexampleSearchView() 00039 { 00040 delete iContainer; 00041 iContainer = NULL; 00042 } 00043 00044 00045 CCalendarAPIexampleSearchView::CCalendarAPIexampleSearchView( 00046 MCalendarEngineCommandsInterface& aEngine) : iEngine(aEngine) 00047 { 00048 } 00049 00050 00051 // Symbian OS default constructor can leave. 00052 void CCalendarAPIexampleSearchView::ConstructL() 00053 { 00054 BaseConstructL(R_CALENDARAPIEXAMPLE_SEARCH_VIEW); 00055 } 00056 00057 // ---------------------------------------------------- 00058 // CCalendarAPIexampleSearchView::Id() 00059 // Returns ID of View 00060 // ---------------------------------------------------- 00061 // 00062 TUid CCalendarAPIexampleSearchView::Id() const 00063 { 00064 return KSearchViewId; 00065 } 00066 00067 // ---------------------------------------------------- 00068 // CCalendarAPIexampleSearchView::HandleCommandL() 00069 // Takes care of command handling 00070 // ---------------------------------------------------- 00071 // 00072 void CCalendarAPIexampleSearchView::HandleCommandL( TInt aCommand ) 00073 { 00074 switch (aCommand) 00075 { 00076 case EAknSoftkeyExit: 00077 AppUi()->ProcessCommandL(EAknCmdExit); 00078 break; 00079 00080 case ECalendarAPIexampleCmdAdd: 00081 DoAddL(); 00082 break; 00083 case ECalendarAPIexampleCmdSearch: 00084 DoSearchL(); 00085 break; 00086 00087 default: 00088 break; 00089 } 00090 } 00091 00092 // ---------------------------------------------------- 00093 // CCalendarAPIexampleSearchView::DoActivateL() 00094 // Gets called when the view is activated. Creates 00095 // the search container, adds it to view control stack 00096 // and sets it visible. 00097 // ---------------------------------------------------- 00098 // 00099 void CCalendarAPIexampleSearchView::DoActivateL( 00100 const TVwsViewId& /*aPrevViewId*/, 00101 TUid /*aCustomMessageId*/, 00102 const TDesC8& /*aCustomMessage*/ ) 00103 { 00104 if ( !iContainer ) 00105 { 00106 iContainer = CCalendarAPIexampleSearchContainer::NewL( 00107 ClientRect(),*this); 00108 iContainer->SetMopParent(this); 00109 00110 // Adds Container to View control stack. 00111 AppUi()->AddToStackL( *this, iContainer ); 00112 00113 // Requires to display the default screen. 00114 iContainer->MakeVisible( ETrue ); 00115 } 00116 } 00117 00118 // ---------------------------------------------------- 00119 // CCalendarAPIexampleSearchView::DoDeactivate() 00120 // Gets called when the view is deactivated. Removes 00121 // the search container from view control stack and 00122 // deletes it. 00123 // ---------------------------------------------------- 00124 // 00125 void CCalendarAPIexampleSearchView::DoDeactivate() 00126 { 00127 if ( iContainer ) 00128 { 00129 // Removes Container from View control stack. 00130 AppUi()->RemoveFromStack( iContainer ); 00131 } 00132 00133 delete iContainer; 00134 iContainer = NULL; 00135 00136 } 00137 00138 // ---------------------------------------------------- 00139 // CCalendarAPIexampleSearchView::DoSearchL() 00140 // Requests the model to do an entry search. If no 00141 // entries were found, an information note about it is 00142 // displayed. If entries were found, entries view is 00143 // activated. 00144 // ---------------------------------------------------- 00145 // 00146 void CCalendarAPIexampleSearchView::DoSearchL() 00147 { 00148 TSearchType type = iContainer->SearchType(); 00149 00150 iEngine.DoSearchL(type); 00151 00152 // No entries found, display information note. 00153 if (0 >= iEngine.EntryCount()) 00154 { 00155 CAknInformationNote* note = new (ELeave) CAknInformationNote; 00156 HBufC* errorMsg = CCoeEnv::Static()->AllocReadResourceLC( 00157 R_CALENDARAPIEXAMPLE_NO_ENTRIES_FOUND); 00158 00159 note->ExecuteLD(*errorMsg); 00160 CleanupStack::PopAndDestroy(errorMsg); 00161 } 00162 // Entries found, activate entries view 00163 else 00164 { 00165 AppUi()->ActivateLocalViewL(KEntriesViewId); 00166 } 00167 } 00168 00169 // ---------------------------------------------------- 00170 // CCalendarAPIexampleSearchView::DoAddL() 00171 // Resets models modify index, so that next call to 00172 // models EntryForModifycation will create a new entry. 00173 // Activates the entry view. 00174 // ---------------------------------------------------- 00175 // 00176 void CCalendarAPIexampleSearchView::DoAddL() 00177 { 00178 iEngine.DoAddL(); 00179 } 00180 00181 // End of file
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.