20
|
1 |
/*
|
|
2 |
* Copyright (c) 2005 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 of the class CFMRadioChannelListContainer
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <e32math.h>
|
|
21 |
#include <AknsSkinInstance.h>
|
|
22 |
#include <AknsUtils.h>
|
|
23 |
#include <AknsDrawUtils.h>
|
|
24 |
#include <AknsBasicBackgroundControlContext.h>
|
|
25 |
#include <gulutil.h>
|
|
26 |
#include <w32std.h>
|
|
27 |
#include <fmradio.rsg>
|
|
28 |
#if defined __SERIES60_HELP || defined FF_S60_HELPS_IN_USE
|
|
29 |
#include "radio.hlp.hrh"
|
|
30 |
#endif
|
|
31 |
#include <StringLoader.h>
|
|
32 |
#include <eiklabel.h>
|
|
33 |
#include <AknIconArray.h>
|
|
34 |
#include <gulicon.h>
|
|
35 |
#include <fmradiouids.h>
|
|
36 |
#include <aknconsts.h>
|
|
37 |
#include <avkon.mbg>
|
|
38 |
|
|
39 |
|
|
40 |
#include "fmradioappui.h"
|
|
41 |
#include "fmradiochannellistcontainer.h"
|
|
42 |
#include "fmradiochannellistview.h"
|
|
43 |
|
|
44 |
// CONSTANTS
|
|
45 |
|
|
46 |
// ================= MEMBER FUNCTIONS =======================
|
|
47 |
|
|
48 |
|
|
49 |
// ----------------------------------------------------------------------------
|
|
50 |
// CFMRadioChannelListContainer::CFMRadioChannelListContainer
|
|
51 |
// Default constructor
|
|
52 |
// ----------------------------------------------------------------------------
|
|
53 |
//
|
|
54 |
CFMRadioChannelListContainer::CFMRadioChannelListContainer(
|
|
55 |
CRadioEngine& aRadioEngine,
|
|
56 |
MChannelListHandler& aObserver ) :
|
|
57 |
iRadioEngine( aRadioEngine ),
|
|
58 |
iObserver( aObserver )
|
|
59 |
|
|
60 |
{
|
|
61 |
}
|
|
62 |
|
|
63 |
// ---------------------------------------------------------
|
|
64 |
// CFMRadioChannelListContainer::NewL
|
|
65 |
// Two-phase constructor of CFMRadioChannelListContainer
|
|
66 |
// ---------------------------------------------------------
|
|
67 |
//
|
|
68 |
CFMRadioChannelListContainer* CFMRadioChannelListContainer::NewL( const TRect& aRect,
|
|
69 |
CRadioEngine& aRadioEngine, MChannelListHandler& aObserver )
|
|
70 |
{
|
|
71 |
CFMRadioChannelListContainer* self = new (ELeave) CFMRadioChannelListContainer( aRadioEngine,
|
|
72 |
aObserver );
|
|
73 |
CleanupStack::PushL( self );
|
|
74 |
self->ConstructL( aRect );
|
|
75 |
CleanupStack::Pop( self );
|
|
76 |
return self;
|
|
77 |
}
|
|
78 |
|
|
79 |
//
|
|
80 |
// ----------------------------------------------------
|
|
81 |
// CFMRadioChannelListContainer::ConstructL
|
|
82 |
// EPOC two phased constructor
|
|
83 |
// ----------------------------------------------------
|
|
84 |
//
|
|
85 |
void CFMRadioChannelListContainer::ConstructL( const TRect& aRect )
|
|
86 |
{
|
|
87 |
CreateWindowL();
|
|
88 |
|
|
89 |
// Instantiate a listbox for the channel list
|
|
90 |
iChannelList = new ( ELeave ) CAknDoubleNumberStyleListBox();
|
|
91 |
iChannelList->SetContainerWindowL( *this );
|
|
92 |
iChannelList->SetListBoxObserver( this );
|
|
93 |
iChannelList->ConstructL( this, CEikListBox::ELoopScrolling | EAknListBoxSelectionList ); // Looped list
|
|
94 |
iChannelList->SetRect( aRect ); // Set boundaries for listbox
|
|
95 |
// Create scrollbars
|
|
96 |
iChannelList->CreateScrollBarFrameL( ETrue );
|
|
97 |
iChannelList->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
|
|
98 |
HBufC* emptyString = NULL;
|
|
99 |
emptyString = StringLoader::LoadLC( R_QTN_FMRADIO_LIST_NO_STATIONS, iEikonEnv );
|
|
100 |
|
|
101 |
iChannelList->View()->SetListEmptyTextL( *emptyString );
|
|
102 |
CleanupStack::PopAndDestroy( emptyString );
|
|
103 |
|
|
104 |
CAknIconArray* listIconArray = new ( ELeave ) CAknIconArray( 2 );
|
|
105 |
CleanupStack::PushL( listIconArray );
|
|
106 |
CreateListIconsL( *listIconArray );
|
|
107 |
iChannelList->ItemDrawer()->FormattedCellData()->SetIconArrayL( listIconArray );
|
|
108 |
CleanupStack::Pop( listIconArray );
|
|
109 |
|
|
110 |
// Array for channels
|
|
111 |
iChannelItemArray = new( ELeave ) CDesCArrayFlat( KMaxNumberOfChannelListItems );
|
|
112 |
InitializeChannelListL();
|
|
113 |
SetRect( aRect ); // Set its rectangle
|
|
114 |
|
|
115 |
CFMRadioAppUi* appUi = static_cast<CFMRadioAppUi*>( iCoeEnv->AppUi() );
|
|
116 |
iChannelView = static_cast<CFMRadioChannelListView*> ( appUi->View( KFMRadioChannelListViewId ) );
|
|
117 |
ActivateL();
|
|
118 |
}
|
|
119 |
|
|
120 |
// ----------------------------------------------------
|
|
121 |
// CFMRadioChannelListContainer::~CFMRadioChannelListContainer
|
|
122 |
// Class destructor
|
|
123 |
// ----------------------------------------------------
|
|
124 |
//
|
|
125 |
CFMRadioChannelListContainer::~CFMRadioChannelListContainer()
|
|
126 |
{
|
|
127 |
delete iChannelList;
|
|
128 |
iBitMaps.ResetAndDestroy();
|
|
129 |
iBitMaps.Close();
|
|
130 |
delete iChannelItemArray;
|
|
131 |
}
|
|
132 |
|
|
133 |
// ----------------------------------------------------
|
|
134 |
// CFMRadioChannelListContainer::CreateListIconsL
|
|
135 |
// ----------------------------------------------------
|
|
136 |
//
|
|
137 |
void CFMRadioChannelListContainer::CreateListIconsL( CArrayPtr<CGulIcon>& aArray )
|
|
138 |
{
|
|
139 |
if ( iBitMaps.Count() )
|
|
140 |
{
|
|
141 |
// release any previously created bitmaps
|
|
142 |
iBitMaps.ResetAndDestroy();
|
|
143 |
}
|
|
144 |
|
|
145 |
TRgb defaultColor = iEikonEnv->Color( EColorControlText );
|
|
146 |
MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
|
|
147 |
|
|
148 |
// speaker icon
|
|
149 |
CFbsBitmap* playingIconBitmap = NULL;
|
|
150 |
CFbsBitmap* playingIconBitmapMask = NULL;
|
|
151 |
|
|
152 |
AknsUtils::CreateColorIconLC( skinInstance,
|
|
153 |
KAknsIIDQgnIndiSpeaker,
|
|
154 |
KAknsIIDQsnIconColors,
|
|
155 |
EAknsCIQsnIconColorsCG13,
|
|
156 |
playingIconBitmap,
|
|
157 |
playingIconBitmapMask,
|
|
158 |
KAvkonBitmapFile,
|
|
159 |
EMbmAvkonQgn_indi_speaker,
|
|
160 |
EMbmAvkonQgn_indi_speaker_mask,
|
|
161 |
defaultColor
|
|
162 |
);
|
|
163 |
iBitMaps.AppendL( playingIconBitmap );
|
|
164 |
iBitMaps.AppendL( playingIconBitmapMask );
|
|
165 |
CleanupStack::Pop( 2 ); // playingIconBitmap, playingIconBitmapMask
|
|
166 |
|
|
167 |
CGulIcon* playingIcon = CGulIcon::NewLC();
|
|
168 |
playingIcon->SetBitmapsOwnedExternally( ETrue );
|
|
169 |
playingIcon->SetBitmap( playingIconBitmap );
|
|
170 |
playingIcon->SetMask( playingIconBitmap );
|
|
171 |
aArray.AppendL( playingIcon );
|
|
172 |
CleanupStack::Pop( playingIcon );
|
|
173 |
|
|
174 |
// marked icon
|
|
175 |
CFbsBitmap* markedIconBitmap = NULL;
|
|
176 |
CFbsBitmap* markedIconBitmapMask = NULL;
|
|
177 |
|
|
178 |
AknsUtils::CreateColorIconLC( skinInstance,
|
|
179 |
KAknsIIDQgnIndiMarkedAdd,
|
|
180 |
KAknsIIDQsnIconColors,
|
|
181 |
EAknsCIQsnIconColorsCG13,
|
|
182 |
markedIconBitmap,
|
|
183 |
markedIconBitmapMask,
|
|
184 |
KAvkonBitmapFile,
|
|
185 |
EMbmAvkonQgn_indi_marked_add,
|
|
186 |
EMbmAvkonQgn_indi_marked_add_mask,
|
|
187 |
defaultColor
|
|
188 |
);
|
|
189 |
iBitMaps.AppendL( markedIconBitmap );
|
|
190 |
iBitMaps.AppendL( markedIconBitmapMask );
|
|
191 |
CleanupStack::Pop( 2 ); // markedIconBitmap, markedIconBitmapMask
|
|
192 |
|
|
193 |
CGulIcon* markedIcon = CGulIcon::NewLC();
|
|
194 |
markedIcon->SetBitmapsOwnedExternally( ETrue );
|
|
195 |
markedIcon->SetBitmap( markedIconBitmap );
|
|
196 |
markedIcon->SetMask( markedIconBitmapMask );
|
|
197 |
aArray.AppendL( markedIcon );
|
|
198 |
CleanupStack::Pop( markedIcon );
|
|
199 |
}
|
|
200 |
|
|
201 |
// ----------------------------------------------------
|
|
202 |
// CFMRadioChannelListContainer::InitializeChannelListL
|
|
203 |
// Create the channel list (initially all spots are set as empty)
|
|
204 |
// ----------------------------------------------------
|
|
205 |
//
|
|
206 |
void CFMRadioChannelListContainer::InitializeChannelListL()
|
|
207 |
{
|
|
208 |
TBuf<KLengthOfChannelItemString> textChannelItem;
|
|
209 |
textChannelItem.SetLength( 0 );
|
|
210 |
|
|
211 |
// Pass the array to the listbox model and set the ownership type
|
|
212 |
iChannelList->Model()->SetItemTextArray( (MDesCArray*)iChannelItemArray );
|
|
213 |
iChannelList->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
|
|
214 |
iChannelList->HandleItemAdditionL();
|
|
215 |
DrawDeferred();
|
|
216 |
}
|
|
217 |
|
|
218 |
// ----------------------------------------------------
|
|
219 |
// CFMRadioChannelListContainer::UpdateChannelListContentL
|
|
220 |
// Update the content of the channel at aIndex with the
|
|
221 |
// values specified
|
|
222 |
// ----------------------------------------------------
|
|
223 |
//
|
|
224 |
void CFMRadioChannelListContainer::UpdateChannelListContentL( TInt aIndex,
|
|
225 |
const TDesC& aChannelName,
|
|
226 |
TInt aChannelFrequency )
|
|
227 |
{
|
|
228 |
TBuf<KLengthOfChannelItemString> textChannelItem;
|
|
229 |
TBuf<KLengthOfChIndexStringChList> textChIndex;
|
|
230 |
TBuf<KLengthOfChannelItemIconIndexString> textChIconIndex;
|
|
231 |
|
|
232 |
textChIndex.Format( KChIndexFormatChList, aIndex+1 ); // One over index
|
|
233 |
|
|
234 |
textChIconIndex.Format( KChIconIndexFormatChList, KNowPlayingIconIndexChList );
|
|
235 |
|
|
236 |
//Update to display Devnagari numbers for Text Index.
|
|
237 |
AknTextUtils::LanguageSpecificNumberConversion( textChIndex );
|
|
238 |
|
|
239 |
textChannelItem.Append( textChIndex );
|
|
240 |
textChannelItem.Append( KColumnListSeparator );
|
|
241 |
textChannelItem.Append( aChannelName );
|
|
242 |
textChannelItem.Append( KColumnListSeparator );
|
|
243 |
|
|
244 |
if ( aChannelFrequency )
|
|
245 |
{
|
|
246 |
TReal frequency = static_cast<TReal>( aChannelFrequency / static_cast<TReal>( KHzConversionFactor ));
|
|
247 |
// Gets locale decimal separator automatically
|
|
248 |
TRealFormat format(KFrequencyMaxLength, iRadioEngine.DecimalCount() );
|
|
249 |
TBuf<30> frequencyString;
|
|
250 |
frequencyString.Num( frequency, format );
|
|
251 |
|
|
252 |
HBufC* stringHolder = StringLoader::LoadLC( R_QTN_FMRADIO_DOUBLE2_FREQ, frequencyString, iEikonEnv );
|
|
253 |
//Update for display of Hindi Devnagari Numbers
|
|
254 |
TPtr textItem2 = stringHolder->Des();
|
|
255 |
AknTextUtils::LanguageSpecificNumberConversion(textItem2);
|
|
256 |
textChannelItem.Append( textItem2 );
|
|
257 |
CleanupStack::PopAndDestroy( stringHolder );
|
|
258 |
}
|
|
259 |
|
|
260 |
// Set 'Now Playing' icon to the channel item
|
|
261 |
textChannelItem.Append( KColumnListSeparator );
|
|
262 |
|
|
263 |
if ( iRadioEngine.GetPresetIndex() == aIndex )
|
|
264 |
{
|
|
265 |
textChannelItem.Append( textChIconIndex );
|
|
266 |
}
|
|
267 |
|
|
268 |
if ( aIndex < iChannelItemArray->Count() && aIndex >= 0 )
|
|
269 |
{
|
|
270 |
iChannelItemArray->Delete( aIndex );
|
|
271 |
iChannelItemArray->InsertL( aIndex, textChannelItem );
|
|
272 |
iChannelList->DrawDeferred();
|
|
273 |
}
|
|
274 |
}
|
|
275 |
|
|
276 |
// ----------------------------------------------------
|
|
277 |
// CFMRadioChannelListContainer::RemoveChannelL
|
|
278 |
// Removes channel from container list
|
|
279 |
// ----------------------------------------------------
|
|
280 |
//
|
|
281 |
void CFMRadioChannelListContainer::RemoveChannelL( TInt aIndex )
|
|
282 |
{
|
|
283 |
if ( iChannelItemArray->Count() > 0 )
|
|
284 |
{
|
|
285 |
TInt presetIndex = iRadioEngine.GetPresetIndex();
|
|
286 |
|
|
287 |
iChannelItemArray->Delete( aIndex );
|
|
288 |
iChannelList->HandleItemRemovalL();
|
|
289 |
iChannelList->UpdateScrollBarsL();
|
|
290 |
|
|
291 |
if ( iChannelItemArray->Count() > 0 )
|
|
292 |
{
|
|
293 |
ReIndexAllL();
|
|
294 |
|
|
295 |
if ( presetIndex > aIndex )
|
|
296 |
{
|
|
297 |
// update engine settings also
|
|
298 |
iRadioEngine.SetCurrentPresetIndex( presetIndex - 1 );
|
|
299 |
UpdateItemIconL( presetIndex - 1, KNowPlayingIconIndexChList );
|
|
300 |
}
|
|
301 |
else if ( presetIndex == aIndex )
|
|
302 |
{
|
|
303 |
iRadioEngine.TunePresetL( 0 );
|
|
304 |
UpdateItemIconL( 0, KNowPlayingIconIndexChList );
|
|
305 |
}
|
|
306 |
else
|
|
307 |
{
|
|
308 |
// NOP
|
|
309 |
}
|
|
310 |
iChannelList->SetCurrentItemIndex( 0 );
|
|
311 |
|
|
312 |
}
|
|
313 |
else
|
|
314 |
{
|
|
315 |
// The last item was deleted, tune to current frequency, out of preset mode
|
|
316 |
iRadioEngine.Tune( iRadioEngine.GetTunedFrequency(), CRadioEngine::ERadioTunerMode );
|
|
317 |
}
|
|
318 |
iChannelList->DrawDeferred();
|
|
319 |
}
|
|
320 |
}
|
|
321 |
|
|
322 |
// ----------------------------------------------------
|
|
323 |
// CFMRadioChannelListContainer::AddChannel
|
|
324 |
// Adds channels to container list
|
|
325 |
// ----------------------------------------------------
|
|
326 |
//
|
|
327 |
void CFMRadioChannelListContainer::AddChannelL(
|
|
328 |
const TDesC& aChannelName, TInt aChannelFrequency, TBool aNowPlaying )
|
|
329 |
{
|
|
330 |
TBuf<KLengthOfChannelItemString> textChannelItem;
|
|
331 |
TBuf<KLengthOfChIndexStringChList> textChIndex;
|
|
332 |
TBuf<KLengthOfChannelItemIconIndexString> textChIconIndex;
|
|
333 |
|
|
334 |
textChIndex.Format( KChIndexFormatChList, iChannelItemArray->Count()+1 ); // One over index
|
|
335 |
|
|
336 |
if ( !AknLayoutUtils::PenEnabled() )
|
|
337 |
{
|
|
338 |
textChIconIndex.Format( KChIconIndexFormatChList, KNowPlayingIconIndexChList ) ;
|
|
339 |
}
|
|
340 |
|
|
341 |
//Update to display Devnagari numbers for Text Index.
|
|
342 |
AknTextUtils::LanguageSpecificNumberConversion(textChIndex);
|
|
343 |
//
|
|
344 |
textChannelItem.Append( textChIndex );
|
|
345 |
textChannelItem.Append( KColumnListSeparator );
|
|
346 |
|
|
347 |
TReal frequency = static_cast<TReal>( aChannelFrequency / static_cast<TReal>( KHzConversionFactor ));
|
|
348 |
// Gets locale decimal separator automatically
|
|
349 |
TRealFormat format(KFrequencyMaxLength, iRadioEngine.DecimalCount() );
|
|
350 |
TBuf<30> frequencyString;
|
|
351 |
frequencyString.Num(frequency,format);
|
|
352 |
|
|
353 |
TBool channelHasName = EFalse;
|
|
354 |
TInt resId = 0;
|
|
355 |
// if name exists, place it on the first line
|
|
356 |
if ( aChannelName.Length() > 0 )
|
|
357 |
{
|
|
358 |
textChannelItem.Append( aChannelName );
|
|
359 |
textChannelItem.Append( KColumnListSeparator );
|
|
360 |
channelHasName = ETrue;
|
|
361 |
resId = R_QTN_FMRADIO_DOUBLE2_FREQ;
|
|
362 |
}
|
|
363 |
else // frequency goes to first line
|
|
364 |
{
|
|
365 |
resId = R_QTN_FMRADIO_DOUBLE1_FREQ;
|
|
366 |
}
|
|
367 |
|
|
368 |
HBufC* stringHolder = StringLoader::LoadLC( resId, frequencyString, iEikonEnv );
|
|
369 |
//Update for display of Hindi Devnagari Numbers
|
|
370 |
TPtr textItem2 = stringHolder->Des();
|
|
371 |
AknTextUtils::LanguageSpecificNumberConversion(textItem2);
|
|
372 |
textChannelItem.Append( textItem2 );
|
|
373 |
CleanupStack::PopAndDestroy( stringHolder );
|
|
374 |
|
|
375 |
if ( !channelHasName )
|
|
376 |
{
|
|
377 |
// add placeholder for second line
|
|
378 |
textChannelItem.Append( KColumnListSeparator );
|
|
379 |
}
|
|
380 |
|
|
381 |
// Set 'Now Playing' icon to the channel item
|
|
382 |
textChannelItem.Append( KColumnListSeparator );
|
|
383 |
|
|
384 |
if( !AknLayoutUtils::PenEnabled() && aNowPlaying )
|
|
385 |
{
|
|
386 |
textChannelItem.Append( textChIconIndex );
|
|
387 |
}
|
|
388 |
|
|
389 |
iChannelItemArray->AppendL( textChannelItem );
|
|
390 |
|
|
391 |
iChannelList->HandleItemAdditionL(); // Update list
|
|
392 |
iChannelList->UpdateScrollBarsL();
|
|
393 |
iChannelList->DrawDeferred();
|
|
394 |
|
|
395 |
}
|
|
396 |
// ----------------------------------------------------
|
|
397 |
// CFMRadioChannelListContainer::UpdateItemIconL
|
|
398 |
// Adds icon to a list item
|
|
399 |
// ----------------------------------------------------
|
|
400 |
//
|
|
401 |
void CFMRadioChannelListContainer::UpdateItemIconL( TInt aIndex, TInt aIconIndex )
|
|
402 |
{
|
|
403 |
HideIconsL();
|
|
404 |
|
|
405 |
if ( aIndex >= 0 && aIndex < iChannelItemArray->Count() )
|
|
406 |
{
|
|
407 |
TBuf<KLengthOfChannelItemIconIndexString> textChIconIndex;
|
|
408 |
textChIconIndex.Format( KChIconIndexFormatChList, aIconIndex );
|
|
409 |
HBufC* channelItem = HBufC::NewLC( KLengthOfChannelItemString );
|
|
410 |
channelItem->Des().Copy( iChannelItemArray->MdcaPoint( aIndex ) );
|
|
411 |
TPtr ptr( channelItem->Des() );
|
|
412 |
ptr.Append( textChIconIndex ); // Add icon index
|
|
413 |
|
|
414 |
iChannelItemArray->Delete( aIndex );
|
|
415 |
iChannelItemArray->InsertL( aIndex, *channelItem );
|
|
416 |
CleanupStack::PopAndDestroy( channelItem );
|
|
417 |
}
|
|
418 |
// use draw now so that view is up to date during fast channel switching
|
|
419 |
iChannelList->DrawNow();
|
|
420 |
}
|
|
421 |
|
|
422 |
// ----------------------------------------------------
|
|
423 |
// CFMRadioChannelListContainer::HideIconsL
|
|
424 |
// hide all icons from the list
|
|
425 |
// ----------------------------------------------------
|
|
426 |
//
|
|
427 |
void CFMRadioChannelListContainer::HideIconsL()
|
|
428 |
{
|
|
429 |
for ( TInt index = 0 ; index < iChannelItemArray->Count(); index++ )
|
|
430 |
{
|
|
431 |
HBufC* channelItem = HBufC::NewLC( KLengthOfChannelItemString );
|
|
432 |
channelItem->Des().Copy( iChannelItemArray->MdcaPoint( index ) );
|
|
433 |
TPtr ptr( channelItem->Des() );
|
|
434 |
|
|
435 |
TBuf<KLengthOfChannelItemIconIndexString> textChIconIndex;
|
|
436 |
TPtrC iconIndexPtr( textChIconIndex );
|
|
437 |
TInt err = TextUtils::ColumnText( iconIndexPtr, 3, &ptr );
|
|
438 |
|
|
439 |
if ( iconIndexPtr.Length() > 0 )
|
|
440 |
{
|
|
441 |
ptr.Delete( ptr.Length() - iconIndexPtr.Length(), iconIndexPtr.Length() ); // Remove icon index
|
|
442 |
iChannelItemArray->Delete( index );
|
|
443 |
iChannelItemArray->InsertL( index, *channelItem );
|
|
444 |
}
|
|
445 |
CleanupStack::PopAndDestroy( channelItem );
|
|
446 |
}
|
|
447 |
}
|
|
448 |
|
|
449 |
// ----------------------------------------------------
|
|
450 |
// CFMRadioChannelListContainer::SetFaded
|
|
451 |
// Fades the entire window and controls in the window owned
|
|
452 |
// by this container control.
|
|
453 |
// ----------------------------------------------------
|
|
454 |
//
|
|
455 |
void CFMRadioChannelListContainer::SetFaded( TBool aFaded )
|
|
456 |
{
|
|
457 |
iFadeStatus = aFaded;
|
|
458 |
Window().SetFaded( aFaded, RWindowTreeNode::EFadeIncludeChildren );
|
|
459 |
}
|
|
460 |
|
|
461 |
// ----------------------------------------------------
|
|
462 |
// CFMRadioChannelListContainer::UpdateLastListenedChannel
|
|
463 |
// Updates channel index - the highlighted channel in the list.
|
|
464 |
// ----------------------------------------------------
|
|
465 |
//
|
|
466 |
void CFMRadioChannelListContainer::UpdateLastListenedChannel( TInt aIndex )
|
|
467 |
{
|
|
468 |
iLastChIndex = aIndex;
|
|
469 |
iChannelList->SetCurrentItemIndex( iLastChIndex );
|
|
470 |
iChannelList->ScrollToMakeItemVisible( iLastChIndex );
|
|
471 |
iChannelList->DrawDeferred();
|
|
472 |
}
|
|
473 |
|
|
474 |
// ----------------------------------------------------
|
|
475 |
// CFMRadioChannelListContainer::CurrentlySelectedChannel
|
|
476 |
// Returns the index of the selected channel item from the
|
|
477 |
// channel list.
|
|
478 |
// ----------------------------------------------------
|
|
479 |
//
|
|
480 |
TInt CFMRadioChannelListContainer::CurrentlySelectedChannel() const
|
|
481 |
{
|
|
482 |
return iChannelList->CurrentItemIndex(); // Index of selected channel
|
|
483 |
}
|
|
484 |
|
|
485 |
// ----------------------------------------------------
|
|
486 |
// CFMRadioChannelListContainer::HandleListBoxEventL
|
|
487 |
// For handling listbox-, in this case, channel list events.
|
|
488 |
// The event equals to selecting a channel item from the list.
|
|
489 |
// ----------------------------------------------------
|
|
490 |
//
|
|
491 |
void CFMRadioChannelListContainer::HandleListBoxEventL( CEikListBox* /*aListBox*/,
|
|
492 |
TListBoxEvent aEventType )
|
|
493 |
{
|
|
494 |
// Check the event generated by keypress and report the event,
|
|
495 |
// Also check for Pen Enabled touch screen event
|
|
496 |
|
|
497 |
switch ( aEventType )
|
|
498 |
{
|
|
499 |
case EEventEnterKeyPressed:
|
|
500 |
{
|
|
501 |
ReportEventL( MCoeControlObserver::EEventStateChanged );
|
|
502 |
break;
|
|
503 |
}
|
|
504 |
case EEventItemSingleClicked:
|
|
505 |
{
|
|
506 |
if ( iMoveAction )
|
|
507 |
{
|
|
508 |
TouchMoveEventL( CurrentlySelectedChannel() );
|
|
509 |
}
|
|
510 |
else
|
|
511 |
{
|
|
512 |
ReportEventL( MCoeControlObserver::EEventStateChanged );
|
|
513 |
}
|
|
514 |
break;
|
|
515 |
}
|
|
516 |
default:
|
|
517 |
{
|
|
518 |
break;
|
|
519 |
}
|
|
520 |
}
|
|
521 |
}
|
|
522 |
|
|
523 |
// -----------------------------------------------------------------------------
|
|
524 |
// CFMRadioChannelListContainer::HandleResourceChange
|
|
525 |
// -----------------------------------------------------------------------------
|
|
526 |
//
|
|
527 |
void CFMRadioChannelListContainer::HandleResourceChange(TInt aType)
|
|
528 |
{
|
|
529 |
CCoeControl::HandleResourceChange(aType);
|
|
530 |
if ( aType == KEikDynamicLayoutVariantSwitch )
|
|
531 |
{
|
|
532 |
SizeChanged();
|
|
533 |
}
|
|
534 |
else if ( aType == KAknsMessageSkinChange )
|
|
535 |
{
|
|
536 |
CArrayPtr<CGulIcon>* iconArray = iChannelList->ItemDrawer()->FormattedCellData()->IconArray();
|
|
537 |
// update icons with new skin
|
|
538 |
iconArray->ResetAndDestroy();
|
|
539 |
TRAP_IGNORE( CreateListIconsL( *iconArray ) )
|
|
540 |
}
|
|
541 |
}
|
|
542 |
// ---------------------------------------------------------
|
|
543 |
// CFMRadioChannelListContainer::SizeChanged
|
|
544 |
// Called by framework when the view size is changed
|
|
545 |
// ---------------------------------------------------------
|
|
546 |
//
|
|
547 |
void CFMRadioChannelListContainer::SizeChanged()
|
|
548 |
{
|
|
549 |
// The channel list fills the whole view
|
|
550 |
iChannelList->SetRect( Rect() );
|
|
551 |
DrawDeferred();
|
|
552 |
}
|
|
553 |
|
|
554 |
// ---------------------------------------------------------
|
|
555 |
// CFMRadioChannelListContainer::CountComponentControls
|
|
556 |
// Return the number of controls in the window owned by this container
|
|
557 |
// ---------------------------------------------------------
|
|
558 |
//
|
|
559 |
TInt CFMRadioChannelListContainer::CountComponentControls() const
|
|
560 |
{
|
|
561 |
return 1;
|
|
562 |
}
|
|
563 |
|
|
564 |
// ---------------------------------------------------------
|
|
565 |
// CFMRadioChannelListContainer::ComponentControl
|
|
566 |
// Return the control corresponding to the specified index
|
|
567 |
// ---------------------------------------------------------
|
|
568 |
//
|
|
569 |
CCoeControl* CFMRadioChannelListContainer::ComponentControl( TInt aIndex ) const
|
|
570 |
{
|
|
571 |
CCoeControl* control = NULL;
|
|
572 |
|
|
573 |
switch ( aIndex )
|
|
574 |
{
|
|
575 |
case 0:
|
|
576 |
{
|
|
577 |
control = iChannelList;
|
|
578 |
break;
|
|
579 |
}
|
|
580 |
default:
|
|
581 |
{
|
|
582 |
break;
|
|
583 |
}
|
|
584 |
}
|
|
585 |
|
|
586 |
return control;
|
|
587 |
}
|
|
588 |
|
|
589 |
// ---------------------------------------------------------
|
|
590 |
// CFMRadioChannelListContainer::OfferKeyEventL
|
|
591 |
// Allow the channel list to process key events
|
|
592 |
// ---------------------------------------------------------
|
|
593 |
//
|
|
594 |
TKeyResponse CFMRadioChannelListContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,
|
|
595 |
TEventCode aType )
|
|
596 |
{
|
|
597 |
TKeyResponse response = EKeyWasNotConsumed;
|
|
598 |
|
|
599 |
if ( iFadeStatus )
|
|
600 |
{
|
|
601 |
// don't handle any keys if the view is faded
|
|
602 |
return response;
|
|
603 |
}
|
|
604 |
|
|
605 |
switch ( aKeyEvent.iCode )
|
|
606 |
{
|
|
607 |
case EKeyBackspace:
|
|
608 |
{
|
|
609 |
if ( iChannelList->IsHighlightEnabled() && !iMoveAction )
|
|
610 |
{
|
|
611 |
iChannelView->HandleCommandL( EFMRadioCmdErase );
|
|
612 |
return EKeyWasConsumed;
|
|
613 |
}
|
|
614 |
break;
|
|
615 |
}
|
|
616 |
case EKeyOK: // accept both
|
|
617 |
case EKeyEnter:
|
|
618 |
{
|
|
619 |
// used to accept move action
|
|
620 |
if ( iMoveAction )
|
|
621 |
{
|
|
622 |
iChannelView->MoveActionDoneL();
|
|
623 |
return EKeyWasConsumed;
|
|
624 |
}
|
|
625 |
else if ( iChannelList->IsHighlightEnabled() ) // change to main view
|
|
626 |
{
|
|
627 |
if ( iChannelView->CurrentlyPlayingChannel() ==
|
|
628 |
CurrentlySelectedChannel() )
|
|
629 |
{
|
|
630 |
CFMRadioAppUi* appUi = static_cast<CFMRadioAppUi*>( iCoeEnv->AppUi() );
|
|
631 |
appUi->ActivateLocalViewL( KFMRadioMainViewId );
|
|
632 |
return EKeyWasConsumed;
|
|
633 |
}
|
|
634 |
}
|
|
635 |
break;
|
|
636 |
}
|
|
637 |
case EKeyLeftArrow:
|
|
638 |
case EKeyRightArrow:
|
|
639 |
{
|
|
640 |
return EKeyWasNotConsumed;
|
|
641 |
}
|
|
642 |
case EKeyUpArrow:
|
|
643 |
if ( iMoveAction )
|
|
644 |
{
|
|
645 |
iKeyMoveActivated = ETrue;
|
|
646 |
MoveUpL();
|
|
647 |
response = EKeyWasConsumed;
|
|
648 |
}
|
|
649 |
else
|
|
650 |
{
|
|
651 |
response = iChannelList->OfferKeyEventL(aKeyEvent, aType);
|
|
652 |
if (response == EKeyWasConsumed)
|
|
653 |
{
|
|
654 |
ReportEventL( MCoeControlObserver::EEventRequestFocus );
|
|
655 |
}
|
|
656 |
}
|
|
657 |
return response;
|
|
658 |
case EKeyDownArrow:
|
|
659 |
if ( iMoveAction )
|
|
660 |
{
|
|
661 |
iKeyMoveActivated = ETrue;
|
|
662 |
MoveDownL();
|
|
663 |
response = EKeyWasConsumed;
|
|
664 |
}
|
|
665 |
else
|
|
666 |
{
|
|
667 |
response = iChannelList->OfferKeyEventL(aKeyEvent, aType);
|
|
668 |
if (response == EKeyWasConsumed)
|
|
669 |
{
|
|
670 |
ReportEventL( MCoeControlObserver::EEventRequestFocus );
|
|
671 |
}
|
|
672 |
}
|
|
673 |
return response;
|
|
674 |
default:
|
|
675 |
switch ( aKeyEvent.iScanCode ) //we need to use the scan code, because we need to process the event wrt the keyUp and keyDown action
|
|
676 |
{
|
|
677 |
case EKeyboardKey1: // Timed key
|
|
678 |
case EKeyboardKey2: // Normal keys
|
|
679 |
case EKeyboardKey3:
|
|
680 |
case EKeyboardKey4:
|
|
681 |
case EKeyboardKey5:
|
|
682 |
case EKeyboardKey6:
|
|
683 |
case EKeyboardKey7:
|
|
684 |
case EKeyboardKey8:
|
|
685 |
case EKeyboardKey9:
|
|
686 |
case EKeyboardKey0:
|
|
687 |
return EKeyWasNotConsumed;
|
|
688 |
default:
|
|
689 |
break;
|
|
690 |
}
|
|
691 |
break;
|
|
692 |
}
|
|
693 |
return iChannelList->OfferKeyEventL(aKeyEvent, aType);
|
|
694 |
}
|
|
695 |
|
|
696 |
// ---------------------------------------------------------------------------
|
|
697 |
// CFMRadioChannelListContainer::GetHelpContext
|
|
698 |
// Gets Help
|
|
699 |
//
|
|
700 |
// ---------------------------------------------------------------------------
|
|
701 |
//
|
|
702 |
void CFMRadioChannelListContainer::GetHelpContext(TCoeHelpContext& aContext) const
|
|
703 |
{
|
|
704 |
#if defined __SERIES60_HELP || defined FF_S60_HELPS_IN_USE
|
|
705 |
aContext.iMajor = TUid::Uid( KUidFMRadioApplication );
|
|
706 |
aContext.iContext = KFMRADIO_HLP_LIST;
|
|
707 |
#endif
|
|
708 |
}
|
|
709 |
|
|
710 |
// ---------------------------------------------------------
|
|
711 |
// CFMRadioChannelListContainer::FocusChanged(TDrawNow aDrawNow)
|
|
712 |
//
|
|
713 |
// ---------------------------------------------------------
|
|
714 |
//
|
|
715 |
void CFMRadioChannelListContainer::FocusChanged(TDrawNow aDrawNow)
|
|
716 |
{
|
|
717 |
CCoeControl::FocusChanged(aDrawNow);
|
|
718 |
if ( iChannelList )
|
|
719 |
{
|
|
720 |
iChannelList->SetFocus(IsFocused(), aDrawNow);
|
|
721 |
}
|
|
722 |
}
|
|
723 |
|
|
724 |
// ---------------------------------------------------------
|
|
725 |
// CFMRadioChannelListContainer::HandlePointerEventL
|
|
726 |
// ---------------------------------------------------------
|
|
727 |
//
|
|
728 |
void CFMRadioChannelListContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent )
|
|
729 |
{
|
|
730 |
// don't handle any pointer events if view is faded
|
|
731 |
if ( !iFadeStatus )
|
|
732 |
{
|
|
733 |
CCoeControl::HandlePointerEventL( aPointerEvent );
|
|
734 |
}
|
|
735 |
}
|
|
736 |
|
|
737 |
// ---------------------------------------------------------
|
|
738 |
// CFMRadioChannelListContainer::ActivateMove
|
|
739 |
// ---------------------------------------------------------
|
|
740 |
//
|
|
741 |
void CFMRadioChannelListContainer::ActivateMoveL()
|
|
742 |
{
|
|
743 |
iMoveAction = ETrue;
|
|
744 |
iMoveIndex = iChannelList->CurrentItemIndex();
|
|
745 |
iTouchMoveIndex = iMoveIndex;
|
|
746 |
UpdateItemIconL( iMoveIndex, KMoveIconIndexChList );
|
|
747 |
iKeyMoveActivated = EFalse;;
|
|
748 |
}
|
|
749 |
|
|
750 |
// ---------------------------------------------------------
|
|
751 |
// CFMRadioChannelListContainer::TouchMoveEventL
|
|
752 |
// ---------------------------------------------------------
|
|
753 |
//
|
|
754 |
void CFMRadioChannelListContainer::TouchMoveEventL( TInt aIndex )
|
|
755 |
{
|
|
756 |
HBufC* channelItem = HBufC::NewLC( KLengthOfChannelItemString );
|
|
757 |
channelItem->Des().Copy( iChannelItemArray->MdcaPoint( iTouchMoveIndex ) );
|
|
758 |
TPtr ptr( channelItem->Des() );
|
|
759 |
|
|
760 |
TBuf<KLengthOfChannelItemIconIndexString> textChIconIndex;
|
|
761 |
|
|
762 |
TPtrC iconIndexPtr( textChIconIndex );
|
|
763 |
|
|
764 |
TInt err = TextUtils::ColumnText( iconIndexPtr, 3, &ptr );
|
|
765 |
|
|
766 |
iChannelItemArray->Delete( iTouchMoveIndex );
|
|
767 |
iChannelList->HandleItemRemovalL();
|
|
768 |
|
|
769 |
iChannelItemArray->InsertL( aIndex, *channelItem );
|
|
770 |
iChannelList->HandleItemAdditionL();
|
|
771 |
iChannelList->UpdateScrollBarsL();
|
|
772 |
iChannelList->SetCurrentItemIndex( aIndex );
|
|
773 |
iChannelList->DrawDeferred();
|
|
774 |
|
|
775 |
iTouchMoveIndex = aIndex;
|
|
776 |
|
|
777 |
CleanupStack::PopAndDestroy( channelItem );
|
|
778 |
|
|
779 |
ReIndexAllL();
|
|
780 |
UpdateItemIconL( aIndex, KMoveIconIndexChList );
|
|
781 |
iChannelView->MoveActionDoneL();
|
|
782 |
}
|
|
783 |
|
|
784 |
// ---------------------------------------------------------
|
|
785 |
// CFMRadioChannelListContainer::MoveDownL
|
|
786 |
// ---------------------------------------------------------
|
|
787 |
//
|
|
788 |
void CFMRadioChannelListContainer::MoveDownL()
|
|
789 |
{
|
|
790 |
TInt index = iChannelList->CurrentItemIndex();
|
|
791 |
TInt originalindex = index;
|
|
792 |
|
|
793 |
HBufC* channelItem = HBufC::NewLC( KLengthOfChannelItemString );
|
|
794 |
channelItem->Des().Copy( iChannelItemArray->MdcaPoint( index ) );
|
|
795 |
TPtr ptr( channelItem->Des() );
|
|
796 |
|
|
797 |
iChannelItemArray->Delete( index );
|
|
798 |
iChannelList->HandleItemRemovalL();
|
|
799 |
|
|
800 |
if ( index < iChannelItemArray->Count() )
|
|
801 |
{
|
|
802 |
index = index+1;
|
|
803 |
|
|
804 |
TBuf<KLengthOfChIndexStringChList> channelindex;
|
|
805 |
|
|
806 |
TPtrC indexPtr( channelindex );
|
|
807 |
|
|
808 |
TInt errori = TextUtils::ColumnText( indexPtr, 0, &ptr );
|
|
809 |
|
|
810 |
ptr.Delete( 0, indexPtr.Length() );
|
|
811 |
|
|
812 |
channelindex.Format( KChIndexFormatChList, index+1 );
|
|
813 |
|
|
814 |
AknTextUtils::LanguageSpecificNumberConversion( channelindex );
|
|
815 |
|
|
816 |
ptr.Insert( 0, channelindex );
|
|
817 |
|
|
818 |
iChannelItemArray->InsertL( index, *channelItem );
|
|
819 |
iChannelList->HandleItemAdditionL(); // Update list
|
|
820 |
iChannelList->UpdateScrollBarsL();
|
|
821 |
iChannelList->SetCurrentItemIndex( index );
|
|
822 |
iChannelList->DrawDeferred();
|
|
823 |
|
|
824 |
HBufC* origchannelItem = HBufC::NewLC( KLengthOfChannelItemString );
|
|
825 |
origchannelItem->Des().Copy( iChannelItemArray->MdcaPoint( originalindex ) );
|
|
826 |
TPtr origptr( origchannelItem->Des() );
|
|
827 |
|
|
828 |
iChannelItemArray->Delete( originalindex );
|
|
829 |
iChannelList->HandleItemRemovalL();
|
|
830 |
TBuf<KLengthOfChIndexStringChList> origchannelindex;
|
|
831 |
|
|
832 |
TPtrC origindexPtr( origchannelindex );
|
|
833 |
|
|
834 |
TextUtils::ColumnText( origindexPtr, 0, &origptr );
|
|
835 |
origptr.Delete( 0, origindexPtr.Length() );
|
|
836 |
|
|
837 |
origchannelindex.Format( KChIndexFormatChList, originalindex+1 );
|
|
838 |
|
|
839 |
AknTextUtils::LanguageSpecificNumberConversion( origchannelindex );
|
|
840 |
origptr.Insert( 0, origchannelindex );
|
|
841 |
iChannelItemArray->InsertL( originalindex, *origchannelItem );
|
|
842 |
iChannelList->HandleItemAdditionL();
|
|
843 |
iChannelList->UpdateScrollBarsL();
|
|
844 |
iChannelList->DrawDeferred();
|
|
845 |
|
|
846 |
CleanupStack::PopAndDestroy( origchannelItem );
|
|
847 |
}
|
|
848 |
else
|
|
849 |
{
|
|
850 |
index = 0;
|
|
851 |
iChannelItemArray->InsertL( index, *channelItem );
|
|
852 |
iChannelList->HandleItemAdditionL(); // Update list
|
|
853 |
iChannelList->UpdateScrollBarsL();
|
|
854 |
iChannelList->SetCurrentItemIndex( index );
|
|
855 |
iChannelList->DrawDeferred();
|
|
856 |
|
|
857 |
ReIndexAllL();
|
|
858 |
}
|
|
859 |
|
|
860 |
iChannelList->ScrollToMakeItemVisible( index );
|
|
861 |
|
|
862 |
CleanupStack::PopAndDestroy( channelItem );
|
|
863 |
|
|
864 |
}
|
|
865 |
// ---------------------------------------------------------
|
|
866 |
// CFMRadioChannelListContainer::MoveUpL
|
|
867 |
// ---------------------------------------------------------
|
|
868 |
//
|
|
869 |
void CFMRadioChannelListContainer::MoveUpL()
|
|
870 |
{
|
|
871 |
TInt index = iChannelList->CurrentItemIndex();
|
|
872 |
TInt originalindex = index;
|
|
873 |
|
|
874 |
HBufC* channelItem = HBufC::NewLC( KLengthOfChannelItemString );
|
|
875 |
channelItem->Des().Copy( iChannelItemArray->MdcaPoint( index ) );
|
|
876 |
TPtr ptr( channelItem->Des() );
|
|
877 |
|
|
878 |
iChannelItemArray->Delete( index );
|
|
879 |
iChannelList->HandleItemRemovalL();
|
|
880 |
|
|
881 |
if ( 0 == index )
|
|
882 |
{
|
|
883 |
index = iChannelItemArray->Count();
|
|
884 |
|
|
885 |
TBuf<KLengthOfChIndexStringChList> channelindex;
|
|
886 |
|
|
887 |
TPtrC indexPtr( channelindex );
|
|
888 |
|
|
889 |
iChannelItemArray->InsertL( index, *channelItem );
|
|
890 |
iChannelList->HandleItemAdditionL();
|
|
891 |
iChannelList->UpdateScrollBarsL();
|
|
892 |
|
|
893 |
iChannelList->SetCurrentItemIndex( index );
|
|
894 |
|
|
895 |
iChannelList->DrawItem( index );
|
|
896 |
|
|
897 |
ReIndexAllL();
|
|
898 |
}
|
|
899 |
else
|
|
900 |
{
|
|
901 |
index = index-1;
|
|
902 |
|
|
903 |
TBuf<KLengthOfChIndexStringChList> channelindex;
|
|
904 |
|
|
905 |
TPtrC indexPtr( channelindex );
|
|
906 |
|
|
907 |
TInt errori = TextUtils::ColumnText( indexPtr, 0, &ptr );
|
|
908 |
|
|
909 |
ptr.Delete( 0, indexPtr.Length() );
|
|
910 |
|
|
911 |
channelindex.Format( KChIndexFormatChList, index+1 );
|
|
912 |
|
|
913 |
AknTextUtils::LanguageSpecificNumberConversion( channelindex );
|
|
914 |
ptr.Insert( 0, channelindex ); // Remove icon index
|
|
915 |
|
|
916 |
iChannelItemArray->InsertL( index, *channelItem );
|
|
917 |
iChannelList->SetCurrentItemIndex( index );
|
|
918 |
iChannelList->HandleItemAdditionL();
|
|
919 |
iChannelList->UpdateScrollBarsL();
|
|
920 |
iChannelList->DrawItem( index );
|
|
921 |
|
|
922 |
HBufC* origchannelItem = HBufC::NewLC( KLengthOfChannelItemString );
|
|
923 |
origchannelItem->Des().Copy( iChannelItemArray->MdcaPoint( originalindex ) );
|
|
924 |
TPtr origptr( origchannelItem->Des() );
|
|
925 |
|
|
926 |
iChannelItemArray->Delete( originalindex );
|
|
927 |
iChannelList->HandleItemRemovalL();
|
|
928 |
TBuf<KLengthOfChIndexStringChList> origchannelindex;
|
|
929 |
|
|
930 |
TPtrC origindexPtr( origchannelindex );
|
|
931 |
|
|
932 |
TextUtils::ColumnText( origindexPtr, 0, &origptr );
|
|
933 |
|
|
934 |
origptr.Delete( 0, origindexPtr.Length() );
|
|
935 |
|
|
936 |
origchannelindex.Format( KChIndexFormatChList, originalindex+1 );
|
|
937 |
|
|
938 |
AknTextUtils::LanguageSpecificNumberConversion( origchannelindex );
|
|
939 |
origptr.Insert( 0, origchannelindex );
|
|
940 |
|
|
941 |
iChannelItemArray->InsertL( originalindex, *origchannelItem );
|
|
942 |
iChannelList->HandleItemAdditionL();
|
|
943 |
iChannelList->DrawDeferred();
|
|
944 |
|
|
945 |
iChannelList->UpdateScrollBarsL();
|
|
946 |
|
|
947 |
CleanupStack::PopAndDestroy( origchannelItem );
|
|
948 |
}
|
|
949 |
|
|
950 |
iChannelList->ScrollToMakeItemVisible( index );
|
|
951 |
|
|
952 |
CleanupStack::PopAndDestroy( channelItem );
|
|
953 |
}
|
|
954 |
|
|
955 |
// ---------------------------------------------------------
|
|
956 |
// CFMRadioChannelListContainer::ReIndexAllL
|
|
957 |
// ---------------------------------------------------------
|
|
958 |
//
|
|
959 |
void CFMRadioChannelListContainer::ReIndexAllL()
|
|
960 |
{
|
|
961 |
HBufC* channelItem = HBufC::NewLC( KLengthOfChannelItemString );
|
|
962 |
|
|
963 |
for ( TInt index = 0; index < iChannelItemArray->Count(); index++ )
|
|
964 |
{
|
|
965 |
channelItem->Des().Copy( iChannelItemArray->MdcaPoint( index ) );
|
|
966 |
TPtr ptr( channelItem->Des() );
|
|
967 |
|
|
968 |
iChannelItemArray->Delete( index );
|
|
969 |
iChannelList->HandleItemRemovalL();
|
|
970 |
|
|
971 |
TBuf<KLengthOfChIndexStringChList> channelindex;
|
|
972 |
|
|
973 |
TPtrC indexPtr( channelindex );
|
|
974 |
|
|
975 |
TInt errori = TextUtils::ColumnText( indexPtr, 0, &ptr );
|
|
976 |
|
|
977 |
ptr.Delete( 0, indexPtr.Length() );
|
|
978 |
|
|
979 |
channelindex.Format( KChIndexFormatChList, index+1 );
|
|
980 |
|
|
981 |
AknTextUtils::LanguageSpecificNumberConversion( channelindex );
|
|
982 |
|
|
983 |
ptr.Insert( 0, channelindex ); // Remove icon index
|
|
984 |
|
|
985 |
iChannelItemArray->InsertL( index, *channelItem );
|
|
986 |
|
|
987 |
iChannelList->HandleItemAdditionL();
|
|
988 |
iChannelList->DrawDeferred();
|
|
989 |
iChannelList->UpdateScrollBarsL();
|
|
990 |
}
|
|
991 |
|
|
992 |
CleanupStack::PopAndDestroy( channelItem );
|
|
993 |
}
|
|
994 |
|
|
995 |
// ---------------------------------------------------------
|
|
996 |
// CFMRadioChannelListContainer::HandleDropL
|
|
997 |
// ---------------------------------------------------------
|
|
998 |
//
|
|
999 |
void CFMRadioChannelListContainer::HandleDropL()
|
|
1000 |
{
|
|
1001 |
iMoveAction = EFalse;
|
|
1002 |
|
|
1003 |
if ( iMoveIndex != iChannelList->CurrentItemIndex() )
|
|
1004 |
{
|
|
1005 |
iObserver.UpdateChannelsL( EMoveChannels,
|
|
1006 |
iMoveIndex,
|
|
1007 |
iChannelList->CurrentItemIndex() );
|
|
1008 |
}
|
|
1009 |
HideIconsL();
|
|
1010 |
iChannelList->DrawDeferred();
|
|
1011 |
}
|
|
1012 |
// ---------------------------------------------------------
|
|
1013 |
// CFMRadioChannelListContainer::MoveDoneL
|
|
1014 |
// ---------------------------------------------------------
|
|
1015 |
//
|
|
1016 |
void CFMRadioChannelListContainer::MoveDoneL()
|
|
1017 |
{
|
|
1018 |
if ( iMoveAction )
|
|
1019 |
{
|
|
1020 |
iMoveAction = EFalse;
|
|
1021 |
}
|
|
1022 |
|
|
1023 |
iObserver.UpdateChannelsL( EStoreAllToRepository, 0, 0 );
|
|
1024 |
}
|
|
1025 |
|
|
1026 |
// ---------------------------------------------------------
|
|
1027 |
// CFMRadioChannelListContainer::MoveCanceledL
|
|
1028 |
// ---------------------------------------------------------
|
|
1029 |
//
|
|
1030 |
TBool CFMRadioChannelListContainer::MoveCanceledL()
|
|
1031 |
{
|
|
1032 |
TBool wasmove = EFalse;
|
|
1033 |
|
|
1034 |
if ( iMoveAction )
|
|
1035 |
{
|
|
1036 |
HideIconsL();
|
|
1037 |
iMoveAction = EFalse;
|
|
1038 |
|
|
1039 |
if ( iKeyMoveActivated )
|
|
1040 |
{
|
|
1041 |
TInt index = iChannelList->CurrentItemIndex();
|
|
1042 |
HBufC* channelItem = HBufC::NewLC( KLengthOfChannelItemString );
|
|
1043 |
channelItem->Des().Copy( iChannelItemArray->MdcaPoint( index ) );
|
|
1044 |
TPtr ptr( channelItem->Des() );
|
|
1045 |
|
|
1046 |
TBuf<KLengthOfChannelItemIconIndexString> textChIconIndex;
|
|
1047 |
TPtrC iconIndexPtr( textChIconIndex );
|
|
1048 |
TInt err = TextUtils::ColumnText( iconIndexPtr, 3, &ptr );
|
|
1049 |
iChannelItemArray->Delete( index );
|
|
1050 |
iChannelList->HandleItemRemovalL();
|
|
1051 |
|
|
1052 |
iChannelItemArray->InsertL( iMoveIndex, *channelItem );
|
|
1053 |
iChannelList->HandleItemAdditionL();
|
|
1054 |
iChannelList->SetCurrentItemIndex( iMoveIndex );
|
|
1055 |
CleanupStack::PopAndDestroy( channelItem );
|
|
1056 |
iChannelList->ScrollToMakeItemVisible( index );
|
|
1057 |
}
|
|
1058 |
iChannelList->UpdateScrollBarsL();
|
|
1059 |
iChannelList->DrawDeferred();
|
|
1060 |
wasmove = ETrue;
|
|
1061 |
}
|
|
1062 |
|
|
1063 |
return wasmove;
|
|
1064 |
}
|
|
1065 |
|
|
1066 |
// ---------------------------------------------------------
|
|
1067 |
// CFMRadioChannelListContainer::MoveAction()
|
|
1068 |
// ---------------------------------------------------------
|
|
1069 |
//
|
|
1070 |
TBool CFMRadioChannelListContainer::MoveAction()
|
|
1071 |
{
|
|
1072 |
return iMoveAction;
|
|
1073 |
|
|
1074 |
}
|
|
1075 |
|
|
1076 |
// End of File
|