41 |
41 |
42 class GLX_MEDIAMODEL_EXPORT GlxMediaModel : public QAbstractItemModel |
42 class GLX_MEDIAMODEL_EXPORT GlxMediaModel : public QAbstractItemModel |
43 { |
43 { |
44 Q_OBJECT |
44 Q_OBJECT |
45 public : |
45 public : |
46 |
46 /** |
47 GlxMediaModel(GlxModelParm & modelParm); |
47 * Constructor |
|
48 * @param - model parm struct collectionID, depth, filter, context mode etc |
|
49 */ |
|
50 GlxMediaModel( GlxModelParm & modelParm ); |
|
51 |
|
52 /** |
|
53 * Destructor |
|
54 */ |
48 ~GlxMediaModel(); |
55 ~GlxMediaModel(); |
49 int rowCount(const QModelIndex &parent = QModelIndex()) const; |
56 |
50 int columnCount(const QModelIndex &parent = QModelIndex()) const; |
57 /** |
51 QModelIndex parent(const QModelIndex &child) const; |
58 * rowCount() - return the number of rows in the model. |
52 QVariant data(const QModelIndex &index, int role) const; |
59 * @param - parent model index, not used |
53 bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); |
60 */ |
54 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; |
61 int rowCount( const QModelIndex &parent = QModelIndex() ) const; |
55 |
62 |
56 /* |
63 /** |
57 *for setting external image data to the model. |
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. |
58 */ |
99 */ |
59 void addExternalItems(GlxExternalData* externalItems); |
100 void addExternalItems( GlxExternalData* externalItems ); |
60 /* |
101 |
61 *for removing all external image data from the model. |
102 /** |
62 */ |
103 * clearExternalItems() - for removing all external image data from the model. |
|
104 */ |
63 void clearExternalItems(); |
105 void clearExternalItems(); |
64 /* |
|
65 * for checking if the item is editab |
|
66 */ |
|
67 |
106 |
68 signals : |
107 signals : |
69 void albumTitleAvailable(QString aTitle); |
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 */ |
70 void populated(); |
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(); |
71 |
137 |
72 private: |
138 private: |
73 HbIcon* GetGridIconItem(int itemIndex, GlxTBContextType tbContextType) const; |
139 /** |
74 HbIcon* GetFsIconItem(int itemIndex,GlxTBContextType tbContextType)const; |
140 * GetGridIconItem() - To fetch the grid size thumbnail |
75 HbIcon* GetExternalIconItem(int itemIndex,GlxTBContextType tbContextType)const; |
141 * @param - item index |
76 /** |
142 * @param - media list context type |
77 * for setting the attribute context mode will be used mainly for retreiving thumbnail of different sizes. |
143 * @return - return the hbicon of the item |
78 */ |
144 */ |
79 void setContextMode(GlxContextMode contextMode); |
145 HbIcon* GetGridIconItem( int itemIndex, GlxTBContextType tbContextType ) const; |
80 /* |
146 |
81 *Removes the context |
147 /** |
82 */ |
148 * GetFsIconItem() - To fetch the full screen size thumbnail |
83 void removeContextMode(GlxContextMode contextMode); |
149 * @param - item index |
84 void setFocusIndex(const QModelIndex &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 */ |
85 QModelIndex getFocusIndex() const; |
184 QModelIndex getFocusIndex() const; |
86 void setSelectedIndex(const QModelIndex &index); |
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 */ |
87 HbIcon *getCorruptDefaultIcon ( const QModelIndex &index ) const; |
197 HbIcon *getCorruptDefaultIcon ( const QModelIndex &index ) const; |
88 |
198 |
89 |
199 /** |
90 signals : |
200 * thumbnailPopulatedCheck() - To check the some initial page of item is loaded into cache or not |
91 void iconAvailable(int itemIndex, HbIcon* itemIcon, GlxTBContextType tbContextType) const; |
201 * @param - loaded thumbnail image index in cache. |
92 /* |
202 */ |
93 *signal to update the details view |
203 void thumbnailPopulatedCheck( int index ); |
94 */ |
204 |
95 void updateDetailsView(); |
|
96 public slots: |
205 public slots: |
97 void itemUpdated1(int mlIndex, GlxTBContextType tbContextType); |
206 /** |
98 void itemsAdded(int startIndex, int endIndex); |
207 * itemUpdated() - call back fuction, when thumbnail is added into cache. |
99 void itemsRemoved(int startIndex, int endIndex); |
208 * It remove the icon from the local cache and emit the signal of data change. |
100 void itemCorrupted(int itemIndex); |
209 * @param - item index |
101 void albumTitleUpdated(QString aTitle); |
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 */ |
102 void modelpopulated(); |
244 void modelpopulated(); |
103 /* |
245 |
104 *Emits signal to update the details view |
246 /** |
|
247 * updateDetailItems() - Emits signal to update the details view |
105 */ |
248 */ |
106 void updateDetailItems(); |
249 void updateDetailItems(); |
107 protected: |
|
108 |
250 |
109 private slots: |
251 private slots: |
110 void updateItemIcon(int itemIndex, HbIcon* itemIcon, GlxTBContextType tbContextType); |
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 ); |
111 |
259 |
112 private: |
260 private: |
113 GlxMLWrapper* mMLWrapper; |
261 GlxMLWrapper* mMLWrapper; |
114 QCache<int, HbIcon> itemIconCache; |
262 QCache<int, HbIcon> itemIconCache; |
115 QCache<int, HbIcon> itemFsIconCache; |
263 QCache<int, HbIcon> itemFsIconCache; |