|
1 /* |
|
2 * Copyright (c) 2009 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef GLXMEDIAMODEL_H |
|
21 #define GLXMEDIAMODEL_H |
|
22 |
|
23 #include <QAbstractItemModel> |
|
24 #include <glxuistd.h> |
|
25 #include <QDateTime> |
|
26 #include <glxexternalinterfacedefs.h> |
|
27 //forward declarations |
|
28 |
|
29 #ifdef BUILD_MEDIAMODEL |
|
30 #define GLX_MEDIAMODEL_EXPORT Q_DECL_EXPORT |
|
31 #else |
|
32 #define GLX_MEDIAMODEL_EXPORT Q_DECL_IMPORT |
|
33 #endif |
|
34 |
|
35 class HbIcon; |
|
36 class GlxModelParm; |
|
37 class GlxMLWrapper; |
|
38 class GlxDRMUtilityWrapper; |
|
39 #include <QCache> |
|
40 #include <QVector> |
|
41 |
|
42 class GLX_MEDIAMODEL_EXPORT GlxMediaModel : public QAbstractItemModel |
|
43 { |
|
44 Q_OBJECT |
|
45 public : |
|
46 /** |
|
47 * Constructor |
|
48 * @param - model parm struct collectionID, depth, filter, context mode etc |
|
49 */ |
|
50 GlxMediaModel( GlxModelParm & modelParm ); |
|
51 |
|
52 /** |
|
53 * Destructor |
|
54 */ |
|
55 ~GlxMediaModel(); |
|
56 |
|
57 /** |
|
58 * rowCount() - return the number of rows in the model. |
|
59 * @param - parent model index, not used |
|
60 */ |
|
61 int rowCount( const QModelIndex &parent = QModelIndex() ) const; |
|
62 |
|
63 /** |
|
64 * columnCount() - return 1 |
|
65 * @param - parent model index, not used |
|
66 */ |
|
67 int columnCount( const QModelIndex &parent = QModelIndex() ) const; |
|
68 |
|
69 /** |
|
70 * parent() - return the model index of the child. |
|
71 * It always return invalid model index since no there is no parent |
|
72 */ |
|
73 QModelIndex parent( const QModelIndex &child ) const; |
|
74 |
|
75 /** |
|
76 * data() - return the data of corresponding role. |
|
77 * @param - model index of interested item. |
|
78 * @param - role of corresponding data. |
|
79 */ |
|
80 QVariant data( const QModelIndex &index, int role ) const; |
|
81 |
|
82 /** |
|
83 * setData() - to set the data for corresponding item and role. |
|
84 * @param - model index of interested item. |
|
85 * @param - data of the item |
|
86 * @param - role of corresponding data. |
|
87 */ |
|
88 bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ); |
|
89 |
|
90 /** |
|
91 * index - create a new model index for an item. |
|
92 * @param - row index of the item. |
|
93 * @param - column index of the item, it is always one. |
|
94 */ |
|
95 QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const; |
|
96 |
|
97 /** |
|
98 * addExternalItems() - for setting external image data to the model. |
|
99 */ |
|
100 void addExternalItems( GlxExternalData* externalItems ); |
|
101 |
|
102 /** |
|
103 * clearExternalItems() - for removing all external image data from the model. |
|
104 */ |
|
105 void clearExternalItems(); |
|
106 |
|
107 signals : |
|
108 /** |
|
109 * albumTitleAvailable() - emit this signal when album title is available. |
|
110 * @parma - album title |
|
111 */ |
|
112 void albumTitleAvailable( QString aTitle ); |
|
113 |
|
114 /** |
|
115 * populated() - emit this signal once medialist is populated |
|
116 */ |
|
117 void populated(); |
|
118 |
|
119 /** |
|
120 * thumbnailPopulated() - emit the signal once some initial page of thumbnail are loaded |
|
121 * into cache. |
|
122 */ |
|
123 void thumbnailPopulated(); |
|
124 |
|
125 /** |
|
126 * iconAvailable() - emit the signal to update the icon in the cache. |
|
127 * @param - item index |
|
128 * @param - HbIcon |
|
129 * @param - media list context type |
|
130 */ |
|
131 void iconAvailable( int itemIndex, HbIcon* itemIcon, GlxTBContextType tbContextType ) const; |
|
132 |
|
133 /** |
|
134 * updateDetailsView() - emit the signal to update the details view |
|
135 */ |
|
136 void updateDetailsView(); |
|
137 |
|
138 private: |
|
139 /** |
|
140 * GetGridIconItem() - To fetch the grid size thumbnail |
|
141 * @param - item index |
|
142 * @param - media list context type |
|
143 * @return - return the hbicon of the item |
|
144 */ |
|
145 HbIcon* GetGridIconItem( int itemIndex, GlxTBContextType tbContextType ) const; |
|
146 |
|
147 /** |
|
148 * GetFsIconItem() - To fetch the full screen size thumbnail |
|
149 * @param - item index |
|
150 * @param - media list context type |
|
151 * @return - return the hbicon of the item |
|
152 */ |
|
153 HbIcon* GetFsIconItem( int itemIndex,GlxTBContextType tbContextType )const; |
|
154 |
|
155 /** |
|
156 * GetExternalIconItem() - To fetch the grid size thumbnail of external item. |
|
157 * @param - item index |
|
158 * @param - media list context type |
|
159 * @return - return the hbicon of the item |
|
160 */ |
|
161 HbIcon* GetExternalIconItem( int itemIndex,GlxTBContextType tbContextType )const; |
|
162 |
|
163 /** |
|
164 * setContextMode() - for setting the attribute context mode will be used mainly for |
|
165 * retreiving thumbnail of different sizes. |
|
166 */ |
|
167 void setContextMode( GlxContextMode contextMode ); |
|
168 |
|
169 /** |
|
170 *removeContextMode() - Removes the context |
|
171 */ |
|
172 void removeContextMode( GlxContextMode contextMode ); |
|
173 |
|
174 /** |
|
175 * setFocusIndex() - To set the focus index in medialist |
|
176 * @param - selected item index( focus index ) |
|
177 */ |
|
178 void setFocusIndex( const QModelIndex &index ); |
|
179 |
|
180 /** |
|
181 * getFocusIndex() - Retrun the focus index from the medialist. |
|
182 * @return - focus index. |
|
183 */ |
|
184 QModelIndex getFocusIndex() const; |
|
185 |
|
186 /** |
|
187 * setSelectedIndex() - To make the item as seleted in media list to perform some coomand. |
|
188 * @param - selected item index |
|
189 */ |
|
190 void setSelectedIndex( const QModelIndex &index ); |
|
191 |
|
192 /** |
|
193 * getCorruptDefaultIcon() - IT will return the corrupt icon if item is corrupted else return the |
|
194 * default item. |
|
195 * @param - item index |
|
196 */ |
|
197 HbIcon *getCorruptDefaultIcon ( const QModelIndex &index ) const; |
|
198 |
|
199 /** |
|
200 * thumbnailPopulatedCheck() - To check the some initial page of item is loaded into cache or not |
|
201 * @param - loaded thumbnail image index in cache. |
|
202 */ |
|
203 void thumbnailPopulatedCheck( int index ); |
|
204 |
|
205 public slots: |
|
206 /** |
|
207 * itemUpdated() - call back fuction, when thumbnail is added into cache. |
|
208 * It remove the icon from the local cache and emit the signal of data change. |
|
209 * @param - item index |
|
210 * @param - media list context type |
|
211 */ |
|
212 void itemUpdated( int mlIndex, GlxTBContextType tbContextType ); |
|
213 |
|
214 /** |
|
215 * itemsAdded() - call back function when new items are added into collection. |
|
216 * @param - start index of the newly added item |
|
217 * @param - end endex of the newlyadd item |
|
218 */ |
|
219 void itemsAdded( int startIndex, int endIndex ); |
|
220 |
|
221 /** |
|
222 * itemsRemoved() - call back function when some item are removed from the collection. |
|
223 * @param - start index of the remove items |
|
224 * @param - end endex of the remove items |
|
225 */ |
|
226 void itemsRemoved( int startIndex, int endIndex ); |
|
227 |
|
228 /** |
|
229 * itemCorrupted() - call back function, when a item is corrupted. |
|
230 * @param - index of the corrupt item |
|
231 */ |
|
232 void itemCorrupted( int itemIndex ); |
|
233 |
|
234 /** |
|
235 * albumTitleUpdated() - call back function, when a album collection title is available. |
|
236 * @param - title of the album. |
|
237 */ |
|
238 void albumTitleUpdated( QString aTitle ); |
|
239 |
|
240 /** |
|
241 * modelpopulated() - callback function, when meida list item is populated. |
|
242 * It set the visual window index and emit the signal to view about it. |
|
243 */ |
|
244 void modelpopulated(); |
|
245 |
|
246 /** |
|
247 * updateDetailItems() - Emits signal to update the details view |
|
248 */ |
|
249 void updateDetailItems(); |
|
250 |
|
251 private slots: |
|
252 /** |
|
253 * updateItemIcon() - update the icon into local cache. |
|
254 * @param - item index |
|
255 * @param - HbIcon |
|
256 * @param - media list context type |
|
257 */ |
|
258 void updateItemIcon( int itemIndex, HbIcon* itemIcon, GlxTBContextType tbContextType ); |
|
259 |
|
260 private: |
|
261 GlxMLWrapper* mMLWrapper; |
|
262 QCache<int, HbIcon> itemIconCache; |
|
263 QCache<int, HbIcon> itemFsIconCache; |
|
264 HbIcon* m_DefaultIcon; |
|
265 HbIcon* m_CorruptIcon; |
|
266 |
|
267 GlxContextMode mContextMode; |
|
268 //for external data to be populated by model |
|
269 GlxExternalData* mExternalItems; |
|
270 QCache<int, HbIcon> itemExternalIconCache; |
|
271 int externalDataCount; |
|
272 int mFocusIndex; |
|
273 int mSubState; |
|
274 GlxDRMUtilityWrapper* mDRMUtilityWrapper; |
|
275 int mTempVisibleWindowIndex; |
|
276 bool thumbnailPopulatedFlag; |
|
277 bool mPaintPage; |
|
278 }; |
|
279 |
|
280 |
|
281 #endif /* GLXMEDIAMODEL_H_ */ |