31 // ----------------------------------------------------------------------------- |
31 // ----------------------------------------------------------------------------- |
32 // VideoSortFilterProxyModel::VideoSortFilterProxyModel |
32 // VideoSortFilterProxyModel::VideoSortFilterProxyModel |
33 // ----------------------------------------------------------------------------- |
33 // ----------------------------------------------------------------------------- |
34 // |
34 // |
35 VideoSortFilterProxyModel::VideoSortFilterProxyModel(int type, QObject *parent) : |
35 VideoSortFilterProxyModel::VideoSortFilterProxyModel(int type, QObject *parent) : |
36 QSortFilterProxyModel(parent), |
36 QSortFilterProxyModel(parent), |
37 mModel(0), |
37 mModel(0), |
38 mCollectionClient(0), |
38 mCollectionClient(0), |
39 mType(type), |
39 mType(type), |
40 mLevel(-1), |
40 mLevel(-1), |
41 mGenericFilterId(TMPXItemId::InvalidId()), |
41 mGenericFilterId(TMPXItemId::InvalidId()), |
42 mGenericFilterValue(false), |
42 mGenericFilterValue(false), |
43 mIdleSortTimer(0), |
43 mIdleSortTimer(0), |
44 mWantedSortRole(VideoCollectionCommon::KeyDateTime) |
44 mWantedSortRole(VideoCollectionCommon::KeyDateTime) |
45 { |
45 { |
46 // NOP |
46 // NOP |
47 } |
47 } |
48 |
48 |
49 // ----------------------------------------------------------------------------- |
49 // ----------------------------------------------------------------------------- |
85 // VideoSortFilterProxyModel::connectSignals |
85 // VideoSortFilterProxyModel::connectSignals |
86 // ----------------------------------------------------------------------------- |
86 // ----------------------------------------------------------------------------- |
87 // |
87 // |
88 bool VideoSortFilterProxyModel::connectSignals() |
88 bool VideoSortFilterProxyModel::connectSignals() |
89 { |
89 { |
90 if(!connect(mModel, SIGNAL(fullVideoDetailsReady(TMPXItemId)), |
|
91 this, SIGNAL(fullDetailsReady(TMPXItemId)))) |
|
92 { |
|
93 return false; |
|
94 } |
|
95 |
|
96 if(!connect(mModel, SIGNAL(modelReady()), |
90 if(!connect(mModel, SIGNAL(modelReady()), |
97 this, SIGNAL(modelReady()))) |
91 this, SIGNAL(modelReady()))) |
98 { |
92 { |
99 return false; |
93 return false; |
100 } |
94 } |
101 if(!connect(mModel, SIGNAL(modelChanged()), |
95 if(!connect(mModel, SIGNAL(modelChanged()), |
102 this, SIGNAL(modelChanged()))) |
96 this, SIGNAL(modelChanged()))) |
103 { |
97 { |
104 return false; |
98 return false; |
105 } |
99 } |
106 if(!connect(mModel, SIGNAL(albumChanged()), |
100 if(mType == VideoCollectionWrapper::ECollectionContent) |
107 this, SLOT(albumChangedSlot()))) |
101 { |
108 { |
102 if(!connect(mModel, SIGNAL(albumChanged()), |
109 return false; |
103 this, SLOT(albumChangedSlot()))) |
|
104 { |
|
105 return false; |
|
106 } |
110 } |
107 } |
111 return true; |
108 return true; |
112 } |
109 } |
113 |
110 |
114 // ----------------------------------------------------------------------------- |
111 // ----------------------------------------------------------------------------- |
115 // VideoSortFilterProxyModel::disconnectSignals |
112 // VideoSortFilterProxyModel::disconnectSignals |
116 // ----------------------------------------------------------------------------- |
113 // ----------------------------------------------------------------------------- |
117 // |
114 // |
118 void VideoSortFilterProxyModel::disconnectSignals() |
115 void VideoSortFilterProxyModel::disconnectSignals() |
119 { |
116 { |
120 disconnect(mModel, SIGNAL(fullVideoDetailsReady(TMPXItemId)), |
117 disconnect(mModel, SIGNAL(modelReady()), this, SIGNAL(modelReady())); |
121 this, SIGNAL(fullDetailsReady(TMPXItemId))); |
|
122 disconnect(mModel, SIGNAL(modelReady()), this, SIGNAL(modelReady())); |
|
123 disconnect(mModel, SIGNAL(modelChanged()), this, SIGNAL(modelChanged())); |
118 disconnect(mModel, SIGNAL(modelChanged()), this, SIGNAL(modelChanged())); |
124 disconnect(mModel, SIGNAL(albumChanged()), this, SLOT(albumChangedSlot())); |
119 if(mType == VideoCollectionWrapper::ECollectionContent) |
|
120 { |
|
121 disconnect(mModel, SIGNAL(albumChanged()), this, SLOT(albumChangedSlot())); |
|
122 } |
|
123 |
125 } |
124 } |
126 |
125 |
127 // ----------------------------------------------------------------------------- |
126 // ----------------------------------------------------------------------------- |
128 // VideoSortFilterProxyModel::open |
127 // VideoSortFilterProxyModel::open |
129 // ----------------------------------------------------------------------------- |
128 // ----------------------------------------------------------------------------- |
248 // VideoSortFilterProxyModel::back |
244 // VideoSortFilterProxyModel::back |
249 // ----------------------------------------------------------------------------- |
245 // ----------------------------------------------------------------------------- |
250 // |
246 // |
251 int VideoSortFilterProxyModel::back() |
247 int VideoSortFilterProxyModel::back() |
252 { |
248 { |
253 |
|
254 if(mCollectionClient && mCollectionClient->back() == 0) |
249 if(mCollectionClient && mCollectionClient->back() == 0) |
255 { |
250 { |
256 |
|
257 if(mLevel == VideoCollectionCommon::ELevelAlbum) |
251 if(mLevel == VideoCollectionCommon::ELevelAlbum) |
258 { |
252 { |
259 mLevel = VideoCollectionCommon::ELevelCategory; |
253 mLevel = VideoCollectionCommon::ELevelCategory; |
260 } |
254 } |
261 else |
255 else |
262 { |
256 { |
263 mLevel = VideoCollectionCommon::ELevelVideos; |
257 mLevel = VideoCollectionCommon::ELevelVideos; |
264 } |
258 } |
265 return 0; |
259 return 0; |
266 } |
260 } |
267 |
|
268 return -1; |
261 return -1; |
269 } |
262 } |
270 |
263 |
271 // ----------------------------------------------------------------------------- |
264 // ----------------------------------------------------------------------------- |
272 // VideoSortFilterProxyModel::fetchItemDetails |
265 // VideoSortFilterProxyModel::fetchItemDetails |
412 |
405 |
413 // ----------------------------------------------------------------------------- |
406 // ----------------------------------------------------------------------------- |
414 // VideoSortFilterProxyModel::filterAcceptsRow |
407 // VideoSortFilterProxyModel::filterAcceptsRow |
415 // ----------------------------------------------------------------------------- |
408 // ----------------------------------------------------------------------------- |
416 // |
409 // |
417 bool VideoSortFilterProxyModel::filterAcceptsRow (int source_row, const QModelIndex &source_parent) const |
410 bool VideoSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const |
418 { |
411 { |
419 Q_UNUSED(source_parent); |
412 Q_UNUSED(source_parent); |
420 |
413 |
421 if(!sourceModel()) |
414 if(!sourceModel()) |
422 return false; |
415 return false; |
423 |
416 |
424 if(source_row < 0 || source_row >= sourceModel()->rowCount()) |
417 if(source_row < 0 || source_row >= sourceModel()->rowCount()) |
425 { |
418 { |
622 |
613 |
623 // ----------------------------------------------------------------------------- |
614 // ----------------------------------------------------------------------------- |
624 // VideoSortFilterProxyModel::addItemsInAlbum() |
615 // VideoSortFilterProxyModel::addItemsInAlbum() |
625 // ----------------------------------------------------------------------------- |
616 // ----------------------------------------------------------------------------- |
626 // |
617 // |
627 int VideoSortFilterProxyModel::addItemsInAlbum(TMPXItemId albumId, |
618 int VideoSortFilterProxyModel::addItemsInAlbum(TMPXItemId &albumId, |
628 const QList<TMPXItemId> &mediaIds) |
619 const QList<TMPXItemId> &mediaIds) |
629 { |
620 { |
630 int err(-1); |
621 int err(-1); |
631 |
622 |
632 if (mCollectionClient) |
623 if (mCollectionClient) |
637 |
628 |
638 return err; |
629 return err; |
639 } |
630 } |
640 |
631 |
641 // ----------------------------------------------------------------------------- |
632 // ----------------------------------------------------------------------------- |
|
633 // VideoSortFilterProxyModel::removeItemsFromAlbum() |
|
634 // ----------------------------------------------------------------------------- |
|
635 // |
|
636 int VideoSortFilterProxyModel::removeItemsFromAlbum(TMPXItemId &albumId, |
|
637 const QList<TMPXItemId> &mediaIds) |
|
638 { |
|
639 int err(-1); |
|
640 |
|
641 if (mModel) |
|
642 { |
|
643 // remove items in album |
|
644 err = mModel->removeItemsFromAlbum(albumId, mediaIds); |
|
645 if(err > 0) |
|
646 { |
|
647 // if there really were items to be removed, invalid filter |
|
648 invalidateFilter(); |
|
649 err = 0; |
|
650 } |
|
651 } |
|
652 return err; |
|
653 } |
|
654 |
|
655 // ----------------------------------------------------------------------------- |
642 // VideoSortFilterProxyModel::getOpenItem() |
656 // VideoSortFilterProxyModel::getOpenItem() |
643 // ----------------------------------------------------------------------------- |
657 // ----------------------------------------------------------------------------- |
644 // |
658 // |
645 TMPXItemId VideoSortFilterProxyModel::getOpenItem() const |
659 TMPXItemId VideoSortFilterProxyModel::getOpenItem() const |
646 { |
660 { |
675 invalidateFilter(); |
689 invalidateFilter(); |
676 } |
690 } |
677 } |
691 } |
678 |
692 |
679 // ----------------------------------------------------------------------------- |
693 // ----------------------------------------------------------------------------- |
|
694 // VideoSortFilterProxyModel::setAlbumInUse() |
|
695 // ----------------------------------------------------------------------------- |
|
696 // |
|
697 void VideoSortFilterProxyModel::setAlbumInUse(TMPXItemId albumId) |
|
698 { |
|
699 mModel->setAlbumInUse(albumId); |
|
700 invalidateFilter(); |
|
701 } |
|
702 |
|
703 // ----------------------------------------------------------------------------- |
680 // VideoSortFilterProxyModel::albumChangedSlot() |
704 // VideoSortFilterProxyModel::albumChangedSlot() |
681 // ----------------------------------------------------------------------------- |
705 // ----------------------------------------------------------------------------- |
682 // |
706 // |
683 void VideoSortFilterProxyModel::albumChangedSlot() |
707 void VideoSortFilterProxyModel::albumChangedSlot() |
684 { |
708 { |