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