18
|
1 |
/*
|
|
2 |
* Copyright (c) 2008-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: Container class for Events Management UI startup view.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// SYSTEM INCLUDES
|
|
20 |
#include <avkon.hrh>
|
|
21 |
#include <avkon.mbg>
|
|
22 |
#include <barsread.h>
|
|
23 |
#include <aknlists.h>
|
|
24 |
#include <AknIconArray.h> // Icon Array
|
|
25 |
#include <eikclbd.h> // Column Listbox
|
|
26 |
#include <gulicon.h> // Gul Icon
|
|
27 |
#include <barsread.h> // TResourceReader
|
|
28 |
#include <eikspane.h> // Status pane
|
|
29 |
#include <akntitle.h> // CAknTitlePane
|
|
30 |
#include <StringLoader.h> // String Loader
|
|
31 |
#include <evtmgmtui.rsg>
|
|
32 |
#include <csxhelp/loc.hlp.hrh>
|
|
33 |
#include <AknUtils.h>
|
|
34 |
#include <evtmgmtui.mbg>
|
|
35 |
#include <featmgr.h>
|
|
36 |
#include <data_caging_path_literals.hrh>
|
|
37 |
#include <AknUtils.h>
|
|
38 |
#include <eikmenup.h>
|
|
39 |
#include <AknsConstants.h> // Skin Ids
|
|
40 |
#include <AknIconUtils.h>
|
|
41 |
#include <AknLayout.lag> // AVKON LAF layouts
|
|
42 |
#include <AknLayoutDef.h>
|
|
43 |
#include <aknsfld.h> // For SearchField
|
|
44 |
|
|
45 |
// USER INCLUDES
|
|
46 |
#include "evtmgmtui.hrh"
|
|
47 |
#include "evtmgmtuiuid.hrh"
|
|
48 |
#include "evtmgmtuiappui.h"
|
|
49 |
#include "evtmgmtuimodel.h"
|
|
50 |
#include "evtmgmtuistartupcontainer.h"
|
|
51 |
#include "evtmgmtuilistbox.h"
|
|
52 |
#include "evtmgmtuilistboxmodel.h"
|
|
53 |
#include "evtdebug.h"
|
|
54 |
|
|
55 |
// CONSTANT DEFINITIONS
|
|
56 |
const TInt KIconArrayGranularity = 5; // The number of default icons
|
|
57 |
const TInt KFindBoxTextLength = 32; // Find Box text length.
|
|
58 |
const TInt KMinCountForFilter = 2;
|
|
59 |
_LIT( KEvtMgmtUiIconFileName, "evtmgmtui.mif" );
|
|
60 |
|
|
61 |
// ----------------- Member funtions for CEvtMgmtUiStartupContainer class ------------------
|
|
62 |
|
|
63 |
// ---------------------------------------------------------------------------
|
|
64 |
// CEvtMgmtUiStartupContainer::CEvtMgmtUiStartupContainer
|
|
65 |
// ---------------------------------------------------------------------------
|
|
66 |
//
|
|
67 |
CEvtMgmtUiStartupContainer::CEvtMgmtUiStartupContainer( MEvtMgmtUiCmdHdlr& aCmdHandler )
|
|
68 |
:iCmdHandler(aCmdHandler)
|
|
69 |
{
|
|
70 |
}
|
|
71 |
|
|
72 |
|
|
73 |
// ---------------------------------------------------------------------------
|
|
74 |
// CEvtMgmtUiStartupContainer::~CEvtMgmtUiStartupContainer
|
|
75 |
// ---------------------------------------------------------------------------
|
|
76 |
//
|
|
77 |
CEvtMgmtUiStartupContainer::~CEvtMgmtUiStartupContainer()
|
|
78 |
{
|
|
79 |
// Delete the List box
|
|
80 |
delete iListBox;
|
|
81 |
|
|
82 |
delete iFindBox;
|
|
83 |
}
|
|
84 |
|
|
85 |
// ---------------------------------------------------------------------------
|
|
86 |
// CEvtMgmtUiStartupContainer::NewL
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
//
|
|
89 |
CEvtMgmtUiStartupContainer* CEvtMgmtUiStartupContainer::NewL(
|
|
90 |
const TRect& aRect, CEvtMgmtUiModel* aModel,
|
|
91 |
MEvtMgmtUiCmdHdlr& aCmdHandler )
|
|
92 |
{
|
|
93 |
CEvtMgmtUiStartupContainer* self = new ( ELeave ) CEvtMgmtUiStartupContainer( aCmdHandler );
|
|
94 |
CleanupStack::PushL( self );
|
|
95 |
self->ConstructL( aRect, aModel );
|
|
96 |
CleanupStack::Pop();
|
|
97 |
return self;
|
|
98 |
}
|
|
99 |
|
|
100 |
// ---------------------------------------------------------------------------
|
|
101 |
// CEvtMgmtUiStartupContainer::CEvtMgmtUiStartupContainer
|
|
102 |
// ---------------------------------------------------------------------------
|
|
103 |
//
|
|
104 |
void CEvtMgmtUiStartupContainer::ConstructL( const TRect& aRect, CEvtMgmtUiModel* aModel )
|
|
105 |
{
|
|
106 |
// This is the cheif control for this application. This has to be made a
|
|
107 |
// Window owning control
|
|
108 |
CreateWindowL();
|
|
109 |
|
|
110 |
// Create the List box
|
|
111 |
EVTUIDEBUG( "Listbox creation" );
|
|
112 |
CreateListboxL(aModel);
|
|
113 |
CreateFindBoxL();
|
|
114 |
|
|
115 |
// Check for FindBox Visiblity
|
|
116 |
HandleFindBoxVisibility();
|
|
117 |
|
|
118 |
// Get the Help context
|
|
119 |
iContextName = KHLP_LOC_EVENTS_VIEW();
|
|
120 |
|
|
121 |
// Set Title
|
|
122 |
MakeTitleL();
|
|
123 |
|
|
124 |
SetRect(aRect);
|
|
125 |
ActivateL();
|
|
126 |
}
|
|
127 |
|
|
128 |
// ---------------------------------------------------------------------------
|
|
129 |
// void CEvtMgmtUiStartupContainer::GetHelpContext
|
|
130 |
// ---------------------------------------------------------------------------
|
|
131 |
//
|
|
132 |
void CEvtMgmtUiStartupContainer::GetHelpContext( TCoeHelpContext& aContext ) const
|
|
133 |
{
|
|
134 |
aContext.iContext = iContextName;
|
|
135 |
aContext.iMajor = TUid::Uid( KEvtMgmtUiUid );
|
|
136 |
}
|
|
137 |
|
|
138 |
// --------------------------------------------------------------------------
|
|
139 |
// CEvtMgmtUiStartupContainer::FocusChanged
|
|
140 |
// --------------------------------------------------------------------------
|
|
141 |
//
|
|
142 |
void CEvtMgmtUiStartupContainer::FocusChanged( TDrawNow aDrawNow )
|
|
143 |
{
|
|
144 |
if ( iListBox )
|
|
145 |
{
|
|
146 |
iListBox->SetFocus( IsFocused(), aDrawNow );
|
|
147 |
}
|
|
148 |
|
|
149 |
if ( iFindBox && iFindBox->IsVisible() )
|
|
150 |
{
|
|
151 |
iFindBox->SetFocus( IsFocused(), aDrawNow );
|
|
152 |
if ( aDrawNow == EDrawNow && IsFocused() )
|
|
153 |
{
|
|
154 |
iFindBox->DrawDeferred();
|
|
155 |
}
|
|
156 |
}
|
|
157 |
}
|
|
158 |
|
|
159 |
// ---------------------------------------------------------------------------
|
|
160 |
// void CEvtMgmtUiStartupContainer::SizeChanged
|
|
161 |
// ---------------------------------------------------------------------------
|
|
162 |
//
|
|
163 |
void CEvtMgmtUiStartupContainer::SizeChanged()
|
|
164 |
{
|
|
165 |
EVTUIDEBUG("+ CEvtMgmtUiStartupContainer::SizeChanged()" );
|
|
166 |
const TRect rect( Rect() );
|
|
167 |
TAknLayoutRect controlRect;
|
|
168 |
|
|
169 |
// Since iFindBox->IsVisible() returns EFalse if Adaptive Chars are shown,
|
|
170 |
// We check on FilteredNumberOfItems meaning the FindBox should be visible when
|
|
171 |
// FilteredNumberOfItems is greater than 1
|
|
172 |
if( iListBox && iFindBox &&
|
|
173 |
( iFindBox->IsVisible() || iListBox->Model()->Filter()->FilteredNumberOfItems() > 1 ) )
|
|
174 |
{
|
|
175 |
controlRect.LayoutRect(rect, AknLayout::list_gen_pane( 1 ) );
|
|
176 |
iListBox->SetRect( controlRect.Rect() );
|
|
177 |
controlRect.LayoutRect(rect, AknLayout::find_pane() );
|
|
178 |
iFindBox->SetRect( controlRect.Rect() );
|
|
179 |
}
|
|
180 |
else if( iListBox )
|
|
181 |
{
|
|
182 |
controlRect.LayoutRect(rect, AknLayout::list_gen_pane( 0 ) );
|
|
183 |
iListBox->SetRect( controlRect.Rect() );
|
|
184 |
}
|
|
185 |
EVTUIDEBUG("- CEvtMgmtUiStartupContainer::SizeChanged()" );
|
|
186 |
}
|
|
187 |
|
|
188 |
// ---------------------------------------------------------------------------
|
|
189 |
// TInt CEvtMgmtUiStartupContainer::CountComponentControls
|
|
190 |
// ---------------------------------------------------------------------------
|
|
191 |
//
|
|
192 |
TInt CEvtMgmtUiStartupContainer::CountComponentControls() const
|
|
193 |
{
|
|
194 |
TInt count = 0;
|
|
195 |
CCoeControl* controls[] = { iListBox, iFindBox };
|
|
196 |
|
|
197 |
for ( TUint i = 0; i < sizeof( controls ) / sizeof( CCoeControl* ); i++ )
|
|
198 |
{
|
|
199 |
if ( controls[i] ) // Test for valid controls
|
|
200 |
{
|
|
201 |
count++;
|
|
202 |
}
|
|
203 |
}
|
|
204 |
|
|
205 |
return count;
|
|
206 |
}
|
|
207 |
|
|
208 |
// ---------------------------------------------------------------------------
|
|
209 |
// CCoeControl* CEvtMgmtUiStartupContainer::CEvtMgmtUiStartupContainer
|
|
210 |
// ---------------------------------------------------------------------------
|
|
211 |
//
|
|
212 |
CCoeControl* CEvtMgmtUiStartupContainer::ComponentControl(TInt aIndex ) const
|
|
213 |
{
|
|
214 |
CCoeControl* controls[] = { iListBox,
|
|
215 |
iFindBox};
|
|
216 |
|
|
217 |
for ( TUint i = 0; i < sizeof( controls ) / sizeof( CCoeControl* ); i++ )
|
|
218 |
{
|
|
219 |
// Index is decremented only if control is not NULL
|
|
220 |
if ( controls[i] && aIndex-- == 0 )
|
|
221 |
{
|
|
222 |
return controls[i];
|
|
223 |
}
|
|
224 |
}
|
|
225 |
|
|
226 |
return NULL;
|
|
227 |
}
|
|
228 |
|
|
229 |
// ---------------------------------------------------------------------------
|
|
230 |
// TKeyResponse CEvtMgmtUiStartupContainer::OfferKeyEventL
|
|
231 |
// ---------------------------------------------------------------------------
|
|
232 |
//
|
|
233 |
TKeyResponse CEvtMgmtUiStartupContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,
|
|
234 |
TEventCode aType )
|
|
235 |
{
|
|
236 |
TKeyResponse keyresponse;
|
|
237 |
|
|
238 |
TBool needRefresh = EFalse;
|
|
239 |
TInt keyConsumed = iFindBox->TextLength();
|
|
240 |
|
|
241 |
// Key is first offered to the Find box based on the key press.
|
|
242 |
keyresponse = AknFind::HandleFindOfferKeyEventL(aKeyEvent, aType,
|
|
243 |
this, iListBox, iFindBox, EFalse, needRefresh);
|
|
244 |
|
|
245 |
// Handle the ListBox Filter count changed event
|
|
246 |
iCmdHandler.HandleCmdL( MEvtMgmtUiCmdHdlr::EListBoxFilterCountChanged );
|
|
247 |
|
|
248 |
// This is to avoid the Mark for the First item of the list box.
|
|
249 |
// We reset the modifier attribute
|
|
250 |
TKeyEvent& keyEvent = const_cast<TKeyEvent&>(aKeyEvent);
|
|
251 |
TInt index = CurrentItemIndex();
|
|
252 |
if(index == 0 ||
|
|
253 |
(index == iListBox->Model()->NumberOfItems() - 1) && aKeyEvent.iScanCode == EStdKeyDownArrow ||
|
|
254 |
(index == 1) && aKeyEvent.iScanCode == EStdKeyUpArrow )
|
|
255 |
{
|
|
256 |
if(keyEvent.iModifiers & EModifierShift)
|
|
257 |
keyEvent.iModifiers&= ~EModifierShift;
|
|
258 |
if(keyEvent.iModifiers & EModifierLeftShift)
|
|
259 |
keyEvent.iModifiers&= ~EModifierLeftShift;
|
|
260 |
if(keyEvent.iModifiers & EModifierRightShift)
|
|
261 |
keyEvent.iModifiers&= ~EModifierRightShift;
|
|
262 |
if(keyEvent.iModifiers & EModifierCtrl)
|
|
263 |
keyEvent.iModifiers&= ~EModifierCtrl;
|
|
264 |
if(keyEvent.iModifiers & EModifierRightCtrl)
|
|
265 |
keyEvent.iModifiers&= ~EModifierRightCtrl;
|
|
266 |
}
|
|
267 |
|
|
268 |
// Now handle the Key Event based on the Key type
|
|
269 |
switch ( aKeyEvent.iScanCode )
|
|
270 |
{
|
|
271 |
case EStdKeyUpArrow:
|
|
272 |
case EStdKeyDownArrow:
|
|
273 |
{
|
|
274 |
keyresponse = iListBox->OfferKeyEventL( aKeyEvent, aType );
|
|
275 |
iCmdHandler.HandleCmdL( MEvtMgmtUiCmdHdlr::EListBoxItemFocused );
|
|
276 |
return keyresponse;
|
|
277 |
}
|
|
278 |
case EStdKeyBackspace:
|
|
279 |
case EStdKeyDelete:
|
|
280 |
{
|
|
281 |
if(aType == EEventKey && !keyConsumed )
|
|
282 |
{
|
|
283 |
keyresponse = iListBox->OfferKeyEventL( aKeyEvent, aType );
|
|
284 |
iCmdHandler.HandleCmdL( MEvtMgmtUiCmdHdlr::EListBoxItemDeleted );
|
|
285 |
}
|
|
286 |
return keyresponse;
|
|
287 |
}
|
|
288 |
case EStdKeyHash:
|
|
289 |
{
|
|
290 |
if(!index)
|
|
291 |
{
|
|
292 |
keyresponse = EKeyWasConsumed;
|
|
293 |
}
|
|
294 |
else
|
|
295 |
{
|
|
296 |
TBool shiftKeyPressed = ( aKeyEvent.iModifiers & EModifierShift );
|
|
297 |
keyresponse = iListBox->OfferKeyEventL( aKeyEvent, aType );
|
|
298 |
if( aType == EEventKeyUp && ( EKeyWasConsumed == keyresponse || !shiftKeyPressed ) )
|
|
299 |
iCmdHandler.HandleCmdL( MEvtMgmtUiCmdHdlr::EListBoxItemFocused );
|
|
300 |
}
|
|
301 |
return keyresponse;
|
|
302 |
}
|
|
303 |
default:
|
|
304 |
{
|
|
305 |
break;
|
|
306 |
}
|
|
307 |
}
|
|
308 |
// Now it's List box's job to process the key event
|
|
309 |
return iListBox->OfferKeyEventL( aKeyEvent, aType );
|
|
310 |
}
|
|
311 |
|
|
312 |
// ---------------------------------------------------------------------------
|
|
313 |
// void CEvtMgmtUiStartupContainer::HandleResourceChange
|
|
314 |
// ---------------------------------------------------------------------------
|
|
315 |
//
|
|
316 |
void CEvtMgmtUiStartupContainer::HandleResourceChange( TInt aType )
|
|
317 |
{
|
|
318 |
// Pass the event to the base class
|
|
319 |
CCoeControl::HandleResourceChange(aType);
|
|
320 |
|
|
321 |
switch( aType )
|
|
322 |
{
|
|
323 |
case KAknsMessageSkinChange:
|
|
324 |
{
|
|
325 |
TRAPD( error, UpdateIconsL() );
|
|
326 |
if ( error != KErrNone )
|
|
327 |
{
|
|
328 |
iEikonEnv->HandleError( error );
|
|
329 |
}
|
|
330 |
DrawDeferred();
|
|
331 |
|
|
332 |
break;
|
|
333 |
}
|
|
334 |
// Dynamic Layout switch
|
|
335 |
case KEikDynamicLayoutVariantSwitch:
|
|
336 |
{
|
|
337 |
// Handle the screen change event
|
|
338 |
// Trap and Ignore the error
|
|
339 |
TRAP_IGNORE(
|
|
340 |
iCmdHandler.HandleCmdL( MEvtMgmtUiCmdHdlr::EScreenSizeChanged ));
|
|
341 |
break;
|
|
342 |
}
|
|
343 |
default:
|
|
344 |
{
|
|
345 |
break;
|
|
346 |
}
|
|
347 |
}
|
|
348 |
}
|
|
349 |
|
|
350 |
// ---------------------------------------------------------------------------
|
|
351 |
// void CEvtMgmtUiStartupContainer::HandleListBoxEventL
|
|
352 |
// ---------------------------------------------------------------------------
|
|
353 |
//
|
|
354 |
void CEvtMgmtUiStartupContainer::HandleListBoxEventL(
|
|
355 |
CEikListBox* /* aListBox */,
|
|
356 |
TListBoxEvent aEventType )
|
|
357 |
{
|
|
358 |
switch (aEventType)
|
|
359 |
{
|
|
360 |
// List box Item Selection
|
|
361 |
case EEventEnterKeyPressed:
|
|
362 |
case EEventItemSingleClicked:
|
|
363 |
{
|
|
364 |
iCmdHandler.HandleCmdL( MEvtMgmtUiCmdHdlr::EListBoxItemDoubleClicked );
|
|
365 |
break;
|
|
366 |
}
|
|
367 |
case EEventItemClicked:
|
|
368 |
{
|
|
369 |
iCmdHandler.HandleCmdL( MEvtMgmtUiCmdHdlr::EListBoxItemFocused);
|
|
370 |
break;
|
|
371 |
}
|
|
372 |
default:
|
|
373 |
break;
|
|
374 |
}
|
|
375 |
}
|
|
376 |
|
|
377 |
// ---------------------------------------------------------------------------
|
|
378 |
// void CEvtMgmtUiStartupContainer::CreateListboxL
|
|
379 |
// ---------------------------------------------------------------------------
|
|
380 |
//
|
|
381 |
void CEvtMgmtUiStartupContainer::CreateListboxL( CEvtMgmtUiModel* aModel )
|
|
382 |
{
|
|
383 |
EVTUIDEBUG("+ CEvtMgmtUiStartupContainer::CreateListboxL()" );
|
|
384 |
// Create the List box
|
|
385 |
iListBox = new ( ELeave ) CEvtMgmtUiListBox();
|
|
386 |
iListBox->ConstructL( this, EAknListBoxStylusMarkableList );
|
|
387 |
iListBox->SetContainerWindowL( *this );
|
|
388 |
iListBox->SetListBoxObserver( this );
|
|
389 |
iListBox->CreateScrollBarFrameL(ETrue);
|
|
390 |
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,
|
|
391 |
CEikScrollBarFrame::EAuto );
|
|
392 |
|
|
393 |
UpdateIconsL();
|
|
394 |
|
|
395 |
// Create the Listbox model
|
|
396 |
CEvtMgmtUiListBoxModel* model = static_cast<CEvtMgmtUiListBoxModel*>(iListBox->Model());
|
|
397 |
model->SetItemTextArray( aModel );
|
|
398 |
model->SetOwnershipType( ELbmDoesNotOwnItemArray );
|
|
399 |
model->SetItemTextArrayToFilterModel();
|
|
400 |
|
|
401 |
iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
|
|
402 |
|
|
403 |
iListBox->ActivateL();
|
|
404 |
|
|
405 |
EVTUIDEBUG("- CEvtMgmtUiStartupContainer::CreateListboxL()" );
|
|
406 |
}
|
|
407 |
|
|
408 |
// -----------------------------------------------------------------------------
|
|
409 |
// CEvtMgmtUiStartupContainer::CreateFindBoxL()
|
|
410 |
//
|
|
411 |
// Creates the member iFindBox
|
|
412 |
// -----------------------------------------------------------------------------
|
|
413 |
//
|
|
414 |
void CEvtMgmtUiStartupContainer::CreateFindBoxL()
|
|
415 |
{
|
|
416 |
EVTUIDEBUG("+ CEvtMgmtUiStartupContainer::CreateFindBoxL()" );
|
|
417 |
|
|
418 |
// Create the findbox.
|
|
419 |
iFindBox = CAknSearchField::NewL( *this, CAknSearchField::EAdaptiveSearch,
|
|
420 |
NULL, KFindBoxTextLength );
|
|
421 |
|
|
422 |
// Set default input mode to Katakana if current UI language is Japanese
|
|
423 |
if (FeatureManager::FeatureSupported(KFeatureIdJapanese) &&
|
|
424 |
(User::Language() == ELangJapanese))
|
|
425 |
{
|
|
426 |
iFindBox->Editor().SetAknEditorInputMode(EAknEditorKatakanaInputMode);
|
|
427 |
}
|
|
428 |
else
|
|
429 |
{
|
|
430 |
iFindBox->Editor().SetAknEditorCurrentInputMode(EAknEditorTextInputMode);
|
|
431 |
}
|
|
432 |
|
|
433 |
// Set Column mask
|
|
434 |
iFindBox->SetListColumnFilterFlags(2); // This is set to search only "Subject" column
|
|
435 |
|
|
436 |
STATIC_CAST(CAknFilteredTextListBoxModel*, iListBox->Model())->CreateFilterL(iListBox,iFindBox);
|
|
437 |
STATIC_CAST(CAknFilteredTextListBoxModel*, iListBox->Model())->Filter()->SetParentControl( this );
|
|
438 |
iListBox->Model()->SetFindToFilterModel(iFindBox);
|
|
439 |
|
|
440 |
iFindBox->ActivateL();
|
|
441 |
|
|
442 |
EVTUIDEBUG("- CEvtMgmtUiStartupContainer::CreateFindBoxL()" );
|
|
443 |
}
|
|
444 |
|
|
445 |
// -----------------------------------------------------------------------------
|
|
446 |
// CEvtMgmtUiStartupContainer::MakeFindBoxVisible()
|
|
447 |
//
|
|
448 |
// Deletes the member iFindBox
|
|
449 |
// -----------------------------------------------------------------------------
|
|
450 |
//
|
|
451 |
void CEvtMgmtUiStartupContainer::HandleFindBoxVisibility()
|
|
452 |
{
|
|
453 |
if( iListBox && iFindBox )
|
|
454 |
{
|
|
455 |
if(iListBox->Model()->Filter()->FilteredNumberOfItems() < KMinCountForFilter )
|
|
456 |
{
|
|
457 |
iFindBox->SetFocusing( EFalse );
|
|
458 |
iFindBox->MakeVisible( EFalse );
|
|
459 |
iListBox->SetFocusing( ETrue );
|
|
460 |
}
|
|
461 |
else
|
|
462 |
{
|
|
463 |
iFindBox->SetFocusing( ETrue );
|
|
464 |
iFindBox->MakeVisible( ETrue );
|
|
465 |
iListBox->SetFocusing( EFalse );
|
|
466 |
}
|
|
467 |
|
|
468 |
SizeChanged();
|
|
469 |
DrawNow();
|
|
470 |
}
|
|
471 |
}
|
|
472 |
|
|
473 |
// -----------------------------------------------------------------------------
|
|
474 |
// CEvtMgmtUiStartupContainer::UpdateIconsL
|
|
475 |
// -----------------------------------------------------------------------------
|
|
476 |
void CEvtMgmtUiStartupContainer::UpdateIconsL()
|
|
477 |
{
|
|
478 |
EVTUIDEBUG( "+ CEvtMgmtUiStartupContainer::UpdateIconsL()" );
|
|
479 |
|
|
480 |
CAknIconArray* icons = new( ELeave ) CAknIconArray( KIconArrayGranularity );
|
|
481 |
CleanupStack::PushL( icons );
|
|
482 |
|
|
483 |
TFileName *iconFile = IconFileNameLC();
|
|
484 |
|
|
485 |
//mark
|
|
486 |
AddColorIconL( *icons,
|
|
487 |
AknIconUtils::AvkonIconFileName(),
|
|
488 |
KAknsIIDQgnIndiMarkedAdd,
|
|
489 |
EMbmAvkonQgn_indi_marked_add, EMbmAvkonQgn_indi_marked_add_mask );
|
|
490 |
|
|
491 |
//Create new event
|
|
492 |
AddIconL( *icons,
|
|
493 |
*iconFile,
|
|
494 |
KAknsIIDQgnPropLocevNew,
|
|
495 |
EMbmEvtmgmtuiQgn_prop_locev_new, EMbmEvtmgmtuiQgn_prop_locev_new_mask);
|
|
496 |
|
|
497 |
//active
|
|
498 |
AddIconL( *icons,
|
|
499 |
*iconFile,
|
|
500 |
KAknsIIDQgnPropLocevTrigger,
|
|
501 |
EMbmEvtmgmtuiQgn_prop_locev_trigger, EMbmEvtmgmtuiQgn_prop_locev_trigger_mask);
|
|
502 |
|
|
503 |
//draft
|
|
504 |
AddIconL( *icons,
|
|
505 |
*iconFile,
|
|
506 |
KAknsIIDQgnPropLocevDraft,
|
|
507 |
EMbmEvtmgmtuiQgn_prop_locev_draft, EMbmEvtmgmtuiQgn_prop_locev_draft_mask);
|
|
508 |
|
|
509 |
//completed
|
|
510 |
AddIconL( *icons,
|
|
511 |
*iconFile,
|
|
512 |
KAknsIIDQgnPropLocevCompleted,
|
|
513 |
EMbmEvtmgmtuiQgn_prop_locev_completed, EMbmEvtmgmtuiQgn_prop_locev_completed_mask);
|
|
514 |
|
|
515 |
// repeat
|
|
516 |
AddColorIconL( *icons,
|
|
517 |
*iconFile,
|
|
518 |
KAknsIIDQgnIndiRepeatAdd,
|
|
519 |
EMbmEvtmgmtuiQgn_indi_repeat_add, EMbmEvtmgmtuiQgn_indi_repeat_add_mask);
|
|
520 |
|
|
521 |
CleanupStack::PopAndDestroy(iconFile);
|
|
522 |
|
|
523 |
//get old icons and delete those
|
|
524 |
CAknIconArray* oldIcons = static_cast<CAknIconArray*>(
|
|
525 |
iListBox->ItemDrawer()->ColumnData()->IconArray() );
|
|
526 |
delete oldIcons;
|
|
527 |
|
|
528 |
//set new icons to array
|
|
529 |
iListBox->ItemDrawer()->ColumnData()->SetIconArray( icons );
|
|
530 |
CleanupStack::Pop(icons);
|
|
531 |
|
|
532 |
EVTUIDEBUG( "- CEvtMgmtUiStartupContainer::UpdateIconsL()" );
|
|
533 |
|
|
534 |
}
|
|
535 |
|
|
536 |
// -----------------------------------------------------------------------------
|
|
537 |
// CEvtMgmtUiStartupContainer::AddIconL
|
|
538 |
// -----------------------------------------------------------------------------
|
|
539 |
void CEvtMgmtUiStartupContainer::AddIconL( CAknIconArray& aIcons,
|
|
540 |
const TDesC& aIconFileWithPath,
|
|
541 |
TAknsItemID aSkinID,
|
|
542 |
TInt aIconGraphicsIndex,
|
|
543 |
TInt aIconGraphicsMaskIndex )
|
|
544 |
{
|
|
545 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
|
|
546 |
|
|
547 |
EVTUIDEBUG( "AknsUtils::SkinInstance" );
|
|
548 |
|
|
549 |
CFbsBitmap* bitmap = NULL;
|
|
550 |
CFbsBitmap* bitmapMask = NULL;
|
|
551 |
TRAPD( err, AknsUtils::CreateIconL( skin,
|
|
552 |
aSkinID,
|
|
553 |
bitmap,
|
|
554 |
bitmapMask,
|
|
555 |
aIconFileWithPath,
|
|
556 |
aIconGraphicsIndex,
|
|
557 |
aIconGraphicsMaskIndex ) );
|
|
558 |
|
|
559 |
|
|
560 |
EVTUIDEBUG1( "AknsUtils::CreateIconL - %d", err );
|
|
561 |
if(err != KErrNone)
|
|
562 |
{
|
|
563 |
TRAP( err, AknIconUtils::CreateIconL( bitmap,
|
|
564 |
bitmapMask,
|
|
565 |
aIconFileWithPath,
|
|
566 |
aIconGraphicsIndex,
|
|
567 |
aIconGraphicsMaskIndex ) );
|
|
568 |
EVTUIDEBUG1( "AknIconUtils::CreateIconL - %d", err );
|
|
569 |
}
|
|
570 |
User::LeaveIfError( err );
|
|
571 |
|
|
572 |
CleanupStack::PushL( bitmap );
|
|
573 |
CleanupStack::PushL( bitmapMask );
|
|
574 |
|
|
575 |
CGulIcon* icon = CGulIcon::NewL( bitmap, bitmapMask );
|
|
576 |
|
|
577 |
// Remove the Bitmap and the Bitmap Icon from the Clean up stack since
|
|
578 |
// the ownership is taken over by the icon
|
|
579 |
CleanupStack::Pop( bitmapMask );
|
|
580 |
CleanupStack::Pop( bitmap );
|
|
581 |
|
|
582 |
CleanupStack::PushL( icon );
|
|
583 |
aIcons.AppendL( icon );
|
|
584 |
CleanupStack::Pop( icon ); // icon
|
|
585 |
}
|
|
586 |
|
|
587 |
// -----------------------------------------------------------------------------
|
|
588 |
// CEvtMgmtUiStartupContainer::AddColorIconL
|
|
589 |
// -----------------------------------------------------------------------------
|
|
590 |
void CEvtMgmtUiStartupContainer::AddColorIconL( CAknIconArray& aIcons,
|
|
591 |
const TDesC& aIconFileWithPath,
|
|
592 |
TAknsItemID aSkinID,
|
|
593 |
TInt aIconGraphicsIndex,
|
|
594 |
TInt aIconGraphicsMaskIndex )
|
|
595 |
{
|
|
596 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
|
|
597 |
|
|
598 |
// Repeat icon. Color skinned with day view icon color
|
|
599 |
// FIXME: highlight coloring in lists doesn't work for icons.
|
|
600 |
// When Avkon suplies some method to do that, change these
|
|
601 |
TAknsItemID colorGroup = KAknsIIDQsnIconColors;
|
|
602 |
TInt colorIndex = EAknsCIQsnIconColorsCG19;
|
|
603 |
TRgb nonSkinColor = AKN_LAF_COLOR(215);
|
|
604 |
|
|
605 |
CFbsBitmap* bitmap = NULL;
|
|
606 |
CFbsBitmap* bitmapMask = NULL;
|
|
607 |
AknsUtils::CreateColorIconLC( skin,
|
|
608 |
aSkinID,
|
|
609 |
colorGroup,
|
|
610 |
colorIndex,
|
|
611 |
bitmap,
|
|
612 |
bitmapMask,
|
|
613 |
aIconFileWithPath,
|
|
614 |
aIconGraphicsIndex,
|
|
615 |
aIconGraphicsMaskIndex,
|
|
616 |
nonSkinColor );
|
|
617 |
|
|
618 |
CGulIcon* icon = CGulIcon::NewL( bitmap, bitmapMask );
|
|
619 |
|
|
620 |
// Remove the Bitmap and the Bitmap Icon from the Clean up stack since
|
|
621 |
// the ownership is taken over by the icon
|
|
622 |
CleanupStack::Pop( bitmapMask );
|
|
623 |
CleanupStack::Pop( bitmap );
|
|
624 |
|
|
625 |
CleanupStack::PushL( icon );
|
|
626 |
aIcons.AppendL( icon );
|
|
627 |
CleanupStack::Pop( icon ); // icon
|
|
628 |
}
|
|
629 |
|
|
630 |
// -----------------------------------------------------------------------------
|
|
631 |
// CEvtMgmtUiStartupContainer::IconFileNameLC
|
|
632 |
// -----------------------------------------------------------------------------
|
|
633 |
TFileName* CEvtMgmtUiStartupContainer::IconFileNameLC() const
|
|
634 |
{
|
|
635 |
TFileName* fileName = new(ELeave) TFileName;
|
|
636 |
CleanupStack::PushL( fileName );
|
|
637 |
|
|
638 |
TFileName* tmpName = new(ELeave) TFileName;
|
|
639 |
CleanupStack::PushL( tmpName );
|
|
640 |
|
|
641 |
tmpName->Append( KDC_BITMAP_DIR );
|
|
642 |
tmpName->Append( KEvtMgmtUiIconFileName );
|
|
643 |
|
|
644 |
CEikAppUi *appUi = ( CEikAppUi *)( CEikonEnv::Static()->AppUi());
|
|
645 |
TFileName appDrive = appUi->Application()->AppFullName();
|
|
646 |
|
|
647 |
TParse parse;
|
|
648 |
User::LeaveIfError( parse.Set( appDrive, NULL, NULL ) );
|
|
649 |
User::LeaveIfError( parse.Set( parse.Drive(), tmpName, NULL ) );
|
|
650 |
|
|
651 |
fileName->Copy(parse.FullName());
|
|
652 |
|
|
653 |
CleanupStack::PopAndDestroy( tmpName );
|
|
654 |
|
|
655 |
return fileName;
|
|
656 |
}
|
|
657 |
// ---------------------------------------------------------------------------
|
|
658 |
// CEvtMgmtUiModel::UpdateListBoxL()
|
|
659 |
// It will update listbox
|
|
660 |
// ---------------------------------------------------------------------------
|
|
661 |
//
|
|
662 |
void CEvtMgmtUiStartupContainer::UpdateListBoxL(TInt aSelectedItemIndex)
|
|
663 |
{
|
|
664 |
iListBox->Model()->Filter()->ResetFilteringL();
|
|
665 |
iFindBox->ResetL();
|
|
666 |
iListBox->ClearSelection();
|
|
667 |
|
|
668 |
TInt count = iListBox->Model()->NumberOfItems();
|
|
669 |
if( iPrevCount > count )
|
|
670 |
{
|
|
671 |
iListBox->HandleItemRemovalL();
|
|
672 |
iListBox->DrawNow();
|
|
673 |
}
|
|
674 |
else
|
|
675 |
{
|
|
676 |
iListBox->HandleItemAdditionL();
|
|
677 |
}
|
|
678 |
|
|
679 |
iPrevCount = count;
|
|
680 |
|
|
681 |
if( aSelectedItemIndex >= count )
|
|
682 |
aSelectedItemIndex = count-1;
|
|
683 |
if(aSelectedItemIndex<0)
|
|
684 |
aSelectedItemIndex = 0;
|
|
685 |
|
|
686 |
iListBox->SetCurrentItemIndexAndDraw( aSelectedItemIndex );
|
|
687 |
|
|
688 |
// Check for FindBox Visiblity
|
|
689 |
HandleFindBoxVisibility();
|
|
690 |
}
|
|
691 |
|
|
692 |
// ---------------------------------------------------------------------------
|
|
693 |
// CEvtMgmtUiStartupContainer::CurrentItemIndex()
|
|
694 |
// It will return the index of the selected item
|
|
695 |
// ---------------------------------------------------------------------------
|
|
696 |
//
|
|
697 |
TInt CEvtMgmtUiStartupContainer::CurrentItemIndex()
|
|
698 |
{
|
|
699 |
return iListBox->Model()->Filter()->FilteredItemIndex( iListBox->CurrentItemIndex() );
|
|
700 |
}
|
|
701 |
|
|
702 |
// ---------------------------------------------------------------------------
|
|
703 |
// CEvtMgmtUiStartupContainer::HandleMarkCmd()
|
|
704 |
// It will handle mark functionality.
|
|
705 |
// ---------------------------------------------------------------------------
|
|
706 |
//
|
|
707 |
void CEvtMgmtUiStartupContainer::HandleMarkCmdL( TInt aIndex, TBool aIsMarked )
|
|
708 |
{
|
|
709 |
CListBoxView* listBoxView = iListBox->View();
|
|
710 |
CAknFilteredTextListBoxModel* model = iListBox->Model();
|
|
711 |
if( aIndex != KErrNotFound )
|
|
712 |
{
|
|
713 |
TInt visibleIndex = model->Filter()->VisibleItemIndex(aIndex);
|
|
714 |
if (aIsMarked)
|
|
715 |
{
|
|
716 |
listBoxView->SelectItemL(visibleIndex);
|
|
717 |
}
|
|
718 |
else
|
|
719 |
{
|
|
720 |
listBoxView->DeselectItem(visibleIndex);
|
|
721 |
}
|
|
722 |
}
|
|
723 |
else
|
|
724 |
{
|
|
725 |
TInt itemCount = model->NumberOfItems();
|
|
726 |
for (TUint i = 1; i < itemCount; i++)
|
|
727 |
{
|
|
728 |
TInt visibleIndex = model->Filter()->VisibleItemIndex(i);
|
|
729 |
if (aIsMarked)
|
|
730 |
{
|
|
731 |
listBoxView->SelectItemL(i);
|
|
732 |
}
|
|
733 |
else
|
|
734 |
{
|
|
735 |
listBoxView->DeselectItem(i);
|
|
736 |
}
|
|
737 |
}
|
|
738 |
}
|
|
739 |
}
|
|
740 |
|
|
741 |
// ---------------------------------------------------------------------------
|
|
742 |
// CEvtMgmtUiStartupContainer::HandleMarkableListDynInitMenuPane()
|
|
743 |
// It will display mark menu items dynamically
|
|
744 |
// ---------------------------------------------------------------------------
|
|
745 |
//
|
|
746 |
void CEvtMgmtUiStartupContainer::HandleMarkableListDynInitMenuPane( TInt /*ResourceId */, CEikMenuPane *aMenuPane )
|
|
747 |
{
|
|
748 |
TInt pos;
|
|
749 |
if( !aMenuPane->MenuItemExists(EAknCmdMark, pos) )
|
|
750 |
return;
|
|
751 |
|
|
752 |
TInt markItems = iListBox->SelectionIndexes()->Count();
|
|
753 |
if( iListBox->CurrentItemIndex() == 0 ) //if 'Create New Event'
|
|
754 |
{
|
|
755 |
aMenuPane->SetItemDimmed( EAknCmdMark, ETrue );
|
|
756 |
aMenuPane->SetItemDimmed( EAknCmdUnmark, ETrue );
|
|
757 |
}
|
|
758 |
else
|
|
759 |
{
|
|
760 |
if(iListBox->View()->ItemIsSelected(iListBox->CurrentItemIndex()) )
|
|
761 |
{
|
|
762 |
aMenuPane->SetItemDimmed( EAknCmdMark, ETrue );
|
|
763 |
aMenuPane->SetItemDimmed( EAknCmdUnmark, EFalse );
|
|
764 |
}
|
|
765 |
else
|
|
766 |
{
|
|
767 |
aMenuPane->SetItemDimmed( EAknCmdMark, EFalse );
|
|
768 |
aMenuPane->SetItemDimmed( EAknCmdUnmark, ETrue );
|
|
769 |
}
|
|
770 |
}
|
|
771 |
if( markItems < 1 )// if no item is selected
|
|
772 |
{
|
|
773 |
aMenuPane->SetItemDimmed( EAknUnmarkAll, ETrue );
|
|
774 |
}
|
|
775 |
else
|
|
776 |
{
|
|
777 |
aMenuPane->SetItemDimmed( EAknUnmarkAll, EFalse );
|
|
778 |
}
|
|
779 |
|
|
780 |
if( markItems == iListBox->Model()->NumberOfItems()-1 )// if all items are selected
|
|
781 |
{
|
|
782 |
aMenuPane->SetItemDimmed( EAknMarkAll, ETrue );
|
|
783 |
}
|
|
784 |
else
|
|
785 |
{
|
|
786 |
aMenuPane->SetItemDimmed( EAknMarkAll, EFalse );
|
|
787 |
}
|
|
788 |
}
|
|
789 |
|
|
790 |
// ---------------------------------------------------------------------------
|
|
791 |
// CEvtMgmtUiStartupContainer::NumberOfMarkedItems()
|
|
792 |
// It will return count of marked items
|
|
793 |
// ---------------------------------------------------------------------------
|
|
794 |
//
|
|
795 |
TInt CEvtMgmtUiStartupContainer::NumberOfMarkedItems()
|
|
796 |
{
|
|
797 |
return iListBox->SelectionIndexes()->Count();
|
|
798 |
}
|
|
799 |
|
|
800 |
// ---------------------------------------------------------------------------
|
|
801 |
// CEvtMgmtUiStartupContainer::MarkItems()
|
|
802 |
// It will return marked items
|
|
803 |
// ---------------------------------------------------------------------------
|
|
804 |
//
|
|
805 |
const CArrayFix<TInt>* CEvtMgmtUiStartupContainer::MarkItems()
|
|
806 |
{
|
|
807 |
return iListBox->SelectionIndexes();
|
|
808 |
}
|
|
809 |
|
|
810 |
// ---------------------------------------------------------------------------
|
|
811 |
// CEvtMgmtUiStartupContainer::FilteredIndex()
|
|
812 |
// It will return marked items
|
|
813 |
// ---------------------------------------------------------------------------
|
|
814 |
//
|
|
815 |
TInt CEvtMgmtUiStartupContainer::FilteredIndex(TInt aIndex)
|
|
816 |
{
|
|
817 |
return iListBox->Model()->Filter()->FilteredItemIndex( aIndex );
|
|
818 |
}
|
|
819 |
|
|
820 |
// ---------------------------------------------------------------------------
|
|
821 |
// CEvtMgmtUiStartupContainer::FilteredCount()
|
|
822 |
// It will return count of marked items
|
|
823 |
// ---------------------------------------------------------------------------
|
|
824 |
//
|
|
825 |
TInt CEvtMgmtUiStartupContainer::FilteredCount()
|
|
826 |
{
|
|
827 |
return iListBox->Model()->Filter()->FilteredNumberOfItems();
|
|
828 |
}
|
|
829 |
|
|
830 |
// ---------------------------------------------------------------------------
|
|
831 |
// CEvtMgmtUiStartupContainer::MakeTitleL()
|
|
832 |
// Set the Title Text
|
|
833 |
// ---------------------------------------------------------------------------
|
|
834 |
//
|
|
835 |
void CEvtMgmtUiStartupContainer::MakeTitleL()
|
|
836 |
{
|
|
837 |
// Obtain the title from the Status Pane
|
|
838 |
CAknTitlePane* title = static_cast<CAknTitlePane*>( iEikonEnv->AppUiFactory()->
|
|
839 |
StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle )));
|
|
840 |
|
|
841 |
// Set the Title's buffer
|
|
842 |
HBufC* buf = StringLoader::LoadL( R_EVTUI_TITLE );
|
|
843 |
title->SetText( buf ); // Takes ownership of buf
|
|
844 |
}
|
|
845 |
// End of File
|