1 /* |
|
2 * Copyright (c) 2005-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: Shortcut plug-in extension data model |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "caiscutextdatamodel.h" |
|
20 #include "caiscutextdata.h" |
|
21 |
|
22 // ======== LOCAL DEFINITIONS ======== |
|
23 |
|
24 namespace |
|
25 { |
|
26 } |
|
27 |
|
28 // ======== MEMBER FUNCTIONS ======== |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 CAiScutExtDataModel* CAiScutExtDataModel::NewL() |
|
35 { |
|
36 CAiScutExtDataModel* self = CAiScutExtDataModel::NewLC(); |
|
37 CleanupStack::Pop( self ); |
|
38 return self; |
|
39 } |
|
40 |
|
41 CAiScutExtDataModel* CAiScutExtDataModel::NewLC() |
|
42 { |
|
43 CAiScutExtDataModel* self = new( ELeave ) CAiScutExtDataModel; |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL(); |
|
46 return self; |
|
47 } |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 CAiScutExtDataModel::~CAiScutExtDataModel() |
|
53 { |
|
54 iAiScutExtDataArray.ResetAndDestroy(); |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 CAiScutExtDataModel::CAiScutExtDataModel() |
|
62 { |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 void CAiScutExtDataModel::ConstructL() |
|
70 { |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 CAiScutExtData* CAiScutExtDataModel::SetPopupLineArrayL( |
|
78 const TDesC& aDefinition, CDesCArray* aLineArray ) |
|
79 { |
|
80 CAiScutExtData* extData = NULL; |
|
81 TInt index = FindAiScutExtData( aDefinition ); |
|
82 if( index != KErrNotFound ) |
|
83 { |
|
84 extData = iAiScutExtDataArray[ index ]; |
|
85 } |
|
86 else |
|
87 { |
|
88 extData = CreateAiScutExtDataL( aDefinition ); |
|
89 } |
|
90 |
|
91 extData->SwitchPopupLineArray( aLineArray ); //Takes ownership |
|
92 return extData; |
|
93 } |
|
94 |
|
95 CAiScutExtData* CAiScutExtDataModel::ResetPopupLineArray( const TDesC& aDefinition ) |
|
96 { |
|
97 CAiScutExtData* extData = NULL; |
|
98 TInt index = FindAiScutExtData( aDefinition ); |
|
99 if( index != KErrNotFound ) |
|
100 { |
|
101 extData = iAiScutExtDataArray[ index ]; |
|
102 if( extData->Icon() ) |
|
103 { |
|
104 extData->ResetPopupLineArray(); |
|
105 } |
|
106 else |
|
107 { |
|
108 iAiScutExtDataArray.Remove( index ); |
|
109 delete extData; |
|
110 extData = NULL; |
|
111 } |
|
112 } |
|
113 return extData; |
|
114 } |
|
115 |
|
116 CAiScutExtData* CAiScutExtDataModel::SetIconL( const TDesC& aDefinition, CGulIcon* aIcon ) |
|
117 { |
|
118 CAiScutExtData* extData = NULL; |
|
119 TInt index = FindAiScutExtData( aDefinition ); |
|
120 if( index != KErrNotFound ) |
|
121 { |
|
122 extData = iAiScutExtDataArray[ index ]; |
|
123 } |
|
124 else |
|
125 { |
|
126 extData = CreateAiScutExtDataL( aDefinition ); |
|
127 } |
|
128 |
|
129 extData->SwitchIcon( aIcon ); //Takes ownership |
|
130 return extData; |
|
131 } |
|
132 |
|
133 CAiScutExtData* CAiScutExtDataModel::ResetIcon( const TDesC& aDefinition ) |
|
134 { |
|
135 CAiScutExtData* extData = NULL; |
|
136 TInt index = FindAiScutExtData( aDefinition ); |
|
137 if( index != KErrNotFound ) |
|
138 { |
|
139 extData = iAiScutExtDataArray[ index ]; |
|
140 if( extData->PopupLineArray() ) |
|
141 { |
|
142 extData->ResetIcon(); |
|
143 } |
|
144 else |
|
145 { |
|
146 iAiScutExtDataArray.Remove( index ); |
|
147 delete extData; |
|
148 extData = NULL; |
|
149 } |
|
150 } |
|
151 return extData; |
|
152 } |
|
153 |
|
154 TArray<CAiScutExtData*> CAiScutExtDataModel::AiScutExtDataArray() const |
|
155 { |
|
156 return iAiScutExtDataArray.Array(); |
|
157 } |
|
158 |
|
159 void CAiScutExtDataModel::RemoveAiScutExtData( const TDesC& aDefinition ) |
|
160 { |
|
161 TInt index = FindAiScutExtData( aDefinition ); |
|
162 if( index != KErrNotFound ) |
|
163 { |
|
164 CAiScutExtData* extData = iAiScutExtDataArray[ index ]; |
|
165 iAiScutExtDataArray.Remove( index ); |
|
166 delete extData; |
|
167 } |
|
168 } |
|
169 |
|
170 TInt CAiScutExtDataModel::FindAiScutExtData( const TDesC& aDefinition ) const |
|
171 { |
|
172 const TInt count = iAiScutExtDataArray.Count(); |
|
173 for( TInt i = 0; i < count; i++ ) |
|
174 { |
|
175 if( iAiScutExtDataArray[ i ]->TargetDefinition().CompareF( aDefinition ) == 0 ) |
|
176 { |
|
177 return i; |
|
178 } |
|
179 } |
|
180 return KErrNotFound; |
|
181 } |
|
182 |
|
183 CAiScutExtData* CAiScutExtDataModel::CreateAiScutExtDataL( const TDesC& aDefinition ) |
|
184 { |
|
185 CAiScutExtData* extData = CAiScutExtData::NewLC( aDefinition ); |
|
186 iAiScutExtDataArray.AppendL( extData ); //Takes ownership |
|
187 CleanupStack::Pop( extData ); |
|
188 return extData; |
|
189 } |
|
190 // End of File. |
|