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: VideoListDataModelPrivate class implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
50
|
18 |
// Version : %version: 38.1.6 %
|
30
|
19 |
|
36
|
20 |
// INCLUDE FILES
|
|
21 |
#include <hbglobal.h>
|
30
|
22 |
#include <mpxmediageneraldefs.h>
|
36
|
23 |
#include <mpxmediavideodefs.h>
|
30
|
24 |
#include <thumbnailmanager_qt.h>
|
|
25 |
#include <mpxmediaarray.h>
|
|
26 |
#include <mpxmedia.h>
|
|
27 |
#include <qvariant.h>
|
36
|
28 |
#include <hbextendedlocale.h>
|
50
|
29 |
#include <qfileinfo.h>
|
30
|
30 |
|
|
31 |
#include "videolistdatamodel.h"
|
34
|
32 |
#include "videocollectionclient.h"
|
|
33 |
#include "videodeleteworker.h"
|
30
|
34 |
#include "videolistdatamodel_p.h"
|
|
35 |
#include "videothumbnaildata.h"
|
|
36 |
#include "vcxmyvideosdefs.h"
|
|
37 |
#include "videocollectionutils.h"
|
|
38 |
#include "videocollectioncommon.h"
|
36
|
39 |
#include "videocollectiontrace.h"
|
30
|
40 |
|
|
41 |
/**
|
34
|
42 |
* global qHash function required fo creating hash values for TMPXItemId -keys
|
30
|
43 |
*/
|
|
44 |
inline uint qHash(TMPXItemId key)
|
|
45 |
{
|
|
46 |
QPair<uint, uint> keyPair(key.iId1, key.iId2);
|
|
47 |
return qHash(keyPair);
|
|
48 |
}
|
|
49 |
|
|
50 |
// ================= MEMBER FUNCTIONS =======================
|
|
51 |
//
|
|
52 |
|
|
53 |
// -----------------------------------------------------------------------------
|
|
54 |
// VideoListDataModelPrivate
|
|
55 |
// -----------------------------------------------------------------------------
|
|
56 |
//
|
|
57 |
VideoListDataModelPrivate::VideoListDataModelPrivate(VideoListDataModel *model) :
|
|
58 |
q_ptr(model),
|
34
|
59 |
mVideoThumbnailData(0),
|
|
60 |
mInitialized(false),
|
|
61 |
mCurrentAlbum(TMPXItemId::InvalidId())
|
30
|
62 |
{
|
36
|
63 |
FUNC_LOG;
|
30
|
64 |
}
|
|
65 |
|
|
66 |
// -----------------------------------------------------------------------------
|
|
67 |
// ~VideoListDataModelPrivate
|
|
68 |
// -----------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
VideoListDataModelPrivate::~VideoListDataModelPrivate()
|
|
71 |
{
|
36
|
72 |
FUNC_LOG;
|
34
|
73 |
QHash<TMPXItemId, QSet<TMPXItemId> >::iterator iter = mAlbumData.begin();
|
|
74 |
while(iter != mAlbumData.end())
|
|
75 |
{
|
|
76 |
iter->clear();
|
|
77 |
++iter;
|
|
78 |
}
|
|
79 |
mAlbumData.clear();
|
30
|
80 |
mMediaData.clear();
|
|
81 |
}
|
|
82 |
|
|
83 |
// -----------------------------------------------------------------------------
|
|
84 |
// initialize
|
|
85 |
// -----------------------------------------------------------------------------
|
|
86 |
//
|
|
87 |
int VideoListDataModelPrivate::initialize()
|
|
88 |
{
|
36
|
89 |
FUNC_LOG;
|
30
|
90 |
if(mInitialized)
|
|
91 |
{
|
|
92 |
return 0;
|
|
93 |
}
|
34
|
94 |
mVideoThumbnailData = &(VideoThumbnailData::instance());
|
50
|
95 |
if(!connect( mVideoThumbnailData, SIGNAL(thumbnailsFetched( QList<TMPXItemId>& )),
|
|
96 |
this, SLOT(thumbnailsFetchedSlot( QList<TMPXItemId>& ))))
|
30
|
97 |
{
|
|
98 |
return -1;
|
|
99 |
}
|
|
100 |
|
|
101 |
mInitialized = true;
|
|
102 |
return 0;
|
|
103 |
}
|
|
104 |
|
|
105 |
// -----------------------------------------------------------------------------
|
|
106 |
// getVideoCount
|
|
107 |
// -----------------------------------------------------------------------------
|
|
108 |
//
|
|
109 |
int VideoListDataModelPrivate::getVideoCount()
|
|
110 |
{
|
|
111 |
return mMediaData.count();
|
|
112 |
}
|
|
113 |
|
|
114 |
// -----------------------------------------------------------------------------
|
|
115 |
// getMediaIdFromIndex
|
|
116 |
// -----------------------------------------------------------------------------
|
|
117 |
//
|
50
|
118 |
const TMPXItemId& VideoListDataModelPrivate::getMediaIdFromIndex(const int &index ) const
|
30
|
119 |
{
|
|
120 |
return mMediaData.idFromIndex(index);
|
|
121 |
}
|
|
122 |
|
|
123 |
// -----------------------------------------------------------------------------
|
|
124 |
// getVideoNameFromIndex
|
|
125 |
// -----------------------------------------------------------------------------
|
|
126 |
//
|
50
|
127 |
const QString VideoListDataModelPrivate::getVideoNameFromIndex(const int &index ) const
|
30
|
128 |
{
|
|
129 |
QString txt;
|
|
130 |
CMPXMedia* media = mMediaData.fromIndex(index);
|
|
131 |
VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralTitle, txt );
|
|
132 |
return txt;
|
|
133 |
}
|
|
134 |
|
|
135 |
// -----------------------------------------------------------------------------
|
|
136 |
// getVideoThumbnailFromIndex
|
|
137 |
// -----------------------------------------------------------------------------
|
|
138 |
//
|
50
|
139 |
const QIcon* VideoListDataModelPrivate::getVideoThumbnailFromIndex(const int &index ) const
|
30
|
140 |
{
|
34
|
141 |
if(mVideoThumbnailData)
|
|
142 |
{
|
|
143 |
return mVideoThumbnailData->getThumbnail( mMediaData.idFromIndex(index) );
|
|
144 |
}
|
|
145 |
return 0;
|
30
|
146 |
}
|
|
147 |
|
|
148 |
// -----------------------------------------------------------------------------
|
35
|
149 |
// getCategoryVideoCountFromIndex
|
|
150 |
// -----------------------------------------------------------------------------
|
|
151 |
//
|
50
|
152 |
quint32 VideoListDataModelPrivate::getCategoryVideoCountFromIndex(const int &index ) const
|
35
|
153 |
{
|
|
154 |
quint32 count(0);
|
|
155 |
CMPXMedia *media = mMediaData.fromIndex(index);
|
|
156 |
VideoCollectionUtils::instance().mediaValue<quint32>(media, KVcxMediaMyVideosCategoryItemCount, count );
|
|
157 |
return count;
|
|
158 |
}
|
|
159 |
|
|
160 |
// -----------------------------------------------------------------------------
|
30
|
161 |
// getVideoSizeFromIndex
|
|
162 |
// -----------------------------------------------------------------------------
|
|
163 |
//
|
50
|
164 |
quint32 VideoListDataModelPrivate::getVideoSizeFromIndex(const int &index ) const
|
30
|
165 |
{
|
|
166 |
quint32 size(0);
|
|
167 |
CMPXMedia *media = mMediaData.fromIndex(index);
|
|
168 |
VideoCollectionUtils::instance().mediaValue<quint32>(media, KMPXMediaGeneralSize, size );
|
35
|
169 |
return size;
|
30
|
170 |
}
|
|
171 |
|
|
172 |
// -----------------------------------------------------------------------------
|
|
173 |
// getVideoAgeProfileFromIndex
|
|
174 |
// ---------------------------------------------------------------------------
|
|
175 |
//
|
50
|
176 |
quint32 VideoListDataModelPrivate::getVideoAgeProfileFromIndex(const int &index ) const
|
30
|
177 |
{
|
|
178 |
quint32 ageProfile(0);
|
|
179 |
CMPXMedia *media = mMediaData.fromIndex(index);
|
|
180 |
VideoCollectionUtils::instance().mediaValue<quint32>(media, KVcxMediaMyVideosAgeProfile, ageProfile );
|
|
181 |
return ageProfile;
|
|
182 |
}
|
|
183 |
|
|
184 |
// -----------------------------------------------------------------------------
|
|
185 |
// getVideodurationFromIndex
|
|
186 |
// -----------------------------------------------------------------------------
|
|
187 |
//
|
50
|
188 |
quint32 VideoListDataModelPrivate::getVideodurationFromIndex(const int &index ) const
|
30
|
189 |
{
|
36
|
190 |
CMPXMedia *media = mMediaData.fromIndex(index);
|
|
191 |
return getVideoDuration(media);
|
|
192 |
}
|
|
193 |
|
|
194 |
// -----------------------------------------------------------------------------
|
|
195 |
// getVideodurationFromIndex
|
|
196 |
// -----------------------------------------------------------------------------
|
|
197 |
//
|
|
198 |
quint32 VideoListDataModelPrivate::getVideoDuration(CMPXMedia* media) const
|
|
199 |
{
|
30
|
200 |
quint32 returnDuration(0);
|
|
201 |
float duration(0);
|
|
202 |
VideoCollectionUtils::instance().mediaValue<float>(media, KVcxMediaMyVideosDuration, duration );
|
|
203 |
returnDuration = static_cast<quint32>(duration);
|
|
204 |
return returnDuration;
|
|
205 |
}
|
|
206 |
|
|
207 |
// -----------------------------------------------------------------------------
|
|
208 |
// getVideoDateFromIndex
|
|
209 |
// -----------------------------------------------------------------------------
|
|
210 |
//
|
50
|
211 |
QDateTime VideoListDataModelPrivate::getVideoDateFromIndex(const int &index ) const
|
30
|
212 |
{
|
36
|
213 |
return getVideoDate(mMediaData.fromIndex(index));
|
|
214 |
}
|
|
215 |
|
|
216 |
// -----------------------------------------------------------------------------
|
|
217 |
// getVideoDate
|
|
218 |
// -----------------------------------------------------------------------------
|
|
219 |
//
|
|
220 |
QDateTime VideoListDataModelPrivate::getVideoDate(CMPXMedia* media) const
|
|
221 |
{
|
30
|
222 |
QDateTime date;
|
|
223 |
quint64 dateTimeValue;
|
36
|
224 |
if(!VideoCollectionUtils::instance().mediaValue<quint64>(media, KMPXMediaGeneralDate, dateTimeValue))
|
30
|
225 |
{
|
|
226 |
return date;
|
|
227 |
}
|
|
228 |
TDateTime temp = TTime( dateTimeValue ).DateTime();
|
|
229 |
date = QDateTime(QDate(temp.Year(), temp.Month()+1, temp.Day()+1),
|
|
230 |
QTime(temp.Hour(), temp.Minute(), temp.Second(), temp.MicroSecond()));
|
|
231 |
return date;
|
|
232 |
}
|
|
233 |
|
|
234 |
// -----------------------------------------------------------------------------
|
|
235 |
// markVideosRemoved
|
|
236 |
// -----------------------------------------------------------------------------
|
|
237 |
//
|
50
|
238 |
const TMPXItemId VideoListDataModelPrivate::markVideoRemoved(const QModelIndex &itemIndex)
|
30
|
239 |
{
|
34
|
240 |
return mMediaData.markItemRemoved(itemIndex.row());
|
30
|
241 |
}
|
|
242 |
|
|
243 |
// -----------------------------------------------------------------------------
|
34
|
244 |
// restoreRemoved
|
30
|
245 |
// -----------------------------------------------------------------------------
|
|
246 |
//
|
34
|
247 |
void VideoListDataModelPrivate::restoreRemoved(QList<TMPXItemId> *idList)
|
30
|
248 |
{
|
36
|
249 |
FUNC_LOG;
|
34
|
250 |
int startIndex = mMediaData.count();
|
|
251 |
int restored = mMediaData.restoreRemovedItems(idList);
|
|
252 |
if(restored > 0)
|
30
|
253 |
{
|
34
|
254 |
q_ptr->beginInsertRows(QModelIndex(), startIndex, startIndex + (restored - 1));
|
|
255 |
q_ptr->endInsertRows();
|
30
|
256 |
}
|
|
257 |
}
|
|
258 |
|
|
259 |
// -----------------------------------------------------------------------------
|
|
260 |
// getFilePathFromIndex
|
|
261 |
// -----------------------------------------------------------------------------
|
|
262 |
//
|
50
|
263 |
const QString VideoListDataModelPrivate::getFilePathFromIndex(const int &index) const
|
30
|
264 |
{
|
|
265 |
QString filePath;
|
|
266 |
VideoCollectionUtils::instance().mediaValue<QString>(mMediaData.fromIndex(index),
|
|
267 |
KMPXMediaGeneralUri, filePath );
|
|
268 |
return filePath;
|
|
269 |
}
|
|
270 |
|
|
271 |
// -----------------------------------------------------------------------------
|
|
272 |
// getFilePathForId
|
|
273 |
// -----------------------------------------------------------------------------
|
|
274 |
//
|
50
|
275 |
const QString VideoListDataModelPrivate::getFilePathForId(const TMPXItemId &mediaId)
|
30
|
276 |
{
|
|
277 |
QString filePath;
|
|
278 |
int index = mMediaData.indexOfId(mediaId);
|
|
279 |
VideoCollectionUtils::instance().mediaValue<QString>(mMediaData.fromIndex(index),
|
|
280 |
KMPXMediaGeneralUri, filePath );
|
|
281 |
return filePath;
|
|
282 |
}
|
|
283 |
|
|
284 |
// -----------------------------------------------------------------------------
|
34
|
285 |
// belongsToAlbum
|
|
286 |
// -----------------------------------------------------------------------------
|
|
287 |
//
|
|
288 |
bool VideoListDataModelPrivate::belongsToAlbum(const TMPXItemId &itemId, TMPXItemId albumId) const
|
|
289 |
{
|
|
290 |
bool contains(false);
|
|
291 |
QHash<TMPXItemId, QSet<TMPXItemId> >::const_iterator iter;
|
|
292 |
if(albumId == TMPXItemId::InvalidId())
|
|
293 |
{
|
|
294 |
// album id not specified, use the current album
|
|
295 |
iter = mAlbumData.constFind(mCurrentAlbum);
|
|
296 |
}
|
|
297 |
else
|
|
298 |
{
|
|
299 |
iter = mAlbumData.constFind(albumId);
|
|
300 |
}
|
|
301 |
if (iter != mAlbumData.constEnd())
|
|
302 |
{
|
|
303 |
contains = iter->contains(itemId);
|
|
304 |
}
|
|
305 |
return contains;
|
|
306 |
}
|
|
307 |
|
|
308 |
// -----------------------------------------------------------------------------
|
35
|
309 |
// setAlbumInUse
|
34
|
310 |
// -----------------------------------------------------------------------------
|
|
311 |
//
|
50
|
312 |
void VideoListDataModelPrivate::setAlbumInUse(const TMPXItemId &albumId)
|
34
|
313 |
{
|
36
|
314 |
FUNC_LOG;
|
34
|
315 |
mCurrentAlbum = albumId;
|
|
316 |
}
|
|
317 |
|
|
318 |
// -----------------------------------------------------------------------------
|
35
|
319 |
// removeItemsFromAlbum
|
|
320 |
// -----------------------------------------------------------------------------
|
|
321 |
//
|
50
|
322 |
int VideoListDataModelPrivate::removeItemsFromAlbum(const TMPXItemId &albumId,
|
35
|
323 |
const QList<TMPXItemId> &items)
|
|
324 |
{
|
36
|
325 |
FUNC_LOG;
|
35
|
326 |
QHash<TMPXItemId, QSet<TMPXItemId> >::iterator iter = mAlbumData.find(albumId);
|
|
327 |
if(iter == mAlbumData.end())
|
|
328 |
{
|
|
329 |
return 0;
|
|
330 |
}
|
|
331 |
int removeCount = 0;
|
|
332 |
int count = items.count();
|
|
333 |
for(int i = 0; i < count; ++i)
|
|
334 |
{
|
|
335 |
if(iter->remove(items.at(i)))
|
|
336 |
{
|
|
337 |
++removeCount;
|
|
338 |
}
|
|
339 |
}
|
|
340 |
return removeCount;
|
|
341 |
}
|
|
342 |
|
|
343 |
// -----------------------------------------------------------------------------
|
30
|
344 |
// getMediaId
|
|
345 |
// -----------------------------------------------------------------------------
|
|
346 |
//
|
|
347 |
TMPXItemId VideoListDataModelPrivate::getMediaId(const CMPXMedia *media ) const
|
|
348 |
{
|
|
349 |
TMPXItemId mediaId = TMPXItemId::InvalidId();
|
|
350 |
|
|
351 |
VideoCollectionUtils::instance().mediaValue<TMPXItemId>(media, KMPXMediaGeneralId, mediaId );
|
|
352 |
|
|
353 |
return mediaId;
|
|
354 |
}
|
|
355 |
|
|
356 |
// -----------------------------------------------------------------------------
|
|
357 |
// appendDataToContainerL
|
|
358 |
// -----------------------------------------------------------------------------
|
|
359 |
//
|
34
|
360 |
void VideoListDataModelPrivate::appendDataToContainerL(
|
|
361 |
CMPXMediaArray *videoArray,
|
|
362 |
unsigned int startIndex)
|
30
|
363 |
{
|
36
|
364 |
FUNC_LOG;
|
|
365 |
|
34
|
366 |
if (!videoArray ||
|
41
|
367 |
startIndex >= videoArray->Count())
|
30
|
368 |
{
|
|
369 |
return;
|
|
370 |
}
|
|
371 |
|
41
|
372 |
INFO_2("VideoListDataModelPrivate::appendDataToContainerL() array count: %d, start index: %d", videoArray->Count(), startIndex);
|
|
373 |
|
30
|
374 |
CMPXMedia *newMedia = 0;
|
34
|
375 |
CMPXMedia *mediaFromArray = 0;
|
30
|
376 |
TMPXItemId itemId = TMPXItemId::InvalidId();
|
41
|
377 |
int count = videoArray->Count();
|
|
378 |
|
30
|
379 |
for(int i = startIndex; i < count; ++i)
|
|
380 |
{
|
34
|
381 |
mediaFromArray = videoArray->AtL(i);
|
|
382 |
itemId = getMediaId(mediaFromArray);
|
|
383 |
if (isValid(*mediaFromArray, itemId))
|
30
|
384 |
{
|
34
|
385 |
newMedia = CMPXMedia::NewL(*mediaFromArray);
|
30
|
386 |
mMediaData.append(newMedia);
|
34
|
387 |
newMedia = 0;
|
30
|
388 |
}
|
36
|
389 |
}
|
30
|
390 |
}
|
|
391 |
|
|
392 |
// -----------------------------------------------------------------------------
|
34
|
393 |
// isValid
|
|
394 |
// -----------------------------------------------------------------------------
|
|
395 |
//
|
|
396 |
bool VideoListDataModelPrivate::isValid(const CMPXMedia &media,
|
|
397 |
const TMPXItemId &itemId) const
|
|
398 |
{
|
|
399 |
if(itemId == TMPXItemId::InvalidId())
|
|
400 |
{
|
|
401 |
return false;
|
|
402 |
}
|
|
403 |
// temporary to remove all items with out a title
|
|
404 |
QString title;
|
|
405 |
VideoCollectionUtils::instance().mediaValue<QString>(&media,
|
|
406 |
KMPXMediaGeneralTitle,
|
|
407 |
title);
|
|
408 |
if (!title.length())
|
|
409 |
{
|
|
410 |
return false;
|
|
411 |
}
|
|
412 |
// recently played and podcasts are not yet supported
|
|
413 |
if(itemId.iId2 == KVcxMvcMediaTypeCategory &&
|
|
414 |
(itemId.iId1 != KVcxMvcCategoryIdDownloads &&
|
|
415 |
itemId.iId1 != KVcxMvcCategoryIdCaptured))
|
|
416 |
{
|
|
417 |
return false;
|
|
418 |
}
|
|
419 |
return true;
|
|
420 |
}
|
|
421 |
|
|
422 |
// -----------------------------------------------------------------------------
|
35
|
423 |
// albumDataChangedL
|
34
|
424 |
// -----------------------------------------------------------------------------
|
|
425 |
//
|
50
|
426 |
void VideoListDataModelPrivate::albumDataChangedL(TMPXItemId &albumId,
|
34
|
427 |
CMPXMediaArray *videoArray)
|
|
428 |
{
|
36
|
429 |
FUNC_LOG;
|
34
|
430 |
if (!videoArray || albumId == TMPXItemId::InvalidId())
|
|
431 |
{
|
|
432 |
return;
|
|
433 |
}
|
|
434 |
QSet<TMPXItemId> items;
|
49
|
435 |
|
|
436 |
int oldCount = mAlbumData[albumId].count();
|
|
437 |
|
35
|
438 |
// remove existing
|
|
439 |
mAlbumData.remove(albumId);
|
|
440 |
|
34
|
441 |
int videoCount = videoArray->Count();
|
|
442 |
CMPXMedia *media = 0;
|
|
443 |
TMPXItemId id = TMPXItemId::InvalidId();
|
|
444 |
for (int i = videoCount - 1; i >= 0; i--)
|
|
445 |
{
|
|
446 |
media = videoArray->AtL(i);
|
|
447 |
id = getMediaId(media);
|
35
|
448 |
if (id != TMPXItemId::InvalidId() && id.iId2 == KVcxMvcMediaTypeVideo)
|
|
449 |
{
|
34
|
450 |
items.insert(id);
|
|
451 |
}
|
|
452 |
}
|
35
|
453 |
|
34
|
454 |
mAlbumData[albumId] = items;
|
35
|
455 |
|
49
|
456 |
if(oldCount != items.count())
|
|
457 |
{
|
|
458 |
// signal that album has been updated
|
|
459 |
emit q_ptr->albumChanged();
|
34
|
460 |
|
49
|
461 |
// signal that model has changed.
|
|
462 |
emit q_ptr->modelChanged();
|
|
463 |
}
|
34
|
464 |
}
|
|
465 |
|
|
466 |
|
|
467 |
// -----------------------------------------------------------------------------
|
30
|
468 |
// thumbnailsFetchedSlot
|
|
469 |
// -----------------------------------------------------------------------------
|
|
470 |
//
|
50
|
471 |
void VideoListDataModelPrivate::thumbnailsFetchedSlot(QList<TMPXItemId> &mediaIds)
|
30
|
472 |
{
|
|
473 |
TMPXItemId id;
|
|
474 |
QModelIndex rowIndex;
|
|
475 |
|
|
476 |
while(!mediaIds.isEmpty())
|
|
477 |
{
|
|
478 |
id = mediaIds.takeFirst();
|
|
479 |
rowIndex = q_ptr->index(mMediaData.indexOfId(id), 0);
|
|
480 |
if(rowIndex.isValid())
|
|
481 |
{
|
50
|
482 |
emit q_ptr->dataChanged( rowIndex, rowIndex);
|
30
|
483 |
}
|
|
484 |
}
|
|
485 |
}
|
|
486 |
|
|
487 |
// -----------------------------------------------------------------------------
|
|
488 |
// newVideoListSlot
|
|
489 |
// -----------------------------------------------------------------------------
|
|
490 |
//
|
|
491 |
void VideoListDataModelPrivate::newVideoListSlot( CMPXMediaArray *newVideoList )
|
|
492 |
{
|
36
|
493 |
FUNC_LOG;
|
30
|
494 |
if( !newVideoList )
|
|
495 |
{
|
|
496 |
return;
|
|
497 |
}
|
36
|
498 |
|
34
|
499 |
int startIndex = mMediaData.count();
|
30
|
500 |
|
|
501 |
TRAP_IGNORE(appendDataToContainerL(newVideoList));
|
|
502 |
|
34
|
503 |
int endIndex = mMediaData.count() - 1;
|
|
504 |
if(startIndex <= endIndex)
|
|
505 |
{
|
|
506 |
q_ptr->beginInsertRows(QModelIndex(), startIndex, endIndex);
|
|
507 |
q_ptr->endInsertRows();
|
38
|
508 |
emit q_ptr->modelChanged();
|
34
|
509 |
}
|
30
|
510 |
}
|
|
511 |
|
|
512 |
// -----------------------------------------------------------------------------
|
|
513 |
// appendVideoListSlot
|
|
514 |
// -----------------------------------------------------------------------------
|
|
515 |
//
|
|
516 |
void VideoListDataModelPrivate::appendVideoListSlot(CMPXMediaArray* videoList)
|
|
517 |
{
|
36
|
518 |
FUNC_LOG;
|
30
|
519 |
if(!videoList)
|
|
520 |
{
|
|
521 |
return;
|
|
522 |
}
|
|
523 |
if(videoList->Count() == 0 || videoList->Count() <= mMediaData.count())
|
|
524 |
{
|
|
525 |
// nothing to append or count matches, no changes -> nothing to append
|
|
526 |
return;
|
|
527 |
}
|
|
528 |
|
|
529 |
// array gotten is in same order as existing data from the start,
|
|
530 |
// so we only need to go throught the appendding array from the index
|
|
531 |
// at position where first new items is excepted to exists.
|
|
532 |
int startIndex = mMediaData.count();
|
|
533 |
|
|
534 |
q_ptr->beginInsertRows(QModelIndex(), startIndex, videoList->Count() - 1);
|
|
535 |
|
|
536 |
TRAP_IGNORE(appendDataToContainerL(videoList, startIndex));
|
|
537 |
|
|
538 |
q_ptr->endInsertRows();
|
34
|
539 |
emit q_ptr->modelChanged();
|
30
|
540 |
}
|
|
541 |
|
|
542 |
// -----------------------------------------------------------------------------
|
|
543 |
// newVideoAvailable
|
|
544 |
// -----------------------------------------------------------------------------
|
|
545 |
//
|
|
546 |
void VideoListDataModelPrivate::newVideoAvailableSlot(CMPXMedia *newVideo)
|
|
547 |
{
|
36
|
548 |
FUNC_LOG;
|
30
|
549 |
if(!newVideo )
|
|
550 |
{
|
|
551 |
return;
|
|
552 |
}
|
|
553 |
|
|
554 |
// try to get id of the video, if not found consider invalid clip
|
|
555 |
TMPXItemId mediaId = getMediaId(newVideo);
|
|
556 |
if( mediaId == TMPXItemId::InvalidId())
|
|
557 |
{
|
|
558 |
return;
|
|
559 |
}
|
|
560 |
|
|
561 |
// append video into list, ownership of provided mediaobject is not transferred,
|
|
562 |
// so we need to create copy of CMPXMedia
|
34
|
563 |
if (isValid(*newVideo, mediaId))
|
|
564 |
{
|
|
565 |
CMPXMedia *videoToAppend = 0;
|
|
566 |
TRAP_IGNORE(videoToAppend = CMPXMedia::NewL(*newVideo));
|
30
|
567 |
|
34
|
568 |
q_ptr->beginInsertRows(QModelIndex(), mMediaData.count(), mMediaData.count());
|
|
569 |
|
|
570 |
mMediaData.append(videoToAppend);
|
|
571 |
|
|
572 |
q_ptr->endInsertRows();
|
30
|
573 |
|
34
|
574 |
emit q_ptr->modelChanged();
|
|
575 |
}
|
|
576 |
}
|
|
577 |
|
|
578 |
// -----------------------------------------------------------------------------
|
|
579 |
// itemDeletedSlot
|
|
580 |
// -----------------------------------------------------------------------------
|
|
581 |
//
|
50
|
582 |
void VideoListDataModelPrivate::itemDeletedSlot(TMPXItemId &itemId)
|
34
|
583 |
{
|
36
|
584 |
FUNC_LOG;
|
34
|
585 |
if(itemId == TMPXItemId::InvalidId())
|
|
586 |
{
|
|
587 |
return;
|
|
588 |
}
|
|
589 |
|
|
590 |
if(itemId.iId2 == KVcxMvcMediaTypeVideo)
|
|
591 |
{
|
|
592 |
videoDeleted(itemId);
|
|
593 |
}
|
|
594 |
else if (itemId.iId2 == KVcxMvcMediaTypeAlbum)
|
|
595 |
{
|
|
596 |
albumRemoved(itemId);
|
|
597 |
}
|
|
598 |
}
|
30
|
599 |
|
34
|
600 |
// -----------------------------------------------------------------------------
|
|
601 |
// albumRemoved
|
|
602 |
// -----------------------------------------------------------------------------
|
|
603 |
//
|
50
|
604 |
void VideoListDataModelPrivate::albumRemoved(TMPXItemId &albumId)
|
34
|
605 |
{
|
36
|
606 |
FUNC_LOG;
|
34
|
607 |
if (albumId == TMPXItemId::InvalidId() || albumId.iId2 != KVcxMvcMediaTypeAlbum)
|
|
608 |
{
|
|
609 |
return;
|
|
610 |
}
|
|
611 |
|
|
612 |
bool changed(false);
|
|
613 |
|
|
614 |
if(mVideoThumbnailData)
|
|
615 |
{
|
|
616 |
mVideoThumbnailData->removeThumbnail( albumId );
|
|
617 |
}
|
|
618 |
|
|
619 |
int index = mMediaData.indexOfId(albumId);
|
|
620 |
if(index >= 0)
|
|
621 |
{
|
|
622 |
q_ptr->beginRemoveRows(QModelIndex(), index, index);
|
|
623 |
mMediaData.remove(albumId);
|
|
624 |
q_ptr->endRemoveRows();
|
|
625 |
changed = true;
|
|
626 |
}
|
|
627 |
|
|
628 |
//remove album data
|
|
629 |
QHash<TMPXItemId, QSet<TMPXItemId> >::iterator iter;
|
|
630 |
iter = mAlbumData.find(albumId);
|
|
631 |
if(iter != mAlbumData.end())
|
|
632 |
{
|
|
633 |
iter->clear();
|
35
|
634 |
mAlbumData.remove(albumId);
|
34
|
635 |
changed = true;
|
|
636 |
}
|
|
637 |
|
|
638 |
if(changed)
|
|
639 |
{
|
|
640 |
emit q_ptr->modelChanged();
|
|
641 |
}
|
30
|
642 |
}
|
|
643 |
|
|
644 |
// -----------------------------------------------------------------------------
|
|
645 |
// videoDeleted
|
|
646 |
// -----------------------------------------------------------------------------
|
|
647 |
//
|
50
|
648 |
void VideoListDataModelPrivate::videoDeleted(TMPXItemId &videoId)
|
30
|
649 |
{
|
36
|
650 |
FUNC_LOG;
|
34
|
651 |
if(videoId == TMPXItemId::InvalidId())
|
|
652 |
{
|
|
653 |
return;
|
|
654 |
}
|
|
655 |
// check if provided id is in the deleted -container and remove
|
|
656 |
// it from there if it is.
|
|
657 |
QList<TMPXItemId> ids;
|
|
658 |
ids.append(videoId);
|
|
659 |
if(!mMediaData.clearRemoved(&ids))
|
30
|
660 |
{
|
34
|
661 |
q_ptr->mDeleteWorker->removeFromRequest(videoId);
|
|
662 |
if(mVideoThumbnailData)
|
|
663 |
{
|
|
664 |
mVideoThumbnailData->removeThumbnail( videoId );
|
|
665 |
}
|
|
666 |
// media removed was not in the deleted -container, so we have external
|
|
667 |
// removal: in this case we need to indicate UI
|
|
668 |
int index = mMediaData.indexOfId(videoId);
|
|
669 |
if(index >= 0)
|
|
670 |
{
|
|
671 |
q_ptr->beginRemoveRows(QModelIndex(), index, index);
|
36
|
672 |
mMediaData.remove(videoId);
|
34
|
673 |
q_ptr->endRemoveRows();
|
|
674 |
emit q_ptr->modelChanged();
|
|
675 |
}
|
|
676 |
}
|
30
|
677 |
}
|
|
678 |
|
|
679 |
// -----------------------------------------------------------------------------
|
|
680 |
// videoDeleteCompleted
|
|
681 |
// -----------------------------------------------------------------------------
|
|
682 |
//
|
|
683 |
void VideoListDataModelPrivate::videoDeleteCompletedSlot(int overallCount, QList<TMPXItemId> *failedMediaIds)
|
34
|
684 |
{
|
36
|
685 |
FUNC_LOG;
|
30
|
686 |
Q_UNUSED(overallCount);
|
|
687 |
if(!failedMediaIds)
|
|
688 |
{
|
34
|
689 |
// invalid signal received, do nothing
|
30
|
690 |
return;
|
|
691 |
}
|
34
|
692 |
int status(VideoCollectionCommon::statusDeleteSucceed);
|
|
693 |
QVariant data;
|
|
694 |
if(failedMediaIds->count() > 0)
|
|
695 |
{
|
|
696 |
QString nameOfFirstFailed("");
|
50
|
697 |
CMPXMedia *media = mMediaData.getRemovedMedia(failedMediaIds->first());
|
34
|
698 |
VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralTitle, nameOfFirstFailed );
|
|
699 |
if(failedMediaIds->count() == 1)
|
30
|
700 |
{
|
34
|
701 |
status = VideoCollectionCommon::statusSingleDeleteFail;
|
|
702 |
data = nameOfFirstFailed;
|
30
|
703 |
}
|
|
704 |
else
|
|
705 |
{
|
34
|
706 |
status = VideoCollectionCommon::statusMultipleDeleteFail;
|
|
707 |
data = failedMediaIds->count();
|
|
708 |
}
|
|
709 |
restoreRemoved(failedMediaIds);
|
36
|
710 |
}
|
34
|
711 |
q_ptr->reportAsyncStatus(status, data);
|
|
712 |
emit q_ptr->modelChanged();
|
|
713 |
}
|
|
714 |
|
|
715 |
// -----------------------------------------------------------------------------
|
|
716 |
// albumRemoveFailureSlot
|
|
717 |
// -----------------------------------------------------------------------------
|
|
718 |
//
|
|
719 |
void VideoListDataModelPrivate::albumRemoveFailureSlot(QList<TMPXItemId> *failedMediaIds)
|
|
720 |
{
|
36
|
721 |
FUNC_LOG;
|
35
|
722 |
if(!failedMediaIds)
|
|
723 |
{
|
|
724 |
return;
|
|
725 |
}
|
34
|
726 |
int status(VideoCollectionCommon::statusRemoveSucceed);
|
|
727 |
QVariant data;
|
|
728 |
if(failedMediaIds->count() > 0)
|
|
729 |
{
|
|
730 |
QString nameOfFirstFailed("");
|
50
|
731 |
CMPXMedia *media = mMediaData.getRemovedMedia(failedMediaIds->first());
|
34
|
732 |
VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralTitle, nameOfFirstFailed );
|
|
733 |
if(failedMediaIds->count() == 1)
|
|
734 |
{
|
|
735 |
status = VideoCollectionCommon::statusSingleRemoveFail;
|
|
736 |
data = nameOfFirstFailed;
|
|
737 |
}
|
|
738 |
else
|
|
739 |
{
|
|
740 |
status = VideoCollectionCommon::statusMultiRemoveFail;
|
|
741 |
data = failedMediaIds->count();
|
|
742 |
}
|
|
743 |
}
|
|
744 |
q_ptr->reportAsyncStatus(status, data);
|
30
|
745 |
}
|
|
746 |
|
|
747 |
// -----------------------------------------------------------------------------
|
|
748 |
// VideoDetailsCompleted
|
|
749 |
// -----------------------------------------------------------------------------
|
|
750 |
//
|
36
|
751 |
void VideoListDataModelPrivate::videoDetailsCompletedSlot(CMPXMedia* media)
|
30
|
752 |
{
|
36
|
753 |
FUNC_LOG;
|
|
754 |
if(!media)
|
|
755 |
{
|
|
756 |
return;
|
|
757 |
}
|
|
758 |
|
|
759 |
using namespace VideoCollectionCommon;
|
|
760 |
QMap<QString, QVariant> map;
|
|
761 |
|
|
762 |
HbExtendedLocale locale = HbExtendedLocale::system();
|
|
763 |
|
|
764 |
// MetaKeyDate
|
|
765 |
QDateTime date = getVideoDate(media);
|
|
766 |
if(date.isValid()) {
|
|
767 |
map[MetaKeyDate] = locale.format( date.date(), r_qtn_date_usual );
|
|
768 |
}
|
|
769 |
|
|
770 |
// MetaKeyDurationString
|
|
771 |
quint32 dur = getVideoDuration(media);
|
|
772 |
QString duration = VideoCollectionUtils::instance().prepareLengthString(dur);
|
|
773 |
if(!duration.isNull() && !duration.isEmpty()) {
|
|
774 |
map[MetaKeyDurationString] = duration;
|
|
775 |
}
|
|
776 |
|
|
777 |
// MetaKeySizeString
|
|
778 |
quint32 s;
|
|
779 |
VideoCollectionUtils::instance().mediaValue<quint32>(media, KMPXMediaGeneralSize, s );
|
|
780 |
QString size = VideoCollectionUtils::instance().prepareSizeString(s);
|
|
781 |
if(!size.isNull() && !size.isEmpty()) {
|
|
782 |
map[MetaKeySizeString] = size;
|
|
783 |
}
|
|
784 |
|
|
785 |
// MetaKeyStarRating
|
|
786 |
quint8 rating = 0;
|
|
787 |
if(VideoCollectionUtils::instance().mediaValue<quint8>(media, KVcxMediaMyVideosRating, rating))
|
30
|
788 |
{
|
36
|
789 |
map[MetaKeyStarRating] = rating;
|
|
790 |
}
|
|
791 |
|
|
792 |
// MetaKeyDRMInfo
|
|
793 |
|
|
794 |
// MetaKeyServiceURL
|
|
795 |
|
|
796 |
// MetaKeyDescription
|
|
797 |
QString desc;
|
|
798 |
if(VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralComment, desc)) {
|
|
799 |
map[MetaKeyDescription] = desc;
|
|
800 |
}
|
|
801 |
|
|
802 |
// MetaKeyModifiedDate
|
|
803 |
quint64 dateTimeValue;
|
|
804 |
if(VideoCollectionUtils::instance().mediaValue<quint64>(media, KVcxMediaMyVideosModifiedDate, dateTimeValue)) {
|
|
805 |
TDateTime temp = TTime( dateTimeValue ).DateTime();
|
37
|
806 |
QDateTime date = QDateTime(QDate(temp.Year(), temp.Month()+1, temp.Day()+1),
|
36
|
807 |
QTime(temp.Hour(), temp.Minute(), temp.Second(), temp.MicroSecond()));
|
|
808 |
map[MetaKeyModifiedDate] = locale.format( date.date(), r_qtn_date_usual );
|
|
809 |
}
|
|
810 |
|
|
811 |
// MetaKeyShotLocation
|
|
812 |
|
|
813 |
// MetaKeyAuthor
|
|
814 |
QString author;
|
|
815 |
if(VideoCollectionUtils::instance().mediaValue<QString>(media, KVcxMediaMyVideosAuthor, author)) {
|
|
816 |
map[MetaKeyAuthor] = author;
|
|
817 |
}
|
|
818 |
|
|
819 |
// MetaKeyCopyright
|
|
820 |
QString copyright;
|
|
821 |
if(VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralCopyright, copyright)) {
|
|
822 |
map[MetaKeyCopyright] = copyright;
|
30
|
823 |
}
|
36
|
824 |
|
|
825 |
// MetaKeyAudioType
|
|
826 |
|
|
827 |
// MetaKeyLanguageString
|
|
828 |
QString language;
|
|
829 |
if(VideoCollectionUtils::instance().mediaValue<QString>(media, KVcxMediaMyVideosAudioLanguage, language)) {
|
|
830 |
map[MetaKeyLanguageString] = language;
|
|
831 |
}
|
|
832 |
|
|
833 |
// MetaKeyKeywords
|
|
834 |
|
|
835 |
// MetaKeyVideoResolutionString
|
|
836 |
quint16 width;
|
|
837 |
quint16 heigth;
|
|
838 |
if(VideoCollectionUtils::instance().mediaValue<quint16>(media, KMPXMediaVideoWidth, width) &&
|
|
839 |
VideoCollectionUtils::instance().mediaValue<quint16>(media, KMPXMediaVideoHeight, heigth))
|
|
840 |
{
|
|
841 |
map[MetaKeyVideoResolutionString] = hbTrId("txt_videos_list_l1l2").arg(width).arg(heigth);
|
|
842 |
}
|
|
843 |
|
|
844 |
// MetaKeyBitRate
|
|
845 |
qint16 bitrate;
|
|
846 |
if(VideoCollectionUtils::instance().mediaValue<qint16>(media, KMPXMediaVideoBitRate, bitrate))
|
|
847 |
{
|
|
848 |
const char* loc = "txt_videos_list_l1_kbps";
|
|
849 |
|
|
850 |
if(bitrate > 999)
|
|
851 |
{
|
|
852 |
loc = "txt_videos_list_l1_mbps";
|
|
853 |
bitrate = (double)bitrate / (double)1000 + 0.5;
|
|
854 |
}
|
|
855 |
|
37
|
856 |
map[MetaKeyBitRate] = hbTrId(loc).arg(bitrate);
|
36
|
857 |
}
|
|
858 |
|
|
859 |
// MetaKeyFormat
|
|
860 |
QString format;
|
|
861 |
if(VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralMimeType, format)) {
|
|
862 |
map[MetaKeyFormat] = format;
|
|
863 |
}
|
|
864 |
|
50
|
865 |
// MetaKeyFileName and MetaKeyFilePath
|
|
866 |
QString fileName;
|
|
867 |
if(VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralUri, fileName)) {
|
|
868 |
|
|
869 |
QFileInfo fInfo(fileName);
|
|
870 |
if(fInfo.isFile())
|
|
871 |
{
|
|
872 |
map[MetaKeyFileName] = fInfo.fileName();
|
|
873 |
map[MetaKeyFilePath] = fInfo.absolutePath();
|
|
874 |
}
|
|
875 |
}
|
|
876 |
|
|
877 |
// Metakey video title
|
|
878 |
QString videoTitle;
|
|
879 |
if(VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralTitle, videoTitle)) {
|
|
880 |
map[MetaKeyVideoTitle] = videoTitle;
|
|
881 |
}
|
|
882 |
|
|
883 |
|
36
|
884 |
QVariant variant = QVariant(map);
|
50
|
885 |
emit q_ptr->fullVideoDetailsReady(variant);
|
30
|
886 |
}
|
|
887 |
|
34
|
888 |
// -----------------------------------------------------------------------------
|
|
889 |
// albumListAvailableSlot
|
|
890 |
// -----------------------------------------------------------------------------
|
|
891 |
//
|
50
|
892 |
void VideoListDataModelPrivate::albumListAvailableSlot(TMPXItemId &albumId,
|
34
|
893 |
CMPXMediaArray *albumItems)
|
|
894 |
{
|
36
|
895 |
FUNC_LOG;
|
34
|
896 |
// currently only one album is kept in memory
|
35
|
897 |
TRAP_IGNORE(albumDataChangedL(albumId, albumItems));
|
34
|
898 |
}
|
|
899 |
|
36
|
900 |
// -----------------------------------------------------------------------------
|
|
901 |
// itemModifiedSlot
|
|
902 |
// -----------------------------------------------------------------------------
|
|
903 |
//
|
|
904 |
void VideoListDataModelPrivate::itemModifiedSlot(const TMPXItemId &itemId)
|
|
905 |
{
|
|
906 |
FUNC_LOG;
|
|
907 |
int index = mMediaData.indexOfId(itemId);
|
|
908 |
if(index != -1)
|
|
909 |
{
|
|
910 |
QModelIndex rowIndex = q_ptr->index(index, 0);
|
|
911 |
if(rowIndex.isValid())
|
50
|
912 |
{
|
|
913 |
emit q_ptr->dataChanged(rowIndex, rowIndex);
|
|
914 |
emit q_ptr->modelChanged();
|
36
|
915 |
}
|
|
916 |
}
|
|
917 |
}
|
|
918 |
|
38
|
919 |
// -----------------------------------------------------------------------------
|
50
|
920 |
// videoListCompleteSlot
|
38
|
921 |
// -----------------------------------------------------------------------------
|
|
922 |
//
|
50
|
923 |
void VideoListDataModelPrivate::videoListCompleteSlot()
|
38
|
924 |
{
|
|
925 |
emit q_ptr->modelReady();
|
|
926 |
}
|
|
927 |
|
50
|
928 |
// -----------------------------------------------------------------------------
|
|
929 |
// albumListCompleteSlot
|
|
930 |
// -----------------------------------------------------------------------------
|
|
931 |
//
|
|
932 |
void VideoListDataModelPrivate::albumListCompleteSlot()
|
|
933 |
{
|
|
934 |
emit q_ptr->albumListReady();
|
|
935 |
}
|
|
936 |
|
30
|
937 |
// End of file
|