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