|
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 #include <glxmediamodel.h> |
|
21 #include <hbicon.h> |
|
22 #include <qimage.h> |
|
23 #include <glxmodelparm.h> |
|
24 #include <QCache> |
|
25 #include <QDebug> |
|
26 #include <glxmlwrapper.h> |
|
27 #include"glxdrmutilitywrapper.h" |
|
28 |
|
29 #include <glxfiltergeneraldefs.h> |
|
30 |
|
31 #include <glximageviewermanager.h> |
|
32 //#define GLXPERFORMANCE_LOG |
|
33 #include <glxperformancemacro.h> |
|
34 |
|
35 #include "glxicondefs.h" //Contains the icon names/Ids |
|
36 #include "glxcollectionpluginall.hrh" |
|
37 #include "glxviewids.h" |
|
38 |
|
39 #define DELTA_IMAGE 5 |
|
40 #define INITIAL_POPULATE_IMAGE_COUNT 30 |
|
41 |
|
42 GlxMediaModel::GlxMediaModel(GlxModelParm & modelParm) |
|
43 { |
|
44 qDebug("GlxMediaModel::GlxMediaModel"); |
|
45 |
|
46 thumbnailPopulatedFlag = modelParm.collection() == KGlxCollectionPluginAllImplementationUid ? false : true; |
|
47 mPaintPage = modelParm.collection() == KGlxCollectionPluginAllImplementationUid ? true : false; |
|
48 mMLWrapper = new GlxMLWrapper(modelParm.collection(),0,EGlxFilterImage); |
|
49 mMLWrapper->setContextMode( modelParm.contextMode() ); |
|
50 mContextMode = modelParm.contextMode( ) ; |
|
51 mDRMUtilityWrapper = new GlxDRMUtilityWrapper(); |
|
52 |
|
53 int err = connect(mMLWrapper, SIGNAL(updateItem(int, GlxTBContextType)), this, SLOT(itemUpdated(int, GlxTBContextType))); |
|
54 qDebug("updateItem() connection status %d", err); |
|
55 err = connect(mMLWrapper, SIGNAL(itemCorrupted(int)), this, SLOT(itemCorrupted(int))); |
|
56 qDebug("itemCorrupted() connection status %d", err); |
|
57 err = connect(mMLWrapper, SIGNAL(insertItems(int, int)), this, SLOT(itemsAdded(int, int))); |
|
58 qDebug("updateItem() connection status %d", err); |
|
59 err = connect(mMLWrapper, SIGNAL(removeItems(int, int)), this, SLOT(itemsRemoved(int, int))); |
|
60 qDebug("updateItem() connection status %d", err); |
|
61 err = connect(this, SIGNAL(iconAvailable(int, HbIcon*, GlxTBContextType)), this, SLOT(updateItemIcon(int, HbIcon*, GlxTBContextType))); |
|
62 qDebug("iconAvailable() connection status %d", err); |
|
63 err = connect( mMLWrapper, SIGNAL(updateAlbumTitle(QString)), this, SLOT(albumTitleUpdated(QString))); |
|
64 qDebug("updateAlbumTitle() connection status %d", err); |
|
65 err = connect(mMLWrapper, SIGNAL(populated()), this, SLOT(modelpopulated())); |
|
66 err = connect(mMLWrapper, SIGNAL(updateDetails()), this, SLOT(updateDetailItems())); |
|
67 |
|
68 itemIconCache.setMaxCost(20); //Changed While Doing Media Wall |
|
69 itemFsIconCache.setMaxCost(5); |
|
70 itemExternalIconCache.setMaxCost(0); |
|
71 |
|
72 m_DefaultIcon = new HbIcon( GLXICON_DEFAULT ); |
|
73 m_CorruptIcon = new HbIcon( GLXICON_CORRUPT ); |
|
74 mExternalItems = NULL; |
|
75 externalDataCount = 0; |
|
76 mFocusIndex = -1; |
|
77 mSubState = -1; |
|
78 mTempVisibleWindowIndex = 0; |
|
79 } |
|
80 |
|
81 GlxMediaModel::~GlxMediaModel() |
|
82 { |
|
83 //itemadded.clear(); |
|
84 qDebug("GlxMediaModel::~GlxMediaModel"); |
|
85 itemIconCache.clear(); |
|
86 itemFsIconCache.clear(); |
|
87 delete m_DefaultIcon; |
|
88 m_DefaultIcon = NULL; |
|
89 delete m_CorruptIcon; |
|
90 m_CorruptIcon = NULL; |
|
91 clearExternalItems(); |
|
92 delete mMLWrapper; |
|
93 delete mDRMUtilityWrapper; |
|
94 } |
|
95 |
|
96 //------------------------------------------------------------------------------------------------------------ |
|
97 //setContextMode |
|
98 //------------------------------------------------------------------------------------------------------------ |
|
99 void GlxMediaModel::setContextMode(GlxContextMode contextMode) |
|
100 { |
|
101 if(contextMode == GlxContextComment) |
|
102 { |
|
103 mMLWrapper->setContextMode(contextMode); |
|
104 } |
|
105 else |
|
106 { |
|
107 if(mContextMode != contextMode) { |
|
108 |
|
109 itemFsIconCache.clear(); |
|
110 mMLWrapper->setContextMode(contextMode); |
|
111 mContextMode = contextMode; |
|
112 if ( mContextMode == GlxContextLsGrid || mContextMode == GlxContextPtGrid ) { |
|
113 itemIconCache.clear(); |
|
114 //emit dataChanged( index( 0, 0), index( rowCount() - 1, 0) ); // Not Needed for HgWidget |
|
115 } |
|
116 } |
|
117 } |
|
118 } |
|
119 |
|
120 //------------------------------------------------------------------------------------------------------------ |
|
121 //removeContextMode |
|
122 //------------------------------------------------------------------------------------------------------------ |
|
123 void GlxMediaModel::removeContextMode(GlxContextMode contextMode) |
|
124 { |
|
125 mMLWrapper->removeContextMode(contextMode); |
|
126 } |
|
127 |
|
128 //to add external data to the model |
|
129 void GlxMediaModel::addExternalItems(GlxExternalData* externalItems) |
|
130 { |
|
131 externalDataCount = externalItems->count(); |
|
132 beginInsertRows(QModelIndex(), 0, externalDataCount); |
|
133 mExternalItems = externalItems; |
|
134 itemExternalIconCache.setMaxCost(15); |
|
135 endInsertRows(); |
|
136 setFocusIndex(index(0,0)); |
|
137 } |
|
138 |
|
139 |
|
140 /* |
|
141 *for removing all external image data from the model. |
|
142 */ |
|
143 void GlxMediaModel::clearExternalItems() |
|
144 { |
|
145 if(externalDataCount) { |
|
146 beginRemoveRows(QModelIndex(), 0, externalDataCount); |
|
147 if(mExternalItems) { |
|
148 delete mExternalItems; |
|
149 mExternalItems = NULL; |
|
150 externalDataCount = 0; |
|
151 } |
|
152 itemExternalIconCache.clear(); |
|
153 endRemoveRows(); |
|
154 } |
|
155 |
|
156 } |
|
157 |
|
158 int GlxMediaModel::rowCount(const QModelIndex &parent ) const |
|
159 { |
|
160 Q_UNUSED(parent); |
|
161 qDebug("GlxMediaModel::rowCount %d", mMLWrapper->getItemCount()); |
|
162 return (mMLWrapper->getItemCount() + externalDataCount); |
|
163 } |
|
164 |
|
165 int GlxMediaModel::columnCount(const QModelIndex &parent ) const |
|
166 { |
|
167 Q_UNUSED(parent); |
|
168 return 1; |
|
169 } |
|
170 |
|
171 QModelIndex GlxMediaModel::parent(const QModelIndex &child) const |
|
172 { |
|
173 Q_UNUSED(child); |
|
174 |
|
175 //returns always invalid model index |
|
176 return QModelIndex(); |
|
177 } |
|
178 |
|
179 |
|
180 //todo refactor this whole function ... too many return statements are not good |
|
181 QVariant GlxMediaModel::data( const QModelIndex &index, int role ) const |
|
182 { |
|
183 if (role == GlxViewTitle) { |
|
184 return mMLWrapper->retrieveViewTitle(); |
|
185 } |
|
186 |
|
187 if(role == GlxPopulated) { |
|
188 return mMLWrapper->IsPopulated(); |
|
189 } |
|
190 |
|
191 if ( role == GlxSubStateRole ) { |
|
192 return mSubState; |
|
193 } |
|
194 |
|
195 if ( role == GlxHgVisibilityRole ) { |
|
196 return TRUE; |
|
197 } |
|
198 |
|
199 if ( role == Qt::DisplayRole ) { |
|
200 return QVariant(); |
|
201 } |
|
202 |
|
203 if (role == GlxPaintPageFlag) { |
|
204 return mPaintPage; |
|
205 } |
|
206 |
|
207 if ( role == GlxDefaultImage ) { |
|
208 if(!m_DefaultIcon->isNull()) { |
|
209 // this image Creation is Slow. |
|
210 // But what to do, Q class's Does not undersatnd our Localised File names |
|
211 return m_DefaultIcon->pixmap().toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied); |
|
212 } |
|
213 else { |
|
214 return QImage(); |
|
215 } |
|
216 } |
|
217 |
|
218 HbIcon* itemIcon = NULL; |
|
219 QImage itemImage; |
|
220 int itemIndex = index.row(); |
|
221 qDebug("GlxMediaModel::data buffer concept index %d role %d", index.row(), role); |
|
222 if ((!index.isValid()) || (index.row() > rowCount()-1)) { |
|
223 return QVariant(); |
|
224 } |
|
225 |
|
226 //retrieve Data from Media List |
|
227 if ( role == Qt::DecorationRole ) { |
|
228 itemIcon = GetGridIconItem(itemIndex,GlxTBContextGrid); |
|
229 if( itemIcon == NULL || itemIcon->isNull() ) { |
|
230 itemIcon = getCorruptDefaultIcon( index ); |
|
231 } |
|
232 return *itemIcon; |
|
233 } |
|
234 |
|
235 if (role == GlxQImageSmall) { |
|
236 return mMLWrapper->retrieveItemImage(itemIndex, GlxTBContextGrid); |
|
237 } |
|
238 |
|
239 if (role == GlxFsImageRole){ |
|
240 if(mContextMode == GlxContextLsFs){ |
|
241 itemIcon = GetFsIconItem(itemIndex,GlxTBContextLsFs); |
|
242 } |
|
243 else if (mContextMode == GlxContextPtFs){ |
|
244 itemIcon = GetFsIconItem(itemIndex,GlxTBContextPtFs); |
|
245 } |
|
246 |
|
247 if ( itemIcon == NULL ) { |
|
248 HbIcon* tempIcon = GetGridIconItem( itemIndex, GlxTBContextGrid ); |
|
249 if (tempIcon && !tempIcon->isNull()) { |
|
250 qDebug("GlxMediaModel::scaling thumbnail"); |
|
251 QPixmap tempPixmap = tempIcon->qicon().pixmap(128, 128); |
|
252 QSize itemSize = mMLWrapper->retrieveItemDimension(itemIndex); |
|
253 QSize sz = ( mContextMode == GlxContextLsFs ) ? QSize ( 640, 360) : QSize ( 360, 640 ); |
|
254 if( !( ( itemSize.width() < sz.width() ) && ( itemSize.height() < sz.height() ) ) ) { |
|
255 itemSize.scale(sz, Qt::KeepAspectRatio); |
|
256 } |
|
257 tempPixmap = tempPixmap.scaled(itemSize, Qt::IgnoreAspectRatio ); |
|
258 HbIcon tmp = HbIcon( QIcon(tempPixmap)) ; |
|
259 if(!tmp.isNull()){ |
|
260 return tmp; |
|
261 } |
|
262 } |
|
263 } |
|
264 |
|
265 if ( itemIcon == NULL || itemIcon->isNull() ) { |
|
266 itemIcon = getCorruptDefaultIcon( index ) ; |
|
267 } |
|
268 return *itemIcon; |
|
269 } |
|
270 |
|
271 if (role == GlxQImageLarge) { |
|
272 if(mContextMode == GlxContextLsFs) { |
|
273 itemImage = mMLWrapper->retrieveItemImage(itemIndex, GlxTBContextLsFs); |
|
274 } |
|
275 else { |
|
276 itemImage = mMLWrapper->retrieveItemImage(itemIndex, GlxTBContextPtFs); |
|
277 } |
|
278 if(!itemImage.isNull()) { |
|
279 return itemImage; |
|
280 } |
|
281 else { |
|
282 itemImage = mMLWrapper->retrieveItemImage(itemIndex, GlxTBContextGrid); |
|
283 if (!itemImage.isNull()) { |
|
284 QSize sz = ( mContextMode == GlxContextLsFs ) ? QSize ( 640, 360) : QSize ( 360, 640 ); |
|
285 itemImage = itemImage.scaled(sz,Qt::KeepAspectRatio); |
|
286 } |
|
287 return itemImage; |
|
288 } |
|
289 } |
|
290 |
|
291 if (role == GlxVisualWindowIndex) { |
|
292 return mMLWrapper->getVisibleWindowIndex(); |
|
293 } |
|
294 |
|
295 QModelIndex idx; |
|
296 if ( GlxFocusIndexRole == role ) { |
|
297 idx = getFocusIndex(); |
|
298 return idx.row(); |
|
299 } |
|
300 |
|
301 if(role == GlxUriRole) { |
|
302 return (mMLWrapper->retrieveItemUri(itemIndex)); |
|
303 } |
|
304 |
|
305 if(role == GlxDimensionsRole) { |
|
306 return (mMLWrapper->retrieveItemDimension(itemIndex)); |
|
307 } |
|
308 |
|
309 if(role == GlxDateRole ) { |
|
310 return (mMLWrapper->retrieveItemDate(itemIndex)); |
|
311 } |
|
312 |
|
313 if (role == GlxFrameCount) { |
|
314 return (mMLWrapper->retrieveItemFrameCount(itemIndex)); |
|
315 } |
|
316 |
|
317 if (role == GlxHdmiBitmap) { |
|
318 return mMLWrapper->RetrieveBitmap(itemIndex); |
|
319 } |
|
320 |
|
321 if ( role == GlxImageCorruptRole ) { |
|
322 return mMLWrapper->isCorruptedImage( itemIndex ); |
|
323 } |
|
324 |
|
325 if (role == GlxTimeRole) { |
|
326 return mMLWrapper->retrieveItemTime(itemIndex); |
|
327 } |
|
328 |
|
329 if (role == GlxSizeRole) { |
|
330 return mMLWrapper->retrieveItemSize(itemIndex); |
|
331 } |
|
332 |
|
333 if (role == GlxDescRole) { |
|
334 return mMLWrapper->retrieveListDesc(itemIndex); |
|
335 } |
|
336 return QVariant(); |
|
337 } |
|
338 |
|
339 //GetGridIconItem |
|
340 HbIcon* GlxMediaModel::GetGridIconItem(int itemIndex, GlxTBContextType tbContextType) const |
|
341 { |
|
342 HbIcon* itemIcon = itemIconCache[itemIndex]; //Initialize icon from the Cache will be NULL if Item not present |
|
343 if (!itemIcon) |
|
344 { |
|
345 itemIcon = mMLWrapper->retrieveItemIcon(itemIndex, tbContextType); |
|
346 if(itemIcon){ |
|
347 emit iconAvailable(itemIndex,itemIcon, GlxTBContextGrid); |
|
348 } |
|
349 itemIcon = itemIconCache[itemIndex]; |
|
350 } |
|
351 return itemIcon; |
|
352 |
|
353 } |
|
354 |
|
355 HbIcon* GlxMediaModel::GetFsIconItem(int itemIndex, GlxTBContextType tbContextType) const |
|
356 { |
|
357 HbIcon* itemIcon = NULL; //Initialize icon from the Cache will be NULL if Item not present |
|
358 |
|
359 bool drmProtected = mMLWrapper->IsDrmProtected(itemIndex); |
|
360 if(drmProtected) |
|
361 { |
|
362 QString imagePath = mMLWrapper->retrieveItemUri(itemIndex); |
|
363 bool rightValid = mMLWrapper->IsDrmValid(itemIndex); |
|
364 if(!rightValid) |
|
365 { |
|
366 //show error note here |
|
367 if(itemIndex == mFocusIndex ) |
|
368 mDRMUtilityWrapper->ShowRightsInfo(imagePath); |
|
369 return itemIcon; |
|
370 } |
|
371 else |
|
372 { |
|
373 //consumeDrmRights(imagePath); |
|
374 mDRMUtilityWrapper->ConsumeRights(imagePath); |
|
375 bool rightValid = mDRMUtilityWrapper->ItemRightsValidityCheck(imagePath,true); |
|
376 mMLWrapper->setDrmValid(itemIndex,rightValid); |
|
377 } |
|
378 } |
|
379 itemIcon = itemFsIconCache[itemIndex]; //Initialize icon from the Cache will be NULL if Item not present |
|
380 if (!itemIcon) { |
|
381 itemIcon = mMLWrapper->retrieveItemIcon(itemIndex, tbContextType); |
|
382 if(itemIcon){ |
|
383 emit iconAvailable(itemIndex,itemIcon, tbContextType); |
|
384 } |
|
385 itemIcon = itemFsIconCache[itemIndex]; |
|
386 } |
|
387 return itemIcon; |
|
388 |
|
389 } |
|
390 |
|
391 HbIcon* GlxMediaModel::GetExternalIconItem(int itemIndex,GlxTBContextType tbContextType) const |
|
392 { |
|
393 //todo add asserts here as the cache and the array is not preinitialized |
|
394 HbIcon* itemIcon = itemExternalIconCache[itemIndex]; //Initialize icon from the Cache will be NULL if Item not present |
|
395 if (!itemIcon) { |
|
396 QPixmap* itemPixmap = mExternalItems->at(itemIndex).image; |
|
397 itemIcon = new HbIcon(QIcon(*itemPixmap)); |
|
398 emit iconAvailable(itemIndex,itemIcon, tbContextType); |
|
399 } |
|
400 return itemIcon; |
|
401 } |
|
402 |
|
403 |
|
404 void GlxMediaModel::itemUpdated(int mlIndex,GlxTBContextType tbContextType ) |
|
405 { |
|
406 qDebug("GlxMediaModel::itemUpdated %d", mlIndex); |
|
407 //clear the grid and FS cache if they have any icons with them for that index |
|
408 if( tbContextType == GlxTBContextGrid ) { |
|
409 if ( !thumbnailPopulatedFlag ) { |
|
410 thumbnailPopulatedCheck( mlIndex ); |
|
411 } |
|
412 itemIconCache.remove(mlIndex); |
|
413 } |
|
414 if(tbContextType == GlxTBContextLsFs || tbContextType == GlxTBContextPtFs) { |
|
415 itemFsIconCache.remove(mlIndex); |
|
416 } |
|
417 emit dataChanged( index( mlIndex , 0 ), index( mlIndex, 0 ) ); |
|
418 } |
|
419 |
|
420 void GlxMediaModel::itemCorrupted(int itemIndex) |
|
421 { |
|
422 qDebug("GlxMediaModel::itemCorrupted %d", itemIndex); |
|
423 if ( !thumbnailPopulatedFlag ) { |
|
424 thumbnailPopulatedCheck( itemIndex ); |
|
425 } |
|
426 emit dataChanged( index( itemIndex , 0 ), index( itemIndex, 0 ) ); |
|
427 } |
|
428 |
|
429 void GlxMediaModel::modelpopulated() |
|
430 { |
|
431 if ( mTempVisibleWindowIndex!=-1) { |
|
432 //Set the visible Window index only ff the index stored in the activity manager is not out of range |
|
433 if( rowCount() > mTempVisibleWindowIndex && mTempVisibleWindowIndex > 0 ) { |
|
434 mMLWrapper->setVisibleWindowIndex(mTempVisibleWindowIndex); |
|
435 } |
|
436 else { |
|
437 mMLWrapper->setVisibleWindowIndex(0); |
|
438 } |
|
439 mTempVisibleWindowIndex = -1; |
|
440 } |
|
441 emit populated(); |
|
442 } |
|
443 |
|
444 //------------------------------------------------------------------------------------------------------------ |
|
445 //updateDetailItems |
|
446 //------------------------------------------------------------------------------------------------------------ |
|
447 void GlxMediaModel::updateDetailItems() |
|
448 { |
|
449 qDebug("GlxMediaModel::updateDetailItems"); |
|
450 emit updateDetailsView(); |
|
451 } |
|
452 |
|
453 void GlxMediaModel::itemsAdded(int startIndex, int endIndex) |
|
454 { |
|
455 qDebug("GlxMediaModel::itemsAdded %d %d", startIndex, endIndex); |
|
456 mFocusIndex = -1; |
|
457 //emit rowsAboutToBeInserted(index(startIndex,0), startIndex, endIndex ); |
|
458 beginInsertRows(QModelIndex(), startIndex+externalDataCount, endIndex+externalDataCount); |
|
459 //itemadded.insert(startIndex,(endIndex - startIndex),NULL ); |
|
460 itemIconCache.clear(); |
|
461 itemFsIconCache.clear(); |
|
462 endInsertRows(); |
|
463 //emit rowsInserted(index(startIndex,0), startIndex, endIndex ); |
|
464 |
|
465 } |
|
466 |
|
467 void GlxMediaModel::itemsRemoved(int startIndex, int endIndex) |
|
468 { |
|
469 qDebug("GlxMediaModel::itemsRemoved %d %d", startIndex, endIndex); |
|
470 mFocusIndex = -1; |
|
471 //emit rowsAboutToBeRemoved(index(startIndex,0), startIndex, endIndex ); |
|
472 beginRemoveRows(QModelIndex(), startIndex+externalDataCount, endIndex+externalDataCount); |
|
473 //itemadded.remove(startIndex,(endIndex - startIndex) ); |
|
474 itemIconCache.clear(); |
|
475 itemFsIconCache.clear(); |
|
476 endRemoveRows(); |
|
477 //emit rowsRemoved(index(startIndex,0), startIndex, endIndex ); |
|
478 |
|
479 } |
|
480 |
|
481 void GlxMediaModel::updateItemIcon(int itemIndex, HbIcon* itemIcon, GlxTBContextType tbContextType) |
|
482 { |
|
483 qDebug("GlxMediaModel::updateItemIcon %d", itemIndex); |
|
484 if(tbContextType == GlxTBContextGrid){ |
|
485 itemIconCache.insert(itemIndex, itemIcon); |
|
486 } |
|
487 else if(tbContextType == GlxTBContextLsFs || tbContextType == GlxTBContextPtFs){ |
|
488 itemFsIconCache.insert(itemIndex, itemIcon); |
|
489 } |
|
490 else if (tbContextType == GlxTBContextExternal){ |
|
491 itemExternalIconCache.insert(itemIndex, itemIcon); |
|
492 } |
|
493 } |
|
494 |
|
495 void GlxMediaModel::albumTitleUpdated(QString aTitle) |
|
496 { |
|
497 emit albumTitleAvailable(aTitle); |
|
498 } |
|
499 |
|
500 void GlxMediaModel::setFocusIndex(const QModelIndex &index) |
|
501 { |
|
502 qDebug("GlxMediaModel::setFocusIndex%d", index.row()); |
|
503 int itemIndex = index.row(); |
|
504 int mlIndex = -1; |
|
505 if(itemIndex >=externalDataCount) |
|
506 { |
|
507 mlIndex = itemIndex - externalDataCount; |
|
508 mMLWrapper->setFocusIndex(mlIndex); |
|
509 mFocusIndex = -1; |
|
510 } |
|
511 else{ |
|
512 mFocusIndex = itemIndex; |
|
513 if(rowCount() > externalDataCount) { |
|
514 mMLWrapper->setFocusIndex(0); |
|
515 mlIndex = 0; |
|
516 } |
|
517 |
|
518 } |
|
519 if(mSubState != IMAGEVIEWER_S ){ |
|
520 if( mMLWrapper->IsDrmProtected(mlIndex) && (!mMLWrapper->IsDrmValid(mlIndex)) ) |
|
521 { |
|
522 QString imagePath = mMLWrapper->retrieveItemUri(mlIndex); |
|
523 mDRMUtilityWrapper->ShowRightsInfo(imagePath); |
|
524 } |
|
525 }else { |
|
526 CGlxImageViewerManager* CGlxImageViewerManager = CGlxImageViewerManager::InstanceL(); |
|
527 const TDesC& title = CGlxImageViewerManager->ImageUri()->Des(); |
|
528 QString imagePath = QString::fromUtf16(title.Ptr(),title.Length()); |
|
529 mDRMUtilityWrapper->ShowRightsInfo(imagePath); |
|
530 } |
|
531 } |
|
532 |
|
533 QModelIndex GlxMediaModel::getFocusIndex() const |
|
534 { |
|
535 int itemIndex = 0; |
|
536 //return index(itemIndex+externalDataCount,0); |
|
537 if(mFocusIndex == -1){ |
|
538 int mlIndex = mMLWrapper->getFocusIndex(); |
|
539 itemIndex = mlIndex + externalDataCount; |
|
540 } |
|
541 else { |
|
542 itemIndex = mFocusIndex; |
|
543 } |
|
544 return index(itemIndex,0); |
|
545 } |
|
546 |
|
547 void GlxMediaModel::setSelectedIndex(const QModelIndex &index) |
|
548 { |
|
549 int itemIndex = index.row(); |
|
550 qDebug("GlxMediaModel::setSelectedIndex()%d", itemIndex); |
|
551 mMLWrapper->setSelectedIndex(itemIndex); |
|
552 } |
|
553 |
|
554 HbIcon * GlxMediaModel::getCorruptDefaultIcon( const QModelIndex &index ) const |
|
555 { |
|
556 if ( mMLWrapper->isCorruptedImage( index.row() ) ) { |
|
557 return m_CorruptIcon ; |
|
558 } |
|
559 return m_DefaultIcon ; |
|
560 } |
|
561 |
|
562 void GlxMediaModel::thumbnailPopulatedCheck( int index ) |
|
563 { |
|
564 int count = rowCount() - DELTA_IMAGE ; |
|
565 int maxRange = INITIAL_POPULATE_IMAGE_COUNT + DELTA_IMAGE ; |
|
566 if ( index >= count || ( index >= INITIAL_POPULATE_IMAGE_COUNT && index < maxRange ) ) { |
|
567 thumbnailPopulatedFlag = TRUE; |
|
568 emit thumbnailPopulated(); |
|
569 } |
|
570 } |
|
571 |
|
572 bool GlxMediaModel::setData ( const QModelIndex & idx, const QVariant & value, int role ) |
|
573 { |
|
574 Q_UNUSED( idx ) |
|
575 |
|
576 if ( GlxContextRole == role ) { |
|
577 if ( value.isValid() && value.canConvert <int> () ) { |
|
578 setContextMode( (GlxContextMode) value.value <int> () ); |
|
579 return TRUE; |
|
580 } |
|
581 } |
|
582 |
|
583 if ( GlxRemoveContextRole == role ) { |
|
584 if ( value.isValid() && value.canConvert <int> () ) { |
|
585 removeContextMode( (GlxContextMode) value.value <int> () ); |
|
586 return TRUE; |
|
587 } |
|
588 } |
|
589 |
|
590 |
|
591 if ( GlxFocusIndexRole == role ) { |
|
592 if ( value.isValid() && value.canConvert <int> () ) { |
|
593 setFocusIndex( index( value.value <int> (), 0) ); |
|
594 return TRUE; |
|
595 } |
|
596 } |
|
597 |
|
598 if ( GlxVisualWindowIndex == role ) { |
|
599 if ( value.isValid() && value.canConvert <int> () ) { |
|
600 mMLWrapper->setVisibleWindowIndex( value.value <int> () ); |
|
601 return TRUE; |
|
602 } |
|
603 } |
|
604 |
|
605 if ( GlxSelectedIndexRole == role ) { |
|
606 qDebug("GlxMediaModel::setData::GlxSelectedIndexRole()::BEFORE%d", idx.row()); |
|
607 if ( value.isValid() && value.canConvert <int> () ) { |
|
608 qDebug("GlxMediaModel::setData()::GlxSelectedIndexRole%d", idx.row()); |
|
609 setSelectedIndex( index( value.value <int> (), 0) ); |
|
610 return TRUE; |
|
611 } |
|
612 } |
|
613 |
|
614 if ( role == GlxSubStateRole && value.isValid() && value.canConvert <int> ()) { |
|
615 mSubState = value.value <int> () ; |
|
616 return TRUE; |
|
617 } |
|
618 if ( GlxTempVisualWindowIndex == role ) { |
|
619 if ( value.isValid() && value.canConvert<int> () ) { |
|
620 mTempVisibleWindowIndex = value.value <int> (); |
|
621 return TRUE; |
|
622 } |
|
623 } |
|
624 |
|
625 return FALSE; |
|
626 } |
|
627 |
|
628 QModelIndex GlxMediaModel::index(int row, int column, const QModelIndex &parent) const |
|
629 { |
|
630 Q_UNUSED(parent) |
|
631 qDebug("GlxMediaModel::index row %d column %d", row, column); |
|
632 |
|
633 if ( ( row < 0 ) |
|
634 || ( row >= rowCount() ) |
|
635 || ( column < 0 ) |
|
636 || ( column >= columnCount() ) ) { |
|
637 return QModelIndex(); |
|
638 } |
|
639 |
|
640 return QAbstractItemModel::createIndex(row, column); |
|
641 } |
|
642 |