author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 33 | 50974a8b132e |
parent 19 | 989d2f495d90 |
permissions | -rw-r--r-- |
19 | 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 |
||
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
20 |
#include <MCLFItem.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
21 |
#include <MCLFItemListModel.h> |
19 | 22 |
|
23 |
#include "mgitemslist.h" |
|
24 |
#include "mgmediaitemfactory.h" |
|
25 |
#include "mgmediaitem.h" |
|
26 |
||
27 |
||
28 |
_LIT8( KMgFileNameAndPath, "FileNameAndPath" ); |
|
29 |
||
30 |
const TInt KStartItemIndex = -1; |
|
31 |
||
32 |
// --------------------------------------------------------------------------- |
|
33 |
// CMgItemsList::CMgItemsList |
|
34 |
// Parameterised constructor |
|
35 |
// --------------------------------------------------------------------------- |
|
36 |
// |
|
37 |
||
38 |
CMgItemsList::CMgItemsList( MCLFItemListModel* aItemListModel, TMgCmdId aCmdId ) |
|
39 |
{ |
|
40 |
iItemListModel = aItemListModel; |
|
41 |
iCount = iItemListModel->ItemCount(); |
|
42 |
iCurrent = KStartItemIndex; |
|
43 |
iCmdId = aCmdId; |
|
44 |
iMediaItem = NULL; |
|
45 |
||
46 |
} |
|
47 |
// --------------------------------------------------------------------------- |
|
48 |
// CMgItemsList::NewL |
|
49 |
// Two-phased constructor |
|
50 |
// --------------------------------------------------------------------------- |
|
51 |
// |
|
52 |
||
53 |
CMgItemsList* CMgItemsList::NewL( MCLFItemListModel* aItemListModel, TMgCmdId aCmdId ) |
|
54 |
{ |
|
55 |
CMgItemsList* self = new( ELeave ) CMgItemsList( aItemListModel, aCmdId); |
|
56 |
CleanupStack::PushL( self ); |
|
57 |
self->ConstructL(); |
|
58 |
CleanupStack::Pop( self ); |
|
59 |
return self; |
|
60 |
} |
|
61 |
||
62 |
// --------------------------------------------------------------------------- |
|
63 |
// CMgItemsList::ConstructL |
|
64 |
// Two-phased constructor |
|
65 |
// --------------------------------------------------------------------------- |
|
66 |
// |
|
67 |
||
68 |
void CMgItemsList::ConstructL() |
|
69 |
{ |
|
70 |
iMGMediaItemFactory = CMgMediaItemFactory::NewL(); |
|
71 |
} |
|
72 |
// --------------------------------------------------------------------------- |
|
73 |
// CMgItemsList::~CMgItemsList |
|
74 |
// Class destructor |
|
75 |
// --------------------------------------------------------------------------- |
|
76 |
// |
|
77 |
CMgItemsList::~CMgItemsList() |
|
78 |
{ |
|
79 |
if( iItemListModel ) |
|
80 |
{ |
|
81 |
delete iItemListModel; |
|
82 |
iItemListModel = NULL; |
|
83 |
} |
|
84 |
||
85 |
if( iMGMediaItemFactory ) |
|
86 |
{ |
|
87 |
delete iMGMediaItemFactory; |
|
88 |
iMGMediaItemFactory = NULL; |
|
89 |
} |
|
90 |
||
91 |
if( iMediaItem ) |
|
92 |
{ |
|
93 |
delete iMediaItem; |
|
94 |
iMediaItem = NULL; |
|
95 |
} |
|
96 |
||
97 |
} |
|
98 |
// --------------------------------------------------------------------------- |
|
99 |
// CMgItemsList::Reset |
|
100 |
// Resets the iterator to point to the beginning of list |
|
101 |
// --------------------------------------------------------------------------- |
|
102 |
// |
|
103 |
||
104 |
void CMgItemsList::Reset() |
|
105 |
{ |
|
106 |
iCurrent = KStartItemIndex;// if user resets the list |
|
107 |
} |
|
108 |
||
109 |
||
110 |
// --------------------------------------------------------------------------- |
|
111 |
// CMgItemsList::NextL |
|
112 |
// Constructs the next media item in the form of a map |
|
113 |
// --------------------------------------------------------------------------- |
|
114 |
// |
|
115 |
TBool CMgItemsList::NextL( TLiwVariant& aItem ) |
|
116 |
{ |
|
117 |
iCurrent++; |
|
118 |
if( iCurrent<iCount ) |
|
119 |
{ |
|
120 |
const MCLFItem& item = iItemListModel->Item( iCurrent ); |
|
121 |
TPtrC fullPath; |
|
122 |
item.GetField(ECLFFieldIdFileNameAndPath, fullPath ); |
|
123 |
CLiwDefaultMap *outputMap = CLiwDefaultMap::NewL(); |
|
124 |
outputMap->InsertL(KMgFileNameAndPath,TLiwVariant(fullPath)); |
|
125 |
if( iCmdId==EMgGetFilesInfo )// if user requests for file metadata |
|
126 |
{ |
|
127 |
if( NULL == iMediaItem ) |
|
128 |
{ |
|
129 |
iMediaItem = iMGMediaItemFactory->GetMediaItemL( item ); |
|
130 |
} |
|
131 |
if( NULL == iMediaItem ) |
|
132 |
{ |
|
133 |
return KErrNotSupported; |
|
134 |
} |
|
135 |
iMediaItem->FillInfo( outputMap, item ); |
|
136 |
} |
|
137 |
aItem.SetL(TLiwVariant(outputMap)); |
|
138 |
return ETrue; |
|
139 |
} |
|
140 |
else |
|
141 |
{ |
|
142 |
return EFalse; |
|
143 |
} |
|
144 |
} |
|
145 |
||
146 |
||
147 |
||
148 |
||
149 |