author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 15 Sep 2010 12:29:17 +0300 | |
branch | RCL_3 |
changeset 64 | 85902f042028 |
parent 56 | d48ab3b357f1 |
child 72 | a5e7a4f63858 |
permissions | -rw-r--r-- |
56 | 1 |
/* |
2 |
* Copyright (c) 2009 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: Marking mode handler. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include <akncollection.h> |
|
19 |
#include <aknitemactionmenu.h> |
|
20 |
#include <eikspane.h> |
|
21 |
#include <aknnavide.h> |
|
22 |
#include <barsread.h> |
|
23 |
#include <AknUtils.h> |
|
24 |
#include <AknTasHook.h> |
|
25 |
||
26 |
#include "akntrace.h" |
|
27 |
#include "aknmarkingmode.h" |
|
28 |
||
29 |
// --------------------------------------------------------------------------- |
|
30 |
// CAknMarkingMode::NewL |
|
31 |
// --------------------------------------------------------------------------- |
|
32 |
// |
|
33 |
CAknMarkingMode* CAknMarkingMode::NewL( |
|
34 |
CAknItemActionMenu& aItemActionMenu, |
|
35 |
CollectionArray& aArray ) |
|
36 |
{ |
|
37 |
_AKNTRACE_FUNC_ENTER; |
|
38 |
CAknMarkingMode* self = |
|
39 |
new ( ELeave ) CAknMarkingMode( aItemActionMenu, aArray ); |
|
40 |
_AKNTRACE_FUNC_EXIT; |
|
41 |
return self; |
|
42 |
} |
|
43 |
||
44 |
||
45 |
// --------------------------------------------------------------------------- |
|
46 |
// CAknMarkingMode::~CAknMarkingMode |
|
47 |
// --------------------------------------------------------------------------- |
|
48 |
// |
|
49 |
CAknMarkingMode::~CAknMarkingMode() |
|
50 |
{ |
|
51 |
_AKNTRACE_FUNC_ENTER; |
|
52 |
AKNTASHOOK_REMOVE(); |
|
53 |
delete iMarkingDecorator; |
|
54 |
_AKNTRACE_FUNC_EXIT; |
|
55 |
} |
|
56 |
||
57 |
||
58 |
// --------------------------------------------------------------------------- |
|
59 |
// CAknMarkingMode::SetCollectionMultipleMarkingState |
|
60 |
// --------------------------------------------------------------------------- |
|
61 |
// |
|
64
85902f042028
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
62 |
EXPORT_C void CAknMarkingMode::SetCollectionMultipleMarkingState( |
85902f042028
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
63 |
TBool aActive ) |
56 | 64 |
{ |
65 |
_AKNTRACE_FUNC_ENTER; |
|
66 |
for ( TInt i = 0; i < iCollections.Count(); i++ ) |
|
67 |
{ |
|
68 |
MAknCollection* collection( iCollections[i] ); |
|
69 |
// Assume the command applies to first list with multiple selection |
|
70 |
if ( collection->CollectionState() & |
|
71 |
MAknCollection::EStateMultipleSelection ) |
|
72 |
{ |
|
73 |
MAknMarkingCollection* markingCollection |
|
74 |
= MarkingCollection( *collection ); |
|
75 |
if ( markingCollection ) |
|
76 |
{ |
|
77 |
markingCollection->SetMultipleMarkingState( aActive ); |
|
78 |
TRAP_IGNORE( UpdateMarkingModeNaviPaneL( aActive ) ); |
|
79 |
} |
|
80 |
iItemActionMenu.CollectionChanged( *collection ); |
|
81 |
break; |
|
82 |
} |
|
83 |
} |
|
84 |
_AKNTRACE_FUNC_EXIT; |
|
85 |
} |
|
86 |
||
87 |
||
88 |
// --------------------------------------------------------------------------- |
|
89 |
// CAknMarkingMode::TryExitMarkingMode |
|
90 |
// --------------------------------------------------------------------------- |
|
91 |
// |
|
92 |
void CAknMarkingMode::TryExitMarkingMode() |
|
93 |
{ |
|
94 |
_AKNTRACE_FUNC_ENTER; |
|
95 |
for ( TInt i = 0; i < iCollections.Count(); i++ ) |
|
96 |
{ |
|
97 |
MAknCollection* collection( iCollections[i] ); |
|
98 |
MAknMarkingCollection* markingCollection |
|
99 |
= MarkingCollection( *collection ); |
|
100 |
if ( markingCollection && markingCollection->MarkingState( |
|
101 |
) & MAknMarkingCollection::EStateMarkingMode ) |
|
102 |
{ |
|
103 |
if ( markingCollection->ExitMarkingMode() ) |
|
104 |
{ |
|
105 |
SetCollectionMultipleMarkingState( EFalse ); |
|
106 |
} |
|
107 |
} |
|
108 |
break; |
|
109 |
} |
|
110 |
_AKNTRACE_FUNC_EXIT; |
|
111 |
} |
|
112 |
||
113 |
||
114 |
// --------------------------------------------------------------------------- |
|
115 |
// CAknMarkingMode::MultipleMarkingActive |
|
116 |
// --------------------------------------------------------------------------- |
|
117 |
// |
|
118 |
TBool CAknMarkingMode::MultipleMarkingActive() const |
|
119 |
{ |
|
120 |
_AKNTRACE_FUNC_ENTER; |
|
121 |
TBool markingActive( EFalse ); |
|
122 |
for ( TInt i = 0; i < iCollections.Count(); i++ ) |
|
123 |
{ |
|
124 |
MAknCollection* collection( iCollections[i] ); |
|
64
85902f042028
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
125 |
MAknMarkingCollection* markingCollection |
85902f042028
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
126 |
= MarkingCollection( *collection ); |
85902f042028
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
127 |
if ( markingCollection ) |
56 | 128 |
{ |
64
85902f042028
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
129 |
markingActive = markingCollection->MarkingState() |
85902f042028
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
130 |
& MAknMarkingCollection::EStateMarkingMode; |
56 | 131 |
} |
132 |
} |
|
133 |
_AKNTRACE_FUNC_EXIT; |
|
134 |
return markingActive; |
|
135 |
} |
|
136 |
||
137 |
||
138 |
// --------------------------------------------------------------------------- |
|
139 |
// CAknMarkingMode::MarkedItems |
|
140 |
// --------------------------------------------------------------------------- |
|
141 |
// |
|
142 |
TBool CAknMarkingMode::MarkedItems() const |
|
143 |
{ |
|
144 |
_AKNTRACE_FUNC_ENTER; |
|
145 |
TBool markedItems( EFalse ); |
|
146 |
for ( TInt i = 0; i < iCollections.Count(); i++ ) |
|
147 |
{ |
|
148 |
MAknCollection* collection( iCollections[i] ); |
|
149 |
if ( collection->CollectionState() & |
|
150 |
MAknCollection::EStateCollectionVisible ) |
|
151 |
{ |
|
152 |
MAknMarkingCollection* markingCollection |
|
153 |
= MarkingCollection( *collection ); |
|
154 |
if ( markingCollection ) |
|
155 |
{ |
|
156 |
TInt markingState = markingCollection->MarkingState(); |
|
157 |
if ( markingState & |
|
158 |
MAknMarkingCollection::EStateMarkingMode ) |
|
159 |
{ |
|
160 |
markedItems = markingState |
|
161 |
& MAknMarkingCollection::EStateMarkedItems; |
|
162 |
} |
|
163 |
} |
|
164 |
break; |
|
165 |
} |
|
166 |
} |
|
167 |
_AKNTRACE_FUNC_EXIT; |
|
168 |
return markedItems; |
|
169 |
} |
|
170 |
||
171 |
// --------------------------------------------------------------------------- |
|
172 |
// CAknMarkingMode::CollectionEmpty |
|
173 |
// --------------------------------------------------------------------------- |
|
174 |
// |
|
175 |
TBool CAknMarkingMode::CollectionEmpty() const |
|
176 |
{ |
|
177 |
_AKNTRACE_FUNC_ENTER; |
|
178 |
TBool empty( EFalse ); |
|
179 |
for ( TInt i = 0; i < iCollections.Count(); i++ ) |
|
180 |
{ |
|
181 |
MAknCollection* collection( iCollections[i] ); |
|
182 |
if ( collection->CollectionState() & |
|
183 |
MAknCollection::EStateCollectionVisible ) |
|
184 |
{ |
|
185 |
MAknMarkingCollection* markingCollection |
|
186 |
= MarkingCollection( *collection ); |
|
187 |
if ( markingCollection ) |
|
188 |
{ |
|
189 |
TInt markingState = markingCollection->MarkingState(); |
|
190 |
if ( markingState & |
|
191 |
MAknMarkingCollection::EStateMarkingMode ) |
|
192 |
{ |
|
193 |
empty = markingState |
|
194 |
& MAknMarkingCollection::EStateCollectionEmpty; |
|
195 |
} |
|
196 |
} |
|
197 |
break; |
|
198 |
} |
|
199 |
} |
|
200 |
_AKNTRACE_FUNC_EXIT; |
|
201 |
return empty; |
|
202 |
} |
|
203 |
||
204 |
||
205 |
// --------------------------------------------------------------------------- |
|
206 |
// CAknMarkingMode::MarkAllL |
|
207 |
// --------------------------------------------------------------------------- |
|
208 |
// |
|
209 |
void CAknMarkingMode::MarkAllL() |
|
210 |
{ |
|
211 |
_AKNTRACE_FUNC_ENTER; |
|
212 |
MAknMarkingCollection* collection = ActiveMarkingCollection(); |
|
213 |
||
214 |
if ( collection ) |
|
215 |
{ |
|
216 |
collection->MarkAllL(); |
|
217 |
} |
|
218 |
_AKNTRACE_FUNC_EXIT; |
|
219 |
} |
|
220 |
||
221 |
||
222 |
// --------------------------------------------------------------------------- |
|
223 |
// CAknMarkingMode::UnmarkAll |
|
224 |
// --------------------------------------------------------------------------- |
|
225 |
// |
|
226 |
void CAknMarkingMode::UnmarkAll() |
|
227 |
{ |
|
228 |
_AKNTRACE_FUNC_ENTER; |
|
229 |
MAknMarkingCollection* collection = ActiveMarkingCollection(); |
|
230 |
||
231 |
if ( collection ) |
|
232 |
{ |
|
233 |
collection->UnmarkAll(); |
|
234 |
} |
|
235 |
_AKNTRACE_FUNC_EXIT; |
|
236 |
} |
|
237 |
||
238 |
||
239 |
// --------------------------------------------------------------------------- |
|
240 |
// CAknMarkingMode::MarkCurrentItemL |
|
241 |
// --------------------------------------------------------------------------- |
|
242 |
// |
|
243 |
void CAknMarkingMode::MarkCurrentItemL() |
|
244 |
{ |
|
245 |
_AKNTRACE_FUNC_ENTER; |
|
246 |
MAknMarkingCollection* collection = ActiveMarkingCollection(); |
|
247 |
||
248 |
// first activate marking mode if needed |
|
249 |
if ( !collection ) |
|
250 |
{ |
|
251 |
SetCollectionMultipleMarkingState( ETrue ); |
|
252 |
collection = ActiveMarkingCollection(); |
|
253 |
} |
|
254 |
||
255 |
// then mark the current item |
|
256 |
if ( collection ) |
|
257 |
{ |
|
258 |
collection->MarkCurrentItemL(); |
|
259 |
} |
|
260 |
_AKNTRACE_FUNC_EXIT; |
|
261 |
} |
|
262 |
||
263 |
// --------------------------------------------------------------------------- |
|
264 |
// CAknMarkingMode::CurrentItemMarkable |
|
265 |
// --------------------------------------------------------------------------- |
|
266 |
// |
|
267 |
TBool CAknMarkingMode::CurrentItemMarkable() |
|
268 |
{ |
|
269 |
_AKNTRACE_FUNC_ENTER; |
|
270 |
_AKNTRACE_FUNC_EXIT; |
|
271 |
return MarkingCollection()->CurrentItemMarkable(); |
|
272 |
} |
|
273 |
||
274 |
// --------------------------------------------------------------------------- |
|
275 |
// CAknMarkingMode::CAknMarkingMode |
|
276 |
// --------------------------------------------------------------------------- |
|
277 |
// |
|
278 |
CAknMarkingMode::CAknMarkingMode( |
|
279 |
CAknItemActionMenu& aItemActionMenu, |
|
280 |
CollectionArray& aArray ) |
|
281 |
: iCollections( aArray ), |
|
282 |
iItemActionMenu( aItemActionMenu ), |
|
283 |
iMarkingDecorator( NULL ) |
|
284 |
{ |
|
285 |
_AKNTRACE_FUNC_ENTER; |
|
286 |
AKNTASHOOK_ADD( this, "CAknMarkingMode" ); |
|
287 |
_AKNTRACE_FUNC_EXIT; |
|
288 |
} |
|
289 |
||
290 |
||
291 |
// --------------------------------------------------------------------------- |
|
292 |
// CAknMarkingMode::MarkingCollection |
|
293 |
// --------------------------------------------------------------------------- |
|
294 |
// |
|
295 |
MAknMarkingCollection* CAknMarkingMode::MarkingCollection( |
|
296 |
MAknCollection& aCollection ) |
|
297 |
{ |
|
298 |
_AKNTRACE_FUNC_ENTER; |
|
299 |
TAny* extension( NULL ); |
|
300 |
aCollection.CollectionExtension( |
|
301 |
MAknMarkingCollection::TYPE, extension, NULL ); |
|
302 |
_AKNTRACE_FUNC_EXIT; |
|
303 |
return static_cast<MAknMarkingCollection*>( extension ); |
|
304 |
} |
|
305 |
||
306 |
||
307 |
// --------------------------------------------------------------------------- |
|
308 |
// CAknMarkingMode::MarkingCollection |
|
309 |
// --------------------------------------------------------------------------- |
|
310 |
// |
|
311 |
MAknMarkingCollection* CAknMarkingMode::MarkingCollection() |
|
312 |
{ |
|
313 |
_AKNTRACE_FUNC_ENTER; |
|
314 |
for ( TInt i = 0; i < iCollections.Count(); i++ ) |
|
315 |
{ |
|
316 |
MAknCollection* collection( iCollections[i] ); |
|
317 |
if ( collection->CollectionState() & |
|
318 |
MAknCollection::EStateCollectionVisible ) |
|
319 |
{ |
|
320 |
_AKNTRACE_FUNC_EXIT; |
|
321 |
return MarkingCollection( *collection ); |
|
322 |
} |
|
323 |
} |
|
324 |
_AKNTRACE_FUNC_EXIT; |
|
325 |
return NULL; |
|
326 |
} |
|
327 |
||
328 |
||
329 |
// --------------------------------------------------------------------------- |
|
330 |
// CAknMarkingMode::ActiveMarkingCollection |
|
331 |
// --------------------------------------------------------------------------- |
|
332 |
// |
|
333 |
MAknMarkingCollection* CAknMarkingMode::ActiveMarkingCollection() |
|
334 |
{ |
|
335 |
_AKNTRACE_FUNC_ENTER; |
|
336 |
for ( TInt i = 0; i < iCollections.Count(); i++ ) |
|
337 |
{ |
|
338 |
MAknCollection* collection( iCollections[i] ); |
|
339 |
||
340 |
MAknMarkingCollection* markingCollection = |
|
341 |
MarkingCollection( *collection ); |
|
342 |
||
343 |
if ( markingCollection && markingCollection->MarkingState() & |
|
344 |
MAknMarkingCollection::EStateMarkingMode ) |
|
345 |
{ |
|
346 |
_AKNTRACE_FUNC_EXIT; |
|
347 |
return markingCollection; |
|
348 |
} |
|
349 |
} |
|
350 |
_AKNTRACE_FUNC_EXIT; |
|
351 |
return NULL; |
|
352 |
} |
|
353 |
||
354 |
// --------------------------------------------------------------------------- |
|
355 |
// CAknMarkingMode::UpdateMarkingModeNaviPaneL |
|
356 |
// --------------------------------------------------------------------------- |
|
357 |
// |
|
358 |
void CAknMarkingMode::UpdateMarkingModeNaviPaneL( TBool aEnable ) |
|
359 |
{ |
|
360 |
_AKNTRACE_FUNC_ENTER; |
|
361 |
CEikonEnv* eikonEnv = CEikonEnv::Static(); |
|
362 |
||
363 |
if ( eikonEnv && eikonEnv->AppUiFactory() ) |
|
364 |
{ |
|
365 |
CEikStatusPane* statusPane = eikonEnv->AppUiFactory()->StatusPane(); |
|
366 |
||
367 |
if ( statusPane ) |
|
368 |
{ |
|
369 |
// get navi pane |
|
370 |
CAknNavigationControlContainer* naviPane = |
|
371 |
(CAknNavigationControlContainer *)statusPane->ControlL( |
|
372 |
TUid::Uid(EEikStatusPaneUidNavi)); |
|
373 |
if ( naviPane ) |
|
374 |
{ |
|
375 |
if ( !iMarkingDecorator ) |
|
376 |
{ |
|
377 |
TResourceReader reader; |
|
378 |
eikonEnv->CreateResourceReaderLC( |
|
379 |
reader, R_MARKING_MODE_NAVI_PANE ); |
|
380 |
||
381 |
iMarkingDecorator = naviPane->CreateNavigationLabelL( |
|
382 |
reader ); |
|
383 |
CleanupStack::PopAndDestroy(); // reader |
|
384 |
} |
|
385 |
||
386 |
if ( aEnable ) |
|
387 |
{ |
|
388 |
naviPane->PushL( *iMarkingDecorator ); |
|
389 |
} |
|
390 |
else |
|
391 |
{ |
|
392 |
naviPane->Pop( iMarkingDecorator ); |
|
393 |
} |
|
394 |
naviPane->DrawDeferred(); |
|
395 |
} |
|
396 |
} |
|
397 |
} |
|
398 |
_AKNTRACE_FUNC_EXIT; |
|
399 |
} |
|
400 |
||
401 |
// End of File |