|
1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #pragma message(__FILE__ "(5) : This test code memory leaks on exit due to a bug in the code...fix when have time") |
|
17 |
|
18 #include "THelpView.h" |
|
19 |
|
20 // System includes |
|
21 #include <coemain.h> |
|
22 #include <eikenv.h> |
|
23 #include <techview/eikrted.h> |
|
24 #include <techview/eikmenup.h> |
|
25 #include <techview/eikchlst.h> |
|
26 #include <techview/eikon.hrh> |
|
27 #include <techview/eiksbfrm.h> |
|
28 #include <eikstart.h> |
|
29 #include <txtrich.h> |
|
30 #include "hlpmodel.h" |
|
31 #include <thelpview.rsg> |
|
32 |
|
33 // User includes |
|
34 #include "thelpviewctrls.h" |
|
35 #include "THelpView.hrh" |
|
36 |
|
37 // Constants |
|
38 const TInt KSizeSearchPromptIndent = 5; |
|
39 const TInt KSizeSearchPromptHeight = 25; |
|
40 const TInt KResultsViewWidth = 150; |
|
41 |
|
42 // Panic enum |
|
43 enum THlpViewerPanic |
|
44 { |
|
45 EHlpViewPanicNoSearchSpec |
|
46 }; |
|
47 |
|
48 |
|
49 // |
|
50 // ----> Global functions / Entry points (source) |
|
51 // |
|
52 |
|
53 LOCAL_C CApaApplication* NewApplication() |
|
54 // Ordinal 1 export for App Dll's |
|
55 { |
|
56 return new CHlpApplication(); |
|
57 } |
|
58 |
|
59 GLDEF_C TInt E32Main() |
|
60 { |
|
61 return EikStart::RunApplication(NewApplication); |
|
62 } |
|
63 |
|
64 |
|
65 void Panic(THlpViewerPanic aPanic) |
|
66 { |
|
67 _LIT(KHlpViewPanicCategory, "HlpView"); |
|
68 User::Panic(KHlpViewPanicCategory, aPanic); |
|
69 } |
|
70 |
|
71 |
|
72 |
|
73 // |
|
74 // ----> CHlpApplication (source) |
|
75 // |
|
76 TUid CHlpApplication::AppDllUid() const |
|
77 { |
|
78 return KUidHelpViewApp; |
|
79 } |
|
80 |
|
81 CApaDocument* CHlpApplication::CreateDocumentL() |
|
82 { |
|
83 CHlpDocument* document = new(ELeave) CHlpDocument(*this); |
|
84 CleanupStack::PushL(document); |
|
85 document->NewDocumentL(); |
|
86 CleanupStack::Pop(); |
|
87 return document; |
|
88 } |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 // |
|
95 // ----> CHlpAppUi (source) |
|
96 // |
|
97 CHlpDocument::CHlpDocument(CEikApplication& aApp) |
|
98 : CEikDocument(aApp) |
|
99 { |
|
100 } |
|
101 |
|
102 CHlpDocument::~CHlpDocument() |
|
103 { |
|
104 delete iModel; |
|
105 } |
|
106 |
|
107 CEikAppUi* CHlpDocument::CreateAppUiL() |
|
108 { |
|
109 return(new(ELeave) CHlpAppUi()); |
|
110 } |
|
111 |
|
112 void CHlpDocument::NewDocumentL() |
|
113 { |
|
114 CHlpModel* model = CHlpModel::NewL(Process()->FsSession(), NULL); |
|
115 CleanupStack::PushL(model); |
|
116 model->OpenL(); |
|
117 delete iModel; |
|
118 iModel = model; |
|
119 CleanupStack::Pop(); // model |
|
120 } |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 // |
|
127 // ----> CHlpAppUi (source) |
|
128 // |
|
129 CHlpAppUi::~CHlpAppUi() |
|
130 { |
|
131 CCoeAppUi::RemoveFromStack(iView); |
|
132 delete iView; |
|
133 } |
|
134 |
|
135 void CHlpAppUi::ConstructL() |
|
136 { |
|
137 BaseConstructL(); |
|
138 |
|
139 iView = new(ELeave) CHlpMainView(*this, Document().Model()); |
|
140 iView->ConstructL(); |
|
141 iView->SetRect(ClientRect()); |
|
142 |
|
143 AddToStackL(iView); |
|
144 } |
|
145 |
|
146 // |
|
147 // FROM CEikAppUi |
|
148 // |
|
149 |
|
150 void CHlpAppUi::HandleCommandL(TInt aCommand) |
|
151 { |
|
152 switch (aCommand) |
|
153 { |
|
154 case EEikCmdExit: |
|
155 Exit(); |
|
156 break; |
|
157 |
|
158 case EHlpCmdSearch: |
|
159 iView->ShowSearchPrompt(ETrue); |
|
160 break; |
|
161 |
|
162 case EHlpCmdSearchDone: |
|
163 iView->MakeResultsVisible(EFalse); |
|
164 break; |
|
165 |
|
166 case EEikCmdZoomIn: |
|
167 case EEikCmdZoomOut: |
|
168 HandleZoomL(aCommand); |
|
169 break; |
|
170 |
|
171 default: |
|
172 User::Leave(KErrNotSupported); |
|
173 break; |
|
174 } |
|
175 } |
|
176 |
|
177 void CHlpAppUi::DynInitMenuPaneL(TInt aMenuId, CEikMenuPane* aMenuPane) |
|
178 { |
|
179 switch (aMenuId) |
|
180 { |
|
181 case R_HELPVIEW_TOOLS_MENU: |
|
182 aMenuPane->SetItemDimmed(EHlpCmdSearchDone, !iView->IsSearchResultVisible()); |
|
183 break; |
|
184 } |
|
185 } |
|
186 |
|
187 // |
|
188 // NEW |
|
189 // |
|
190 |
|
191 void CHlpAppUi::HandleZoomL(TInt aZoomEvent) |
|
192 { |
|
193 if (!iZoomHandler) |
|
194 return; |
|
195 iZoomHandler->HandleZoomEventL(STATIC_CAST(MZoomableControl::TZoomEvent, aZoomEvent)); |
|
196 } |
|
197 |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 |
|
203 // |
|
204 // ----> CHlpView (source) |
|
205 // |
|
206 CHlpView::CHlpView(CHlpAppUi& aAppUi, CHlpModel& aModel) |
|
207 : iAppUi(aAppUi), iHelpModel(aModel), iCurrentZoom(EZoomStateTwo) |
|
208 { |
|
209 } |
|
210 |
|
211 CHlpView::~CHlpView() |
|
212 { |
|
213 delete iHelpCategories; |
|
214 delete iHelpTopicsForCategory; |
|
215 delete iRichTextEditor; |
|
216 delete iCurrentTopics; |
|
217 delete iLastTopic; |
|
218 |
|
219 // Remove this when the memory leak is finished... |
|
220 iCoeEnv->DisableExitChecks(ETrue); |
|
221 } |
|
222 |
|
223 void CHlpView::ConstructL() |
|
224 { |
|
225 iLastTopic = CHlpTopic::NewL(); |
|
226 iZoom.SetGraphicsDeviceMap(iCoeEnv->ScreenDevice()); |
|
227 |
|
228 iHelpModel.SetObserver(this); |
|
229 |
|
230 iHelpCategories = new(ELeave) CEikChoiceList(); |
|
231 iHelpCategories->SetContainerWindowL(*this); |
|
232 iHelpCategories->SetFocus(ETrue); |
|
233 iHelpCategories->SetObserver(this); |
|
234 |
|
235 iHelpTopicsForCategory = new(ELeave) CEikChoiceList(); |
|
236 iHelpTopicsForCategory->SetContainerWindowL(*this); |
|
237 iHelpTopicsForCategory->SetObserver(this); |
|
238 |
|
239 iRichTextEditor = new(ELeave) CEikRichTextEditor(); |
|
240 iRichTextEditor->SetContainerWindowL(*this); |
|
241 iRichTextEditor->ConstructL(this, 6, 100000, CEikEdwin::EWidthInPixels | CEikEdwin::EReadOnly | CEikEdwin::ENoAutoSelection | CEikEdwin::EKeepDocument); |
|
242 iRichTextEditor->SetZoomFactorL(&iZoom); |
|
243 iRichTextEditor->CreateTextViewL(); |
|
244 iRichTextEditor->CreateScrollBarFrameL()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); |
|
245 iRichTextEditor->SetObserver(this); |
|
246 |
|
247 HandleZoomEventL(EEventZoomDefault); |
|
248 PopulateCategoryListL(); |
|
249 |
|
250 iHelpModel.SetZoomFactors(EHlpZoomStateSmall, 750); |
|
251 iHelpModel.SetZoomFactors(EHlpZoomStateMedium, 1000); |
|
252 iHelpModel.SetZoomFactors(EHlpZoomStateLarge, 1250); |
|
253 } |
|
254 |
|
255 |
|
256 // |
|
257 // NEW |
|
258 // |
|
259 void CHlpView::PopulateCategoryListL() |
|
260 { |
|
261 // First get a category listing, then get the list of topics |
|
262 // for each specified category. |
|
263 // Get and print the category listing |
|
264 CDesCArrayFlat* array = new(ELeave) CDesCArrayFlat(5); |
|
265 CleanupStack::PushL(array); |
|
266 iHelpModel.CategoryListL(array); |
|
267 |
|
268 if (!array->Count()) |
|
269 User::Leave(KErrArgument); // ?? |
|
270 |
|
271 iHelpCategories->SetArrayExternalOwnership(EFalse); |
|
272 iHelpCategories->SetArrayL(array); |
|
273 iHelpCategories->SetArrayExternalOwnership(EFalse); |
|
274 iHelpCategories->SetCurrentItem(0); |
|
275 |
|
276 PopulateTopicListL(iHelpCategories->Array()->MdcaPoint(iHelpCategories->CurrentItem())); |
|
277 |
|
278 CleanupStack::Pop(); |
|
279 } |
|
280 |
|
281 void CHlpView::PopulateTopicListL(const TDesC& aTopic) |
|
282 { |
|
283 iHelpModel.SearchL(ETopicListForCategory, aTopic); |
|
284 |
|
285 CHlpList* list = CHlpList::NewLC(); |
|
286 iHelpModel.LoadListL(list); |
|
287 iHelpTopicsForCategory->SetArrayL(list); // Derrives from MDesCArray so we can do this |
|
288 delete iCurrentTopics; |
|
289 iCurrentTopics = list; |
|
290 iHelpTopicsForCategory->SetArrayExternalOwnership(ETrue); // owned by this class |
|
291 CleanupStack::Pop(); // list |
|
292 |
|
293 if (list->MdcaCount()) |
|
294 { |
|
295 UpdateEdwinL(*list->Item(0)); |
|
296 iHelpTopicsForCategory->SetCurrentItem(0); |
|
297 iHelpTopicsForCategory->DrawNow(); |
|
298 } |
|
299 } |
|
300 |
|
301 |
|
302 void CHlpView::UpdateEdwinL(const CHlpItem& aItem) |
|
303 // |
|
304 // Extract the rich text from the help file and display it in the |
|
305 // read only edit window. |
|
306 // |
|
307 { |
|
308 // Search for a specific topic. |
|
309 iHelpModel.TopicSearchL(aItem); |
|
310 if (iLastResponseFromHelpModel == ETopicAvailable) |
|
311 { |
|
312 CHlpTopic* topic = CHlpTopic::NewLC(); |
|
313 iHelpModel.LoadTopicL(topic); |
|
314 iRichTextEditor->SetDocumentContentL(*topic->TopicText(), CEikEdwin::EUseText); |
|
315 iRichTextEditor->NotifyNewFormatL(); |
|
316 iRichTextEditor->TextView()->SetViewLineAtTopL(1); |
|
317 iRichTextEditor->UpdateScrollBarsL(); |
|
318 delete iLastTopic; |
|
319 iLastTopic = topic; |
|
320 CleanupStack::Pop(); // topic |
|
321 } |
|
322 else |
|
323 iEikonEnv->InfoMsg(R_HELPVIEW_TEXT_NO_TOPIC_FOR_ID); |
|
324 } |
|
325 |
|
326 // |
|
327 // FROM MZoomableControl |
|
328 // |
|
329 |
|
330 void CHlpView::HandleZoomEventL(TZoomEvent aEvent) |
|
331 { |
|
332 switch(aEvent) |
|
333 { |
|
334 case EEventZoomIn: |
|
335 if (++iCurrentZoom>=KNumberOfZoomStates) |
|
336 iCurrentZoom = 0; |
|
337 break; |
|
338 case EEventZoomOut: |
|
339 if (--iCurrentZoom < 0) |
|
340 iCurrentZoom = KNumberOfZoomStates-1; |
|
341 break; |
|
342 case EEventZoomDefault: |
|
343 iCurrentZoom = 1; |
|
344 break; |
|
345 default: |
|
346 User::Leave(KErrNotSupported); |
|
347 } |
|
348 |
|
349 // Select bitmap zoom size in the 'hlpmodel', according to the value of 'iCurrentZoom' |
|
350 switch (iCurrentZoom) |
|
351 { |
|
352 case 0: |
|
353 iHelpModel.SetZoomSizeL(EHlpZoomStateSmall); |
|
354 break; |
|
355 default: |
|
356 case 1: |
|
357 iHelpModel.SetZoomSizeL(EHlpZoomStateMedium); |
|
358 break; |
|
359 case 2: |
|
360 iHelpModel.SetZoomSizeL(EHlpZoomStateLarge); |
|
361 break; |
|
362 } |
|
363 |
|
364 |
|
365 iZoom.SetZoomFactor(ZoomForIndex(iCurrentZoom)); |
|
366 iRichTextEditor->NotifyNewFormatL(); |
|
367 iRichTextEditor->UpdateScrollBarsL(); |
|
368 iRichTextEditor->DrawNow(); |
|
369 } |
|
370 |
|
371 TInt CHlpView::ZoomForIndex(TInt aIndex) |
|
372 { |
|
373 switch(aIndex) |
|
374 { |
|
375 case 0: |
|
376 return EZoomStateOne; |
|
377 default: |
|
378 case 1: |
|
379 return EZoomStateTwo; |
|
380 case 2: |
|
381 return EZoomStateThree; |
|
382 } |
|
383 } |
|
384 |
|
385 // |
|
386 // FROM CCoeControl |
|
387 // |
|
388 |
|
389 void CHlpView::SizeChanged() |
|
390 { |
|
391 const TInt KKludgeFactor = 4; |
|
392 |
|
393 TRect rect(Position(), Rect().Size()); |
|
394 TSize choiceListSize = iHelpCategories->MinimumSize() + TSize(0, KKludgeFactor); |
|
395 |
|
396 TPoint topLeft(rect.iTl); |
|
397 |
|
398 iHelpCategories->SetExtent(topLeft, TSize(rect.Width()/2, choiceListSize.iHeight)); |
|
399 iHelpTopicsForCategory->SetExtent(TPoint(rect.Size().iWidth/2,topLeft.iY), TSize(rect.Size().iWidth/2, choiceListSize.iHeight)); |
|
400 iRichTextEditor->SetRect(TRect(TPoint(topLeft.iX, choiceListSize.iHeight), rect.iBr)); |
|
401 } |
|
402 |
|
403 TInt CHlpView::CountComponentControls() const |
|
404 { |
|
405 return 3; |
|
406 } |
|
407 |
|
408 CCoeControl* CHlpView::ComponentControl(TInt aIndex) const |
|
409 { |
|
410 switch (aIndex) |
|
411 { |
|
412 default: |
|
413 case 0: |
|
414 return iHelpCategories; |
|
415 case 1: |
|
416 return iHelpTopicsForCategory; |
|
417 case 2: |
|
418 return iRichTextEditor; |
|
419 } |
|
420 } |
|
421 |
|
422 TKeyResponse CHlpView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
423 { |
|
424 return iRichTextEditor->OfferKeyEventL(aKeyEvent, aType); |
|
425 } |
|
426 |
|
427 // |
|
428 // FROM MCoeControlObserver |
|
429 // |
|
430 void CHlpView::HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType) |
|
431 { |
|
432 if (aEventType == EEventRequestFocus) |
|
433 { |
|
434 if (iFocusedControl) |
|
435 { |
|
436 iFocusedControl->PrepareForFocusLossL(); |
|
437 iFocusedControl->SetFocus(EFalse); |
|
438 } |
|
439 iFocusedControl = aControl; |
|
440 iFocusedControl->SetFocus(ETrue); |
|
441 } |
|
442 else if (aControl == iHelpCategories && aEventType == EEventStateChanged) |
|
443 { |
|
444 // Update the list of topics available for this category |
|
445 PopulateTopicListL(iHelpCategories->Array()->MdcaPoint(iHelpCategories->CurrentItem())); |
|
446 } |
|
447 else if (aControl == iHelpTopicsForCategory && aEventType == EEventStateChanged) |
|
448 { |
|
449 // Update the edwin contents |
|
450 UpdateEdwinL(*iCurrentTopics->Item(iHelpTopicsForCategory->CurrentItem())); |
|
451 } |
|
452 } |
|
453 |
|
454 // |
|
455 // FROM MHlpModelObserver |
|
456 // |
|
457 void CHlpView::HandleModelEventL(TInt aEvent) |
|
458 { |
|
459 iLastResponseFromHelpModel = aEvent; |
|
460 } |
|
461 |
|
462 |
|
463 |
|
464 |
|
465 |
|
466 |
|
467 |
|
468 // |
|
469 // ----> CHlpMainView (source) |
|
470 // |
|
471 |
|
472 CHlpMainView::CHlpMainView(CHlpAppUi& aAppUi, CHlpModel& aModel) |
|
473 : iAppUi(aAppUi), iModel(aModel) |
|
474 { |
|
475 } |
|
476 |
|
477 CHlpMainView::~CHlpMainView() |
|
478 { |
|
479 delete iSearchResults; |
|
480 delete iSearchPrompt; |
|
481 delete iView; |
|
482 } |
|
483 |
|
484 void CHlpMainView::ConstructL() |
|
485 { |
|
486 CreateWindowL(); |
|
487 |
|
488 iView = new(ELeave) CHlpView(iAppUi, iModel); |
|
489 iView->SetContainerWindowL(*this); |
|
490 iView->ConstructL(); |
|
491 iAppUi.SetZoomHandler(iView); |
|
492 |
|
493 iSearchPrompt = new(ELeave) CHlpSearchPrompt(); |
|
494 iSearchPrompt->ConstructL(*this); |
|
495 iSearchPrompt->SetObserver(this); |
|
496 iSearchPrompt->MakeVisible(EFalse); |
|
497 |
|
498 iSearchResults = new(ELeave) CHlpListBox(); |
|
499 iSearchResults->ConstructL(*this); |
|
500 iSearchResults->SetObserver(this); |
|
501 iSearchResults->MakeVisible(EFalse); |
|
502 |
|
503 iView->SetFocus(ETrue); |
|
504 |
|
505 ActivateL(); |
|
506 } |
|
507 |
|
508 // |
|
509 // ACCESS |
|
510 // |
|
511 |
|
512 TBool CHlpMainView::IsSearchPromptVisible() const |
|
513 { |
|
514 return iSearchPrompt->IsVisible(); |
|
515 } |
|
516 |
|
517 TBool CHlpMainView::IsSearchResultVisible() const |
|
518 { |
|
519 return iSearchResults->IsVisible(); |
|
520 } |
|
521 |
|
522 void CHlpMainView::ShowSearchPrompt(TBool aShow) |
|
523 { |
|
524 iSearchPrompt->MakeVisible(aShow); |
|
525 } |
|
526 |
|
527 void CHlpMainView::MakeResultsVisible(TBool aVisible) |
|
528 { |
|
529 TRect rect(Rect()); |
|
530 TSize resultsSize = iSearchResults->Size(); |
|
531 |
|
532 if (!aVisible) |
|
533 { |
|
534 // Make the main view rect 'full size' again |
|
535 iView->SetRect(rect); |
|
536 iSearchResults->ListBox()->SetFocus(EFalse); |
|
537 iView->SetFocus(ETrue); |
|
538 } |
|
539 else |
|
540 { |
|
541 rect.iBr.iX -= resultsSize.iWidth; |
|
542 iView->SetRect(rect); |
|
543 iView->SetFocus(EFalse); |
|
544 iSearchResults->ListBox()->SetFocus(ETrue); |
|
545 } |
|
546 iSearchResults->MakeVisible(aVisible); |
|
547 DrawNow(); |
|
548 } |
|
549 |
|
550 // |
|
551 // FROM CCoeControl |
|
552 // |
|
553 |
|
554 void CHlpMainView::SizeChanged() |
|
555 { |
|
556 iView->SetRect(Rect()); |
|
557 |
|
558 TRect rect(Rect()); |
|
559 TSize KScreenSize(iCoeEnv->ScreenDevice()->SizeInPixels()); |
|
560 |
|
561 // Work out the size of the search prompt minus the inset for the left and right |
|
562 // hand size. Kludge this a bit to make sure we allow for the size of any scrollbar |
|
563 // (hence the *6 rather than the expected *2) |
|
564 TSize searchPromptSize(KScreenSize.iWidth - (4*KSizeSearchPromptIndent), KSizeSearchPromptHeight); |
|
565 iSearchPrompt->SetExtent(TPoint(KSizeSearchPromptIndent, rect.iBr.iY - KSizeSearchPromptHeight - KSizeSearchPromptIndent), searchPromptSize); |
|
566 |
|
567 TRect resultsRect(rect); |
|
568 resultsRect.iTl.iX = resultsRect.iBr.iX - KResultsViewWidth; |
|
569 iSearchResults->SetRect(resultsRect); |
|
570 } |
|
571 |
|
572 TInt CHlpMainView::CountComponentControls() const |
|
573 { |
|
574 return 3; |
|
575 } |
|
576 |
|
577 CCoeControl* CHlpMainView::ComponentControl(TInt aIndex) const |
|
578 { |
|
579 switch (aIndex) |
|
580 { |
|
581 default: |
|
582 case 0: |
|
583 return iView; |
|
584 case 1: |
|
585 return iSearchPrompt; |
|
586 case 2: |
|
587 return iSearchResults; |
|
588 } |
|
589 } |
|
590 |
|
591 TKeyResponse CHlpMainView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
592 { |
|
593 // Send cursors to the rich text edwin (kludgy) |
|
594 if (aKeyEvent.iCode >= EKeyPageUp && aKeyEvent.iCode <= EKeyDownArrow) |
|
595 { |
|
596 if (iView->IsFocused()) |
|
597 return iView->OfferKeyEventL(aKeyEvent, aType); |
|
598 else |
|
599 return iSearchResults->OfferKeyEventL(aKeyEvent, aType); |
|
600 } |
|
601 else |
|
602 { |
|
603 if (!iSearchPrompt->IsVisible() && aType == EEventKey) |
|
604 { |
|
605 iSearchPrompt->MakeVisible(ETrue); |
|
606 iSearchPrompt->SetFocus(ETrue); |
|
607 } |
|
608 return iSearchPrompt->OfferKeyEventL(aKeyEvent, aType); |
|
609 } |
|
610 } |
|
611 |
|
612 // |
|
613 // FROM MCoeControlObserver |
|
614 // |
|
615 |
|
616 void CHlpMainView::HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType) |
|
617 { |
|
618 if (aControl == iSearchPrompt && aEventType == EEventStateChanged) |
|
619 { |
|
620 // Action the search |
|
621 DoSearchL(); |
|
622 |
|
623 // Update the list of topics available for this category |
|
624 iSearchPrompt->MakeVisible(EFalse); |
|
625 |
|
626 // Reset the search prompt |
|
627 iSearchPrompt->ResetSearchL(); |
|
628 } |
|
629 else if (aControl == iSearchResults && aEventType == EEventRequestExit) |
|
630 { |
|
631 // Finished with results |
|
632 MakeResultsVisible(EFalse); |
|
633 } |
|
634 else if (aControl == iSearchResults && aEventType == EEventStateChanged) |
|
635 { |
|
636 // Display the selected topic that the user searched for |
|
637 iView->UpdateEdwinL(iSearchResults->HelpItemL()); |
|
638 } |
|
639 } |
|
640 |
|
641 // |
|
642 // FROM MHlpModelObserver |
|
643 // |
|
644 |
|
645 void CHlpMainView::HandleModelEventL(TInt aEvent) |
|
646 { |
|
647 iLastHelpModelResponse = aEvent; |
|
648 |
|
649 if (aEvent == ESearchListAvailable || aEvent == ESearchListNoneFound) |
|
650 { |
|
651 iEikonEnv->BusyMsgCancel(); |
|
652 |
|
653 // This is a special case which is initiated by full text searching... |
|
654 iModel.SetObserver(iView); |
|
655 |
|
656 // Now populate the search results listbox. |
|
657 if (iLastHelpModelResponse == ESearchListNoneFound) |
|
658 { |
|
659 iEikonEnv->InfoMsg(R_HELPVIEW_TEXT_NO_SEARCH_RESULTS); |
|
660 return; |
|
661 } |
|
662 |
|
663 // Get a topic list (because some were found) |
|
664 CHlpList* list = CHlpList::NewL(); |
|
665 iModel.LoadListL(list); |
|
666 iSearchResults->PopulateListBoxL(list); // takes ownership |
|
667 MakeResultsVisible(ETrue); // show results |
|
668 } |
|
669 } |
|
670 |
|
671 // |
|
672 // INTERNAL |
|
673 // |
|
674 |
|
675 void CHlpMainView::DoSearchL() |
|
676 { |
|
677 HBufC* searchSpec = iSearchPrompt->SearchTextLC(); |
|
678 __ASSERT_DEBUG(searchSpec, Panic(EHlpViewPanicNoSearchSpec)); |
|
679 |
|
680 // Set this class as the observer (kludge) |
|
681 iModel.SetObserver(this); |
|
682 |
|
683 // Request a search |
|
684 iModel.SearchL(EFullTextSearch, searchSpec); // Asynch... |
|
685 iEikonEnv->BusyMsgL(R_HELPVIEW_TEXT_SEARCHING, 0); |
|
686 |
|
687 CleanupStack::PopAndDestroy(); // searchSpec |
|
688 } |
|
689 |
|
690 |
|
691 |
|
692 |