diff -r bbb98528c666 -r 3738fe97f027 videocollection/videocollectionwrapper/src/videosortfilterproxymodel.cpp --- a/videocollection/videocollectionwrapper/src/videosortfilterproxymodel.cpp Thu Apr 01 23:22:15 2010 +0300 +++ b/videocollection/videocollectionwrapper/src/videosortfilterproxymodel.cpp Thu Apr 01 23:32:44 2010 +0300 @@ -33,15 +33,15 @@ // ----------------------------------------------------------------------------- // VideoSortFilterProxyModel::VideoSortFilterProxyModel(int type, QObject *parent) : - QSortFilterProxyModel(parent), - mModel(0), - mCollectionClient(0), - mType(type), - mLevel(-1), - mGenericFilterId(TMPXItemId::InvalidId()), +QSortFilterProxyModel(parent), +mModel(0), +mCollectionClient(0), +mType(type), +mLevel(-1), +mGenericFilterId(TMPXItemId::InvalidId()), mGenericFilterValue(false), - mIdleSortTimer(0), - mWantedSortRole(VideoCollectionCommon::KeyDateTime) +mIdleSortTimer(0), +mWantedSortRole(VideoCollectionCommon::KeyDateTime) { // NOP } @@ -87,12 +87,6 @@ // bool VideoSortFilterProxyModel::connectSignals() { - if(!connect(mModel, SIGNAL(fullVideoDetailsReady(TMPXItemId)), - this, SIGNAL(fullDetailsReady(TMPXItemId)))) - { - return false; - } - if(!connect(mModel, SIGNAL(modelReady()), this, SIGNAL(modelReady()))) { @@ -103,10 +97,13 @@ { return false; } - if(!connect(mModel, SIGNAL(albumChanged()), - this, SLOT(albumChangedSlot()))) + if(mType == VideoCollectionWrapper::ECollectionContent) { - return false; + if(!connect(mModel, SIGNAL(albumChanged()), + this, SLOT(albumChangedSlot()))) + { + return false; + } } return true; } @@ -117,11 +114,13 @@ // void VideoSortFilterProxyModel::disconnectSignals() { - disconnect(mModel, SIGNAL(fullVideoDetailsReady(TMPXItemId)), - this, SIGNAL(fullDetailsReady(TMPXItemId))); - disconnect(mModel, SIGNAL(modelReady()), this, SIGNAL(modelReady())); + disconnect(mModel, SIGNAL(modelReady()), this, SIGNAL(modelReady())); disconnect(mModel, SIGNAL(modelChanged()), this, SIGNAL(modelChanged())); - disconnect(mModel, SIGNAL(albumChanged()), this, SLOT(albumChangedSlot())); + if(mType == VideoCollectionWrapper::ECollectionContent) + { + disconnect(mModel, SIGNAL(albumChanged()), this, SLOT(albumChangedSlot())); + } + } // ----------------------------------------------------------------------------- @@ -137,7 +136,7 @@ if(mLevel != level) { - mLevel = level; + mLevel = level; invalidateFilter(); } // need to call open every time to make sure all items are @@ -213,7 +212,6 @@ { // Start fetching thumbnails at start of the model. VideoThumbnailData::instance().startBackgroundFetching(0, 0); - return 0; } } @@ -228,8 +226,6 @@ { if(mediaId != TMPXItemId::InvalidId() && mCollectionClient) { - mModel->setAlbumInUse(TMPXItemId::InvalidId()); - if(mCollectionClient->openItem(mediaId) == 0) { if(mediaId.iId2 != KVcxMvcMediaTypeVideo) @@ -250,10 +246,8 @@ // int VideoSortFilterProxyModel::back() { - if(mCollectionClient && mCollectionClient->back() == 0) { - if(mLevel == VideoCollectionCommon::ELevelAlbum) { mLevel = VideoCollectionCommon::ELevelCategory; @@ -264,7 +258,6 @@ } return 0; } - return -1; } @@ -414,10 +407,10 @@ // VideoSortFilterProxyModel::filterAcceptsRow // ----------------------------------------------------------------------------- // -bool VideoSortFilterProxyModel::filterAcceptsRow (int source_row, const QModelIndex &source_parent) const +bool VideoSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { Q_UNUSED(source_parent); - + if(!sourceModel()) return false; @@ -440,7 +433,6 @@ } else if(mType == VideoCollectionWrapper::ECollections) { - if(mLevel == VideoCollectionCommon::ELevelCategory && id.iId2 != KVcxMvcMediaTypeVideo) { return true; @@ -456,7 +448,6 @@ } else if(mType == VideoCollectionWrapper::EGeneric) { - if(mLevel == VideoCollectionCommon::ELevelVideos && id.iId2 == KVcxMvcMediaTypeVideo) { // filter items that belong to that album setted as filter id @@ -624,7 +615,7 @@ // VideoSortFilterProxyModel::addItemsInAlbum() // ----------------------------------------------------------------------------- // -int VideoSortFilterProxyModel::addItemsInAlbum(TMPXItemId albumId, +int VideoSortFilterProxyModel::addItemsInAlbum(TMPXItemId &albumId, const QList &mediaIds) { int err(-1); @@ -639,6 +630,29 @@ } // ----------------------------------------------------------------------------- +// VideoSortFilterProxyModel::removeItemsFromAlbum() +// ----------------------------------------------------------------------------- +// +int VideoSortFilterProxyModel::removeItemsFromAlbum(TMPXItemId &albumId, + const QList &mediaIds) +{ + int err(-1); + + if (mModel) + { + // remove items in album + err = mModel->removeItemsFromAlbum(albumId, mediaIds); + if(err > 0) + { + // if there really were items to be removed, invalid filter + invalidateFilter(); + err = 0; + } + } + return err; +} + +// ----------------------------------------------------------------------------- // VideoSortFilterProxyModel::getOpenItem() // ----------------------------------------------------------------------------- // @@ -677,6 +691,16 @@ } // ----------------------------------------------------------------------------- +// VideoSortFilterProxyModel::setAlbumInUse() +// ----------------------------------------------------------------------------- +// +void VideoSortFilterProxyModel::setAlbumInUse(TMPXItemId albumId) +{ + mModel->setAlbumInUse(albumId); + invalidateFilter(); +} + +// ----------------------------------------------------------------------------- // VideoSortFilterProxyModel::albumChangedSlot() // ----------------------------------------------------------------------------- //