45
|
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, const TInt32 aPriority):
|
|
25 |
CCSXHHelpContentBase(aName, aPriority), 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 |
TBool CCSXHGenericTOC1::InsertChildWithPriority(CCSXHHelpContentBase* aChild, TBool aDeleteObject)
|
|
112 |
{
|
|
113 |
ConstructChildList();
|
|
114 |
TLinearOrder<CCSXHHelpContentBase> anOrder(OrdererWithPriority<CCSXHHelpContentBase>);
|
|
115 |
if (KErrNone != iChildList->InsertInOrder(aChild,anOrder))
|
|
116 |
{
|
|
117 |
if(aDeleteObject)
|
|
118 |
delete aChild;
|
|
119 |
|
|
120 |
return EFalse;
|
|
121 |
}
|
|
122 |
return ETrue;
|
|
123 |
}
|
|
124 |
|
|
125 |
// ---------------------------------------------------------
|
|
126 |
// Items commented in header.
|
|
127 |
// ---------------------------------------------------------
|
|
128 |
void CCSXHGenericTOC1::CopyChildListL(CDesCArray* aArray)
|
|
129 |
{
|
|
130 |
TInt count = iChildList->Count();
|
|
131 |
CCSXHHelpContentBase* child;
|
|
132 |
for(TInt i = 0; i < count; ++i)
|
|
133 |
{
|
|
134 |
child = (*iChildList)[i];
|
|
135 |
if (child && child->GetName().Length() != 0)
|
|
136 |
{
|
|
137 |
TBuf<KMaxFileName> toc2Entry(KTabSpace);
|
|
138 |
toc2Entry.Append(child->GetName());
|
|
139 |
aArray->AppendL(toc2Entry);
|
|
140 |
}
|
|
141 |
}
|
|
142 |
}
|
|
143 |
|
|
144 |
// ---------------------------------------------------------
|
|
145 |
// Items commented in header.
|
|
146 |
// ---------------------------------------------------------
|
|
147 |
void CCSXHGenericTOC1::InitChildList()
|
|
148 |
{
|
|
149 |
ConstructChildList();
|
|
150 |
}
|
|
151 |
|
|
152 |
// ---------------------------------------------------------
|
|
153 |
// Items commented in header.
|
|
154 |
// ---------------------------------------------------------
|
|
155 |
TBool CCSXHGenericTOC1::ConstructChildList()
|
|
156 |
{
|
|
157 |
if(iChildList != NULL)
|
|
158 |
return ETrue;
|
|
159 |
|
|
160 |
TRAPD(err,ConstructChildListL());
|
|
161 |
if(err == KErrNone)
|
|
162 |
return ETrue;
|
|
163 |
else
|
|
164 |
{
|
|
165 |
iChildList = NULL;
|
|
166 |
return EFalse;
|
|
167 |
}
|
|
168 |
}
|