30
|
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: stubclass of videolistdata for testing VideoListDataModel class methods*
|
|
15 |
*/
|
|
16 |
// INCLUDE FILES
|
|
17 |
|
|
18 |
#include <mpxmediageneraldefs.h>
|
|
19 |
#include <thumbnailmanager_qt.h>
|
|
20 |
#include <mpxmediaarray.h>
|
|
21 |
#include <mpxmedia.h>
|
|
22 |
#include <qvariant.h>
|
|
23 |
|
|
24 |
#include "videolistdatamodel.h"
|
|
25 |
#include "videocollectionutils.h"
|
|
26 |
#include "videolistdatamodel_p.h"
|
|
27 |
#include "videothumbnaildata.h"
|
|
28 |
#include "vcxmyvideosdefs.h"
|
|
29 |
#include "videocollectioncommon.h"
|
|
30 |
|
|
31 |
inline uint qHash(TMPXItemId key)
|
|
32 |
{
|
|
33 |
QPair<uint, uint> keyPair(key.iId1, key.iId2);
|
|
34 |
|
|
35 |
return qHash(keyPair);
|
|
36 |
}
|
|
37 |
|
|
38 |
// helper funtion to parse QString -data from media
|
|
39 |
template<class T>
|
|
40 |
bool mediaValue(const CMPXMedia *media, const TMPXAttributeData& attribute, QString& result)
|
|
41 |
{
|
|
42 |
bool status = false;
|
|
43 |
if( media && media->IsSupported(attribute))
|
|
44 |
{
|
|
45 |
HBufC* valueText = NULL;
|
|
46 |
TRAPD(error, valueText = media->ValueText( attribute ).AllocL() );
|
|
47 |
if (error == KErrNone && valueText->Length() > 0)
|
|
48 |
{
|
|
49 |
// temp QString needed to make sure string is initialized correctly (Error #424)
|
|
50 |
QString text((QChar*)valueText->Des().Ptr(),valueText->Length());
|
|
51 |
result = text;
|
|
52 |
status = true;
|
|
53 |
}
|
|
54 |
delete valueText;
|
|
55 |
}
|
|
56 |
return status;
|
|
57 |
}
|
|
58 |
|
34
|
59 |
bool VideoListDataModelPrivate::mReturnInvalidMarked = false;
|
|
60 |
|
30
|
61 |
|
|
62 |
/**
|
|
63 |
* init failure flag
|
|
64 |
*/
|
34
|
65 |
bool VideoListDataModelPrivate::mFailInit = false;
|
30
|
66 |
|
35
|
67 |
bool VideoListDataModelPrivate::mOverrideVideoCount = false;
|
|
68 |
quint32 VideoListDataModelPrivate::mVideoCount = 0;
|
30
|
69 |
|
34
|
70 |
bool VideoListDataModelPrivate::mOverrideSize = false;
|
|
71 |
quint32 VideoListDataModelPrivate::mSize = 0;
|
30
|
72 |
|
34
|
73 |
bool VideoListDataModelPrivate::mOverrideDuration = false;
|
|
74 |
quint32 VideoListDataModelPrivate::mDuration = 0;
|
30
|
75 |
|
34
|
76 |
int VideoListDataModelPrivate::mGetVideoCountFail = -1;
|
30
|
77 |
|
34
|
78 |
bool VideoListDataModelPrivate::mBelongsToAlbum = false;
|
30
|
79 |
|
35
|
80 |
int VideoListDataModelPrivate::mRemoveFrAlbumReturn = -1;
|
|
81 |
|
30
|
82 |
// -----------------------------------------------------------------------------
|
|
83 |
// CVideoListData
|
|
84 |
// -----------------------------------------------------------------------------
|
|
85 |
//
|
|
86 |
VideoListDataModelPrivate::VideoListDataModelPrivate(VideoListDataModel *model) :
|
|
87 |
q_ptr(model),
|
34
|
88 |
mMediaData(*(new DummyData)),
|
30
|
89 |
mMediaArray(0)
|
|
90 |
{
|
34
|
91 |
mMediaData.mObj = this;
|
30
|
92 |
mIcon = QIcon(":/icons/default_thumbnail.svg");
|
|
93 |
}
|
|
94 |
|
|
95 |
// -----------------------------------------------------------------------------
|
|
96 |
// ~VideoListDataModelPrivate
|
|
97 |
// -----------------------------------------------------------------------------
|
|
98 |
//
|
|
99 |
VideoListDataModelPrivate::~VideoListDataModelPrivate()
|
|
100 |
{
|
34
|
101 |
delete &mMediaData;
|
30
|
102 |
}
|
|
103 |
|
|
104 |
// -----------------------------------------------------------------------------
|
|
105 |
// initialize
|
|
106 |
// -----------------------------------------------------------------------------
|
|
107 |
//
|
|
108 |
int VideoListDataModelPrivate::initialize()
|
|
109 |
{
|
34
|
110 |
if(mFailInit)
|
30
|
111 |
{
|
|
112 |
return -1;
|
|
113 |
}
|
|
114 |
|
|
115 |
return 0;
|
|
116 |
}
|
|
117 |
|
|
118 |
// -----------------------------------------------------------------------------
|
34
|
119 |
// callModelDisconnect
|
|
120 |
// -----------------------------------------------------------------------------
|
|
121 |
//
|
|
122 |
void VideoListDataModelPrivate::callModelDisconnect()
|
|
123 |
{
|
|
124 |
q_ptr->disconnectSignals();
|
|
125 |
}
|
|
126 |
|
|
127 |
// -----------------------------------------------------------------------------
|
|
128 |
// callModelAsyncReport
|
|
129 |
// -----------------------------------------------------------------------------
|
|
130 |
//
|
|
131 |
void VideoListDataModelPrivate::callModelAsyncReport(int status, QVariant data)
|
|
132 |
{
|
|
133 |
q_ptr->reportAsyncStatus(status, data);
|
|
134 |
}
|
|
135 |
|
|
136 |
// -----------------------------------------------------------------------------
|
30
|
137 |
// getVideoCount
|
|
138 |
// -----------------------------------------------------------------------------
|
|
139 |
//
|
|
140 |
int VideoListDataModelPrivate::getVideoCount()
|
|
141 |
{
|
|
142 |
int count = 0;
|
|
143 |
if(mMediaArray)
|
|
144 |
{
|
|
145 |
count = mMediaArray->Count();
|
|
146 |
}
|
34
|
147 |
mGetVideoCountFail--;
|
|
148 |
if(mGetVideoCountFail == 0)
|
30
|
149 |
{
|
|
150 |
return 0;
|
|
151 |
}
|
|
152 |
return count;
|
|
153 |
}
|
|
154 |
|
|
155 |
// -----------------------------------------------------------------------------
|
|
156 |
// getVideoNameFromIndex
|
|
157 |
// -----------------------------------------------------------------------------
|
|
158 |
//
|
|
159 |
const QString VideoListDataModelPrivate::getVideoNameFromIndex( int index ) const
|
|
160 |
{
|
|
161 |
QString txt = "";
|
|
162 |
CMPXMedia* media = getMediaFromIndex(index);
|
|
163 |
|
|
164 |
mediaValue<QString>(media, KMPXMediaGeneralTitle, txt );
|
|
165 |
return txt;
|
|
166 |
}
|
|
167 |
|
|
168 |
// -----------------------------------------------------------------------------
|
|
169 |
// getVideoThumbnailFromIndex
|
|
170 |
// -----------------------------------------------------------------------------
|
|
171 |
//
|
|
172 |
const QIcon* VideoListDataModelPrivate::getVideoThumbnailFromIndex( int index ) const
|
|
173 |
{
|
|
174 |
Q_UNUSED(index);
|
|
175 |
|
|
176 |
return &mIcon;
|
|
177 |
}
|
|
178 |
|
|
179 |
// -----------------------------------------------------------------------------
|
35
|
180 |
// getVideoThumbnailFromIndex
|
|
181 |
// -----------------------------------------------------------------------------
|
|
182 |
//
|
|
183 |
quint32 VideoListDataModelPrivate::getCategoryVideoCountFromIndex( int index ) const
|
|
184 |
{
|
|
185 |
if(mOverrideVideoCount)
|
|
186 |
{
|
|
187 |
return mVideoCount;
|
|
188 |
}
|
|
189 |
|
|
190 |
quint32 count(0);
|
|
191 |
CMPXMedia *media = getMediaFromIndex(index);
|
|
192 |
if( media && media->IsSupported( KVcxMediaMyVideosCategoryItemCount ) )
|
|
193 |
{
|
|
194 |
count = *media->Value<TUint32>( KVcxMediaMyVideosCategoryItemCount );
|
|
195 |
}
|
|
196 |
return count;
|
|
197 |
}
|
|
198 |
|
|
199 |
// -----------------------------------------------------------------------------
|
30
|
200 |
// getVideoSizeFromIndex
|
|
201 |
// -----------------------------------------------------------------------------
|
|
202 |
//
|
|
203 |
quint32 VideoListDataModelPrivate::getVideoSizeFromIndex( int index ) const
|
|
204 |
{
|
35
|
205 |
if(mOverrideSize)
|
|
206 |
{
|
|
207 |
return mSize;
|
|
208 |
}
|
30
|
209 |
quint32 size(0);
|
|
210 |
CMPXMedia *media = getMediaFromIndex(index);
|
|
211 |
if(media && media->IsSupported( KMPXMediaGeneralSize ))
|
|
212 |
{
|
|
213 |
size = *( media->Value<quint32>( KMPXMediaGeneralSize ) ); // In bytes
|
|
214 |
}
|
|
215 |
return size;
|
|
216 |
}
|
|
217 |
|
|
218 |
// -----------------------------------------------------------------------------
|
|
219 |
// getVideodurationFromIndex
|
|
220 |
// -----------------------------------------------------------------------------
|
|
221 |
//
|
|
222 |
quint32 VideoListDataModelPrivate::getVideodurationFromIndex( int index ) const
|
|
223 |
{
|
34
|
224 |
if(mOverrideDuration)
|
30
|
225 |
{
|
34
|
226 |
return mDuration;
|
30
|
227 |
}
|
|
228 |
quint32 returnDuration(0);
|
|
229 |
float duration(0);
|
|
230 |
CMPXMedia *media = getMediaFromIndex(index);
|
|
231 |
if(media && media->IsSupported( KMPXMediaGeneralDuration ))
|
|
232 |
{
|
|
233 |
duration = *( media->Value<float>( KMPXMediaGeneralDuration ) );
|
|
234 |
}
|
|
235 |
returnDuration = static_cast<quint32>(duration);
|
|
236 |
return returnDuration;
|
|
237 |
}
|
|
238 |
|
|
239 |
// -----------------------------------------------------------------------------
|
|
240 |
// getVideoDateFromIndex
|
|
241 |
// -----------------------------------------------------------------------------
|
|
242 |
//
|
|
243 |
QDateTime VideoListDataModelPrivate::getVideoDateFromIndex( int index ) const
|
|
244 |
{
|
|
245 |
QDateTime date;
|
|
246 |
CMPXMedia *media = getMediaFromIndex(index);
|
|
247 |
if(media && media->IsSupported(KMPXMediaGeneralDate)) {
|
|
248 |
|
|
249 |
TInt64 temp = *(media->Value<TInt64>(KMPXMediaGeneralDate));
|
|
250 |
TDateTime tempDate = TTime(temp).DateTime();
|
|
251 |
date = QDateTime(QDate(tempDate.Year(), tempDate.Month()+1, tempDate.Day()+1),
|
|
252 |
QTime(tempDate.Hour(), tempDate.Minute(), tempDate.Second(), tempDate.MicroSecond()));
|
|
253 |
}
|
|
254 |
return date;
|
|
255 |
}
|
|
256 |
|
|
257 |
// -----------------------------------------------------------------------------
|
|
258 |
// getMediaIdFromIndex
|
|
259 |
// -----------------------------------------------------------------------------
|
|
260 |
//
|
34
|
261 |
TMPXItemId VideoListDataModelPrivate::getMediaIdFromIndex( int index ) const
|
30
|
262 |
{
|
|
263 |
return getMediaId( getMediaFromIndex(index) );
|
|
264 |
}
|
|
265 |
|
|
266 |
// -----------------------------------------------------------------------------
|
|
267 |
// getFilePathForId
|
|
268 |
// -----------------------------------------------------------------------------
|
|
269 |
//
|
|
270 |
const QString VideoListDataModelPrivate::getFilePathForId( TMPXItemId mediaId ) const
|
|
271 |
{
|
|
272 |
return getFilePathFromIndex( indexOfMediaId(mediaId) );
|
|
273 |
}
|
|
274 |
|
|
275 |
// -----------------------------------------------------------------------------
|
34
|
276 |
// getFilePathForId
|
|
277 |
// -----------------------------------------------------------------------------
|
|
278 |
//
|
|
279 |
bool VideoListDataModelPrivate::belongsToAlbum(TMPXItemId itemId, TMPXItemId albumId)
|
|
280 |
{
|
|
281 |
Q_UNUSED(itemId);
|
|
282 |
Q_UNUSED(albumId);
|
|
283 |
return mBelongsToAlbum;
|
|
284 |
}
|
|
285 |
|
|
286 |
// -----------------------------------------------------------------------------
|
|
287 |
// setAlbumInUse
|
|
288 |
// -----------------------------------------------------------------------------
|
|
289 |
//
|
|
290 |
void VideoListDataModelPrivate::setAlbumInUse(TMPXItemId albumId)
|
|
291 |
{
|
|
292 |
mCurrentAlbum = albumId;
|
|
293 |
}
|
|
294 |
|
35
|
295 |
// -----------------------------------------------------------------------------
|
|
296 |
// removeItemsFromAlbum
|
|
297 |
// -----------------------------------------------------------------------------
|
|
298 |
//
|
|
299 |
int VideoListDataModelPrivate::removeItemsFromAlbum(TMPXItemId &albumId, const QList<TMPXItemId> &ids)
|
|
300 |
{
|
|
301 |
Q_UNUSED(albumId);
|
|
302 |
Q_UNUSED(ids);
|
|
303 |
return mRemoveFrAlbumReturn;
|
|
304 |
}
|
34
|
305 |
|
|
306 |
// -----------------------------------------------------------------------------
|
30
|
307 |
// getVideoStatusFromIndex
|
|
308 |
// -----------------------------------------------------------------------------
|
|
309 |
//
|
|
310 |
int VideoListDataModelPrivate::getVideoStatusFromIndex(int index) const
|
|
311 |
{
|
|
312 |
int status = 0;
|
|
313 |
if(mItemsUnderDeletion.contains(getMediaIdFromIndex(index)))
|
|
314 |
{
|
|
315 |
status = VideoCollectionCommon::StatusDeleted;
|
|
316 |
}
|
|
317 |
return status;
|
|
318 |
}
|
|
319 |
|
|
320 |
|
|
321 |
// -----------------------------------------------------------------------------
|
|
322 |
// markVideoRemoved
|
|
323 |
// -----------------------------------------------------------------------------
|
|
324 |
//
|
34
|
325 |
TMPXItemId VideoListDataModelPrivate::markVideoRemoved(const QModelIndex &itemIndex)
|
30
|
326 |
{
|
34
|
327 |
TMPXItemId id = TMPXItemId::InvalidId();
|
|
328 |
if(!mReturnInvalidMarked)
|
30
|
329 |
{
|
34
|
330 |
if(!itemIndex.isValid() || itemIndex.row() >= mMediaArray->Count())
|
|
331 |
{
|
|
332 |
return id;
|
|
333 |
}
|
|
334 |
id = getMediaIdFromIndex(itemIndex.row());
|
|
335 |
mItemsUnderDeletion.append(id);
|
30
|
336 |
}
|
34
|
337 |
return id;
|
30
|
338 |
}
|
|
339 |
|
|
340 |
// -----------------------------------------------------------------------------
|
34
|
341 |
// restoreRemoved
|
30
|
342 |
// -----------------------------------------------------------------------------
|
|
343 |
//
|
34
|
344 |
void VideoListDataModelPrivate::restoreRemoved(QList<TMPXItemId> *idList)
|
30
|
345 |
{
|
|
346 |
TMPXItemId id;
|
34
|
347 |
foreach(id, *idList)
|
30
|
348 |
{
|
34
|
349 |
mItemsUnderDeletion.removeAll(id);
|
30
|
350 |
}
|
|
351 |
}
|
|
352 |
|
|
353 |
// -----------------------------------------------------------------------------
|
|
354 |
// getFilePathFromIndex
|
|
355 |
// -----------------------------------------------------------------------------
|
|
356 |
//
|
|
357 |
const QString VideoListDataModelPrivate::getFilePathFromIndex(int index) const
|
|
358 |
{
|
|
359 |
QString filePath;
|
|
360 |
VideoCollectionUtils::instance().mediaValue<QString>(getMediaFromIndex(index),
|
|
361 |
KMPXMediaGeneralUri, filePath );
|
|
362 |
return filePath;
|
|
363 |
}
|
|
364 |
|
|
365 |
// -----------------------------------------------------------------------------
|
|
366 |
// getMediaFromIndex
|
|
367 |
// -----------------------------------------------------------------------------
|
|
368 |
//
|
|
369 |
CMPXMedia* VideoListDataModelPrivate::getMediaFromIndex( int index ) const
|
|
370 |
{
|
|
371 |
CMPXMedia *media = NULL;
|
|
372 |
if( mMediaArray && index >= 0 && index < mMediaArray->Count() )
|
|
373 |
{
|
|
374 |
media = (*mMediaArray)[index];
|
|
375 |
}
|
|
376 |
return media;
|
|
377 |
}
|
|
378 |
|
|
379 |
// -----------------------------------------------------------------------------
|
|
380 |
// getMediaId
|
|
381 |
// -----------------------------------------------------------------------------
|
|
382 |
//
|
|
383 |
TMPXItemId VideoListDataModelPrivate::getMediaId(const CMPXMedia *media ) const
|
|
384 |
{
|
|
385 |
TMPXItemId mediaId = TMPXItemId::InvalidId();
|
|
386 |
if( media && media->IsSupported( KMPXMediaGeneralId ) )
|
|
387 |
{
|
|
388 |
TRAPD(err, mediaId = media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
|
|
389 |
}
|
|
390 |
return mediaId;
|
|
391 |
}
|
|
392 |
|
|
393 |
// -----------------------------------------------------------------------------
|
|
394 |
// indexOfMediaId
|
|
395 |
// -----------------------------------------------------------------------------
|
|
396 |
//
|
|
397 |
int VideoListDataModelPrivate::indexOfMediaId(TMPXItemId mediaId) const
|
|
398 |
{
|
|
399 |
int index = -1;
|
|
400 |
if( !mMediaArray )
|
|
401 |
{
|
|
402 |
// nothing to look for
|
|
403 |
return index;
|
|
404 |
}
|
|
405 |
const CMPXMedia* media = NULL;
|
|
406 |
int count = mMediaArray->Count();
|
|
407 |
for(int i = 0; i < count; ++i)
|
|
408 |
{
|
|
409 |
media = getMediaFromIndex(i);
|
|
410 |
if(media )
|
|
411 |
{
|
|
412 |
TMPXItemId itemId = getMediaId(media);
|
|
413 |
if( mediaId == itemId)
|
|
414 |
{
|
|
415 |
index = i;
|
|
416 |
break;
|
|
417 |
}
|
|
418 |
media = NULL;
|
|
419 |
}
|
|
420 |
}
|
|
421 |
return index;
|
|
422 |
}
|
|
423 |
|
|
424 |
// -----------------------------------------------------------------------------
|
|
425 |
// newVideoList
|
|
426 |
// -----------------------------------------------------------------------------
|
|
427 |
//
|
|
428 |
void VideoListDataModelPrivate::newVideoListSlot( CMPXMediaArray* aVideoList )
|
|
429 |
{
|
|
430 |
mMediaArray = aVideoList;
|
|
431 |
}
|
|
432 |
|
|
433 |
// -----------------------------------------------------------------------------
|
|
434 |
// appendVideoListSlot
|
|
435 |
// -----------------------------------------------------------------------------
|
|
436 |
//
|
34
|
437 |
void VideoListDataModelPrivate::appendVideoListSlot(CMPXMediaArray* aVideo)
|
30
|
438 |
{
|
34
|
439 |
Q_UNUSED(aVideo);
|
30
|
440 |
}
|
|
441 |
|
|
442 |
// -----------------------------------------------------------------------------
|
|
443 |
// newVideoAvailable
|
|
444 |
// -----------------------------------------------------------------------------
|
|
445 |
//
|
34
|
446 |
void VideoListDataModelPrivate::newVideoAvailableSlot(CMPXMedia* aVideo)
|
30
|
447 |
{
|
34
|
448 |
Q_UNUSED(aVideo);
|
30
|
449 |
}
|
|
450 |
|
|
451 |
// -----------------------------------------------------------------------------
|
|
452 |
// videoDeleted
|
|
453 |
// -----------------------------------------------------------------------------
|
|
454 |
//
|
34
|
455 |
void VideoListDataModelPrivate::videoDeletedSlot(TMPXItemId videoId)
|
30
|
456 |
{
|
34
|
457 |
Q_UNUSED(videoId);
|
30
|
458 |
}
|
|
459 |
|
|
460 |
// -----------------------------------------------------------------------------
|
|
461 |
// videoDeleteCompleted
|
|
462 |
// -----------------------------------------------------------------------------
|
|
463 |
//
|
34
|
464 |
void VideoListDataModelPrivate::videoDeleteCompletedSlot(int overallCount, QList<TMPXItemId> *failedMediaIds)
|
30
|
465 |
{
|
34
|
466 |
Q_UNUSED(overallCount);
|
|
467 |
Q_UNUSED(failedMediaIds);
|
30
|
468 |
mItemsUnderDeletion.clear();
|
|
469 |
}
|
|
470 |
|
|
471 |
// -----------------------------------------------------------------------------
|
|
472 |
// videoDetailsCompleted
|
|
473 |
// -----------------------------------------------------------------------------
|
|
474 |
//
|
36
|
475 |
void VideoListDataModelPrivate::videoDetailsCompletedSlot(CMPXMedia* media)
|
34
|
476 |
{
|
36
|
477 |
Q_UNUSED(media);
|
34
|
478 |
}
|
|
479 |
|
|
480 |
// -----------------------------------------------------------------------------
|
|
481 |
// albumListAvailableSlot
|
|
482 |
// -----------------------------------------------------------------------------
|
|
483 |
//
|
|
484 |
void VideoListDataModelPrivate::albumListAvailableSlot(TMPXItemId albumId,
|
|
485 |
CMPXMediaArray *albumItems)
|
30
|
486 |
{
|
34
|
487 |
Q_UNUSED(albumId);
|
|
488 |
Q_UNUSED(albumItems);
|
|
489 |
}
|
|
490 |
|
|
491 |
// -----------------------------------------------------------------------------
|
36
|
492 |
// itemModifiedSlot
|
|
493 |
// -----------------------------------------------------------------------------
|
|
494 |
//
|
|
495 |
void VideoListDataModelPrivate::itemModifiedSlot(const TMPXItemId &itemId)
|
|
496 |
{
|
|
497 |
Q_UNUSED(itemId);
|
|
498 |
}
|
|
499 |
|
|
500 |
// -----------------------------------------------------------------------------
|
34
|
501 |
// albumRemoveFailureSlot
|
|
502 |
// -----------------------------------------------------------------------------
|
|
503 |
//
|
|
504 |
void VideoListDataModelPrivate::albumRemoveFailureSlot(QList<TMPXItemId> *items)
|
|
505 |
{
|
|
506 |
Q_UNUSED(items);
|
|
507 |
}
|
|
508 |
|
|
509 |
// -----------------------------------------------------------------------------
|
|
510 |
// itemDeletedSlot
|
|
511 |
// -----------------------------------------------------------------------------
|
|
512 |
//
|
|
513 |
void VideoListDataModelPrivate::itemDeletedSlot(TMPXItemId id)
|
|
514 |
{
|
|
515 |
Q_UNUSED(id);
|
30
|
516 |
}
|
|
517 |
|
|
518 |
// End of file
|