|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: CCSXHGenericTOC1 class definition |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "CSXHGenericTOC1.h" |
|
19 #include "csxhconstants.h" |
|
20 |
|
21 // --------------------------------------------------------- |
|
22 // Items commented in header. |
|
23 // --------------------------------------------------------- |
|
24 CCSXHGenericTOC1::CCSXHGenericTOC1(const TDesC& aName): |
|
25 CCSXHHelpContentBase(aName),iChildList(NULL) |
|
26 {//No Implementation required |
|
27 } |
|
28 |
|
29 // --------------------------------------------------------- |
|
30 // Items commented in header. |
|
31 // --------------------------------------------------------- |
|
32 CCSXHGenericTOC1::~CCSXHGenericTOC1() |
|
33 { |
|
34 ResetChildList(); |
|
35 } |
|
36 |
|
37 // --------------------------------------------------------- |
|
38 // Items commented in header. |
|
39 // --------------------------------------------------------- |
|
40 void CCSXHGenericTOC1::ResetChildList() |
|
41 { |
|
42 if(iChildList == NULL) |
|
43 return; |
|
44 TInt count = iChildList->Count(); |
|
45 CCSXHHelpContentBase* toc2; |
|
46 for(TInt i=0;i<count;++i ) |
|
47 { |
|
48 toc2 = (*iChildList)[i]; |
|
49 delete toc2; |
|
50 } |
|
51 iChildList->Reset(); |
|
52 delete iChildList; |
|
53 iChildList = NULL; |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------- |
|
57 // Items commented in header. |
|
58 // --------------------------------------------------------- |
|
59 void CCSXHGenericTOC1::ConstructChildListL() |
|
60 { |
|
61 iChildList = new(ELeave) RPointerArray<CCSXHHelpContentBase>(); |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------- |
|
65 // Items commented in header. |
|
66 // --------------------------------------------------------- |
|
67 EXPORT_C CCSXHHelpContentBase* CCSXHGenericTOC1::GetChildL(const TDesC& aName) |
|
68 { |
|
69 if(iChildList == NULL) |
|
70 return NULL; |
|
71 |
|
72 TInt count = iChildList->Count(); |
|
73 CCSXHHelpContentBase* child = NULL; |
|
74 for(TInt i=0;i<count;++i ) |
|
75 { |
|
76 child = (*iChildList)[i]; |
|
77 if(aName.Compare(child->GetName())==0) |
|
78 return child; |
|
79 } |
|
80 return NULL; |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------- |
|
84 // Items commented in header. |
|
85 // --------------------------------------------------------- |
|
86 EXPORT_C void CCSXHGenericTOC1::FillChildDataL(CDesCArray* aArray) |
|
87 { |
|
88 //Using Template Pattern. Both the functions below are virtual |
|
89 InitChildList(); |
|
90 CopyChildListL(aArray); |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------- |
|
94 // Items commented in header. |
|
95 // --------------------------------------------------------- |
|
96 TBool CCSXHGenericTOC1::InsertChild(CCSXHHelpContentBase* aChild, |
|
97 TBool aDeleteObject) |
|
98 { |
|
99 ConstructChildList(); |
|
100 TLinearOrder<CCSXHHelpContentBase> anOrder(Orderer<CCSXHHelpContentBase>); |
|
101 if (KErrNone != iChildList->InsertInOrder(aChild,anOrder)) |
|
102 { |
|
103 if(aDeleteObject) |
|
104 delete aChild; |
|
105 |
|
106 return EFalse; |
|
107 } |
|
108 return ETrue; |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------- |
|
112 // Items commented in header. |
|
113 // --------------------------------------------------------- |
|
114 void CCSXHGenericTOC1::CopyChildListL(CDesCArray* aArray) |
|
115 { |
|
116 TInt count = iChildList->Count(); |
|
117 CCSXHHelpContentBase* child; |
|
118 for(TInt i=0;i<count;++i ) |
|
119 { |
|
120 child = (*iChildList)[i]; |
|
121 TBuf<KMaxFileName> toc2Entry(KTabSpace); |
|
122 toc2Entry.Append(child->GetName()); |
|
123 aArray->AppendL(toc2Entry); |
|
124 } |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------- |
|
128 // Items commented in header. |
|
129 // --------------------------------------------------------- |
|
130 void CCSXHGenericTOC1::InitChildList() |
|
131 { |
|
132 ConstructChildList(); |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------- |
|
136 // Items commented in header. |
|
137 // --------------------------------------------------------- |
|
138 TBool CCSXHGenericTOC1::ConstructChildList() |
|
139 { |
|
140 if(iChildList != NULL) |
|
141 return ETrue; |
|
142 |
|
143 TRAPD(err,ConstructChildListL()); |
|
144 if(err == KErrNone) |
|
145 return ETrue; |
|
146 else |
|
147 { |
|
148 iChildList = NULL; |
|
149 return EFalse; |
|
150 } |
|
151 } |