5
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2007 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 the License "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: Implements CLiwIterable type
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <mclfitem.h>
|
|
20 |
#include <mclfitemlistmodel.h>
|
|
21 |
|
|
22 |
#include "mgitemslist.h"
|
|
23 |
#include "mgmediaitemfactory.h"
|
|
24 |
#include "mgmediaitem.h"
|
|
25 |
|
|
26 |
|
|
27 |
_LIT8( KMgFileNameAndPath, "FileNameAndPath" );
|
|
28 |
|
|
29 |
const TInt KStartItemIndex = -1;
|
|
30 |
|
|
31 |
// ---------------------------------------------------------------------------
|
|
32 |
// CMgItemsList::CMgItemsList
|
|
33 |
// Parameterised constructor
|
|
34 |
// ---------------------------------------------------------------------------
|
|
35 |
//
|
|
36 |
|
|
37 |
CMgItemsList::CMgItemsList( MCLFItemListModel* aItemListModel, TMgCmdId aCmdId )
|
|
38 |
: iItemListModel(aItemListModel),
|
|
39 |
iCmdId(aCmdId),
|
|
40 |
iCount(iItemListModel->ItemCount()),
|
|
41 |
iCurrent(KStartItemIndex),
|
|
42 |
iMediaItem(NULL)
|
|
43 |
{
|
|
44 |
|
|
45 |
}
|
|
46 |
// ---------------------------------------------------------------------------
|
|
47 |
// CMgItemsList::NewL
|
|
48 |
// Two-phased constructor
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
//
|
|
51 |
|
|
52 |
CMgItemsList* CMgItemsList::NewL( MCLFItemListModel* aItemListModel, TMgCmdId aCmdId )
|
|
53 |
{
|
|
54 |
return new( ELeave ) CMgItemsList( aItemListModel, aCmdId );
|
|
55 |
}
|
|
56 |
|
|
57 |
|
|
58 |
// ---------------------------------------------------------------------------
|
|
59 |
// CMgItemsList::~CMgItemsList
|
|
60 |
// Class destructor
|
|
61 |
// ---------------------------------------------------------------------------
|
|
62 |
//
|
|
63 |
CMgItemsList::~CMgItemsList()
|
|
64 |
{
|
|
65 |
|
|
66 |
delete iItemListModel;
|
|
67 |
|
|
68 |
delete iMediaItem;
|
|
69 |
|
|
70 |
}
|
|
71 |
// ---------------------------------------------------------------------------
|
|
72 |
// CMgItemsList::Reset
|
|
73 |
// Resets the iterator to point to the beginning of list
|
|
74 |
// ---------------------------------------------------------------------------
|
|
75 |
//
|
|
76 |
|
|
77 |
void CMgItemsList::Reset()
|
|
78 |
{
|
|
79 |
iCurrent = KStartItemIndex;// if user resets the list
|
|
80 |
}
|
|
81 |
|
|
82 |
|
|
83 |
// ---------------------------------------------------------------------------
|
|
84 |
// CMgItemsList::NextL
|
|
85 |
// Constructs the next media item in the form of a map
|
|
86 |
// ---------------------------------------------------------------------------
|
|
87 |
//
|
|
88 |
TBool CMgItemsList::NextL( TLiwVariant& aItem )
|
|
89 |
{
|
|
90 |
|
|
91 |
iCurrent++;
|
|
92 |
|
|
93 |
if( iCurrent<iCount )
|
|
94 |
{
|
|
95 |
|
|
96 |
const MCLFItem& item = iItemListModel->Item( iCurrent );
|
|
97 |
|
|
98 |
TPtrC fullPath;
|
|
99 |
item.GetField( ECLFFieldIdFileNameAndPath, fullPath );
|
|
100 |
|
|
101 |
CLiwDefaultMap *outputMap = CLiwDefaultMap::NewL();
|
|
102 |
CleanupStack::PushL( outputMap );
|
|
103 |
outputMap->InsertL( KMgFileNameAndPath,TLiwVariant( fullPath ) );
|
|
104 |
|
|
105 |
// if( EMgGetFilesInfo == iCmdId )// if user requests for file metadata
|
|
106 |
//{
|
|
107 |
if( NULL == iMediaItem )
|
|
108 |
{
|
|
109 |
iMediaItem = MgMediaItemFactory::GetMediaItemL( item );
|
|
110 |
|
|
111 |
if( NULL == iMediaItem )
|
|
112 |
{
|
|
113 |
return KErrNotSupported;
|
|
114 |
}
|
|
115 |
}
|
|
116 |
iMediaItem->FillInfoL( outputMap, item );
|
|
117 |
//}
|
|
118 |
|
|
119 |
aItem.SetL( TLiwVariant( outputMap ) );
|
|
120 |
if( outputMap )
|
|
121 |
{
|
|
122 |
outputMap->DecRef();
|
|
123 |
}
|
|
124 |
CleanupStack::Pop( outputMap );
|
|
125 |
return ETrue;
|
|
126 |
|
|
127 |
}
|
|
128 |
else
|
|
129 |
{
|
|
130 |
|
|
131 |
return EFalse;
|
|
132 |
|
|
133 |
}
|
|
134 |
}
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|