25 #include "videocollectioncommon.h" |
28 #include "videocollectioncommon.h" |
26 #include "videosortfilterproxymodel.h" |
29 #include "videosortfilterproxymodel.h" |
27 #include "videolistdatamodel.h" |
30 #include "videolistdatamodel.h" |
28 #include "videocollectionclient.h" |
31 #include "videocollectionclient.h" |
29 #include "videocollectionwrapper.h" |
32 #include "videocollectionwrapper.h" |
|
33 #include "videocollectiontrace.h" |
30 |
34 |
31 // ----------------------------------------------------------------------------- |
35 // ----------------------------------------------------------------------------- |
32 // VideoSortFilterProxyModel::VideoSortFilterProxyModel |
36 // VideoSortFilterProxyModel::VideoSortFilterProxyModel |
33 // ----------------------------------------------------------------------------- |
37 // ----------------------------------------------------------------------------- |
34 // |
38 // |
35 VideoSortFilterProxyModel::VideoSortFilterProxyModel(int type, QObject *parent) : |
39 VideoSortFilterProxyModel::VideoSortFilterProxyModel(VideoCollectionCommon::TModelType type, QObject *parent) : |
36 QSortFilterProxyModel(parent), |
40 QSortFilterProxyModel(parent), |
37 mModel(0), |
41 mModel(0), |
38 mCollectionClient(0), |
42 mCollectionClient(0), |
39 mType(type), |
43 mType(type), |
40 mLevel(-1), |
44 mLevel(VideoCollectionCommon::ELevelInvalid), |
41 mGenericFilterId(TMPXItemId::InvalidId()), |
45 mGenericFilterId(TMPXItemId::InvalidId()), |
42 mGenericFilterValue(false), |
46 mGenericFilterValue(false), |
43 mIdleSortTimer(0), |
47 mIdleSortTimer(0), |
44 mWantedSortRole(VideoCollectionCommon::KeyDateTime) |
48 mWantedSortRole(VideoCollectionCommon::KeyDateTime), |
45 { |
49 mWantedSortOrder(Qt::AscendingOrder) |
46 // NOP |
50 { |
|
51 FUNC_LOG_ADDR(this); |
|
52 INFO_2("VideoSortFilterProxyModel::VideoSortFilterProxyModel() [0x%x]: type: %d", this, type); |
47 } |
53 } |
48 |
54 |
49 // ----------------------------------------------------------------------------- |
55 // ----------------------------------------------------------------------------- |
50 // VideoSortFilterProxyModel::~VideoSortFilterProxyModel |
56 // VideoSortFilterProxyModel::~VideoSortFilterProxyModel |
51 // ----------------------------------------------------------------------------- |
57 // ----------------------------------------------------------------------------- |
52 // |
58 // |
53 VideoSortFilterProxyModel::~VideoSortFilterProxyModel() |
59 VideoSortFilterProxyModel::~VideoSortFilterProxyModel() |
54 { |
60 { |
55 // NOP |
61 FUNC_LOG_ADDR(this); |
56 } |
62 } |
57 |
63 |
58 // ----------------------------------------------------------------------------- |
64 // ----------------------------------------------------------------------------- |
59 // VideoSortFilterProxyModel::initialize |
65 // VideoSortFilterProxyModel::initialize |
60 // ----------------------------------------------------------------------------- |
66 // ----------------------------------------------------------------------------- |
61 // |
67 // |
62 int VideoSortFilterProxyModel::initialize(VideoListDataModel *sourceModel) |
68 int VideoSortFilterProxyModel::initialize(VideoListDataModel *sourceModel) |
63 { |
69 { |
|
70 FUNC_LOG_ADDR(this); |
64 if(!sourceModel) |
71 if(!sourceModel) |
65 { |
72 { |
66 return -1; |
73 return -1; |
67 } |
74 } |
68 |
75 |
69 if(!mModel) |
76 if(!mModel) |
70 { |
77 { |
71 mModel = sourceModel; |
78 mModel = sourceModel; |
72 if(!connectSignals()) |
79 if(!connectSignals()) |
73 { |
80 { |
|
81 ERROR_1(-1, "VideoSortFilterProxyModel::initialize() [0x%x] failed to connect signals.", this); |
74 disconnectSignals(); |
82 disconnectSignals(); |
75 mModel = 0; |
83 mModel = 0; |
76 return -1; |
84 return -1; |
77 } |
85 } |
78 mCollectionClient = mModel->getCollectionClient(); |
86 mCollectionClient = mModel->getCollectionClient(); |
85 // VideoSortFilterProxyModel::connectSignals |
93 // VideoSortFilterProxyModel::connectSignals |
86 // ----------------------------------------------------------------------------- |
94 // ----------------------------------------------------------------------------- |
87 // |
95 // |
88 bool VideoSortFilterProxyModel::connectSignals() |
96 bool VideoSortFilterProxyModel::connectSignals() |
89 { |
97 { |
|
98 FUNC_LOG_ADDR(this); |
90 if(!connect(mModel, SIGNAL(modelReady()), |
99 if(!connect(mModel, SIGNAL(modelReady()), |
91 this, SIGNAL(modelReady()))) |
100 this, SIGNAL(modelReady()))) |
92 { |
101 { |
93 return false; |
102 return false; |
94 } |
103 } |
95 if(!connect(mModel, SIGNAL(modelChanged()), |
104 if(!connect(mModel, SIGNAL(modelChanged()), |
96 this, SIGNAL(modelChanged()))) |
105 this, SIGNAL(modelChanged()))) |
97 { |
106 { |
98 return false; |
107 return false; |
99 } |
108 } |
100 if(mType == VideoCollectionWrapper::ECollectionContent) |
109 if(mType == VideoCollectionCommon::EModelTypeCollectionContent) |
101 { |
110 { |
102 if(!connect(mModel, SIGNAL(albumChanged()), |
111 if(!connect(mModel, SIGNAL(albumChanged()), |
103 this, SLOT(albumChangedSlot()))) |
112 this, SLOT(albumChangedSlot()))) |
104 { |
113 { |
105 return false; |
114 return false; |
106 } |
115 } |
107 } |
116 } |
|
117 if(mType == VideoCollectionCommon::EModelTypeCollections) |
|
118 { |
|
119 if(!connect(mModel, SIGNAL(itemModified(const TMPXItemId &)), |
|
120 this, SLOT(itemModifiedSlot(const TMPXItemId &)))) |
|
121 { |
|
122 return false; |
|
123 } |
|
124 } |
108 return true; |
125 return true; |
109 } |
126 } |
110 |
127 |
111 // ----------------------------------------------------------------------------- |
128 // ----------------------------------------------------------------------------- |
112 // VideoSortFilterProxyModel::disconnectSignals |
129 // VideoSortFilterProxyModel::disconnectSignals |
113 // ----------------------------------------------------------------------------- |
130 // ----------------------------------------------------------------------------- |
114 // |
131 // |
115 void VideoSortFilterProxyModel::disconnectSignals() |
132 void VideoSortFilterProxyModel::disconnectSignals() |
116 { |
133 { |
|
134 FUNC_LOG_ADDR(this); |
117 disconnect(mModel, SIGNAL(modelReady()), this, SIGNAL(modelReady())); |
135 disconnect(mModel, SIGNAL(modelReady()), this, SIGNAL(modelReady())); |
118 disconnect(mModel, SIGNAL(modelChanged()), this, SIGNAL(modelChanged())); |
136 disconnect(mModel, SIGNAL(modelChanged()), this, SIGNAL(modelChanged())); |
119 if(mType == VideoCollectionWrapper::ECollectionContent) |
137 if(mType == VideoCollectionCommon::EModelTypeCollectionContent) |
120 { |
138 { |
121 disconnect(mModel, SIGNAL(albumChanged()), this, SLOT(albumChangedSlot())); |
139 disconnect(mModel, SIGNAL(albumChanged()), this, SLOT(albumChangedSlot())); |
122 } |
140 } |
123 |
141 if(mType == VideoCollectionCommon::EModelTypeCollections) |
|
142 { |
|
143 disconnect(mModel, SIGNAL(itemModified(const TMPXItemId &)), |
|
144 this, SLOT(itemModifiedSlot(const TMPXItemId &))); |
|
145 } |
124 } |
146 } |
125 |
147 |
126 // ----------------------------------------------------------------------------- |
148 // ----------------------------------------------------------------------------- |
127 // VideoSortFilterProxyModel::open |
149 // VideoSortFilterProxyModel::open |
128 // ----------------------------------------------------------------------------- |
150 // ----------------------------------------------------------------------------- |
129 // |
151 // |
130 int VideoSortFilterProxyModel::open(int level) |
152 int VideoSortFilterProxyModel::open(VideoCollectionCommon::TCollectionLevels level) |
131 { |
153 { |
|
154 FUNC_LOG_ADDR(this); |
|
155 INFO_2("VideoSortFilterProxyModel::open() [0x%x] level: %d", this, level); |
|
156 |
132 if(!mCollectionClient) |
157 if(!mCollectionClient) |
133 { |
158 { |
134 return -1; |
159 return -1; |
135 } |
160 } |
136 |
161 |
137 if(mLevel != level) |
162 if(mLevel != level) |
138 { |
163 { |
|
164 INFO_1("VideoSortFilterProxyModel::open() [0x%x] opening different level, invalidating.", this); |
139 mLevel = level; |
165 mLevel = level; |
140 invalidateFilter(); |
166 invalidateFilter(); |
141 } |
167 } |
142 // need to call open every time to make sure all items are |
168 // need to call open every time to make sure all items are |
143 // inserted to UI ( recent open might have been cancelled) |
169 // inserted to UI ( recent open might have been cancelled) |
149 // ----------------------------------------------------------------------------- |
175 // ----------------------------------------------------------------------------- |
150 // |
176 // |
151 void VideoSortFilterProxyModel::doSorting(int sortingRole, Qt::SortOrder order, |
177 void VideoSortFilterProxyModel::doSorting(int sortingRole, Qt::SortOrder order, |
152 bool async) |
178 bool async) |
153 { |
179 { |
154 if((sortingRole != Qt::DisplayRole) && |
180 FUNC_LOG_ADDR(this); |
155 (sortingRole != VideoCollectionCommon::KeySizeValue) && |
181 INFO_3("VideoSortFilterProxyModel::doSorting() [0x%x] sortingRole: %d, order: %d", this, sortingRole, order); |
156 (sortingRole != VideoCollectionCommon::KeyDateTime)) |
182 |
157 { |
183 if(sortingRole != VideoCollectionCommon::KeyTitle && |
158 // default sorting order is by date |
184 sortingRole != VideoCollectionCommon::KeySizeValue && |
159 mWantedSortRole = VideoCollectionCommon::KeyDateTime; |
185 sortingRole != VideoCollectionCommon::KeyDateTime && |
|
186 sortingRole != VideoCollectionCommon::KeyNumberOfItems) |
|
187 { |
|
188 // default sorting order is by date for other models but collections. |
|
189 if(mType != VideoCollectionCommon::EModelTypeCollections) |
|
190 { |
|
191 mWantedSortRole = VideoCollectionCommon::KeyDateTime; |
|
192 } |
|
193 else |
|
194 { |
|
195 mWantedSortRole = VideoCollectionCommon::KeyTitle; |
|
196 } |
160 } |
197 } |
161 else |
198 else |
162 { |
199 { |
163 mWantedSortRole = sortingRole; |
200 mWantedSortRole = sortingRole; |
164 } |
201 } |
178 { |
215 { |
179 mIdleSortTimer = new QTimer(this); |
216 mIdleSortTimer = new QTimer(this); |
180 connect(mIdleSortTimer, SIGNAL(timeout()), this, SLOT(processSorting())); |
217 connect(mIdleSortTimer, SIGNAL(timeout()), this, SLOT(processSorting())); |
181 } |
218 } |
182 mIdleSortTimer->start(0); |
219 mIdleSortTimer->start(0); |
183 } else { |
220 } |
|
221 else |
|
222 { |
184 processSorting(); |
223 processSorting(); |
185 } |
224 } |
186 } |
225 } |
187 // ----------------------------------------------------------------------------- |
226 // ----------------------------------------------------------------------------- |
188 // VideoSortFilterProxyModel::getSorting |
227 // VideoSortFilterProxyModel::getSorting |
189 // ----------------------------------------------------------------------------- |
228 // ----------------------------------------------------------------------------- |
190 // |
229 // |
191 void VideoSortFilterProxyModel::getSorting(int &sortingRole, Qt::SortOrder &order) |
230 void VideoSortFilterProxyModel::getSorting(int &sortingRole, Qt::SortOrder &order) |
192 { |
231 { |
|
232 FUNC_LOG_ADDR(this); |
193 sortingRole = mWantedSortRole; |
233 sortingRole = mWantedSortRole; |
194 order = mWantedSortOrder; |
234 order = mWantedSortOrder; |
195 } |
235 } |
196 |
236 |
197 // ----------------------------------------------------------------------------- |
237 // ----------------------------------------------------------------------------- |
198 // VideoSortFilterProxyModel::deleteItems |
238 // VideoSortFilterProxyModel::deleteItems |
199 // ----------------------------------------------------------------------------- |
239 // ----------------------------------------------------------------------------- |
200 // |
240 // |
201 int VideoSortFilterProxyModel::deleteItems(const QModelIndexList &indexList) |
241 int VideoSortFilterProxyModel::deleteItems(const QModelIndexList &indexList) |
202 { |
242 { |
|
243 FUNC_LOG_ADDR(this); |
203 if(mModel) |
244 if(mModel) |
204 { |
245 { |
205 QModelIndexList mappedList; |
246 QModelIndexList mappedList; |
206 for(int i = 0; i < indexList.count(); ++i) |
247 for(int i = 0; i < indexList.count(); ++i) |
207 { |
248 { |
222 // VideoSortFilterProxyModel::openItem |
263 // VideoSortFilterProxyModel::openItem |
223 // ----------------------------------------------------------------------------- |
264 // ----------------------------------------------------------------------------- |
224 // |
265 // |
225 int VideoSortFilterProxyModel::openItem(TMPXItemId mediaId) |
266 int VideoSortFilterProxyModel::openItem(TMPXItemId mediaId) |
226 { |
267 { |
|
268 FUNC_LOG_ADDR(this); |
227 if(mediaId != TMPXItemId::InvalidId() && mCollectionClient) |
269 if(mediaId != TMPXItemId::InvalidId() && mCollectionClient) |
228 { |
270 { |
229 if(mCollectionClient->openItem(mediaId) == 0) |
271 if(mCollectionClient->openItem(mediaId) == 0) |
230 { |
272 { |
231 if(mediaId.iId2 != KVcxMvcMediaTypeVideo) |
273 if(mediaId.iId2 != KVcxMvcMediaTypeVideo) |
232 { |
274 { |
233 mLevel = VideoCollectionCommon::ELevelAlbum; |
275 mLevel = VideoCollectionCommon::ELevelAlbum; |
234 mModel->setAlbumInUse(mediaId); |
276 mModel->setAlbumInUse(mediaId); |
|
277 INFO_1("VideoSortFilterProxyModel::open() [0x%x] opening album or category, invalidating.", this); |
235 invalidateFilter(); |
278 invalidateFilter(); |
236 } |
279 } |
237 return 0; |
280 return 0; |
238 } |
281 } |
239 } |
282 } |
265 // VideoSortFilterProxyModel::fetchItemDetails |
309 // VideoSortFilterProxyModel::fetchItemDetails |
266 // ----------------------------------------------------------------------------- |
310 // ----------------------------------------------------------------------------- |
267 // |
311 // |
268 int VideoSortFilterProxyModel::fetchItemDetails(const QModelIndex &index) |
312 int VideoSortFilterProxyModel::fetchItemDetails(const QModelIndex &index) |
269 { |
313 { |
|
314 FUNC_LOG_ADDR(this); |
270 // no need to map index beforehand, because |
315 // no need to map index beforehand, because |
271 // getMediaIdAtIndex maps it |
316 // getMediaIdAtIndex maps it |
272 TMPXItemId mpxId1 = getMediaIdAtIndex(index); |
317 TMPXItemId mpxId1 = getMediaIdAtIndex(index); |
273 if(mpxId1 != TMPXItemId::InvalidId() && mCollectionClient) |
318 if(mpxId1 != TMPXItemId::InvalidId() && mCollectionClient) |
274 { |
319 { |
275 if(mCollectionClient->getVideoDetails(mpxId1) == 0) |
320 if(mCollectionClient->getVideoDetails(mpxId1) == 0) |
276 { |
321 { |
277 |
|
278 emit shortDetailsReady(mpxId1); |
322 emit shortDetailsReady(mpxId1); |
279 return 0; |
323 return 0; |
280 } |
324 } |
281 } |
325 } |
282 return -1; |
326 return -1; |
366 { |
411 { |
367 return mWantedSortOrder == Qt::AscendingOrder ? lessThan : !lessThan; |
412 return mWantedSortOrder == Qt::AscendingOrder ? lessThan : !lessThan; |
368 } |
413 } |
369 |
414 |
370 // Do comparisation based on the role: |
415 // Do comparisation based on the role: |
371 // Qt::DisplayRole, |
416 // VideoCollectionCommon::KeyTitle, |
372 // VideoCollectionCommon::KeySizeValue, |
417 // VideoCollectionCommon::KeySizeValue, |
|
418 // VideoCollectionCommon::KeyNumberOfItems, |
373 // VideoCollectionCommon::KeyDateValue |
419 // VideoCollectionCommon::KeyDateValue |
374 // |
420 // |
375 // If role does not match, do not sort |
421 // If role does not match, do not sort |
376 int sRole = sortRole(); |
422 int sRole = sortRole(); |
377 QVariant leftData = sourceModel()->data(left, sRole); |
423 QVariant leftData = sourceModel()->data(left, sRole); |
379 |
425 |
380 if(!leftData.isValid() || !rightData.isValid()) |
426 if(!leftData.isValid() || !rightData.isValid()) |
381 { |
427 { |
382 return false; |
428 return false; |
383 } |
429 } |
384 if(sRole == Qt::DisplayRole) |
430 if(sRole == VideoCollectionCommon::KeyTitle) |
385 { |
431 { |
386 QString leftString = leftData.toStringList().first().toUpper(); |
432 QString leftString = leftData.toString().toUpper(); |
387 QString rightString = rightData.toStringList().first().toUpper(); |
433 QString rightString = rightData.toString().toUpper(); |
388 return QString::localeAwareCompare(leftString, rightString) < 0; |
434 return QString::localeAwareCompare(leftString, rightString) < 0; |
389 } |
435 } |
390 else if(sRole == VideoCollectionCommon::KeySizeValue) |
436 else if(sRole == VideoCollectionCommon::KeySizeValue || |
|
437 sRole == VideoCollectionCommon::KeyNumberOfItems) |
391 { |
438 { |
392 quint32 leftSize = leftData.toUInt(); |
439 quint32 leftSize = leftData.toUInt(); |
393 quint32 rightSize = rightData.toUInt(); |
440 quint32 rightSize = rightData.toUInt(); |
394 return leftSize < rightSize; |
441 return leftSize < rightSize; |
395 } |
442 } |
422 if(id == TMPXItemId::InvalidId()) |
471 if(id == TMPXItemId::InvalidId()) |
423 { |
472 { |
424 return false; |
473 return false; |
425 } |
474 } |
426 |
475 |
427 if (mType == VideoCollectionWrapper::EAllVideos) |
476 if (mType == VideoCollectionCommon::EModelTypeAllVideos) |
428 { |
477 { |
429 if(id.iId2 == KVcxMvcMediaTypeVideo) |
478 if(id.iId2 == KVcxMvcMediaTypeVideo) |
430 { |
479 { |
431 return true; |
480 return true; |
432 } |
481 } |
433 } |
482 } |
434 else if(mType == VideoCollectionWrapper::ECollections) |
483 else if(mType == VideoCollectionCommon::EModelTypeCollections) |
435 { |
484 { |
436 if(mLevel == VideoCollectionCommon::ELevelCategory && id.iId2 != KVcxMvcMediaTypeVideo) |
485 if(mLevel == VideoCollectionCommon::ELevelCategory && id.iId2 != KVcxMvcMediaTypeVideo) |
437 { |
486 { |
438 return true; |
487 return true; |
439 } |
488 } |
440 } |
489 } |
441 else if (mType == VideoCollectionWrapper::ECollectionContent) |
490 else if (mType == VideoCollectionCommon::EModelTypeCollectionContent) |
442 { |
491 { |
443 // if item belongs to the open album, accept it |
492 // if item belongs to the open album, accept it |
444 if (mModel->belongsToAlbum(id)) |
493 if (mModel->belongsToAlbum(id)) |
445 { |
494 { |
446 return true; |
495 return true; |
447 } |
496 } |
448 } |
497 } |
449 else if(mType == VideoCollectionWrapper::EGeneric) |
498 else if(mType == VideoCollectionCommon::EModelTypeGeneric) |
450 { |
499 { |
451 if(mLevel == VideoCollectionCommon::ELevelVideos && id.iId2 == KVcxMvcMediaTypeVideo) |
500 if(mLevel == VideoCollectionCommon::ELevelVideos && id.iId2 == KVcxMvcMediaTypeVideo) |
452 { |
501 { |
453 // filter items that belong to that album setted as filter id |
502 // filter items that belong to that album setted as filter id |
454 // if there's no filter or setted filter is "all videos", we accept everything |
503 // if there's no filter or setted filter is "all videos", we accept everything |
567 // ----------------------------------------------------------------------------- |
617 // ----------------------------------------------------------------------------- |
568 // |
618 // |
569 QString VideoSortFilterProxyModel::resolveAlbumName( |
619 QString VideoSortFilterProxyModel::resolveAlbumName( |
570 const QString& albumName) const |
620 const QString& albumName) const |
571 { |
621 { |
|
622 FUNC_LOG_ADDR(this); |
572 QString resolvedName = albumName.trimmed(); |
623 QString resolvedName = albumName.trimmed(); |
573 |
624 |
574 // for checking names, we need to use collection list proxy model |
625 // for checking names, we need to use collection list proxy model |
575 // to get all existing album names including default ones |
626 // to get all existing album names including default ones |
576 VideoSortFilterProxyModel *collectionModel = |
627 VideoSortFilterProxyModel *collectionModel = |
577 VideoCollectionWrapper::instance().getModel( |
628 VideoCollectionWrapper::instance().getModel( |
578 VideoCollectionWrapper::ECollections); |
629 VideoCollectionCommon::EModelTypeCollections); |
579 if(!collectionModel || !mModel) |
630 if(!collectionModel || !mModel) |
580 { |
631 { |
581 return resolvedName; |
632 return resolvedName; |
582 } |
633 } |
583 |
634 |
634 // ----------------------------------------------------------------------------- |
685 // ----------------------------------------------------------------------------- |
635 // |
686 // |
636 int VideoSortFilterProxyModel::removeItemsFromAlbum(TMPXItemId &albumId, |
687 int VideoSortFilterProxyModel::removeItemsFromAlbum(TMPXItemId &albumId, |
637 const QList<TMPXItemId> &mediaIds) |
688 const QList<TMPXItemId> &mediaIds) |
638 { |
689 { |
|
690 FUNC_LOG_ADDR(this); |
639 int err(-1); |
691 int err(-1); |
640 |
692 |
641 if (mModel) |
693 if (mModel) |
642 { |
694 { |
643 // remove items in album |
695 // remove items in album |
644 err = mModel->removeItemsFromAlbum(albumId, mediaIds); |
696 err = mModel->removeItemsFromAlbum(albumId, mediaIds); |
645 if(err > 0) |
697 if(err > 0) |
646 { |
698 { |
647 // if there really were items to be removed, invalid filter |
699 // if there really were items to be removed, invalid filter |
|
700 INFO_1("VideoSortFilterProxyModel::removeItemsFromAlbum() [0x%x] items removed, invaliding.", this); |
648 invalidateFilter(); |
701 invalidateFilter(); |
649 err = 0; |
702 err = 0; |
650 } |
703 } |
651 } |
704 } |
652 return err; |
705 return err; |
653 } |
706 } |
654 |
707 |
655 // ----------------------------------------------------------------------------- |
708 // ----------------------------------------------------------------------------- |
|
709 // VideoSortFilterProxyModel::renameAlbum() |
|
710 // ----------------------------------------------------------------------------- |
|
711 // |
|
712 int VideoSortFilterProxyModel::renameAlbum(const TMPXItemId &albumId, const QString &newTitle) |
|
713 { |
|
714 FUNC_LOG_ADDR(this); |
|
715 int err(-1); |
|
716 |
|
717 if(mCollectionClient) |
|
718 { |
|
719 return mCollectionClient->renameAlbum(albumId, newTitle); |
|
720 } |
|
721 return err; |
|
722 } |
|
723 |
|
724 // ----------------------------------------------------------------------------- |
656 // VideoSortFilterProxyModel::getOpenItem() |
725 // VideoSortFilterProxyModel::getOpenItem() |
657 // ----------------------------------------------------------------------------- |
726 // ----------------------------------------------------------------------------- |
658 // |
727 // |
659 TMPXItemId VideoSortFilterProxyModel::getOpenItem() const |
728 TMPXItemId VideoSortFilterProxyModel::getOpenItem() const |
660 { |
729 { |
|
730 FUNC_LOG_ADDR(this); |
661 TMPXItemId itemId = TMPXItemId::InvalidId(); |
731 TMPXItemId itemId = TMPXItemId::InvalidId(); |
662 |
732 |
663 if(mModel && mCollectionClient) |
733 if(mModel && mCollectionClient) |
664 { |
734 { |
665 if(mType == VideoCollectionWrapper::EAllVideos) |
735 if(mType == VideoCollectionCommon::EModelTypeAllVideos) |
666 { |
736 { |
|
737 INFO_1("VideoSortFilterProxyModel::getOpenItem() [0x%x] all videos is open.", this); |
667 itemId.iId1 = KVcxMvcCategoryIdAll; |
738 itemId.iId1 = KVcxMvcCategoryIdAll; |
668 itemId.iId2 = KVcxMvcMediaTypeCategory; |
739 itemId.iId2 = KVcxMvcMediaTypeCategory; |
669 } |
740 } |
670 else if(mType == VideoCollectionWrapper::ECollectionContent) |
741 else if(mType == VideoCollectionCommon::EModelTypeCollectionContent) |
671 { |
742 { |
|
743 INFO_1("VideoSortFilterProxyModel::getOpenItem() [0x%x] category or album is open.", this); |
672 itemId = mModel->albumInUse(); |
744 itemId = mModel->albumInUse(); |
673 } |
745 } |
674 } |
746 } |
675 |
747 |
676 return itemId; |
748 return itemId; |
680 // VideoSortFilterProxyModel::setGenericIdFilter() |
752 // VideoSortFilterProxyModel::setGenericIdFilter() |
681 // ----------------------------------------------------------------------------- |
753 // ----------------------------------------------------------------------------- |
682 // |
754 // |
683 void VideoSortFilterProxyModel::setGenericIdFilter(TMPXItemId itemId, bool filterValue) |
755 void VideoSortFilterProxyModel::setGenericIdFilter(TMPXItemId itemId, bool filterValue) |
684 { |
756 { |
685 if(mType == VideoCollectionWrapper::EGeneric) |
757 FUNC_LOG_ADDR(this); |
686 { |
758 if(mType == VideoCollectionCommon::EModelTypeGeneric) |
|
759 { |
|
760 INFO_3("VideoSortFilterProxyModel::setGenericIdFilter() [0x%x] itemId.iId2: %d, filterValue: %d", this, itemId.iId2, filterValue); |
687 mGenericFilterId = itemId; |
761 mGenericFilterId = itemId; |
688 mGenericFilterValue = filterValue; |
762 mGenericFilterValue = filterValue; |
|
763 INFO_1("VideoSortFilterProxyModel::setGenericIdFilter() [0x%x] invalidating.", this); |
689 invalidateFilter(); |
764 invalidateFilter(); |
690 } |
765 } |
691 } |
766 } |
692 |
767 |
693 // ----------------------------------------------------------------------------- |
768 // ----------------------------------------------------------------------------- |
694 // VideoSortFilterProxyModel::setAlbumInUse() |
769 // VideoSortFilterProxyModel::setAlbumInUse() |
695 // ----------------------------------------------------------------------------- |
770 // ----------------------------------------------------------------------------- |
696 // |
771 // |
697 void VideoSortFilterProxyModel::setAlbumInUse(TMPXItemId albumId) |
772 void VideoSortFilterProxyModel::setAlbumInUse(TMPXItemId albumId) |
698 { |
773 { |
699 mModel->setAlbumInUse(albumId); |
774 FUNC_LOG_ADDR(this); |
700 invalidateFilter(); |
775 if(mModel) |
|
776 { |
|
777 INFO_1("VideoSortFilterProxyModel::setAlbumInUse() [0x%x] invalidating.", this); |
|
778 mModel->setAlbumInUse(albumId); |
|
779 invalidateFilter(); |
|
780 } |
701 } |
781 } |
702 |
782 |
703 // ----------------------------------------------------------------------------- |
783 // ----------------------------------------------------------------------------- |
704 // VideoSortFilterProxyModel::albumChangedSlot() |
784 // VideoSortFilterProxyModel::albumChangedSlot() |
705 // ----------------------------------------------------------------------------- |
785 // ----------------------------------------------------------------------------- |
706 // |
786 // |
707 void VideoSortFilterProxyModel::albumChangedSlot() |
787 void VideoSortFilterProxyModel::albumChangedSlot() |
708 { |
788 { |
|
789 FUNC_LOG_ADDR(this); |
709 // ignore if not collection content model |
790 // ignore if not collection content model |
710 if (mType == VideoCollectionWrapper::ECollectionContent) |
791 if (mType == VideoCollectionCommon::EModelTypeCollectionContent) |
711 { |
792 { |
712 invalidateFilter(); |
793 INFO_1("VideoSortFilterProxyModel::albumChangedSlot() [0x%x] invalidating.", this); |
713 } |
794 //otherwise newle created album content won't sort |
714 } |
795 setSortRole(mWantedSortRole); |
715 |
796 sort(0, mWantedSortOrder); |
716 // end of file |
797 invalidateFilter(); |
717 |
798 } |
|
799 } |
|
800 |
|
801 // ----------------------------------------------------------------------------- |
|
802 // VideoSortFilterProxyModel::itemModifiedSlot() |
|
803 // ----------------------------------------------------------------------------- |
|
804 // |
|
805 void VideoSortFilterProxyModel::itemModifiedSlot(const TMPXItemId &itemId) |
|
806 { |
|
807 FUNC_LOG_ADDR(this); |
|
808 if(mType == VideoCollectionCommon::EModelTypeCollections && |
|
809 (itemId.iId2 == KVcxMvcMediaTypeAlbum || itemId.iId2 == KVcxMvcMediaTypeCategory)) |
|
810 { |
|
811 INFO_1("VideoSortFilterProxyModel::itemModifiedSlot() [0x%x] invalidating.", this); |
|
812 invalidate(); |
|
813 } |
|
814 } |
|
815 |
|
816 // ----------------------------------------------------------------------------- |
|
817 // VideoSortFilterProxyModel::getType() |
|
818 // ----------------------------------------------------------------------------- |
|
819 // |
|
820 VideoCollectionCommon::TModelType VideoSortFilterProxyModel::getType() |
|
821 { |
|
822 FUNC_LOG_ADDR(this); |
|
823 return mType; |
|
824 } |
|
825 |
|
826 // End of file |