23
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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 : Implementation for cvimpstuiblockviewcontrol.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// INCLUDE FILES
|
|
19 |
#include "cvimpstuiblockviewcontrol.h"
|
|
20 |
#include "cvimpstuiblockview.h"
|
|
21 |
#include "vimpstutils.h"
|
|
22 |
#include "tvimpstconsts.h"
|
|
23 |
#include "vimpstui.hrh"
|
|
24 |
|
|
25 |
// system include
|
|
26 |
#include <aknlists.h>
|
|
27 |
#include <eikclbd.h>
|
|
28 |
#include <vimpstuires.rsg>
|
|
29 |
|
|
30 |
#include <MPbk2KeyEventHandler.h>
|
|
31 |
#include "uiservicetabtracer.h"
|
|
32 |
|
|
33 |
|
|
34 |
// ================= MEMBER FUNCTIONS =======================
|
|
35 |
|
|
36 |
|
|
37 |
// --------------------------------------------------------------------------
|
|
38 |
// CVIMPSTUiBlockViewControl::CVIMPSTUiBlockViewControl
|
|
39 |
// --------------------------------------------------------------------------
|
|
40 |
//
|
|
41 |
CVIMPSTUiBlockViewControl::CVIMPSTUiBlockViewControl( CVIMPSTUiBlockView& aBlockedView,MPbk2KeyEventHandler& aKeyEventHandler,
|
|
42 |
MVIMPSTEngine& aEngine,
|
|
43 |
RPointerArray<HBufC>* aBlockedList)
|
|
44 |
:iBlockedView(aBlockedView),
|
|
45 |
iKeyEventHandler(aKeyEventHandler),
|
|
46 |
iEngine( aEngine ),
|
|
47 |
iBlockedList(aBlockedList)
|
|
48 |
{
|
|
49 |
|
|
50 |
}
|
|
51 |
|
|
52 |
|
|
53 |
// --------------------------------------------------------------------------
|
|
54 |
// CVIMPSTUiBlockViewControl::ConstructL
|
|
55 |
// --------------------------------------------------------------------------
|
|
56 |
//
|
|
57 |
void CVIMPSTUiBlockViewControl::ConstructL()
|
|
58 |
{
|
|
59 |
TRACER_AUTO;
|
|
60 |
CreateWindowL();
|
|
61 |
iItemArray = new ( ELeave ) CDesCArrayFlat( KArrayGranularity );
|
|
62 |
// Create listbox
|
|
63 |
iListBox = new ( ELeave ) CAknSingleGraphicStyleListBox;
|
|
64 |
iListBox->ConstructL( this, EAknListBoxSelectionList );
|
|
65 |
|
|
66 |
iListBox->SetContainerWindowL(*this);
|
|
67 |
iListBox->CreateScrollBarFrameL(ETrue);
|
|
68 |
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL
|
|
69 |
(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
|
|
70 |
|
|
71 |
// set marquee on
|
|
72 |
iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
|
|
73 |
iListBox->Model()->SetItemTextArray( iItemArray );
|
|
74 |
iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
|
|
75 |
|
|
76 |
iListBox->SetListBoxObserver( this );
|
|
77 |
|
|
78 |
iCurrentItemIndex = 0;
|
|
79 |
UpdateBlockedListL();
|
|
80 |
ActivateL();
|
|
81 |
|
|
82 |
}
|
|
83 |
|
|
84 |
|
|
85 |
// --------------------------------------------------------------------------
|
|
86 |
// CVIMPSTUiBlockViewControl::NewL
|
|
87 |
// --------------------------------------------------------------------------
|
|
88 |
//
|
|
89 |
CVIMPSTUiBlockViewControl* CVIMPSTUiBlockViewControl::NewL( CVIMPSTUiBlockView& aBlockedView,
|
|
90 |
MPbk2KeyEventHandler& aKeyEventHandler,
|
|
91 |
MVIMPSTEngine& aEngine,
|
|
92 |
RPointerArray<HBufC>* aBlockedList )
|
|
93 |
{
|
|
94 |
CVIMPSTUiBlockViewControl* self = NewLC(aBlockedView,aKeyEventHandler,aEngine, aBlockedList );
|
|
95 |
CleanupStack::Pop(self);
|
|
96 |
return self;
|
|
97 |
}
|
|
98 |
|
|
99 |
|
|
100 |
// --------------------------------------------------------------------------
|
|
101 |
// CVIMPSTUiBlockViewControl::NewLC
|
|
102 |
// --------------------------------------------------------------------------
|
|
103 |
//
|
|
104 |
CVIMPSTUiBlockViewControl* CVIMPSTUiBlockViewControl::NewLC( CVIMPSTUiBlockView& aBlockedView,
|
|
105 |
MPbk2KeyEventHandler& aKeyEventHandler,
|
|
106 |
MVIMPSTEngine& aEngine,
|
|
107 |
RPointerArray<HBufC>* aBlockedList )
|
|
108 |
{
|
|
109 |
CVIMPSTUiBlockViewControl* self =
|
|
110 |
new (ELeave) CVIMPSTUiBlockViewControl(aBlockedView,aKeyEventHandler, aEngine, aBlockedList );
|
|
111 |
CleanupStack::PushL(self);
|
|
112 |
self->ConstructL();
|
|
113 |
return self;
|
|
114 |
}
|
|
115 |
|
|
116 |
// -----------------------------------------------------------------------------
|
|
117 |
// CVIMPSTUiBlockViewControl::Destructor
|
|
118 |
// -----------------------------------------------------------------------------
|
|
119 |
//
|
|
120 |
CVIMPSTUiBlockViewControl::~CVIMPSTUiBlockViewControl()
|
|
121 |
{
|
|
122 |
|
|
123 |
delete iItemArray;
|
|
124 |
iItemArray = NULL;
|
|
125 |
delete iListBox;
|
|
126 |
iListBox = NULL;
|
|
127 |
}
|
|
128 |
|
|
129 |
// ---------------------------------------------------------
|
|
130 |
// CVIMPSTUiBlockViewControl::HandleControlEventL
|
|
131 |
// ---------------------------------------------------------
|
|
132 |
//
|
|
133 |
void CVIMPSTUiBlockViewControl::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
|
|
134 |
{
|
|
135 |
}
|
|
136 |
|
|
137 |
|
|
138 |
// ---------------------------------------------------------
|
|
139 |
// CVIMPSTUiBlockViewControl::HandleListBoxEventL
|
|
140 |
// Handles list box events
|
|
141 |
// (other items were commented in a header).
|
|
142 |
// ---------------------------------------------------------
|
|
143 |
//
|
|
144 |
void CVIMPSTUiBlockViewControl::HandleListBoxEventL( CEikListBox* /*aListBox*/,
|
|
145 |
TListBoxEvent aEventType )
|
|
146 |
{
|
|
147 |
iCurrentItemIndex = iListBox->CurrentItemIndex();
|
|
148 |
if(aEventType == EEventEnterKeyPressed)
|
|
149 |
{
|
|
150 |
iBlockedView.HandleCommandL(ECmdUnBlock);
|
|
151 |
}
|
|
152 |
}
|
|
153 |
|
|
154 |
|
|
155 |
// ---------------------------------------------------------
|
|
156 |
// CVIMPSTUiBlockViewControl::SizeChanged()
|
|
157 |
// Called by framework
|
|
158 |
// (other items were commented in a header).
|
|
159 |
// ---------------------------------------------------------
|
|
160 |
//
|
|
161 |
void CVIMPSTUiBlockViewControl::SizeChanged()
|
|
162 |
{
|
|
163 |
if ( iListBox )
|
|
164 |
{
|
|
165 |
iListBox->SetRect(Rect());
|
|
166 |
}
|
|
167 |
}
|
|
168 |
|
|
169 |
// ---------------------------------------------------------
|
|
170 |
// CVIMPSTUiBlockViewControl::CountComponentControls()
|
|
171 |
// Returns number of controls
|
|
172 |
// (other items were commented in a header).
|
|
173 |
// ---------------------------------------------------------
|
|
174 |
//
|
|
175 |
TInt CVIMPSTUiBlockViewControl::CountComponentControls() const
|
|
176 |
{
|
|
177 |
//Only one compound control so returning 1
|
|
178 |
return 1;
|
|
179 |
}
|
|
180 |
|
|
181 |
// ---------------------------------------------------------
|
|
182 |
// CVIMPSTUiBlockViewControl::ComponentControl( TInt aIndex )
|
|
183 |
// Returns control for given index
|
|
184 |
// (other items were commented in a header).
|
|
185 |
// ---------------------------------------------------------
|
|
186 |
//
|
|
187 |
CCoeControl* CVIMPSTUiBlockViewControl::ComponentControl( TInt aIndex ) const
|
|
188 |
{
|
|
189 |
if( aIndex == 0 )
|
|
190 |
{
|
|
191 |
return iListBox;
|
|
192 |
}
|
|
193 |
else
|
|
194 |
{
|
|
195 |
return NULL;
|
|
196 |
}
|
|
197 |
}
|
|
198 |
|
|
199 |
|
|
200 |
// ---------------------------------------------------------
|
|
201 |
// CVIMPSTUiBlockViewControl::UpdateBlockedListL()
|
|
202 |
// ---------------------------------------------------------
|
|
203 |
//
|
|
204 |
void CVIMPSTUiBlockViewControl::UpdateBlockedListL()
|
|
205 |
{
|
|
206 |
TRACER_AUTO;
|
|
207 |
iItemArray->Reset();
|
|
208 |
|
|
209 |
TInt granularity( iItemArray->Count() );
|
|
210 |
++granularity;
|
|
211 |
|
|
212 |
CDesCArray* tempArray = new ( ELeave ) CDesCArrayFlat( granularity );
|
|
213 |
CleanupStack::PushL( tempArray );
|
|
214 |
|
|
215 |
iListBox->Model()->SetItemTextArray( tempArray );
|
|
216 |
iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
|
|
217 |
iListBox->HandleItemAdditionL();
|
|
218 |
for ( TInt i =0; i < iBlockedList->Count() ; ++ i)
|
|
219 |
{
|
|
220 |
TInt sizeOfItemText;
|
|
221 |
// Calculating the size of the text that will be entered into listbox.
|
|
222 |
// 3 * KTab().Length() calculates the length of the tabs that is
|
|
223 |
// appended to the actual text.
|
|
224 |
sizeOfItemText = (*iBlockedList)[i]->Length() + 3 * KTab().Length();
|
|
225 |
HBufC* itemText = HBufC::NewLC( sizeOfItemText ); // changing stuff..
|
|
226 |
TPtr itemTextPtr( itemText->Des() );
|
|
227 |
itemTextPtr.Append( KTab );
|
|
228 |
itemTextPtr.Append( (*iBlockedList)[i]->Des());
|
|
229 |
itemTextPtr.Append( KTab );
|
|
230 |
itemTextPtr.Append( KTab );
|
|
231 |
|
|
232 |
iItemArray->AppendL( itemTextPtr );
|
|
233 |
CleanupStack::PopAndDestroy( itemText );
|
|
234 |
}
|
|
235 |
CleanupStack::PopAndDestroy(tempArray ); // tempArray
|
|
236 |
|
|
237 |
iItemArray->Sort();
|
|
238 |
iListBox->Model()->SetItemTextArray( iItemArray );
|
|
239 |
iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
|
|
240 |
|
|
241 |
iListBox->HandleItemAdditionL();
|
|
242 |
|
|
243 |
if(0==iBlockedList->Count())
|
|
244 |
{
|
|
245 |
SetEmptyTextsToListboxL();
|
|
246 |
}
|
|
247 |
|
|
248 |
if ( iItemArray->MdcaCount() > 0 )
|
|
249 |
{
|
|
250 |
iListBox->SetCurrentItemIndexAndDraw( 0 );
|
|
251 |
}
|
|
252 |
iListBox->UpdateScrollBarsL();
|
|
253 |
SetCurrentIndex(iCurrentItemIndex);
|
|
254 |
UpdateCbaL();
|
|
255 |
}
|
|
256 |
|
|
257 |
|
|
258 |
// ---------------------------------------------------------
|
|
259 |
// CVIMPSTUiBlockViewControl::ListBox()
|
|
260 |
// (other items were commented in a header).
|
|
261 |
// ---------------------------------------------------------
|
|
262 |
//
|
|
263 |
CEikListBox* CVIMPSTUiBlockViewControl::ListBox() const
|
|
264 |
{
|
|
265 |
return iListBox;
|
|
266 |
}
|
|
267 |
|
|
268 |
// ---------------------------------------------------------
|
|
269 |
// CVIMPSTUiBlockViewControl::GetFocusedItemText
|
|
270 |
// (other items were commented in a header).
|
|
271 |
// ---------------------------------------------------------
|
|
272 |
//
|
|
273 |
HBufC* CVIMPSTUiBlockViewControl::GetFocusedContactLC() const
|
|
274 |
{
|
|
275 |
TRACER_AUTO;
|
|
276 |
HBufC* retText = NULL;
|
|
277 |
TInt curIndex = iListBox->CurrentItemIndex();
|
|
278 |
if(KErrNotFound != curIndex)
|
|
279 |
{
|
|
280 |
TPtrC ptr= iItemArray->MdcaPoint(curIndex);
|
|
281 |
ptr.Set(ptr.Mid(1)); // set pointer from next char :since first char is KTab
|
|
282 |
TInt pos=ptr.FindC(KTab);
|
|
283 |
if( pos !=KErrNotFound && (pos != ptr.Length()-1))
|
|
284 |
{
|
|
285 |
ptr.Set(ptr.Mid( 0, pos));
|
|
286 |
retText = ptr.AllocLC();
|
|
287 |
}
|
|
288 |
}
|
|
289 |
return retText;
|
|
290 |
}
|
|
291 |
|
|
292 |
// ---------------------------------------------------------
|
|
293 |
// CVIMPSTUiBlockViewControl::GetCurrentIndex
|
|
294 |
// (other items were commented in a header).
|
|
295 |
// ---------------------------------------------------------
|
|
296 |
//
|
|
297 |
TInt CVIMPSTUiBlockViewControl::GetCurrentIndex() const
|
|
298 |
{
|
|
299 |
return iCurrentItemIndex ;
|
|
300 |
}
|
|
301 |
|
|
302 |
// ---------------------------------------------------------
|
|
303 |
// CVIMPSTUiBlockViewControl::GetCurrentIndex
|
|
304 |
// (other items were commented in a header).
|
|
305 |
// ---------------------------------------------------------
|
|
306 |
//
|
|
307 |
void CVIMPSTUiBlockViewControl::SetCurrentIndex(TInt aIndex)
|
|
308 |
{
|
|
309 |
TRACER_AUTO;
|
|
310 |
if(aIndex>0)
|
|
311 |
{
|
|
312 |
TInt blockedCount = iListBox->Model()->NumberOfItems();
|
|
313 |
if(blockedCount > 0)
|
|
314 |
{
|
|
315 |
TInt itemIndex = aIndex % blockedCount;
|
|
316 |
iListBox->SetCurrentItemIndex(itemIndex);
|
|
317 |
}
|
|
318 |
}
|
|
319 |
}
|
|
320 |
|
|
321 |
|
|
322 |
// ---------------------------------------------------------
|
|
323 |
// CVIMPSTUiBlockViewControl::UpdateCbaL()
|
|
324 |
// Updates Softkeys according to current focus.
|
|
325 |
// ---------------------------------------------------------
|
|
326 |
//
|
|
327 |
void CVIMPSTUiBlockViewControl::UpdateCbaL()
|
|
328 |
{
|
|
329 |
TRACER_AUTO;
|
|
330 |
TInt cbaRes = R_SERVTAB_SOFTKEYS_EMPTY_EMPTY__BACK;
|
|
331 |
if ( !iCba )
|
|
332 |
{
|
|
333 |
iCba = CEikButtonGroupContainer::Current();
|
|
334 |
}
|
|
335 |
|
|
336 |
if( iCba )
|
|
337 |
{
|
|
338 |
iCba->SetCommandSetL( cbaRes );
|
|
339 |
iCba->DrawNow();
|
|
340 |
}
|
|
341 |
}
|
|
342 |
|
|
343 |
// ---------------------------------------------------------
|
|
344 |
// CVIMPSTUiBlockViewControl::OfferKeyEventL()
|
|
345 |
// Handles user key inputs
|
|
346 |
// (other items were commented in a header).
|
|
347 |
// ---------------------------------------------------------
|
|
348 |
//
|
|
349 |
TKeyResponse CVIMPSTUiBlockViewControl::OfferKeyEventL( const TKeyEvent& aKeyEvent,
|
|
350 |
TEventCode aType )
|
|
351 |
{
|
|
352 |
TRACER_AUTO;
|
|
353 |
if ( !aKeyEvent.iCode )
|
|
354 |
{
|
|
355 |
//The character code generated
|
|
356 |
//for an EEventKey, or 0 for a down or up event.
|
|
357 |
//For down or up key return key consumed.. handle only the events
|
|
358 |
|
|
359 |
if((EEventKeyDown == aType) && (EStdKeyDevice3 == aKeyEvent.iScanCode))
|
|
360 |
{
|
|
361 |
//for setting the command to be executed for the "Selection key"
|
|
362 |
//in case of selection key, container's OfferKeyEventL() is called only for EEventKeyDown and EEventKeyUp
|
|
363 |
//and not for EEventKey
|
|
364 |
UpdateCbaL();
|
|
365 |
}
|
|
366 |
return EKeyWasConsumed;
|
|
367 |
}
|
|
368 |
TKeyResponse result = EKeyWasNotConsumed;
|
|
369 |
if (iListBox)
|
|
370 |
{
|
|
371 |
iCurrentItemIndex = iListBox->CurrentItemIndex();
|
|
372 |
}
|
|
373 |
// Offer key event first to the key event handler
|
|
374 |
if ( (&iKeyEventHandler ) && iKeyEventHandler.Pbk2ProcessKeyEventL
|
|
375 |
( aKeyEvent, aType ) )
|
|
376 |
{
|
|
377 |
result = EKeyWasConsumed;
|
|
378 |
}
|
|
379 |
switch(aKeyEvent.iCode )
|
|
380 |
{
|
|
381 |
/* case EKeyEnter:
|
|
382 |
{
|
|
383 |
iBlockedView.HandleCommandL(ECmdUnBlock);
|
|
384 |
result = EKeyWasConsumed;
|
|
385 |
break;
|
|
386 |
} */
|
|
387 |
default:
|
|
388 |
{
|
|
389 |
break;
|
|
390 |
}
|
|
391 |
}
|
|
392 |
if( result == EKeyWasConsumed )
|
|
393 |
{
|
|
394 |
// user might has choosen back/end key/application key etc
|
|
395 |
// application might switch to background
|
|
396 |
// return from here
|
|
397 |
return result;
|
|
398 |
}
|
|
399 |
// Not consumed by the key handler, offer to the control next
|
|
400 |
if ( result == EKeyWasNotConsumed )
|
|
401 |
{
|
|
402 |
if ( iListBox )
|
|
403 |
{
|
|
404 |
result = iListBox->OfferKeyEventL(aKeyEvent, aType);
|
|
405 |
}
|
|
406 |
}
|
|
407 |
UpdateCbaL();
|
|
408 |
return result;
|
|
409 |
|
|
410 |
}
|
|
411 |
|
|
412 |
// ---------------------------------------------------------------------------
|
|
413 |
// CVIMPSTUiBlockViewControl::SetEmptyTextsToListboxL()
|
|
414 |
// See header for details.
|
|
415 |
// ---------------------------------------------------------------------------
|
|
416 |
//
|
|
417 |
void CVIMPSTUiBlockViewControl::SetEmptyTextsToListboxL()
|
|
418 |
{
|
|
419 |
TRACER_AUTO;
|
|
420 |
HBufC* emptyFinal = VIMPSTUtils::LoadResourceL(R_SERVTAB_BLOCKLIST_BKGD);
|
|
421 |
CleanupStack::PushL(emptyFinal);
|
|
422 |
iListBox->View()->SetListEmptyTextL( *emptyFinal );
|
|
423 |
CleanupStack::PopAndDestroy(emptyFinal);
|
|
424 |
}
|
|
425 |
|
|
426 |
// ---------------------------------------------------------------------------
|
|
427 |
// CVIMPSTUiBlockViewControl::SetUpdatingTextsToListboxL()
|
|
428 |
// See header for details.
|
|
429 |
// ---------------------------------------------------------------------------
|
|
430 |
//
|
|
431 |
void CVIMPSTUiBlockViewControl::SetUpdatingTextsToListboxL()
|
|
432 |
{
|
|
433 |
TRACER_AUTO;
|
|
434 |
HBufC* updating = VIMPSTUtils::LoadResourceL(R_SERVTAB_BLOCKLIST_BKGDTO);
|
|
435 |
CleanupStack::PushL(updating);
|
|
436 |
iListBox->View()->SetListEmptyTextL( *updating );
|
|
437 |
CleanupStack::PopAndDestroy(updating);
|
|
438 |
}
|
|
439 |
|
|
440 |
|
|
441 |
// End of File
|