# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1284701405 -10800 # Node ID 0e1e938beb1af155807a8471b6767eee07084d4b # Parent a76e86df7ccd4b0f6a7e1b3b0284df1a47f41e8f Revision: 201035 Kit: 201037 diff -r a76e86df7ccd -r 0e1e938beb1a package_definition.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/package_definition.xml Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r a76e86df7ccd -r 0e1e938beb1a package_map.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/package_map.xml Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,1 @@ + diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/bwins/videocollectionwrapperu.def --- a/videocollection/bwins/videocollectionwrapperu.def Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/bwins/videocollectionwrapperu.def Fri Sep 17 08:30:05 2010 +0300 @@ -1,82 +1,82 @@ EXPORTS ?sendAsyncStatus@VideoCollectionWrapper@@QAEXHAAVQVariant@@@Z @ 1 NONAME ; void VideoCollectionWrapper::sendAsyncStatus(int, class QVariant &) - ??1VideoSortFilterProxyModel@@UAE@XZ @ 2 NONAME ; VideoSortFilterProxyModel::~VideoSortFilterProxyModel(void) - ?open@VideoSortFilterProxyModel@@QAEHW4TCollectionLevels@VideoCollectionCommon@@@Z @ 3 NONAME ; int VideoSortFilterProxyModel::open(enum VideoCollectionCommon::TCollectionLevels) - ?deleteItems@VideoSortFilterProxyModel@@QAEHABV?$QList@VQModelIndex@@@@@Z @ 4 NONAME ; int VideoSortFilterProxyModel::deleteItems(class QList const &) - ?trUtf8@VideoThumbnailData@@SA?AVQString@@PBD0@Z @ 5 NONAME ; class QString VideoThumbnailData::trUtf8(char const *, char const *) - ?removeItemsFromAlbum@VideoSortFilterProxyModel@@QAEHAAVTMPXItemId@@ABV?$QList@VTMPXItemId@@@@@Z @ 6 NONAME ; int VideoSortFilterProxyModel::removeItemsFromAlbum(class TMPXItemId &, class QList const &) - ?instance@VideoCollectionWrapper@@SAAAV1@XZ @ 7 NONAME ; class VideoCollectionWrapper & VideoCollectionWrapper::instance(void) - ?back@VideoSortFilterProxyModel@@QAEHXZ @ 8 NONAME ; int VideoSortFilterProxyModel::back(void) - ?modelReady@VideoSortFilterProxyModel@@IAEXXZ @ 9 NONAME ; void VideoSortFilterProxyModel::modelReady(void) - ?albumChangedSlot@VideoSortFilterProxyModel@@AAEXXZ @ 10 NONAME ; void VideoSortFilterProxyModel::albumChangedSlot(void) - ?qt_metacall@VideoThumbnailData@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 11 NONAME ; int VideoThumbnailData::qt_metacall(enum QMetaObject::Call, int, void * *) - ?backgroundFetchingEnabled@VideoThumbnailData@@QAE_NXZ @ 12 NONAME ; bool VideoThumbnailData::backgroundFetchingEnabled(void) - ??1VideoThumbnailData@@EAE@XZ @ 13 NONAME ; VideoThumbnailData::~VideoThumbnailData(void) - ??_EVideoThumbnailData@@UAE@I@Z @ 14 NONAME ; VideoThumbnailData::~VideoThumbnailData(unsigned int) - ?qt_metacast@VideoCollectionWrapper@@UAEPAXPBD@Z @ 15 NONAME ; void * VideoCollectionWrapper::qt_metacast(char const *) - ?addItemsInAlbum@VideoSortFilterProxyModel@@QAEHAAVTMPXItemId@@ABV?$QList@VTMPXItemId@@@@@Z @ 16 NONAME ; int VideoSortFilterProxyModel::addItemsInAlbum(class TMPXItemId &, class QList const &) - ?tr@VideoSortFilterProxyModel@@SA?AVQString@@PBD0H@Z @ 17 NONAME ; class QString VideoSortFilterProxyModel::tr(char const *, char const *, int) - ?getMediaIdAtIndex@VideoSortFilterProxyModel@@QBEABVTMPXItemId@@ABVQModelIndex@@@Z @ 18 NONAME ; class TMPXItemId const & VideoSortFilterProxyModel::getMediaIdAtIndex(class QModelIndex const &) const - ?removeAlbums@VideoSortFilterProxyModel@@QAEHABV?$QList@VQModelIndex@@@@@Z @ 19 NONAME ; int VideoSortFilterProxyModel::removeAlbums(class QList const &) - ?instance@VideoThumbnailData@@SAAAV1@XZ @ 20 NONAME ; class VideoThumbnailData & VideoThumbnailData::instance(void) - ?getType@VideoSortFilterProxyModel@@QAE?AW4TModelType@VideoCollectionCommon@@XZ @ 21 NONAME ; enum VideoCollectionCommon::TModelType VideoSortFilterProxyModel::getType(void) - ?fetchItemDetails@VideoSortFilterProxyModel@@QAEHABVQModelIndex@@@Z @ 22 NONAME ; int VideoSortFilterProxyModel::fetchItemDetails(class QModelIndex const &) - ??0VideoCollectionWrapper@@AAE@XZ @ 23 NONAME ; VideoCollectionWrapper::VideoCollectionWrapper(void) - ?metaObject@VideoSortFilterProxyModel@@UBEPBUQMetaObject@@XZ @ 24 NONAME ; struct QMetaObject const * VideoSortFilterProxyModel::metaObject(void) const - ?metaObject@VideoCollectionWrapper@@UBEPBUQMetaObject@@XZ @ 25 NONAME ; struct QMetaObject const * VideoCollectionWrapper::metaObject(void) const - ?lessThan@VideoSortFilterProxyModel@@MBE_NABVQModelIndex@@0@Z @ 26 NONAME ; bool VideoSortFilterProxyModel::lessThan(class QModelIndex const &, class QModelIndex const &) const - ?getStaticMetaObject@VideoCollectionWrapper@@SAABUQMetaObject@@XZ @ 27 NONAME ; struct QMetaObject const & VideoCollectionWrapper::getStaticMetaObject(void) - ?getStaticMetaObject@VideoSortFilterProxyModel@@SAABUQMetaObject@@XZ @ 28 NONAME ; struct QMetaObject const & VideoSortFilterProxyModel::getStaticMetaObject(void) - ?trUtf8@VideoSortFilterProxyModel@@SA?AVQString@@PBD0@Z @ 29 NONAME ; class QString VideoSortFilterProxyModel::trUtf8(char const *, char const *) - ?doSorting@VideoSortFilterProxyModel@@QAEXHW4SortOrder@Qt@@_N@Z @ 30 NONAME ; void VideoSortFilterProxyModel::doSorting(int, enum Qt::SortOrder, bool) - ?getOpenItem@VideoSortFilterProxyModel@@QBE?AVTMPXItemId@@XZ @ 31 NONAME ; class TMPXItemId VideoSortFilterProxyModel::getOpenItem(void) const - ?startBackgroundFetching@VideoThumbnailData@@QAEXPAVVideoSortFilterProxyModel@@H@Z @ 32 NONAME ; void VideoThumbnailData::startBackgroundFetching(class VideoSortFilterProxyModel *, int) - ??_EVideoCollectionWrapper@@UAE@I@Z @ 33 NONAME ; VideoCollectionWrapper::~VideoCollectionWrapper(unsigned int) - ?resolveAlbumName@VideoSortFilterProxyModel@@QBE?AVQString@@ABV2@@Z @ 34 NONAME ; class QString VideoSortFilterProxyModel::resolveAlbumName(class QString const &) const - ?getThumbnail@VideoThumbnailData@@QAEPBVQIcon@@ABVTMPXItemId@@@Z @ 35 NONAME ; class QIcon const * VideoThumbnailData::getThumbnail(class TMPXItemId const &) - ?getStaticMetaObject@VideoThumbnailData@@SAABUQMetaObject@@XZ @ 36 NONAME ; struct QMetaObject const & VideoThumbnailData::getStaticMetaObject(void) - ?qt_metacall@VideoCollectionWrapper@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 37 NONAME ; int VideoCollectionWrapper::qt_metacall(enum QMetaObject::Call, int, void * *) - ?trUtf8@VideoThumbnailData@@SA?AVQString@@PBD0H@Z @ 38 NONAME ; class QString VideoThumbnailData::trUtf8(char const *, char const *, int) - ?enableBackgroundFetching@VideoThumbnailData@@QAEX_N@Z @ 39 NONAME ; void VideoThumbnailData::enableBackgroundFetching(bool) - ?getMediaFilePathForId@VideoSortFilterProxyModel@@QAE?AVQString@@ABVTMPXItemId@@@Z @ 40 NONAME ; class QString VideoSortFilterProxyModel::getMediaFilePathForId(class TMPXItemId const &) - ?connectSignals@VideoSortFilterProxyModel@@AAE_NXZ @ 41 NONAME ; bool VideoSortFilterProxyModel::connectSignals(void) - ?getModel@VideoCollectionWrapper@@QAEPAVVideoSortFilterProxyModel@@W4TModelType@VideoCollectionCommon@@@Z @ 42 NONAME ; class VideoSortFilterProxyModel * VideoCollectionWrapper::getModel(enum VideoCollectionCommon::TModelType) - ?tr@VideoCollectionWrapper@@SA?AVQString@@PBD0H@Z @ 43 NONAME ; class QString VideoCollectionWrapper::tr(char const *, char const *, int) - ?staticMetaObject@VideoSortFilterProxyModel@@2UQMetaObject@@B @ 44 NONAME ; struct QMetaObject const VideoSortFilterProxyModel::staticMetaObject - ?tr@VideoSortFilterProxyModel@@SA?AVQString@@PBD0@Z @ 45 NONAME ; class QString VideoSortFilterProxyModel::tr(char const *, char const *) - ?asyncStatus@VideoCollectionWrapper@@IAEXHAAVQVariant@@@Z @ 46 NONAME ; void VideoCollectionWrapper::asyncStatus(int, class QVariant &) - ?initialize@VideoSortFilterProxyModel@@QAEHPAVVideoListDataModel@@@Z @ 47 NONAME ; int VideoSortFilterProxyModel::initialize(class VideoListDataModel *) - ?modelChanged@VideoSortFilterProxyModel@@IAEXXZ @ 48 NONAME ; void VideoSortFilterProxyModel::modelChanged(void) - ?removeThumbnail@VideoThumbnailData@@QAE_NABVTMPXItemId@@@Z @ 49 NONAME ; bool VideoThumbnailData::removeThumbnail(class TMPXItemId const &) - ?indexOfId@VideoSortFilterProxyModel@@QAE?AVQModelIndex@@ABVTMPXItemId@@@Z @ 50 NONAME ; class QModelIndex VideoSortFilterProxyModel::indexOfId(class TMPXItemId const &) - ?setGenericIdFilter@VideoSortFilterProxyModel@@QAEXABVTMPXItemId@@_N@Z @ 51 NONAME ; void VideoSortFilterProxyModel::setGenericIdFilter(class TMPXItemId const &, bool) - ?trUtf8@VideoCollectionWrapper@@SA?AVQString@@PBD0@Z @ 52 NONAME ; class QString VideoCollectionWrapper::trUtf8(char const *, char const *) - ?thumbnailsFetched@VideoThumbnailData@@IAEXAAV?$QList@VTMPXItemId@@@@@Z @ 53 NONAME ; void VideoThumbnailData::thumbnailsFetched(class QList &) - ?processSorting@VideoSortFilterProxyModel@@AAEXXZ @ 54 NONAME ; void VideoSortFilterProxyModel::processSorting(void) - ?getSorting@VideoSortFilterProxyModel@@QAEXAAHAAW4SortOrder@Qt@@@Z @ 55 NONAME ; void VideoSortFilterProxyModel::getSorting(int &, enum Qt::SortOrder &) - ?filterAcceptsRow@VideoSortFilterProxyModel@@MBE_NHABVQModelIndex@@@Z @ 56 NONAME ; bool VideoSortFilterProxyModel::filterAcceptsRow(int, class QModelIndex const &) const - ?metaObject@VideoThumbnailData@@UBEPBUQMetaObject@@XZ @ 57 NONAME ; struct QMetaObject const * VideoThumbnailData::metaObject(void) const - ?tr@VideoThumbnailData@@SA?AVQString@@PBD0H@Z @ 58 NONAME ; class QString VideoThumbnailData::tr(char const *, char const *, int) - ?disconnectSignals@VideoSortFilterProxyModel@@AAEXXZ @ 59 NONAME ; void VideoSortFilterProxyModel::disconnectSignals(void) - ?trUtf8@VideoSortFilterProxyModel@@SA?AVQString@@PBD0H@Z @ 60 NONAME ; class QString VideoSortFilterProxyModel::trUtf8(char const *, char const *, int) - ?openItem@VideoSortFilterProxyModel@@QAEHVTMPXItemId@@@Z @ 61 NONAME ; int VideoSortFilterProxyModel::openItem(class TMPXItemId) + ?doSorting@VideoProxyModelGeneric@@QAEXHW4SortOrder@Qt@@_N@Z @ 2 NONAME ; void VideoProxyModelGeneric::doSorting(int, enum Qt::SortOrder, bool) + ?addItemsInAlbum@VideoProxyModelGeneric@@QAEHAAVTMPXItemId@@ABV?$QList@VTMPXItemId@@@@@Z @ 3 NONAME ; int VideoProxyModelGeneric::addItemsInAlbum(class TMPXItemId &, class QList const &) + ?trUtf8@VideoThumbnailData@@SA?AVQString@@PBD0@Z @ 4 NONAME ; class QString VideoThumbnailData::trUtf8(char const *, char const *) + ?tr@VideoProxyModelGeneric@@SA?AVQString@@PBD0H@Z @ 5 NONAME ; class QString VideoProxyModelGeneric::tr(char const *, char const *, int) + ?instance@VideoCollectionWrapper@@SAAAV1@XZ @ 6 NONAME ; class VideoCollectionWrapper & VideoCollectionWrapper::instance(void) + ?qt_metacall@VideoThumbnailData@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 7 NONAME ; int VideoThumbnailData::qt_metacall(enum QMetaObject::Call, int, void * *) + ?backgroundFetchingEnabled@VideoThumbnailData@@QAE_NXZ @ 8 NONAME ; bool VideoThumbnailData::backgroundFetchingEnabled(void) + ?removeItemsFromAlbum@VideoProxyModelGeneric@@QAEHAAVTMPXItemId@@ABV?$QList@VTMPXItemId@@@@@Z @ 9 NONAME ; int VideoProxyModelGeneric::removeItemsFromAlbum(class TMPXItemId &, class QList const &) + ?openItem@VideoProxyModelGeneric@@UAEHVTMPXItemId@@@Z @ 10 NONAME ; int VideoProxyModelGeneric::openItem(class TMPXItemId) + ?getMediaIdAtIndex@VideoProxyModelGeneric@@QBEABVTMPXItemId@@ABVQModelIndex@@@Z @ 11 NONAME ; class TMPXItemId const & VideoProxyModelGeneric::getMediaIdAtIndex(class QModelIndex const &) const + ??1VideoThumbnailData@@EAE@XZ @ 12 NONAME ; VideoThumbnailData::~VideoThumbnailData(void) + ??_EVideoThumbnailData@@UAE@I@Z @ 13 NONAME ; VideoThumbnailData::~VideoThumbnailData(unsigned int) + ?shortDetailsReady@VideoProxyModelGeneric@@IAEXVTMPXItemId@@@Z @ 14 NONAME ; void VideoProxyModelGeneric::shortDetailsReady(class TMPXItemId) + ?fetchItemDetails@VideoProxyModelGeneric@@QAEHABVQModelIndex@@@Z @ 15 NONAME ; int VideoProxyModelGeneric::fetchItemDetails(class QModelIndex const &) + ??1VideoProxyModelGeneric@@UAE@XZ @ 16 NONAME ; VideoProxyModelGeneric::~VideoProxyModelGeneric(void) + ?qt_metacast@VideoCollectionWrapper@@UAEPAXPBD@Z @ 17 NONAME ; void * VideoCollectionWrapper::qt_metacast(char const *) + ?disconnectSignals@VideoProxyModelGeneric@@MAEXXZ @ 18 NONAME ; void VideoProxyModelGeneric::disconnectSignals(void) + ?qt_metacast@VideoProxyModelGeneric@@UAEPAXPBD@Z @ 19 NONAME ; void * VideoProxyModelGeneric::qt_metacast(char const *) + ??0VideoProxyModelGeneric@@QAE@PAVQObject@@@Z @ 20 NONAME ; VideoProxyModelGeneric::VideoProxyModelGeneric(class QObject *) + ?deleteItems@VideoProxyModelGeneric@@QAEHABV?$QList@VQModelIndex@@@@@Z @ 21 NONAME ; int VideoProxyModelGeneric::deleteItems(class QList const &) + ?instance@VideoThumbnailData@@SAAAV1@XZ @ 22 NONAME ; class VideoThumbnailData & VideoThumbnailData::instance(void) + ?qt_metacall@VideoProxyModelGeneric@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 23 NONAME ; int VideoProxyModelGeneric::qt_metacall(enum QMetaObject::Call, int, void * *) + ??0VideoCollectionWrapper@@AAE@XZ @ 24 NONAME ; VideoCollectionWrapper::VideoCollectionWrapper(void) + ?startBackgroundFetching@VideoThumbnailData@@QAEXPAVVideoProxyModelGeneric@@H@Z @ 25 NONAME ; void VideoThumbnailData::startBackgroundFetching(class VideoProxyModelGeneric *, int) + ?metaObject@VideoCollectionWrapper@@UBEPBUQMetaObject@@XZ @ 26 NONAME ; struct QMetaObject const * VideoCollectionWrapper::metaObject(void) const + ?setAlbumInUse@VideoProxyModelGeneric@@UAEXABVTMPXItemId@@@Z @ 27 NONAME ; void VideoProxyModelGeneric::setAlbumInUse(class TMPXItemId const &) + ?staticMetaObject@VideoProxyModelGeneric@@2UQMetaObject@@B @ 28 NONAME ; struct QMetaObject const VideoProxyModelGeneric::staticMetaObject + ?getStaticMetaObject@VideoCollectionWrapper@@SAABUQMetaObject@@XZ @ 29 NONAME ; struct QMetaObject const & VideoCollectionWrapper::getStaticMetaObject(void) + ?getStaticMetaObject@VideoProxyModelGeneric@@SAABUQMetaObject@@XZ @ 30 NONAME ; struct QMetaObject const & VideoProxyModelGeneric::getStaticMetaObject(void) + ?resolveAlbumName@VideoProxyModelGeneric@@QBE?AVQString@@ABV2@@Z @ 31 NONAME ; class QString VideoProxyModelGeneric::resolveAlbumName(class QString const &) const + ?lessThan@VideoProxyModelGeneric@@MBE_NABVQModelIndex@@0@Z @ 32 NONAME ; bool VideoProxyModelGeneric::lessThan(class QModelIndex const &, class QModelIndex const &) const + ?getCollectionsModel@VideoCollectionWrapper@@QAEPAVVideoProxyModelGeneric@@XZ @ 33 NONAME ; class VideoProxyModelGeneric * VideoCollectionWrapper::getCollectionsModel(void) + ?connectSignals@VideoProxyModelGeneric@@MAE_NXZ @ 34 NONAME ; bool VideoProxyModelGeneric::connectSignals(void) + ??_EVideoCollectionWrapper@@UAE@I@Z @ 35 NONAME ; VideoCollectionWrapper::~VideoCollectionWrapper(unsigned int) + ?getThumbnail@VideoThumbnailData@@QAEPBVQIcon@@ABVTMPXItemId@@@Z @ 36 NONAME ; class QIcon const * VideoThumbnailData::getThumbnail(class TMPXItemId const &) + ?back@VideoProxyModelGeneric@@QAEHXZ @ 37 NONAME ; int VideoProxyModelGeneric::back(void) + ?getStaticMetaObject@VideoThumbnailData@@SAABUQMetaObject@@XZ @ 38 NONAME ; struct QMetaObject const & VideoThumbnailData::getStaticMetaObject(void) + ?qt_metacall@VideoCollectionWrapper@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 39 NONAME ; int VideoCollectionWrapper::qt_metacall(enum QMetaObject::Call, int, void * *) + ?trUtf8@VideoThumbnailData@@SA?AVQString@@PBD0H@Z @ 40 NONAME ; class QString VideoThumbnailData::trUtf8(char const *, char const *, int) + ?setGenericIdFilter@VideoProxyModelGeneric@@UAEXABVTMPXItemId@@_N@Z @ 41 NONAME ; void VideoProxyModelGeneric::setGenericIdFilter(class TMPXItemId const &, bool) + ?enableBackgroundFetching@VideoThumbnailData@@QAEX_N@Z @ 42 NONAME ; void VideoThumbnailData::enableBackgroundFetching(bool) + ?trUtf8@VideoProxyModelGeneric@@SA?AVQString@@PBD0H@Z @ 43 NONAME ; class QString VideoProxyModelGeneric::trUtf8(char const *, char const *, int) + ?getMediaFilePathForId@VideoProxyModelGeneric@@QAE?AVQString@@ABVTMPXItemId@@@Z @ 44 NONAME ; class QString VideoProxyModelGeneric::getMediaFilePathForId(class TMPXItemId const &) + ?getGenericModel@VideoCollectionWrapper@@QAEPAVVideoProxyModelGeneric@@XZ @ 45 NONAME ; class VideoProxyModelGeneric * VideoCollectionWrapper::getGenericModel(void) + ?getSorting@VideoProxyModelGeneric@@QAEXAAHAAW4SortOrder@Qt@@@Z @ 46 NONAME ; void VideoProxyModelGeneric::getSorting(int &, enum Qt::SortOrder &) + ?tr@VideoCollectionWrapper@@SA?AVQString@@PBD0H@Z @ 47 NONAME ; class QString VideoCollectionWrapper::tr(char const *, char const *, int) + ?addNewAlbum@VideoProxyModelGeneric@@QAE?AVTMPXItemId@@ABVQString@@@Z @ 48 NONAME ; class TMPXItemId VideoProxyModelGeneric::addNewAlbum(class QString const &) + ?renameItem@VideoProxyModelGeneric@@QAEHABVTMPXItemId@@ABVQString@@@Z @ 49 NONAME ; int VideoProxyModelGeneric::renameItem(class TMPXItemId const &, class QString const &) + ?asyncStatus@VideoCollectionWrapper@@IAEXHAAVQVariant@@@Z @ 50 NONAME ; void VideoCollectionWrapper::asyncStatus(int, class QVariant &) + ?getOpenItem@VideoProxyModelGeneric@@UBE?AVTMPXItemId@@XZ @ 51 NONAME ; class TMPXItemId VideoProxyModelGeneric::getOpenItem(void) const + ?removeThumbnail@VideoThumbnailData@@QAE_NABVTMPXItemId@@@Z @ 52 NONAME ; bool VideoThumbnailData::removeThumbnail(class TMPXItemId const &) + ?trUtf8@VideoCollectionWrapper@@SA?AVQString@@PBD0@Z @ 53 NONAME ; class QString VideoCollectionWrapper::trUtf8(char const *, char const *) + ?thumbnailsFetched@VideoThumbnailData@@IAEXAAV?$QList@VTMPXItemId@@@@@Z @ 54 NONAME ; void VideoThumbnailData::thumbnailsFetched(class QList &) + ?trUtf8@VideoProxyModelGeneric@@SA?AVQString@@PBD0@Z @ 55 NONAME ; class QString VideoProxyModelGeneric::trUtf8(char const *, char const *) + ?metaObject@VideoThumbnailData@@UBEPBUQMetaObject@@XZ @ 56 NONAME ; struct QMetaObject const * VideoThumbnailData::metaObject(void) const + ?tr@VideoThumbnailData@@SA?AVQString@@PBD0H@Z @ 57 NONAME ; class QString VideoThumbnailData::tr(char const *, char const *, int) + ?indexOfId@VideoProxyModelGeneric@@QAE?AVQModelIndex@@ABVTMPXItemId@@@Z @ 58 NONAME ; class QModelIndex VideoProxyModelGeneric::indexOfId(class TMPXItemId const &) + ?initialize@VideoProxyModelGeneric@@UAEHPAVVideoListDataModel@@@Z @ 59 NONAME ; int VideoProxyModelGeneric::initialize(class VideoListDataModel *) + ?getAllVideosModel@VideoCollectionWrapper@@QAEPAVVideoProxyModelGeneric@@XZ @ 60 NONAME ; class VideoProxyModelGeneric * VideoCollectionWrapper::getAllVideosModel(void) + ?processSortingSlot@VideoProxyModelGeneric@@AAEXXZ @ 61 NONAME ; void VideoProxyModelGeneric::processSortingSlot(void) ?qt_metacast@VideoThumbnailData@@UAEPAXPBD@Z @ 62 NONAME ; void * VideoThumbnailData::qt_metacast(char const *) - ?tr@VideoCollectionWrapper@@SA?AVQString@@PBD0@Z @ 63 NONAME ; class QString VideoCollectionWrapper::tr(char const *, char const *) - ??_EVideoSortFilterProxyModel@@UAE@I@Z @ 64 NONAME ; VideoSortFilterProxyModel::~VideoSortFilterProxyModel(unsigned int) - ??0VideoSortFilterProxyModel@@QAE@W4TModelType@VideoCollectionCommon@@PAVQObject@@@Z @ 65 NONAME ; VideoSortFilterProxyModel::VideoSortFilterProxyModel(enum VideoCollectionCommon::TModelType, class QObject *) - ?addNewAlbum@VideoSortFilterProxyModel@@QAE?AVTMPXItemId@@ABVQString@@@Z @ 66 NONAME ; class TMPXItemId VideoSortFilterProxyModel::addNewAlbum(class QString const &) - ?renameItem@VideoSortFilterProxyModel@@QAEHABVTMPXItemId@@ABVQString@@@Z @ 67 NONAME ; int VideoSortFilterProxyModel::renameItem(class TMPXItemId const &, class QString const &) - ?enableThumbnailCreation@VideoThumbnailData@@QAEX_N@Z @ 68 NONAME ; void VideoThumbnailData::enableThumbnailCreation(bool) - ?qt_metacall@VideoSortFilterProxyModel@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 69 NONAME ; int VideoSortFilterProxyModel::qt_metacall(enum QMetaObject::Call, int, void * *) - ?freeThumbnailData@VideoThumbnailData@@QAEXXZ @ 70 NONAME ; void VideoThumbnailData::freeThumbnailData(void) - ?shortDetailsReady@VideoSortFilterProxyModel@@IAEXVTMPXItemId@@@Z @ 71 NONAME ; void VideoSortFilterProxyModel::shortDetailsReady(class TMPXItemId) - ?qt_metacast@VideoSortFilterProxyModel@@UAEPAXPBD@Z @ 72 NONAME ; void * VideoSortFilterProxyModel::qt_metacast(char const *) - ?staticMetaObject@VideoCollectionWrapper@@2UQMetaObject@@B @ 73 NONAME ; struct QMetaObject const VideoCollectionWrapper::staticMetaObject - ?setAlbumInUse@VideoSortFilterProxyModel@@QAEXABVTMPXItemId@@@Z @ 74 NONAME ; void VideoSortFilterProxyModel::setAlbumInUse(class TMPXItemId const &) + ?getCollectionContentModel@VideoCollectionWrapper@@QAEPAVVideoProxyModelGeneric@@XZ @ 63 NONAME ; class VideoProxyModelGeneric * VideoCollectionWrapper::getCollectionContentModel(void) + ?tr@VideoCollectionWrapper@@SA?AVQString@@PBD0@Z @ 64 NONAME ; class QString VideoCollectionWrapper::tr(char const *, char const *) + ?metaObject@VideoProxyModelGeneric@@UBEPBUQMetaObject@@XZ @ 65 NONAME ; struct QMetaObject const * VideoProxyModelGeneric::metaObject(void) const + ?filterAcceptsRow@VideoProxyModelGeneric@@MBE_NHABVQModelIndex@@@Z @ 66 NONAME ; bool VideoProxyModelGeneric::filterAcceptsRow(int, class QModelIndex const &) const + ?tr@VideoProxyModelGeneric@@SA?AVQString@@PBD0@Z @ 67 NONAME ; class QString VideoProxyModelGeneric::tr(char const *, char const *) + ?modelSorted@VideoProxyModelGeneric@@IAEXXZ @ 68 NONAME ; void VideoProxyModelGeneric::modelSorted(void) + ?enableThumbnailCreation@VideoThumbnailData@@QAEX_N@Z @ 69 NONAME ; void VideoThumbnailData::enableThumbnailCreation(bool) + ??_EVideoProxyModelGeneric@@UAE@I@Z @ 70 NONAME ; VideoProxyModelGeneric::~VideoProxyModelGeneric(unsigned int) + ?freeThumbnailData@VideoThumbnailData@@QAEXXZ @ 71 NONAME ; void VideoThumbnailData::freeThumbnailData(void) + ?processSorting@VideoProxyModelGeneric@@MAEXXZ @ 72 NONAME ; void VideoProxyModelGeneric::processSorting(void) + ?open@VideoProxyModelGeneric@@QAEHW4TCollectionLevels@VideoCollectionCommon@@@Z @ 73 NONAME ; int VideoProxyModelGeneric::open(enum VideoCollectionCommon::TCollectionLevels) + ?staticMetaObject@VideoCollectionWrapper@@2UQMetaObject@@B @ 74 NONAME ; struct QMetaObject const VideoCollectionWrapper::staticMetaObject ?tr@VideoThumbnailData@@SA?AVQString@@PBD0@Z @ 75 NONAME ; class QString VideoThumbnailData::tr(char const *, char const *) ??1VideoCollectionWrapper@@EAE@XZ @ 76 NONAME ; VideoCollectionWrapper::~VideoCollectionWrapper(void) ?trUtf8@VideoCollectionWrapper@@SA?AVQString@@PBD0H@Z @ 77 NONAME ; class QString VideoCollectionWrapper::trUtf8(char const *, char const *, int) - ??0VideoThumbnailData@@AAE@XZ @ 78 NONAME ; VideoThumbnailData::VideoThumbnailData(void) - ?staticMetaObject@VideoThumbnailData@@2UQMetaObject@@B @ 79 NONAME ; struct QMetaObject const VideoThumbnailData::staticMetaObject - ?modelSorted@VideoSortFilterProxyModel@@IAEXXZ @ 80 NONAME ; void VideoSortFilterProxyModel::modelSorted(void) + ?staticMetaObject@VideoThumbnailData@@2UQMetaObject@@B @ 78 NONAME ; struct QMetaObject const VideoThumbnailData::staticMetaObject + ??0VideoThumbnailData@@AAE@XZ @ 79 NONAME ; VideoThumbnailData::VideoThumbnailData(void) + ?removeAlbums@VideoProxyModelGeneric@@QAEHABV?$QList@VQModelIndex@@@@@Z @ 80 NONAME ; int VideoProxyModelGeneric::removeAlbums(class QList const &) diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/eabi/videocollectionwrapperu.def --- a/videocollection/eabi/videocollectionwrapperu.def Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/eabi/videocollectionwrapperu.def Fri Sep 17 08:30:05 2010 +0300 @@ -8,7 +8,7 @@ _ZN18VideoThumbnailData17thumbnailsFetchedER5QListI10TMPXItemIdE @ 7 NONAME _ZN18VideoThumbnailData19getStaticMetaObjectEv @ 8 NONAME _ZN18VideoThumbnailData23enableThumbnailCreationEb @ 9 NONAME - _ZN18VideoThumbnailData23startBackgroundFetchingEP25VideoSortFilterProxyModeli @ 10 NONAME + _ZN18VideoThumbnailData23startBackgroundFetchingEP22VideoProxyModelGenerici @ 10 NONAME _ZN18VideoThumbnailData24enableBackgroundFetchingEb @ 11 NONAME _ZN18VideoThumbnailData25backgroundFetchingEnabledEv @ 12 NONAME _ZN18VideoThumbnailData8instanceEv @ 13 NONAME @@ -20,63 +20,63 @@ _ZN22VideoCollectionWrapper11asyncStatusEiR8QVariant @ 19 NONAME _ZN22VideoCollectionWrapper11qt_metacallEN11QMetaObject4CallEiPPv @ 20 NONAME _ZN22VideoCollectionWrapper11qt_metacastEPKc @ 21 NONAME - _ZN22VideoCollectionWrapper15sendAsyncStatusEiR8QVariant @ 22 NONAME - _ZN22VideoCollectionWrapper16staticMetaObjectE @ 23 NONAME DATA 16 - _ZN22VideoCollectionWrapper19getStaticMetaObjectEv @ 24 NONAME - _ZN22VideoCollectionWrapper8getModelEN21VideoCollectionCommon10TModelTypeE @ 25 NONAME - _ZN22VideoCollectionWrapper8instanceEv @ 26 NONAME - _ZN22VideoCollectionWrapperC1Ev @ 27 NONAME - _ZN22VideoCollectionWrapperC2Ev @ 28 NONAME - _ZN22VideoCollectionWrapperD0Ev @ 29 NONAME - _ZN22VideoCollectionWrapperD1Ev @ 30 NONAME - _ZN22VideoCollectionWrapperD2Ev @ 31 NONAME - _ZN25VideoSortFilterProxyModel10getSortingERiRN2Qt9SortOrderE @ 32 NONAME - _ZN25VideoSortFilterProxyModel10initializeEP18VideoListDataModel @ 33 NONAME - _ZN25VideoSortFilterProxyModel10modelReadyEv @ 34 NONAME - _ZN25VideoSortFilterProxyModel10renameItemERK10TMPXItemIdRK7QString @ 35 NONAME - _ZN25VideoSortFilterProxyModel11addNewAlbumERK7QString @ 36 NONAME - _ZN25VideoSortFilterProxyModel11deleteItemsERK5QListI11QModelIndexE @ 37 NONAME - _ZN25VideoSortFilterProxyModel11qt_metacallEN11QMetaObject4CallEiPPv @ 38 NONAME - _ZN25VideoSortFilterProxyModel11qt_metacastEPKc @ 39 NONAME - _ZN25VideoSortFilterProxyModel12modelChangedEv @ 40 NONAME - _ZN25VideoSortFilterProxyModel12removeAlbumsERK5QListI11QModelIndexE @ 41 NONAME - _ZN25VideoSortFilterProxyModel13setAlbumInUseERK10TMPXItemId @ 42 NONAME - _ZN25VideoSortFilterProxyModel14connectSignalsEv @ 43 NONAME - _ZN25VideoSortFilterProxyModel14processSortingEv @ 44 NONAME - _ZN25VideoSortFilterProxyModel15addItemsInAlbumER10TMPXItemIdRK5QListIS0_E @ 45 NONAME - _ZN25VideoSortFilterProxyModel16albumChangedSlotEv @ 46 NONAME - _ZN25VideoSortFilterProxyModel16fetchItemDetailsERK11QModelIndex @ 47 NONAME - _ZN25VideoSortFilterProxyModel16staticMetaObjectE @ 48 NONAME DATA 16 - _ZN25VideoSortFilterProxyModel17disconnectSignalsEv @ 49 NONAME - _ZN25VideoSortFilterProxyModel17shortDetailsReadyE10TMPXItemId @ 50 NONAME - _ZN25VideoSortFilterProxyModel18setGenericIdFilterERK10TMPXItemIdb @ 51 NONAME - _ZN25VideoSortFilterProxyModel19getStaticMetaObjectEv @ 52 NONAME - _ZN25VideoSortFilterProxyModel20removeItemsFromAlbumER10TMPXItemIdRK5QListIS0_E @ 53 NONAME - _ZN25VideoSortFilterProxyModel21getMediaFilePathForIdERK10TMPXItemId @ 54 NONAME - _ZN25VideoSortFilterProxyModel4backEv @ 55 NONAME - _ZN25VideoSortFilterProxyModel4openEN21VideoCollectionCommon17TCollectionLevelsE @ 56 NONAME - _ZN25VideoSortFilterProxyModel7getTypeEv @ 57 NONAME - _ZN25VideoSortFilterProxyModel8openItemE10TMPXItemId @ 58 NONAME - _ZN25VideoSortFilterProxyModel9doSortingEiN2Qt9SortOrderEb @ 59 NONAME - _ZN25VideoSortFilterProxyModel9indexOfIdERK10TMPXItemId @ 60 NONAME - _ZN25VideoSortFilterProxyModelC1EN21VideoCollectionCommon10TModelTypeEP7QObject @ 61 NONAME - _ZN25VideoSortFilterProxyModelC2EN21VideoCollectionCommon10TModelTypeEP7QObject @ 62 NONAME - _ZN25VideoSortFilterProxyModelD0Ev @ 63 NONAME - _ZN25VideoSortFilterProxyModelD1Ev @ 64 NONAME - _ZN25VideoSortFilterProxyModelD2Ev @ 65 NONAME - _ZNK18VideoThumbnailData10metaObjectEv @ 66 NONAME - _ZNK22VideoCollectionWrapper10metaObjectEv @ 67 NONAME - _ZNK25VideoSortFilterProxyModel10metaObjectEv @ 68 NONAME - _ZNK25VideoSortFilterProxyModel11getOpenItemEv @ 69 NONAME - _ZNK25VideoSortFilterProxyModel16filterAcceptsRowEiRK11QModelIndex @ 70 NONAME - _ZNK25VideoSortFilterProxyModel16resolveAlbumNameERK7QString @ 71 NONAME - _ZNK25VideoSortFilterProxyModel17getMediaIdAtIndexERK11QModelIndex @ 72 NONAME - _ZNK25VideoSortFilterProxyModel8lessThanERK11QModelIndexS2_ @ 73 NONAME - _ZTI18VideoThumbnailData @ 74 NONAME - _ZTI22VideoCollectionWrapper @ 75 NONAME - _ZTI25VideoSortFilterProxyModel @ 76 NONAME - _ZTV18VideoThumbnailData @ 77 NONAME - _ZTV22VideoCollectionWrapper @ 78 NONAME - _ZTV25VideoSortFilterProxyModel @ 79 NONAME - _ZN25VideoSortFilterProxyModel11modelSortedEv @ 80 NONAME + _ZN22VideoCollectionWrapper15getGenericModelEv @ 22 NONAME + _ZN22VideoCollectionWrapper15sendAsyncStatusEiR8QVariant @ 23 NONAME + _ZN22VideoCollectionWrapper16staticMetaObjectE @ 24 NONAME DATA 16 + _ZN22VideoCollectionWrapper17getAllVideosModelEv @ 25 NONAME + _ZN22VideoCollectionWrapper19getCollectionsModelEv @ 26 NONAME + _ZN22VideoCollectionWrapper19getStaticMetaObjectEv @ 27 NONAME + _ZN22VideoCollectionWrapper25getCollectionContentModelEv @ 28 NONAME + _ZN22VideoCollectionWrapper8instanceEv @ 29 NONAME + _ZN22VideoCollectionWrapperC1Ev @ 30 NONAME + _ZN22VideoCollectionWrapperC2Ev @ 31 NONAME + _ZN22VideoCollectionWrapperD0Ev @ 32 NONAME + _ZN22VideoCollectionWrapperD1Ev @ 33 NONAME + _ZN22VideoCollectionWrapperD2Ev @ 34 NONAME + _ZN22VideoProxyModelGeneric10getSortingERiRN2Qt9SortOrderE @ 35 NONAME + _ZN22VideoProxyModelGeneric10initializeEP18VideoListDataModel @ 36 NONAME + _ZN22VideoProxyModelGeneric10renameItemERK10TMPXItemIdRK7QString @ 37 NONAME + _ZN22VideoProxyModelGeneric11addNewAlbumERK7QString @ 38 NONAME + _ZN22VideoProxyModelGeneric11deleteItemsERK5QListI11QModelIndexE @ 39 NONAME + _ZN22VideoProxyModelGeneric11modelSortedEv @ 40 NONAME + _ZN22VideoProxyModelGeneric11qt_metacallEN11QMetaObject4CallEiPPv @ 41 NONAME + _ZN22VideoProxyModelGeneric11qt_metacastEPKc @ 42 NONAME + _ZN22VideoProxyModelGeneric12removeAlbumsERK5QListI11QModelIndexE @ 43 NONAME + _ZN22VideoProxyModelGeneric13setAlbumInUseERK10TMPXItemId @ 44 NONAME + _ZN22VideoProxyModelGeneric14connectSignalsEv @ 45 NONAME + _ZN22VideoProxyModelGeneric14processSortingEv @ 46 NONAME + _ZN22VideoProxyModelGeneric15addItemsInAlbumER10TMPXItemIdRK5QListIS0_E @ 47 NONAME + _ZN22VideoProxyModelGeneric16fetchItemDetailsERK11QModelIndex @ 48 NONAME + _ZN22VideoProxyModelGeneric16staticMetaObjectE @ 49 NONAME DATA 16 + _ZN22VideoProxyModelGeneric17disconnectSignalsEv @ 50 NONAME + _ZN22VideoProxyModelGeneric17shortDetailsReadyE10TMPXItemId @ 51 NONAME + _ZN22VideoProxyModelGeneric18processSortingSlotEv @ 52 NONAME + _ZN22VideoProxyModelGeneric18setGenericIdFilterERK10TMPXItemIdb @ 53 NONAME + _ZN22VideoProxyModelGeneric19getStaticMetaObjectEv @ 54 NONAME + _ZN22VideoProxyModelGeneric20removeItemsFromAlbumER10TMPXItemIdRK5QListIS0_E @ 55 NONAME + _ZN22VideoProxyModelGeneric21getMediaFilePathForIdERK10TMPXItemId @ 56 NONAME + _ZN22VideoProxyModelGeneric4backEv @ 57 NONAME + _ZN22VideoProxyModelGeneric4openEN21VideoCollectionCommon17TCollectionLevelsE @ 58 NONAME + _ZN22VideoProxyModelGeneric8openItemE10TMPXItemId @ 59 NONAME + _ZN22VideoProxyModelGeneric9doSortingEiN2Qt9SortOrderEb @ 60 NONAME + _ZN22VideoProxyModelGeneric9indexOfIdERK10TMPXItemId @ 61 NONAME + _ZN22VideoProxyModelGenericC1EP7QObject @ 62 NONAME + _ZN22VideoProxyModelGenericC2EP7QObject @ 63 NONAME + _ZN22VideoProxyModelGenericD0Ev @ 64 NONAME + _ZN22VideoProxyModelGenericD1Ev @ 65 NONAME + _ZN22VideoProxyModelGenericD2Ev @ 66 NONAME + _ZNK18VideoThumbnailData10metaObjectEv @ 67 NONAME + _ZNK22VideoCollectionWrapper10metaObjectEv @ 68 NONAME + _ZNK22VideoProxyModelGeneric10metaObjectEv @ 69 NONAME + _ZNK22VideoProxyModelGeneric11getOpenItemEv @ 70 NONAME + _ZNK22VideoProxyModelGeneric16filterAcceptsRowEiRK11QModelIndex @ 71 NONAME + _ZNK22VideoProxyModelGeneric16resolveAlbumNameERK7QString @ 72 NONAME + _ZNK22VideoProxyModelGeneric17getMediaIdAtIndexERK11QModelIndex @ 73 NONAME + _ZNK22VideoProxyModelGeneric8lessThanERK11QModelIndexS2_ @ 74 NONAME + _ZTI18VideoThumbnailData @ 75 NONAME + _ZTI22VideoCollectionWrapper @ 76 NONAME + _ZTI22VideoProxyModelGeneric @ 77 NONAME + _ZTV18VideoThumbnailData @ 78 NONAME + _ZTV22VideoCollectionWrapper @ 79 NONAME + _ZTV22VideoProxyModelGeneric @ 80 NONAME diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/inc/videocollectioncommon.h --- a/videocollection/inc/videocollectioncommon.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/inc/videocollectioncommon.h Fri Sep 17 08:30:05 2010 +0300 @@ -162,15 +162,6 @@ statusVideosRemovedFromCollection }; - enum TModelType - { - EModelTypeInvalid, - EModelTypeAllVideos, - EModelTypeCollections, - EModelTypeCollectionContent, - EModelTypeGeneric - }; - /** * Utility macro to trace heap consumption. */ diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/simplevideoplayback/inc/svpbengine.h --- a/videocollection/tsrc/simplevideoplayback/inc/svpbengine.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/tsrc/simplevideoplayback/inc/svpbengine.h Fri Sep 17 08:30:05 2010 +0300 @@ -1,3 +1,20 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Engine class of the SimpleVideoPlayback MPX view plugin. +* +*/ + #ifndef SVPBENGINE_H #define SVPBENGINE_H diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/simplevideoplayback/src/svpbengine.cpp --- a/videocollection/tsrc/simplevideoplayback/src/svpbengine.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/tsrc/simplevideoplayback/src/svpbengine.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -1,3 +1,20 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Engine class of the SimpleVideoPlayback MPX view plugin. +* +*/ + #include // MMPXPlaybackUtility #include #include diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/stubs/inc/hblistview.h --- a/videocollection/tsrc/stubs/inc/hblistview.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/tsrc/stubs/inc/hblistview.h Fri Sep 17 08:30:05 2010 +0300 @@ -23,7 +23,7 @@ #include "hblistviewitem.h" #include "hbscrollbar.h" #include "hbabstractitemview.h" -#include "videosortfilterproxymodel.h" +#include "videoproxymodelgeneric.h" #include #include @@ -111,7 +111,7 @@ /** * dummy method */ - void setModel(VideoSortFilterProxyModel *model) + void setModel(VideoProxyModelGeneric *model) { mLatestModel = model; } @@ -322,7 +322,7 @@ /** * provided model */ - static VideoSortFilterProxyModel *mLatestModel; + static VideoProxyModelGeneric *mLatestModel; /** * -1 == initialized diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/stubs/inc/hbmainwindow.h --- a/videocollection/tsrc/stubs/inc/hbmainwindow.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/tsrc/stubs/inc/hbmainwindow.h Fri Sep 17 08:30:05 2010 +0300 @@ -76,9 +76,9 @@ return mSoftKeyAction; } - HbView *addView(QGraphicsWidget *widget = 0); + HbView *addView(HbView *view = 0); - void removeView(QGraphicsWidget *widget); + void removeView(HbView *view); QList views() const; diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/stubs/inc/videocollectionviewutilsdata.h --- a/videocollection/tsrc/stubs/inc/videocollectionviewutilsdata.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/tsrc/stubs/inc/videocollectionviewutilsdata.h Fri Sep 17 08:30:05 2010 +0300 @@ -31,6 +31,7 @@ static void reset() { mLastError = 0; + mIsServiceValue = false; mLoadSortingValuesFails = false; mVideoSortRole = -1; mCollectionSortRole = -1; @@ -48,7 +49,8 @@ public: // data static int mLastError; - static bool mLoadSortingValuesFails; + static bool mIsServiceValue; + static bool mLoadSortingValuesFails; static int mVideoSortRole; static int mCollectionSortRole; static Qt::SortOrder mVideoSortOrder; diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/stubs/inc/videocollectionwrapperdata.h --- a/videocollection/tsrc/stubs/inc/videocollectionwrapperdata.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/tsrc/stubs/inc/videocollectionwrapperdata.h Fri Sep 17 08:30:05 2010 +0300 @@ -18,39 +18,44 @@ #ifndef VIDEOCOLLECTIONWRAPPERDATA_H #define VIDEOCOLLECTIONWRAPPERDATA_H -#include "videosortfilterproxymodel.h" +#include "videoproxymodelgeneric.h" +#include "videoproxymodelallvideos.h" +#include "videoproxymodelcollections.h" +#include "videoproxymodelcontent.h" #include "videolistdatamodel.h" +#include -class VideoCollectionWrapperData +class VideoCollectionWrapperData : public QObject { + Q_OBJECT + public: // methods - static void reset() - { - mGetModelFails = false; + static void reset(); + /*{ + mGetGenericModelFails = false; + mGetAllVideosModelFails = false; + mGetCollectionsModelFails = false; + mGetCollectionContentModelFails = false; delete mAllVideosModel; - mAllVideosModel = 0; - delete mCollectionsModel; - mCollectionsModel = 0; - delete mCollectionContentModel; - mCollectionContentModel = 0; - delete mGenericModel; - mGenericModel = 0; - + delete mSourceModel; mSourceModel = 0; - } + }*/ public: // data - static bool mGetModelFails; + static bool mGetGenericModelFails; + static bool mGetAllVideosModelFails; + static bool mGetCollectionsModelFails; + static bool mGetCollectionContentModelFails; static VideoListDataModel *mSourceModel; - static VideoSortFilterProxyModel *mAllVideosModel; - static VideoSortFilterProxyModel *mCollectionsModel; - static VideoSortFilterProxyModel *mCollectionContentModel; - static VideoSortFilterProxyModel *mGenericModel; + static QPointer mAllVideosModel; + static QPointer mCollectionsModel; + static QPointer mCollectionContentModel; + static QPointer mGenericModel; }; -#endif /* VIDEOSORTFILTERPROXYMODEL_H */ +#endif /* VIDEOCOLLECTIONWRAPPERDATA_H */ diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/stubs/inc/videolistwidgetdata.h --- a/videocollection/tsrc/stubs/inc/videolistwidgetdata.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/tsrc/stubs/inc/videolistwidgetdata.h Fri Sep 17 08:30:05 2010 +0300 @@ -18,6 +18,8 @@ #ifndef VIDEOLISTWIDGETDATA_H #define VIDEOLISTWIDGETDATA_H +#include + class VideoListWidgetData { public: // methods diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/stubs/inc/videoproxymodeldata.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/tsrc/stubs/inc/videoproxymodeldata.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: stub VideoProxyModelData +* +*/ + +#ifndef VIDEOPROXYMODELDATA_H +#define VIDEOPROXYMODELDATA_H + +#include +#include +#include +#include + +class VideoProxyModelData +{ +public: // methods + static void reset() + { + mOpenFails = false; + mSortRole = -1; + mSortOrder = Qt::AscendingOrder; + mSortAsync = false; + mDeleteItemsFails = true; + mRemoveAlbumsFails = true; + mDoSortingCallCount = 0; + mItemIds.clear(); + mLastIndex = QModelIndex(); + mLastItemId = TMPXItemId::InvalidId(); + mOpenedItemId = TMPXItemId::InvalidId(); + mDetailsReturnValue = 0; + mAddItemsInAlbumReturnValue = 0; + mRemoveItemsFromAlbumReturnValue = 0; + mGenericFilterId = TMPXItemId::InvalidId(); + mGenericFilterValue = false; + mNewAlbumId = TMPXItemId::InvalidId(); + mLastItemNameInRename = ""; + mRenameItemReturnValue= 0; + mLastAddedAlbumName = ""; + } + +public: // data + static bool mOpenFails; + static int mSortRole; + static Qt::SortOrder mSortOrder; + static bool mSortAsync; + static bool mDeleteItemsFails; + static bool mRemoveAlbumsFails; + static int mDoSortingCallCount; + static QList mItemIds; + static QModelIndex mLastIndex; + static TMPXItemId mLastItemId; + static TMPXItemId mOpenedItemId; + static int mDetailsReturnValue; + static int mAddItemsInAlbumReturnValue; + static int mRemoveItemsFromAlbumReturnValue; + static TMPXItemId mGenericFilterId; + static bool mGenericFilterValue; + static TMPXItemId mNewAlbumId; + static QString mLastItemNameInRename; + static int mRenameItemReturnValue; + static QString mLastAddedAlbumName; +}; + +#endif /* VIDEOPROXYMODELDATA_H */ diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/stubs/inc/videosortfilterproxymodeldata.h --- a/videocollection/tsrc/stubs/inc/videosortfilterproxymodeldata.h Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: stub videosortfilterproxymodeldata -* -*/ - -#ifndef VIDEOSORTFILTERPROXYMODELDATA_H -#define VIDEOSORTFILTERPROXYMODELDATA_H - -#include -#include - -class VideoSortFilterProxyModelData -{ -public: // methods - static void reset() - { - mOpenFails = false; - mSortRole = -1; - mSortOrder = Qt::AscendingOrder; - mSortAsync = false; - mDeleteItemsFails = true; - mRemoveAlbumsFails = true; - mDoSortingCallCount = 0; - mItemIds.clear(); - mLastIndex = QModelIndex(); - mLastItemId = TMPXItemId::InvalidId(); - mOpenedItemId = TMPXItemId::InvalidId(); - mDetailsReturnValue = 0; - mAddItemsInAlbumReturnValue = 0; - mRemoveItemsFromAlbumReturnValue = 0; - mGenericFilterId = TMPXItemId::InvalidId(); - mGenericFilterValue = false; - mNewAlbumId = TMPXItemId::InvalidId(); - mLastItemNameInRename = ""; - mRenameItemReturnValue= 0; - mLastAddedAlbumName = ""; - } - -public: // data - static bool mOpenFails; - static int mSortRole; - static Qt::SortOrder mSortOrder; - static bool mSortAsync; - static bool mDeleteItemsFails; - static bool mRemoveAlbumsFails; - static int mDoSortingCallCount; - static QList mItemIds; - static QModelIndex mLastIndex; - static TMPXItemId mLastItemId; - static TMPXItemId mOpenedItemId; - static int mDetailsReturnValue; - static int mAddItemsInAlbumReturnValue; - static int mRemoveItemsFromAlbumReturnValue; - static TMPXItemId mGenericFilterId; - static bool mGenericFilterValue; - static TMPXItemId mNewAlbumId; - static QString mLastItemNameInRename; - static int mRenameItemReturnValue; - static QString mLastAddedAlbumName; -}; - -#endif /* VIDEOSORTFILTERPROXYMODEL_H */ diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/stubs/src/hblistview.cpp --- a/videocollection/tsrc/stubs/src/hblistview.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/tsrc/stubs/src/hblistview.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,12 +15,12 @@ * */ -#include "videosortfilterproxymodel.h" +#include "videoproxymodelgeneric.h" #include "hblistview.h" QList HbListView::mVisibleItems = QList(); HbAbstractItemView::SelectionMode HbListView::mSelectionMode = HbAbstractItemView::InvalidSelection; -VideoSortFilterProxyModel* HbListView::mLatestModel = 0; +VideoProxyModelGeneric* HbListView::mLatestModel = 0; bool HbListView::mReturnNullPrototype = false; bool HbListView::mVScrollBarIsNull = false; bool HbListView::mLatestrecycling = false; diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/stubs/src/hbmainwindow.cpp --- a/videocollection/tsrc/stubs/src/hbmainwindow.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/tsrc/stubs/src/hbmainwindow.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -23,9 +23,8 @@ // addView // --------------------------------------------------------------------------- // -HbView* HbMainWindow::addView(QGraphicsWidget *widget) +HbView* HbMainWindow::addView(HbView *view) { - HbView* view = qobject_cast(widget); mViews.append(view); return view; } @@ -34,9 +33,9 @@ // removeView // --------------------------------------------------------------------------- // -void HbMainWindow::removeView(QGraphicsWidget *widget) +void HbMainWindow::removeView(HbView *view) { - mViews.removeAll(qobject_cast(widget)); + mViews.removeAll(view); } // --------------------------------------------------------------------------- diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/stubs/src/videocollectionuiloader.cpp --- a/videocollection/tsrc/stubs/src/videocollectionuiloader.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/tsrc/stubs/src/videocollectionuiloader.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -136,14 +136,17 @@ name == DOCML_NAME_VC_COLLECTIONWIDGET || name == DOCML_NAME_VC_COLLECTIONCONTENTWIDGET) { - VideoCollectionCommon::TModelType type = VideoCollectionCommon::EModelTypeAllVideos; + VideoProxyModelGeneric *model(0); + if(name == DOCML_NAME_VC_COLLECTIONWIDGET) { - type = VideoCollectionCommon::EModelTypeCollections; + model = wrapper.getCollectionsModel(); } else if (name == DOCML_NAME_VC_COLLECTIONCONTENTWIDGET) { - type = VideoCollectionCommon::EModelTypeCollectionContent; + model = wrapper.getCollectionContentModel(); + } else + { + model = wrapper.getAllVideosModel(); } VideoListWidget *videoList = qobject_cast(object); - VideoSortFilterProxyModel *model = wrapper.getModel(type); VideoCollectionCommon::TCollectionLevels level = VideoCollectionCommon::ELevelInvalid; if(name == DOCML_NAME_VC_VIDEOLISTWIDGET ) diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/stubs/src/videocollectionviewutils.cpp --- a/videocollection/tsrc/stubs/src/videocollectionviewutils.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/tsrc/stubs/src/videocollectionviewutils.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -20,6 +20,7 @@ int VideoCollectionViewUtilsData::mLastError = 0; bool VideoCollectionViewUtilsData::mLoadSortingValuesFails = false; +bool VideoCollectionViewUtilsData::mIsServiceValue = false; int VideoCollectionViewUtilsData::mVideoSortRole = -1; int VideoCollectionViewUtilsData::mCollectionSortRole = -1; Qt::SortOrder VideoCollectionViewUtilsData::mVideoSortOrder = Qt::AscendingOrder; @@ -40,6 +41,7 @@ } VideoCollectionViewUtils::VideoCollectionViewUtils(): +mIsService(false), mVideosSortRole(-1), mCollectionsSortRole(-1), mVideosSortOrder(Qt::AscendingOrder), @@ -159,7 +161,7 @@ } -void VideoCollectionViewUtils::sortModel(VideoSortFilterProxyModel *model, +void VideoCollectionViewUtils::sortModel(VideoProxyModelGeneric *model, bool async, VideoCollectionCommon::TCollectionLevels target) { Q_UNUSED(model); @@ -173,3 +175,13 @@ VideoCollectionViewUtilsData::mLastStatusAdditional = additional; VideoCollectionViewUtilsData::mLastError = statusCode; } + +void VideoCollectionViewUtils::setIsService() +{ + mIsService = VideoCollectionViewUtilsData::mIsServiceValue; +} + +bool VideoCollectionViewUtils::isService() +{ + return mIsService; +} diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/stubs/src/videocollectionwrapper.cpp --- a/videocollection/tsrc/stubs/src/videocollectionwrapper.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/tsrc/stubs/src/videocollectionwrapper.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -17,13 +17,16 @@ #include "videocollectionwrapper.h" #include "videocollectionwrapperdata.h" - -bool VideoCollectionWrapperData::mGetModelFails = false; +/* +bool VideoCollectionWrapperData::mGetGenericModelFails = false; +bool VideoCollectionWrapperData::mGetAllVideosModelFails = false; +bool VideoCollectionWrapperData::mGetCollectionsModelFails = false; +bool VideoCollectionWrapperData::mGetCollectionContentModelFails = false; VideoListDataModel *VideoCollectionWrapperData::mSourceModel = 0; -VideoSortFilterProxyModel *VideoCollectionWrapperData::mAllVideosModel = 0; -VideoSortFilterProxyModel *VideoCollectionWrapperData::mCollectionsModel = 0; -VideoSortFilterProxyModel *VideoCollectionWrapperData::mCollectionContentModel = 0; -VideoSortFilterProxyModel *VideoCollectionWrapperData::mGenericModel = 0; +QPointer VideoCollectionWrapperData::mAllVideosModel = 0; +QPointer VideoCollectionWrapperData::mCollectionsModel = 0; +QPointer VideoCollectionWrapperData::mCollectionContentModel = 0; +QPointer VideoCollectionWrapperData::mGenericModel = 0;*/ VideoCollectionWrapper &VideoCollectionWrapper::instance() { @@ -41,85 +44,100 @@ VideoCollectionWrapperData::reset(); } -VideoSortFilterProxyModel* VideoCollectionWrapper::getModel(VideoCollectionCommon::TModelType type) +VideoProxyModelGeneric* VideoCollectionWrapper::getGenericModel() { - VideoSortFilterProxyModel *model = 0; - if (!VideoCollectionWrapperData::mGetModelFails) + VideoProxyModelGeneric *model = 0; + if (!VideoCollectionWrapperData::mGetGenericModelFails) + { + VideoListDataModel *sourceModel = VideoCollectionWrapperData::mSourceModel; + if (!sourceModel) + { + sourceModel = new VideoListDataModel; + sourceModel->initialize(); + VideoCollectionWrapperData::mSourceModel = sourceModel; + } + + model = VideoCollectionWrapperData::mGenericModel; + if(!model && VideoCollectionWrapperData::mSourceModel) + { + model = new VideoProxyModelGeneric(); + model->initialize(VideoCollectionWrapperData::mSourceModel); + VideoCollectionWrapperData::mGenericModel = model; + } + } + + return model; +} + +VideoProxyModelGeneric* VideoCollectionWrapper::getAllVideosModel() +{ + VideoProxyModelGeneric *model = 0; + if (!VideoCollectionWrapperData::mGetAllVideosModelFails) { VideoListDataModel *sourceModel = VideoCollectionWrapperData::mSourceModel; if (!sourceModel) { sourceModel = new VideoListDataModel; - if (sourceModel) - { - sourceModel->initialize(); - VideoCollectionWrapperData::mSourceModel = sourceModel; - } + sourceModel->initialize(); + VideoCollectionWrapperData::mSourceModel = sourceModel; + } + + model = VideoCollectionWrapperData::mAllVideosModel; + if (!model) + { + model = new VideoProxyModelAllVideos(); + model->initialize(VideoCollectionWrapperData::mSourceModel); + VideoCollectionWrapperData::mAllVideosModel = model; } - - switch (type) + } + + return model; +} + +VideoProxyModelGeneric* VideoCollectionWrapper::getCollectionsModel() +{ + VideoProxyModelGeneric *model = 0; + if (!VideoCollectionWrapperData::mGetCollectionsModelFails) + { + VideoListDataModel *sourceModel = VideoCollectionWrapperData::mSourceModel; + if (!sourceModel) { - case VideoCollectionCommon::EModelTypeAllVideos: - { - model = VideoCollectionWrapperData::mAllVideosModel; - if (!model) - { - model = new VideoSortFilterProxyModel(type); - if (model) - { - model->initialize(sourceModel); - VideoCollectionWrapperData::mAllVideosModel = model; - } - } - break; - } - case VideoCollectionCommon::EModelTypeCollections: - { - model = VideoCollectionWrapperData::mCollectionsModel; - if (!model) - { - model = new VideoSortFilterProxyModel(type); - if (model) - { - model->initialize(sourceModel); - VideoCollectionWrapperData::mCollectionsModel = model; - } - } - break; - } - case VideoCollectionCommon::EModelTypeCollectionContent: - { - model = VideoCollectionWrapperData::mCollectionContentModel; - if (!model) - { - model = new VideoSortFilterProxyModel(type); - if (model) - { - model->initialize(sourceModel); - VideoCollectionWrapperData::mCollectionContentModel = model; - } - } - break; - } - case VideoCollectionCommon::EModelTypeGeneric: - { - model = VideoCollectionWrapperData::mGenericModel; - if (!model) - { - model = new VideoSortFilterProxyModel(type); - if (model) - { - model->initialize(sourceModel); - VideoCollectionWrapperData::mGenericModel = model; - } - } - break; - } - default: - { - // invalid model type - break; - } + sourceModel = new VideoListDataModel; + sourceModel->initialize(); + VideoCollectionWrapperData::mSourceModel = sourceModel; + } + + model = VideoCollectionWrapperData::mCollectionsModel; + if (!model) + { + model = new VideoProxyModelCollections(); + model->initialize(VideoCollectionWrapperData::mSourceModel); + VideoCollectionWrapperData::mCollectionsModel = model; + } + } + + return model; +} + +VideoProxyModelGeneric* VideoCollectionWrapper::getCollectionContentModel() +{ + VideoProxyModelGeneric *model = 0; + if (!VideoCollectionWrapperData::mGetCollectionContentModelFails) + { + VideoListDataModel *sourceModel = VideoCollectionWrapperData::mSourceModel; + if (!sourceModel) + { + sourceModel = new VideoListDataModel; + sourceModel->initialize(); + VideoCollectionWrapperData::mSourceModel = sourceModel; + } + + model = VideoCollectionWrapperData::mCollectionContentModel; + if (!model) + { + model = new VideoProxyModelContent(); + model->initialize(VideoCollectionWrapperData::mSourceModel); + VideoCollectionWrapperData::mCollectionContentModel = model; } } diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/stubs/src/videocollectionwrapperdata.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/tsrc/stubs/src/videocollectionwrapperdata.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: VideoCollectionWrapperData class implementation +* +*/ + +#include "videocollectionwrapperdata.h" + +bool VideoCollectionWrapperData::mGetGenericModelFails = false; +bool VideoCollectionWrapperData::mGetAllVideosModelFails = false; +bool VideoCollectionWrapperData::mGetCollectionsModelFails = false; +bool VideoCollectionWrapperData::mGetCollectionContentModelFails = false; +VideoListDataModel *VideoCollectionWrapperData::mSourceModel = 0; +QPointer VideoCollectionWrapperData::mAllVideosModel = 0; +QPointer VideoCollectionWrapperData::mCollectionsModel = 0; +QPointer VideoCollectionWrapperData::mCollectionContentModel = 0; +QPointer VideoCollectionWrapperData::mGenericModel = 0; + +void VideoCollectionWrapperData::reset() +{ + mGetGenericModelFails = false; + mGetAllVideosModelFails = false; + mGetCollectionsModelFails = false; + mGetCollectionContentModelFails = false; + + delete mAllVideosModel; + delete mCollectionsModel; + delete mCollectionContentModel; + delete mGenericModel; + + delete mSourceModel; + mSourceModel = 0; +} + diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/stubs/src/videolistselectiondialog.cpp --- a/videocollection/tsrc/stubs/src/videolistselectiondialog.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/tsrc/stubs/src/videolistselectiondialog.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -20,7 +20,7 @@ #include "videolistselectiondialog.h" #include "videolistselectiondialogdata.h" #include "videocollectionwrapper.h" -#include "videosortfilterproxymodel.h" +#include "videoproxymodelgeneric.h" bool VideoListSelectionDialogData::mExecReturnPrimary = false; int VideoListSelectionDialogData::mSelectionCount = 0; @@ -79,7 +79,7 @@ // fill selection VideoListSelectionDialogData::mMultiSelectionLaunchCount++; VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeGeneric); + VideoProxyModelGeneric *model = wrapper.getGenericModel(); if (model) { for (int i = 0; i < VideoListSelectionDialogData::mSelectionCount; i++) diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/stubs/src/videolistwidget.cpp --- a/videocollection/tsrc/stubs/src/videolistwidget.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/tsrc/stubs/src/videolistwidget.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -47,7 +47,7 @@ VideoListWidgetData::reset(); } -int VideoListWidget::initialize(VideoSortFilterProxyModel &model, +int VideoListWidget::initialize(VideoProxyModelGeneric &model, bool isService, VideoCollectionCommon::TCollectionLevels level) { Q_UNUSED(isService); @@ -109,7 +109,7 @@ return mCurrentLevel; } -VideoSortFilterProxyModel* VideoListWidget::getModel() +VideoProxyModelGeneric* VideoListWidget::getModel() { return mModel; } diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/stubs/src/videoproxymodelallvideos.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/tsrc/stubs/src/videoproxymodelallvideos.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: VideoProxyModelAllVideos implementation +* +*/ + +// Version : + +// INCLUDE FILES +#include +#include "videoproxymodeldata.h" +#include "videoproxymodelallvideos.h" +#include "videolistdatamodel.h" +#include "videocollectiontrace.h" + +// ----------------------------------------------------------------------------- +// VideoProxyModelAllVideos::VideoProxyModelGeneric +// ----------------------------------------------------------------------------- +// +VideoProxyModelAllVideos::VideoProxyModelAllVideos(QObject *parent) : +VideoProxyModelGeneric(parent) +{ + +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelAllVideos::~VideoProxyModelAllVideos +// ----------------------------------------------------------------------------- +// +VideoProxyModelAllVideos::~VideoProxyModelAllVideos() +{ + +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelAllVideos::filterAcceptsRow +// ----------------------------------------------------------------------------- +// +bool VideoProxyModelAllVideos::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const +{ + Q_UNUSED(source_row); + Q_UNUSED(source_parent); + return true; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelAllVideos::getOpenItem() +// ----------------------------------------------------------------------------- +// +TMPXItemId VideoProxyModelAllVideos::getOpenItem() const +{ + return VideoProxyModelData::mOpenedItemId; +} + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/stubs/src/videoproxymodelcollections.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/tsrc/stubs/src/videoproxymodelcollections.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: VideoProxyModelCollections implementation +* +*/ + +// Version : + +// INCLUDE FILES +#include +#include "videoproxymodeldata.h" +#include "videoproxymodelcollections.h" +#include "videolistdatamodel.h" +#include "videocollectiontrace.h" + +// ----------------------------------------------------------------------------- +// VideoProxyModelCollections::VideoProxyModelCollections +// ----------------------------------------------------------------------------- +// +VideoProxyModelCollections::VideoProxyModelCollections(QObject *parent) : +VideoProxyModelGeneric(parent) +{ + mDefaultSortRole = VideoCollectionCommon::KeyTitle; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelCollections::~VideoProxyModelCollections +// ----------------------------------------------------------------------------- +// +VideoProxyModelCollections::~VideoProxyModelCollections() +{ + +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelCollections::lessThan +// ----------------------------------------------------------------------------- +// +bool VideoProxyModelCollections::lessThan(const QModelIndex &left, + const QModelIndex &right) const +{ + Q_UNUSED(left); + Q_UNUSED(right); + return true; +} +// ----------------------------------------------------------------------------- +// VideoProxyModelCollections::filterAcceptsRow +// ----------------------------------------------------------------------------- +// +bool VideoProxyModelCollections::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const +{ + Q_UNUSED(source_parent); + Q_UNUSED(source_row); + return true; +} + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/stubs/src/videoproxymodelcontent.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/tsrc/stubs/src/videoproxymodelcontent.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: VideoProxyModelContent implementation +* +*/ + +// Version : + +// INCLUDE FILES +#include "videoproxymodeldata.h" +#include "videoproxymodelcontent.h" +#include "videolistdatamodel.h" +#include "videocollectiontrace.h" + +// ----------------------------------------------------------------------------- +// VideoProxyModelContent::VideoProxyModelGeneric +// ----------------------------------------------------------------------------- +// +VideoProxyModelContent::VideoProxyModelContent(QObject *parent) : +VideoProxyModelGeneric(parent) +{ +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelContent::~VideoProxyModelContent +// ----------------------------------------------------------------------------- +// +VideoProxyModelContent::~VideoProxyModelContent() +{ + +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelContent::connectSignals +// ----------------------------------------------------------------------------- +// +bool VideoProxyModelContent::connectSignals() +{ + return true; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelContent::disconnectSignals +// ----------------------------------------------------------------------------- +// +void VideoProxyModelContent::disconnectSignals() +{ + +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelContent::filterAcceptsRow +// ----------------------------------------------------------------------------- +// +bool VideoProxyModelContent::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const +{ + Q_UNUSED(source_row); + Q_UNUSED(source_parent); + return true; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelContent::getOpenItem() +// ----------------------------------------------------------------------------- +// +TMPXItemId VideoProxyModelContent::getOpenItem() const +{ + return VideoProxyModelData::mOpenedItemId; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelContent::albumChangedSlot() +// ----------------------------------------------------------------------------- +// +void VideoProxyModelContent::albumChangedSlot() +{ + +} + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/stubs/src/videoproxymodelgeneric.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/tsrc/stubs/src/videoproxymodelgeneric.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,298 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: stub VideoProxyModelGeneric implementation +* +*/ + +#include "videoproxymodelgeneric.h" +#include "videoproxymodeldata.h" +#include "videocollectioncommon.h" +#include "videolistdatamodel.h" + +using namespace VideoCollectionCommon; + +int VideoProxyModelData::mSortRole = -1; +Qt::SortOrder VideoProxyModelData::mSortOrder = Qt::AscendingOrder; +bool VideoProxyModelData::mSortAsync = false; +bool VideoProxyModelData::mDeleteItemsFails = false; +bool VideoProxyModelData::mRemoveAlbumsFails = false; +int VideoProxyModelData::mDoSortingCallCount = 0; +bool VideoProxyModelData::mOpenFails = false; +QList VideoProxyModelData::mItemIds = QList(); +QModelIndex VideoProxyModelData::mLastIndex = QModelIndex(); +TMPXItemId VideoProxyModelData::mLastItemId = TMPXItemId::InvalidId(); +TMPXItemId VideoProxyModelData::mOpenedItemId = TMPXItemId::InvalidId(); +int VideoProxyModelData::mDetailsReturnValue = 0; +int VideoProxyModelData::mAddItemsInAlbumReturnValue = 0; +int VideoProxyModelData::mRemoveItemsFromAlbumReturnValue = 0; +TMPXItemId VideoProxyModelData::mGenericFilterId = TMPXItemId::InvalidId(); +bool VideoProxyModelData::mGenericFilterValue = false; +TMPXItemId VideoProxyModelData::mNewAlbumId = TMPXItemId::InvalidId(); +QString VideoProxyModelData::mLastItemNameInRename = ""; +int VideoProxyModelData::mRenameItemReturnValue = 0; +QString VideoProxyModelData::mLastAddedAlbumName = ""; + +const TMPXItemId INVALID_ID = TMPXItemId::InvalidId(); + +VideoProxyModelGeneric::VideoProxyModelGeneric(QObject *parent): + QSortFilterProxyModel(parent), + mModel(0), + mCollectionClient(0), + mLevel(VideoCollectionCommon::ELevelInvalid), + mIdleSortTimer(0), + mWantedSortRole(VideoCollectionCommon::KeyDateTime), + mDefaultSortRole(VideoCollectionCommon::KeyTitle) +{ + +} + +VideoProxyModelGeneric::~VideoProxyModelGeneric() +{ + VideoProxyModelData::reset(); +} + +int VideoProxyModelGeneric::initialize(VideoListDataModel *sourceModel) +{ + mModel = sourceModel; + setSourceModel(mModel); + return 0; +} + +bool VideoProxyModelGeneric::connectSignals() +{ + // not stubbed + return true; +} + +void VideoProxyModelGeneric::disconnectSignals() +{ + // not stubbed +} + +int VideoProxyModelGeneric::open(VideoCollectionCommon::TCollectionLevels level) +{ + int err = 0; + + mLevel = level; + if (VideoProxyModelData::mOpenFails) + { + err = -1; + } + + return err; +} + +void VideoProxyModelGeneric::doSorting(int sortingRole, + Qt::SortOrder order, + bool async) +{ + VideoProxyModelData::mDoSortingCallCount++; + VideoProxyModelData::mSortRole = sortingRole; + VideoProxyModelData::mSortOrder = order; + VideoProxyModelData::mSortAsync = async; + setSortRole(sortingRole); + sort(0, order); +} + +void VideoProxyModelGeneric::getSorting(int &sortingRole, + Qt::SortOrder &order) +{ + sortingRole = VideoProxyModelData::mSortRole; + order = VideoProxyModelData::mSortOrder; +} + +int VideoProxyModelGeneric::deleteItems(const QModelIndexList &indexList) +{ + + int err = 0; + if (VideoProxyModelData::mDeleteItemsFails) + { + err = -1; + } + else + { + if (indexList.count() > 0) + { + VideoProxyModelData::mLastIndex = indexList.at(0); + } + } + + return err; +} + +int VideoProxyModelGeneric::openItem(TMPXItemId mediaId) +{ + VideoProxyModelData::mLastItemId = mediaId; + + return 0; +} + +int VideoProxyModelGeneric::back() +{ + // not stubbed + return 0; +} + +int VideoProxyModelGeneric::fetchItemDetails(const QModelIndex &index) +{ + VideoProxyModelData::mLastIndex = index; + + return VideoProxyModelData::mDetailsReturnValue; +} + +void VideoProxyModelGeneric::processSorting() +{ + // not stubbed +} + +void VideoProxyModelGeneric::processSortingSlot() +{ + // not stubbed +} + +bool VideoProxyModelGeneric::lessThan(const QModelIndex &left, + const QModelIndex &right) const +{ + Q_UNUSED(left); + Q_UNUSED(right); + // not stubbed + return true; +} + +bool VideoProxyModelGeneric::filterAcceptsRow (int source_row, + const QModelIndex &source_parent) const +{ + Q_UNUSED(source_row); + Q_UNUSED(source_parent); + // not stubbed + return true; +} + + const TMPXItemId& VideoProxyModelGeneric::getMediaIdAtIndex( + const QModelIndex &index) const +{ + if (index.row() >= 0 && + index.row() < VideoProxyModelData::mItemIds.count()) + { + return VideoProxyModelData::mItemIds[index.row()]; + } + return INVALID_ID; +} + +QModelIndex VideoProxyModelGeneric::indexOfId(const TMPXItemId &id) +{ + //VideoListDataModel *sourceModel = qobject_cast(sourceModel()); + + for(int i = 0; i < VideoProxyModelData::mItemIds.count(); i++) + { + if(VideoProxyModelData::mItemIds.at(i) == id) + { + //return sourceModel->index(i, 0); + return index(i, 0); + } + } + return QModelIndex(); +} + +QString VideoProxyModelGeneric::getMediaFilePathForId(const TMPXItemId &mediaId) +{ + Q_UNUSED(mediaId); + // not stubbed + return QString(); +} + +TMPXItemId VideoProxyModelGeneric::addNewAlbum(const QString &title) +{ + VideoProxyModelData::mLastAddedAlbumName = title; + return VideoProxyModelData::mNewAlbumId; +} + +QString VideoProxyModelGeneric::resolveAlbumName( + const QString& albumName) const +{ + QString name = albumName; + return name; +} + +int VideoProxyModelGeneric::addItemsInAlbum(TMPXItemId &albumId, const QList &mediaIds) +{ + if(VideoProxyModelData::mAddItemsInAlbumReturnValue >= 0) + { + VideoProxyModelData::mLastItemId = albumId; + VideoProxyModelData::mItemIds.clear(); + VideoProxyModelData::mItemIds = mediaIds; + } + // not stubbed + return VideoProxyModelData::mAddItemsInAlbumReturnValue; +} + +int VideoProxyModelGeneric::removeAlbums(const QModelIndexList &indexList) +{ + + int err = 0; + if (VideoProxyModelData::mRemoveAlbumsFails) + { + err = -1; + } + else + { + if (indexList.count() > 0) + { + VideoProxyModelData::mLastIndex = indexList.at(0); + } + } + + return err; +} + +int VideoProxyModelGeneric::removeItemsFromAlbum(class TMPXItemId &album, QList const &mediaIds) +{ + if(VideoProxyModelData::mRemoveItemsFromAlbumReturnValue >= 0) + { + VideoProxyModelData::mLastItemId = album; + VideoProxyModelData::mItemIds.clear(); + VideoProxyModelData::mItemIds = mediaIds; + } + return VideoProxyModelData::mRemoveItemsFromAlbumReturnValue; +} + +void VideoProxyModelGeneric::setAlbumInUse(const TMPXItemId &albumId) +{ + VideoProxyModelData::mLastItemId = albumId; +} + +int VideoProxyModelGeneric::renameItem(const TMPXItemId &itemId, const QString &newTitle) +{ + if(VideoProxyModelData::mRemoveItemsFromAlbumReturnValue >= 0) + { + VideoProxyModelData::mLastItemId = itemId; + VideoProxyModelData::mLastItemNameInRename = newTitle; + + } + return VideoProxyModelData::mRenameItemReturnValue; +} + +TMPXItemId VideoProxyModelGeneric::getOpenItem() const +{ + return VideoProxyModelData::mOpenedItemId; +} + +void VideoProxyModelGeneric::setGenericIdFilter(const TMPXItemId &itemId, bool filterValue) +{ + VideoProxyModelData::mGenericFilterId = itemId; + VideoProxyModelData::mGenericFilterValue = filterValue; + return; +} + +// end of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/stubs/src/videosortfilterproxymodel.cpp --- a/videocollection/tsrc/stubs/src/videosortfilterproxymodel.cpp Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,303 +0,0 @@ -/* -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Videosortfilterproxymodel implementation -* -*/ - -#include "videosortfilterproxymodel.h" -#include "videosortfilterproxymodeldata.h" -#include "videocollectioncommon.h" -#include "videolistdatamodel.h" - -using namespace VideoCollectionCommon; - -int VideoSortFilterProxyModelData::mSortRole = -1; -Qt::SortOrder VideoSortFilterProxyModelData::mSortOrder = Qt::AscendingOrder; -bool VideoSortFilterProxyModelData::mSortAsync = false; -bool VideoSortFilterProxyModelData::mDeleteItemsFails = false; -bool VideoSortFilterProxyModelData::mRemoveAlbumsFails = false; -int VideoSortFilterProxyModelData::mDoSortingCallCount = 0; -bool VideoSortFilterProxyModelData::mOpenFails = false; -QList VideoSortFilterProxyModelData::mItemIds = QList(); -QModelIndex VideoSortFilterProxyModelData::mLastIndex = QModelIndex(); -TMPXItemId VideoSortFilterProxyModelData::mLastItemId = TMPXItemId::InvalidId(); -TMPXItemId VideoSortFilterProxyModelData::mOpenedItemId = TMPXItemId::InvalidId(); -int VideoSortFilterProxyModelData::mDetailsReturnValue = 0; -int VideoSortFilterProxyModelData::mAddItemsInAlbumReturnValue = 0; -int VideoSortFilterProxyModelData::mRemoveItemsFromAlbumReturnValue = 0; -TMPXItemId VideoSortFilterProxyModelData::mGenericFilterId = TMPXItemId::InvalidId(); -bool VideoSortFilterProxyModelData::mGenericFilterValue = false; -TMPXItemId VideoSortFilterProxyModelData::mNewAlbumId = TMPXItemId::InvalidId(); -QString VideoSortFilterProxyModelData::mLastItemNameInRename = ""; -int VideoSortFilterProxyModelData::mRenameItemReturnValue = 0; -QString VideoSortFilterProxyModelData::mLastAddedAlbumName = ""; - -const TMPXItemId INVALID_ID = TMPXItemId::InvalidId(); - -VideoSortFilterProxyModel::VideoSortFilterProxyModel(VideoCollectionCommon::TModelType type, QObject *parent): - QSortFilterProxyModel(parent), - mModel(0), - mCollectionClient(0), - mType(type), - mLevel(VideoCollectionCommon::ELevelInvalid), - mIdleSortTimer(0), - mWantedSortRole(VideoCollectionCommon::KeyDateTime) -{ - // NOP -} - -VideoSortFilterProxyModel::~VideoSortFilterProxyModel() -{ - VideoSortFilterProxyModelData::reset(); -} - -int VideoSortFilterProxyModel::initialize(VideoListDataModel *sourceModel) -{ - setSourceModel(sourceModel); - - return 0; -} - -bool VideoSortFilterProxyModel::connectSignals() -{ - // not stubbed - return true; -} - -void VideoSortFilterProxyModel::disconnectSignals() -{ - // not stubbed -} - -int VideoSortFilterProxyModel::open(VideoCollectionCommon::TCollectionLevels level) -{ - int err = 0; - - mLevel = level; - if (VideoSortFilterProxyModelData::mOpenFails) - { - err = -1; - } - - return err; -} - -void VideoSortFilterProxyModel::doSorting(int sortingRole, - Qt::SortOrder order, - bool async) -{ - VideoSortFilterProxyModelData::mDoSortingCallCount++; - VideoSortFilterProxyModelData::mSortRole = sortingRole; - VideoSortFilterProxyModelData::mSortOrder = order; - VideoSortFilterProxyModelData::mSortAsync = async; - setSortRole(sortingRole); - sort(0, order); -} - -void VideoSortFilterProxyModel::getSorting(int &sortingRole, - Qt::SortOrder &order) -{ - sortingRole = VideoSortFilterProxyModelData::mSortRole; - order = VideoSortFilterProxyModelData::mSortOrder; -} - -int VideoSortFilterProxyModel::deleteItems(const QModelIndexList &indexList) -{ - - int err = 0; - if (VideoSortFilterProxyModelData::mDeleteItemsFails) - { - err = -1; - } - else - { - if (indexList.count() > 0) - { - VideoSortFilterProxyModelData::mLastIndex = indexList.at(0); - } - } - - return err; -} - -int VideoSortFilterProxyModel::openItem(TMPXItemId mediaId) -{ - VideoSortFilterProxyModelData::mLastItemId = mediaId; - - return 0; -} - -int VideoSortFilterProxyModel::back() -{ - // not stubbed - return 0; -} - -int VideoSortFilterProxyModel::fetchItemDetails(const QModelIndex &index) -{ - VideoSortFilterProxyModelData::mLastIndex = index; - - return VideoSortFilterProxyModelData::mDetailsReturnValue; -} - -void VideoSortFilterProxyModel::processSorting() -{ - // not stubbed -} - -void VideoSortFilterProxyModel::albumChangedSlot() -{ - // not stubbed -} - -bool VideoSortFilterProxyModel::lessThan(const QModelIndex &left, - const QModelIndex &right) const -{ - Q_UNUSED(left); - Q_UNUSED(right); - // not stubbed - return true; -} - -bool VideoSortFilterProxyModel::filterAcceptsRow (int source_row, - const QModelIndex &source_parent) const -{ - Q_UNUSED(source_row); - Q_UNUSED(source_parent); - // not stubbed - return true; -} - - const TMPXItemId& VideoSortFilterProxyModel::getMediaIdAtIndex( - const QModelIndex &index) const -{ - if (index.row() >= 0 && - index.row() < VideoSortFilterProxyModelData::mItemIds.count()) - { - return VideoSortFilterProxyModelData::mItemIds[index.row()]; - } - return INVALID_ID; -} - -QModelIndex VideoSortFilterProxyModel::indexOfId(const TMPXItemId &id) -{ - //VideoListDataModel *sourceModel = qobject_cast(sourceModel()); - - for(int i = 0; i < VideoSortFilterProxyModelData::mItemIds.count(); i++) - { - if(VideoSortFilterProxyModelData::mItemIds.at(i) == id) - { - //return sourceModel->index(i, 0); - return index(i, 0); - } - } - return QModelIndex(); -} - -QString VideoSortFilterProxyModel::getMediaFilePathForId(const TMPXItemId &mediaId) -{ - Q_UNUSED(mediaId); - // not stubbed - return QString(); -} - -TModelType VideoSortFilterProxyModel::getType() -{ - return mType; -} - -TMPXItemId VideoSortFilterProxyModel::addNewAlbum(const QString &title) -{ - VideoSortFilterProxyModelData::mLastAddedAlbumName = title; - return VideoSortFilterProxyModelData::mNewAlbumId; -} - -QString VideoSortFilterProxyModel::resolveAlbumName( - const QString& albumName) const -{ - QString name = albumName; - return name; -} - -int VideoSortFilterProxyModel::addItemsInAlbum(TMPXItemId &albumId, const QList &mediaIds) -{ - if(VideoSortFilterProxyModelData::mAddItemsInAlbumReturnValue >= 0) - { - VideoSortFilterProxyModelData::mLastItemId = albumId; - VideoSortFilterProxyModelData::mItemIds.clear(); - VideoSortFilterProxyModelData::mItemIds = mediaIds; - } - // not stubbed - return VideoSortFilterProxyModelData::mAddItemsInAlbumReturnValue; -} - -int VideoSortFilterProxyModel::removeAlbums(const QModelIndexList &indexList) -{ - - int err = 0; - if (VideoSortFilterProxyModelData::mRemoveAlbumsFails) - { - err = -1; - } - else - { - if (indexList.count() > 0) - { - VideoSortFilterProxyModelData::mLastIndex = indexList.at(0); - } - } - - return err; -} - -int VideoSortFilterProxyModel::removeItemsFromAlbum(class TMPXItemId &album, QList const &mediaIds) -{ - if(VideoSortFilterProxyModelData::mRemoveItemsFromAlbumReturnValue >= 0) - { - VideoSortFilterProxyModelData::mLastItemId = album; - VideoSortFilterProxyModelData::mItemIds.clear(); - VideoSortFilterProxyModelData::mItemIds = mediaIds; - } - return VideoSortFilterProxyModelData::mRemoveItemsFromAlbumReturnValue; -} - -void VideoSortFilterProxyModel::setAlbumInUse(const TMPXItemId &albumId) -{ - VideoSortFilterProxyModelData::mLastItemId = albumId; -} - -int VideoSortFilterProxyModel::renameItem(const TMPXItemId &itemId, const QString &newTitle) -{ - if(VideoSortFilterProxyModelData::mRemoveItemsFromAlbumReturnValue >= 0) - { - VideoSortFilterProxyModelData::mLastItemId = itemId; - VideoSortFilterProxyModelData::mLastItemNameInRename = newTitle; - - } - return VideoSortFilterProxyModelData::mRenameItemReturnValue; -} - -TMPXItemId VideoSortFilterProxyModel::getOpenItem() const -{ - return VideoSortFilterProxyModelData::mOpenedItemId; -} - -void VideoSortFilterProxyModel::setGenericIdFilter(const TMPXItemId &itemId, bool filterValue) -{ - VideoSortFilterProxyModelData::mGenericFilterId = itemId; - VideoSortFilterProxyModelData::mGenericFilterValue = filterValue; - return; -} - -// end of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/stubs/src/videothumbnaildata.cpp --- a/videocollection/tsrc/stubs/src/videothumbnaildata.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/tsrc/stubs/src/videothumbnaildata.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -60,7 +60,7 @@ return 0; } -void VideoThumbnailData::startBackgroundFetching(VideoSortFilterProxyModel *model, int fetchIndex) +void VideoThumbnailData::startBackgroundFetching(VideoProxyModelGeneric *model, int fetchIndex) { Q_UNUSED(model); VideoThumbnailTestData::mStartBackgroundFetchingCallCount++; diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/stubs/stubs.pro --- a/videocollection/tsrc/stubs/stubs.pro Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/tsrc/stubs/stubs.pro Fri Sep 17 08:30:05 2010 +0300 @@ -76,7 +76,7 @@ inc/videolistwidgetdata.h \ inc/videolistviewdata.h \ inc/videoplayerappexport.h \ - inc/videosortfilterproxymodeldata.h \ + inc/videoproxymodeldata.h \ inc/videothumbnailtestdata.h \ inc/videoactivitystate.h \ inc/xqserviceutilxtra.h \ @@ -92,7 +92,10 @@ ../../videocollectionview/inc/videolistview.h \ ../../videocollectionwrapper/inc/videolistdatamodel.h \ ../../videocollectionwrapper/inc/videocollectionwrapper.h \ - ../../videocollectionwrapper/inc/videosortfilterproxymodel.h \ + ../../videocollectionwrapper/inc/videoproxymodelgeneric.h \ + ../../videocollectionwrapper/inc/videoproxymodelallvideos.h \ + ../../videocollectionwrapper/inc/videoproxymodelcollections.h \ + ../../videocollectionwrapper/inc/videoproxymodelcontent.h \ ../../videocollectionwrapper/inc/videothumbnaildata.h \ ../../videocollectionview/inc/videooperatorservice.h \ ../../videocollectionview/inc/videooperatorservice_p.h @@ -131,7 +134,10 @@ src/videolistview.cpp \ src/videolistdatamodel.cpp \ src/videocollectionwrapper.cpp \ - src/videosortfilterproxymodel.cpp \ + src/videoproxymodelgeneric.cpp \ + src/videoproxymodelallvideos.cpp \ + src/videoproxymodelcollections.cpp \ + src/videoproxymodelcontent.cpp \ src/videothumbnaildata.cpp \ src/videoservices.cpp \ src/videoserviceurifetch.cpp \ @@ -139,6 +145,7 @@ src/videoactivitystate.cpp \ src/videooperatorservice.cpp \ src/videooperatorservice_p.cpp \ + src/videocollectionwrapperdata.cpp \ src/xqsettingsmanagerstub.cpp HEADERS += $$find(HEADERS_TEMP, ^(?!.*$$TESTEDCLASS).*$) diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/tsrc/videoservicestestapp/sis/videoservicestestapp.sisx Binary file videocollection/tsrc/videoservicestestapp/sis/videoservicestestapp.sisx has changed diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionview/inc/videocollectionviewplugin.h --- a/videocollection/videocollectionview/inc/videocollectionviewplugin.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionview/inc/videocollectionviewplugin.h Fri Sep 17 08:30:05 2010 +0300 @@ -21,6 +21,7 @@ #include class VideoCollectionUiLoader; +class VideoCollectionViewUtils; class VideoListView; class VideoServices; @@ -137,6 +138,11 @@ VideoListView *mView; /** + * Reference to video collection view utils + */ + VideoCollectionViewUtils &mUiUtils; + + /** * Activated flag. Set as true when view is properly activated. * If flag is false, no operations can be do to the view. */ diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionview/inc/videocollectionviewutils.h --- a/videocollection/videocollectionview/inc/videocollectionviewutils.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionview/inc/videocollectionviewutils.h Fri Sep 17 08:30:05 2010 +0300 @@ -23,7 +23,7 @@ #include "videocollectioncommon.h" class HbListView; -class VideoSortFilterProxyModel; +class VideoProxyModelGeneric; class VideoCollectionViewUtils : public QObject { @@ -73,6 +73,16 @@ * @return Application UID if operation succeeded, less than zero in error cases. */ int getCenRepIntValue(int key); + + /** + * Set video services in use. + */ + void setIsService(); + + /** + * Get video services in use. + */ + bool isService(); public: /** @@ -84,7 +94,7 @@ /** * Initilizes model sort values. */ - static void sortModel(VideoSortFilterProxyModel *model, bool async, VideoCollectionCommon::TCollectionLevels target); + static void sortModel(VideoProxyModelGeneric *model, bool async, VideoCollectionCommon::TCollectionLevels target); /** * Method saves the latest videolist widget level into local activity manager @@ -149,6 +159,10 @@ virtual ~VideoCollectionViewUtils(); private: + + /** is service */ + bool mIsService; + /** current sorting role */ int mVideosSortRole; int mCollectionsSortRole; diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionview/inc/videolistselectiondialog.h --- a/videocollection/videocollectionview/inc/videolistselectiondialog.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionview/inc/videolistselectiondialog.h Fri Sep 17 08:30:05 2010 +0300 @@ -31,7 +31,7 @@ class HbStackedWidget; class VideoCollectionUiLoader; class VideoCollectionWrapper; -class VideoSortFilterProxyModel; +class VideoProxyModelGeneric; class VideoListWidget; class VideoListSelectionDialog: public HbDialog @@ -265,7 +265,7 @@ /** * Video list model */ - VideoSortFilterProxyModel *mModel; + VideoProxyModelGeneric *mModel; /** * Boolean to know if the model is ready or not. diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionview/inc/videolistview.h --- a/videocollection/videocollectionview/inc/videolistview.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionview/inc/videolistview.h Fri Sep 17 08:30:05 2010 +0300 @@ -30,7 +30,7 @@ class QActionGroup; class QVariant; class VideoCollectionViewUtils; -class VideoSortFilterProxyModel; +class VideoProxyModelGeneric; class VideoCollectionWrapper; class HbStackedWidget; class VideoCollectionUiLoader; diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionview/inc/videolistwidget.h --- a/videocollection/videocollectionview/inc/videolistwidget.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionview/inc/videolistwidget.h Fri Sep 17 08:30:05 2010 +0300 @@ -27,7 +27,7 @@ #include "videoservices.h" #include "videocollectioncommon.h" -class VideoSortFilterProxyModel; +class VideoProxyModelGeneric; class VideoServices; class VideoCollectionUiLoader; class HbAction; @@ -73,7 +73,7 @@ * @param level presetted level for the widget * @return int 0 initialization ok, < 0 if fails. */ - int initialize(VideoSortFilterProxyModel &model, + int initialize(VideoProxyModelGeneric &model, bool isService = false, VideoCollectionCommon::TCollectionLevels level = VideoCollectionCommon::ELevelInvalid); @@ -107,9 +107,9 @@ /** * returns widget's model * - * @return VideoSortFilterProxyModel* + * @return VideoProxyModelGeneric* */ - VideoSortFilterProxyModel* getModel(); + VideoProxyModelGeneric* getModel(); public: @@ -377,7 +377,7 @@ * Provided model * Not own. */ - QPointer mModel; + QPointer mModel; /** * pointer to videoservices instance. If exists, diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionview/src/videocollectionuiloader.cpp --- a/videocollection/videocollectionview/src/videocollectionuiloader.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionview/src/videocollectionuiloader.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 24 % +// Version : %version: 24.1.1 % // INCLUDE FILES #include @@ -32,7 +32,7 @@ #include "videolistwidget.h" #include "videohintwidget.h" #include "videocollectionwrapper.h" -#include "videosortfilterproxymodel.h" +#include "videoproxymodelgeneric.h" #include "videocollectionviewutils.h" #include "videocollectiontrace.h" @@ -368,8 +368,7 @@ VideoListWidget *videoList = qobject_cast(object); if (videoList) { - VideoSortFilterProxyModel *model = - wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); if(model) { VideoCollectionViewUtils::sortModel(model, true, VideoCollectionCommon::ELevelVideos); @@ -381,8 +380,7 @@ } else if (name.compare(DOCML_NAME_VC_COLLECTIONWIDGET) == 0) { - VideoSortFilterProxyModel *model = wrapper.getModel( - VideoCollectionCommon::EModelTypeCollections); + VideoProxyModelGeneric *model = wrapper.getCollectionsModel(); if (model) { VideoCollectionViewUtils::sortModel(model, true, VideoCollectionCommon::ELevelCategory); @@ -399,8 +397,7 @@ } else if (name.compare(DOCML_NAME_VC_COLLECTIONCONTENTWIDGET) == 0) { - VideoSortFilterProxyModel *model = wrapper.getModel( - VideoCollectionCommon::EModelTypeCollectionContent); + VideoProxyModelGeneric *model = wrapper.getCollectionContentModel(); if (model) { // collection content contains always a list of videos so we use diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionview/src/videocollectionviewplugin.cpp --- a/videocollection/videocollectionview/src/videocollectionviewplugin.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionview/src/videocollectionviewplugin.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,11 +15,10 @@ * */ -// Version : %version: 24 % +// Version : %version: 25 % // INCLUDE FILES #include -#include #include #include #include @@ -30,6 +29,7 @@ #include "videocollectionviewplugin.h" #include "videolistview.h" #include "videocollectionuiloader.h" +#include "videocollectionviewutils.h" #include "mpxhbvideocommondefs.h" #include "videocollectiontrace.h" @@ -40,6 +40,7 @@ VideoCollectionViewPlugin::VideoCollectionViewPlugin() : mUiLoader( 0 ) , mView( 0 ) + , mUiUtils( VideoCollectionViewUtils::instance() ) , mActivated( false ) , mVideoServices( 0 ) { @@ -73,7 +74,9 @@ mUiLoader->reset(); - mUiLoader->setIsService(XQServiceUtil::isService()); + mUiUtils.setIsService(); + + mUiLoader->setIsService(mUiUtils.isService()); bool ok(false); @@ -160,7 +163,7 @@ if(wnd) { TMPXItemId itemId = TMPXItemId::InvalidId(); - bool isService = XQServiceUtil::isService(); + bool isService = mUiUtils.isService(); if (isService) { if(!mVideoServices) diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionview/src/videocollectionviewutils.cpp --- a/videocollection/videocollectionview/src/videocollectionviewutils.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionview/src/videocollectionviewutils.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 47 % +// Version : %version: 51 % // INCLUDE FILES #include @@ -27,11 +27,12 @@ #include #include #include +#include #include #include "videocollectioncommon.h" #include "videocollectionviewutils.h" -#include "videosortfilterproxymodel.h" +#include "videoproxymodelgeneric.h" #include "videoactivitystate.h" #include "videocollectioncenrepdefs.h" #include "videocollectiontrace.h" @@ -70,11 +71,12 @@ // VideoCollectionViewUtils // --------------------------------------------------------------------------- // -VideoCollectionViewUtils::VideoCollectionViewUtils(): - mVideosSortRole(-1), - mCollectionsSortRole(-1), - mVideosSortOrder(Qt::AscendingOrder), - mCollectionsSortOrder(Qt::AscendingOrder) +VideoCollectionViewUtils::VideoCollectionViewUtils() + : mIsService(false) + , mVideosSortRole(-1) + , mCollectionsSortRole(-1) + , mVideosSortOrder(Qt::AscendingOrder) + , mCollectionsSortOrder(Qt::AscendingOrder) { FUNC_LOG; } @@ -89,6 +91,30 @@ } // --------------------------------------------------------------------------- +// setIsService +// --------------------------------------------------------------------------- +// +void VideoCollectionViewUtils::setIsService() +{ + FUNC_LOG; + + mIsService = XQServiceUtil::isService(); + + INFO_1("VideoCollectionViewUtils::setService() saving: is service: %d", mIsService); +} + +// --------------------------------------------------------------------------- +// isService +// --------------------------------------------------------------------------- +// +bool VideoCollectionViewUtils::isService() +{ + FUNC_LOG; + + return mIsService; +} + +// --------------------------------------------------------------------------- // saveSortingValues // --------------------------------------------------------------------------- // @@ -256,7 +282,7 @@ // --------------------------------------------------------------------------- // void VideoCollectionViewUtils::sortModel( - VideoSortFilterProxyModel *model, + VideoProxyModelGeneric *model, bool async, VideoCollectionCommon::TCollectionLevels target) { @@ -394,7 +420,7 @@ } break; case VideoCollectionCommon::statusMultipleDeleteFail: - msg = hbTrId("txt_videos_info_unable_to_delete_some_items_which"); + msg = hbTrId("txt_videos_info_unable_to_delete_some_videos_which"); break; case VideoCollectionCommon::statusSingleRemoveFail: format = hbTrId("txt_videos_info_unable_to_remove_collection_1"); @@ -412,9 +438,12 @@ { int count = additional.toList().at(KAddToCollectionCountIndex).toInt(); QString name = additional.toList().at(KAddToCollectionNameIndex).toString(); - if(count && name.length()) + if(count > 0 && name.length()) { - msg = hbTrId("txt_videos_dpopinfo_ln_videos_added_to_1", count).arg(name); + const char* locId = count == 1 ? "txt_videos_dpopinfo_video_added_to_1" : + "txt_videos_dpopinfo_videos_added_to_1"; + + msg = hbTrId(locId).arg(name); } } error = false; diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionview/src/videolistselectiondialog.cpp --- a/videocollection/videocollectionview/src/videolistselectiondialog.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionview/src/videolistselectiondialog.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 30.1.3 % +// Version : %version: 30.1.4 % // INCLUDE FILES #include @@ -30,7 +30,7 @@ #include "videocollectionuiloader.h" #include "videolistwidget.h" -#include "videosortfilterproxymodel.h" +#include "videoproxymodelgeneric.h" #include "videolistselectiondialog.h" #include "videocollectionwrapper.h" #include "videocollectionviewutils.h" @@ -101,8 +101,7 @@ // create model for list widget mModel = - VideoCollectionWrapper::instance().getModel( - VideoCollectionCommon::EModelTypeGeneric); + VideoCollectionWrapper::instance().getGenericModel(); if (mModel) { // create list widget @@ -189,7 +188,7 @@ FUNC_LOG; if(!mModel) { - mModel = VideoCollectionWrapper::instance().getModel(VideoCollectionCommon::EModelTypeGeneric); + mModel = VideoCollectionWrapper::instance().getGenericModel(); if (!mModel) { return false; @@ -793,9 +792,8 @@ QString name; if(mSelectedAlbumId.iId2 > KVcxMvcMediaTypeVideo) { - VideoSortFilterProxyModel *model = - VideoCollectionWrapper::instance().getModel( - VideoCollectionCommon::EModelTypeCollections); + VideoProxyModelGeneric *model = + VideoCollectionWrapper::instance().getCollectionsModel(); if(!model) { return name; diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionview/src/videolistview.cpp --- a/videocollection/videocollectionview/src/videolistview.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionview/src/videolistview.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,10 +15,9 @@ * */ -// Version : %version: 113.1.5 % +// Version : %version: 113.1.8 % // INCLUDE FILES -#include #include #include #include @@ -44,7 +43,7 @@ #include "videolistview.h" #include "videocollectioncommon.h" #include "videocollectionwrapper.h" -#include "videosortfilterproxymodel.h" +#include "videoproxymodelgeneric.h" #include "videocollectionuiloader.h" #include "mpxhbvideocommondefs.h" #include "videooperatorservice.h" @@ -123,7 +122,7 @@ int collectionListPhase = VideoCollectionUiLoaderParam::LoadPhaseSecondary; int collectionContentListPhase = VideoCollectionUiLoaderParam::LoadPhaseSecondary; VideoCollectionCommon::TCollectionLevels level = VideoCollectionCommon::ELevelVideos; - if (XQServiceUtil::isService()) + if (mUiUtils.isService()) { INFO("VideoListView::initializeView() initializing service."); if (!mVideoServices) @@ -608,6 +607,13 @@ else if(level == VideoCollectionCommon::ELevelAlbum) { bar->addActions(mToolbarCollectionActionGroup->actions()); + if(!mModelReady) + { + // if model not ready yet toolbuttons should not be + // visible, after model responds visibility will be updated + mToolbarActions[ETBActionAddVideos]->setVisible(false); + mToolbarActions[ETBActionRemoveVideos]->setVisible(false); + } } if(mToolbarServiceExtension && (level == VideoCollectionCommon::ELevelCategory @@ -738,7 +744,7 @@ return; } - VideoSortFilterProxyModel *model = mCurrentList->getModel(); + VideoProxyModelGeneric *model = mCurrentList->getModel(); if(!model || (!mModelReady && model->rowCount() == 0)) { @@ -774,6 +780,7 @@ if (mToolbarViewsActionGroup && mToolbarCollectionActionGroup && !mVideoServices) { + mToolbarActions[ETBActionAddVideos]->setVisible(true); if (show) { mToolbarActions[ETBActionRemoveVideos]->setVisible(false); @@ -819,7 +826,7 @@ void VideoListView::updateSubLabel() { FUNC_LOG; - VideoSortFilterProxyModel *model = 0; + VideoProxyModelGeneric *model = 0; if(mCurrentList) { model = mCurrentList->getModel(); @@ -1096,7 +1103,7 @@ } // sort model Qt::SortOrder order(Qt::AscendingOrder); - VideoSortFilterProxyModel *model = mCurrentList->getModel(); + VideoProxyModelGeneric *model = mCurrentList->getModel(); if(model->sortRole() == role && model->sortOrder() == Qt::AscendingOrder) { order = Qt::DescendingOrder; @@ -1319,7 +1326,7 @@ } // No other actions shown if there's no videos. - VideoSortFilterProxyModel *model = mCurrentList->getModel(); + VideoProxyModelGeneric *model = mCurrentList->getModel(); if (!model || !model->rowCount()) { return; @@ -1403,7 +1410,7 @@ showAction(false, DOCML_NAME_SORT_BY_SIZE); showAction(false, DOCML_NAME_SORT_MENU); - VideoSortFilterProxyModel *model = mCurrentList->getModel(); + VideoProxyModelGeneric *model = mCurrentList->getModel(); if (!model || !model->rowCount()) { return; @@ -1482,7 +1489,7 @@ return; } - VideoSortFilterProxyModel *model = collectionContentWidget->getModel(); + VideoProxyModelGeneric *model = collectionContentWidget->getModel(); if(!model) { // no model for content widget, cannot activate @@ -1512,18 +1519,21 @@ mModelReady = model->rowCount() > 0; setHintLevel(VideoHintWidget::Collection); - // update toolbar for albums, default categories don't have one. Neither does services. - toolBar()->clearActions(); - if(!mVideoServices && level == VideoCollectionCommon::ELevelAlbum && - mToolbarCollectionActionGroup && mToolbarActions.contains(ETBActionCollections)) + if(mToolbarCollectionActionGroup) { - mToolbarActions[ETBActionCollections]->setChecked(false); - toolBar()->addActions(mToolbarCollectionActionGroup->actions()); - setItemVisible(Hb::ToolBarItem, true); - } - else - { - setItemVisible(Hb::ToolBarItem, false); + // update toolbar for albums, default categories don't have one. Neither does services. + toolBar()->clearActions(); + if(!mVideoServices && level == VideoCollectionCommon::ELevelAlbum && + mToolbarActions.contains(ETBActionCollections)) + { + mToolbarActions[ETBActionCollections]->setChecked(false); + toolBar()->addActions(mToolbarCollectionActionGroup->actions()); + setItemVisible(Hb::ToolBarItem, true); + } + else + { + setItemVisible(Hb::ToolBarItem, false); + } } // restore animations for collection content widget collectionContentWidget->setEnabledAnimations(animationState); diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionview/src/videolistwidget.cpp --- a/videocollection/videocollectionview/src/videolistwidget.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionview/src/videolistwidget.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -18,7 +18,6 @@ #include "videocollectiontrace.h" #include "videolistwidget.h" -#include #include #include #include @@ -37,7 +36,7 @@ #include "videocollectionuiloader.h" #include "videolistselectiondialog.h" #include "videothumbnaildata.h" -#include "videosortfilterproxymodel.h" +#include "videoproxymodelgeneric.h" #include "videocollectioncommon.h" #include "mpxhbvideocommondefs.h" @@ -45,6 +44,7 @@ const char* const LIST_WIDGET_OBJECT_NAME_CONTEXT_MENU = "vc:ListWidgetContextMenu"; const char* const LIST_WIDGET_OBJECT_NAME_DELETE_VIDEO = "vc:ListWidgetMessageBoxDeleteVideo"; const char* const LIST_WIDGET_OBJECT_NAME_RENAME_VIDEO = "vc:ListWidgetInputDialogRenameVideo"; +const char* const LIST_WIDGET_OBJECT_NAME_RENAME_ALBUM = "vc:ListWidgetInputDialogRenameAlbum"; const char* const LIST_WIDGET_OBJECT_NAME_REMOVE_COLLECTION = "vc:ListWidgetMessageBoxRemoveCollection"; const char* const LIST_WIDGET_OBJECT_NAME_NAV_KEY_BACK = "vc:ListWidgetNavKeyBack"; const char* const LIST_WIDGET_OBJECT_NAME_NAV_KEY_QUIT = "vc:ListWidgetNavKeyQuit"; @@ -108,7 +108,7 @@ // initialize // --------------------------------------------------------------------------- // -int VideoListWidget::initialize(VideoSortFilterProxyModel &model, +int VideoListWidget::initialize(VideoProxyModelGeneric &model, bool isService, VideoCollectionCommon::TCollectionLevels level) { @@ -191,18 +191,17 @@ ERROR_1(-1, "VideoListWidget::activate() [0x%x]: connecting signals failed.", this); return -1; } - + + // Enable thumbnail background fetching. + VideoThumbnailData::instance().enableBackgroundFetching(true); + fetchThumbnailsForVisibleItems(); + // open model to the current level in case not in album or category if (level != VideoCollectionCommon::ELevelAlbum && level != VideoCollectionCommon::ELevelDefaultColl) { mModel->open(level); } - - // Enable thumbnail background fetching. - VideoThumbnailData &thumbnailData = VideoThumbnailData::instance(); - thumbnailData.enableBackgroundFetching(true); - fetchThumbnailsForVisibleItems(); return 0; } @@ -222,10 +221,8 @@ setVisible(false); disConnectSignals(); - // Free allocated memory for list thumbnails and disable background fetching. - VideoThumbnailData &thumbnailData = VideoThumbnailData::instance(); - thumbnailData.enableBackgroundFetching(false); - thumbnailData.freeThumbnailData(); + // Disable background thumbnail fetching. + VideoThumbnailData::instance().enableBackgroundFetching(false); } // --------------------------------------------------------------------------- @@ -603,7 +600,7 @@ // getModel // --------------------------------------------------------------------------- // -VideoSortFilterProxyModel* VideoListWidget::getModel() +VideoProxyModelGeneric* VideoListWidget::getModel() { FUNC_LOG_ADDR(this); return mModel; @@ -685,6 +682,10 @@ } else { + if(mModel->getMediaIdAtIndex(index).iId2 == KVcxMvcMediaTypeVideo) + { + VideoThumbnailData::instance().freeThumbnailData(); + } mModel->openItem(mModel->getMediaIdAtIndex(index)); } } @@ -798,18 +799,34 @@ QModelIndex index = currentIndex(); QVariant variant = mModel->data(index, VideoCollectionCommon::KeyTitle); - + if(variant.isValid()) { - QString label(hbTrId("txt_videos_title_enter_name")); - QString albumName = variant.toString(); + QString label; + const char* objectName = 0; + QString currentName = variant.toString(); - HbInputDialog *dialog = new HbInputDialog(); - dialog->setAttribute(Qt::WA_DeleteOnClose); - dialog->setObjectName(LIST_WIDGET_OBJECT_NAME_RENAME_VIDEO); - dialog->setPromptText(label); - dialog->setValue(albumName); - dialog->open(this, SLOT(renameDialogFinished(HbAction *))); + TMPXItemId mpxId = mModel->getMediaIdAtIndex(index); + if(mpxId.iId2 == KVcxMvcMediaTypeAlbum) + { + label = hbTrId("txt_videos_title_enter_name"); + objectName = LIST_WIDGET_OBJECT_NAME_RENAME_ALBUM; + } + else if(mpxId.iId2 == KVcxMvcMediaTypeVideo) + { + label = hbTrId("txt_videos_dialog_video_name"); + objectName = LIST_WIDGET_OBJECT_NAME_RENAME_VIDEO; + } + + if(!label.isEmpty()) + { + HbInputDialog *dialog = new HbInputDialog(); + dialog->setAttribute(Qt::WA_DeleteOnClose); + dialog->setObjectName(objectName); + dialog->setPromptText(label); + dialog->setValue(currentName); + dialog->open(this, SLOT(renameDialogFinished(HbAction *))); + } } } @@ -828,6 +845,7 @@ } QModelIndex index = currentIndex(); TMPXItemId itemId = mModel->getMediaIdAtIndex(index); + QVariant newNameVariant = dialog->value(); QVariant oldNameVariant = mModel->data(index, VideoCollectionCommon::KeyTitle); if(!newNameVariant.isValid() || !oldNameVariant.isValid()) @@ -835,9 +853,10 @@ // invalid data at index return; } - QString newAlbumName = newNameVariant.toString().trimmed(); - QString oldAlbumName = oldNameVariant.toString(); - if(!newAlbumName.length() || newAlbumName == oldAlbumName) + + QString newName = newNameVariant.toString().trimmed(); + QString oldName = oldNameVariant.toString(); + if(!newName.length() || newName == oldName) { // no new name provided or name has not changed return; @@ -845,9 +864,9 @@ if(itemId.iId2 == KVcxMvcMediaTypeAlbum) { // for album, we need to make sure name is unique - newAlbumName = mModel->resolveAlbumName(newAlbumName); + newName = mModel->resolveAlbumName(newName); } - mModel->renameItem(itemId, newAlbumName); + mModel->renameItem(itemId, newName); } // --------------------------------------------------------------------------- diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionview/tsrc/testcollectionview/inc/testcollectionview.h --- a/videocollection/videocollectionview/tsrc/testcollectionview/inc/testcollectionview.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionview/tsrc/testcollectionview/inc/testcollectionview.h Fri Sep 17 08:30:05 2010 +0300 @@ -11,7 +11,7 @@ * * Contributors: * -* Description: tester for methods in VideoSortFilterProxyModel +* Description: tester for methods in VideoProxyModelGeneric * */ diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionview/tsrc/testcollectionview/src/testcollectionview.cpp --- a/videocollection/videocollectionview/tsrc/testcollectionview/src/testcollectionview.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionview/tsrc/testcollectionview/src/testcollectionview.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -11,7 +11,7 @@ * * Contributors: * -* Description: tester for methods in VideoSortFilterProxyModel +* Description: tester for methods in VideoProxyModelGeneric * */ @@ -110,7 +110,8 @@ HbMainWindow *window = hbInstance->allMainWindows().value(0); if (window) { - window->addView(mTestView->getView()); + HbView *view = qobject_cast(mTestView->getView()); + window->addView(view); } } @@ -347,7 +348,6 @@ QApplication::sendEvent(mTestView, &timerEvent); QVERIFY(commandSpy.count() == 1); QVERIFY(delayedSpy.count() == 1); - } // --------------------------------------------------------------------------- diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionview/tsrc/testhintwidget/inc/testhintwidget.h --- a/videocollection/videocollectionview/tsrc/testhintwidget/inc/testhintwidget.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionview/tsrc/testhintwidget/inc/testhintwidget.h Fri Sep 17 08:30:05 2010 +0300 @@ -11,7 +11,7 @@ * * Contributors: * -* Description: tester for methods in VideoSortFilterProxyModel +* Description: tester for methods in VideoProxyModelGeneric * */ diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionview/tsrc/testlistview/inc/testlistview.h --- a/videocollection/videocollectionview/tsrc/testlistview/inc/testlistview.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionview/tsrc/testlistview/inc/testlistview.h Fri Sep 17 08:30:05 2010 +0300 @@ -26,7 +26,7 @@ #include "hbeffect.h" class VideoListView; -class VideoSortFilterProxyModel; +class VideoProxyModelGeneric; class VideoCollectionWrapper; class VideoCollectionUiLoader; class VideoListWidget; @@ -48,7 +48,7 @@ /** * Set row count in model. */ - void setRowCount(int count, VideoSortFilterProxyModel *model = 0); + void setRowCount(int count, VideoProxyModelGeneric *model = 0); /** * Check if action is visible. diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionview/tsrc/testlistview/src/testlistview.cpp --- a/videocollection/videocollectionview/tsrc/testlistview/src/testlistview.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionview/tsrc/testlistview/src/testlistview.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,11 +15,11 @@ * */ -// Version : %version: 54 % +// Version : %version: 55 % #define private public #include "videoservices.h" -#include "videosortfilterproxymodel.h" +#include "videoproxymodelgeneric.h" #include "videolistwidget.h" #include "videolistview.h" #undef private @@ -59,7 +59,7 @@ #include "videocollectionwrapperdata.h" #include "videocollectionviewutilsdata.h" #include "videolistselectiondialogdata.h" -#include "videosortfilterproxymodeldata.h" +#include "videoproxymodeldata.h" #include "videocollectionuiloaderdata.h" #include "videolistdatamodeldata.h" #include "xqserviceutilxtra.h" @@ -147,7 +147,7 @@ VideoCollectionWrapperData::reset(); VideoCollectionViewUtilsData::reset(); VideoListSelectionDialogData::reset(); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); HbDocumentLoader::cleanup(); } @@ -175,7 +175,7 @@ // setRowCount // --------------------------------------------------------------------------- // -void TestListView::setRowCount(int count, VideoSortFilterProxyModel *model) +void TestListView::setRowCount(int count, VideoProxyModelGeneric *model) { if(!model) { @@ -464,7 +464,7 @@ videoListWidget = mUiLoader->findWidget(DOCML_NAME_VC_VIDEOLISTWIDGET); QVERIFY(videoListWidget); VideoListWidgetData::mActivateReturnValue = -1; - QCOMPARE( mTestView->activateView(invalidId), -1 ); + QCOMPARE( mTestView->activateView(invalidId), -1 ); QVERIFY( VideoListWidgetData::mActive == false ); QCOMPARE( VideoListWidgetData::mActivateCount, 1 ); QCOMPARE( VideoListWidgetData::mDeactivateCount, 1 ); @@ -492,7 +492,7 @@ TMPXItemId itemId = TMPXItemId::InvalidId(); init(); VideoListWidgetData::reset(); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); itemId.iId1 = KVcxMvcCategoryIdCaptured; itemId.iId2 = KVcxMvcMediaTypeCategory; QCOMPARE(mTestView->activateView(itemId), 0); @@ -500,14 +500,14 @@ QCOMPARE(VideoListWidgetData::mActivateCount, 1); QCOMPARE(mTestView->mCollectionName, hbTrId("txt_videos_dblist_captured")); QCOMPARE(mTestView->mCurrentList->getLevel(), VideoCollectionCommon::ELevelDefaultColl); - QCOMPARE(VideoSortFilterProxyModelData::mLastItemId, itemId); + QCOMPARE(VideoProxyModelData::mLastItemId, itemId); cleanup(); // activate collection content view:: // -downloaded category init(); VideoListWidgetData::reset(); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); itemId.iId1 = KVcxMvcCategoryIdDownloads; itemId.iId2 = KVcxMvcMediaTypeCategory; QCOMPARE(mTestView->activateView(itemId), 0); @@ -515,7 +515,7 @@ QCOMPARE(VideoListWidgetData::mActivateCount, 1); QCOMPARE(mTestView->mCollectionName, hbTrId("txt_videos_dblist_downloaded")); QCOMPARE(mTestView->mCurrentList->getLevel(), VideoCollectionCommon::ELevelDefaultColl); - QCOMPARE(VideoSortFilterProxyModelData::mLastItemId, itemId); + QCOMPARE(VideoProxyModelData::mLastItemId, itemId); cleanup(); // activate collection content view: @@ -523,7 +523,7 @@ init(); videoListWidget = mUiLoader->findWidget(DOCML_NAME_VC_VIDEOLISTWIDGET); VideoListWidgetData::reset(); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); itemId.iId1 = KVcxMvcCategoryIdOther; itemId.iId2 = KVcxMvcMediaTypeCategory; QCOMPARE(mTestView->activateView(itemId), -1); @@ -532,14 +532,14 @@ QCOMPARE(mTestView->mCollectionName.length(), 0); // for not activated widget, defaultlevel is ELevelVideos QCOMPARE(mTestView->mCurrentList->getLevel(), VideoCollectionCommon::ELevelVideos); - QCOMPARE(VideoSortFilterProxyModelData::mLastItemId, TMPXItemId::InvalidId()); + QCOMPARE(VideoProxyModelData::mLastItemId, TMPXItemId::InvalidId()); cleanup(); // activate collection content view: // -invalid category but item id is ok init(); VideoListWidgetData::reset(); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); itemId.iId1 = 0; itemId.iId2 = KVcxMvcMediaTypeVideo; QCOMPARE(mTestView->activateView(itemId), -1); @@ -548,7 +548,7 @@ QCOMPARE(mTestView->mCollectionName.length(), 0); // for not activated widget, defaultlevel is ELevelVideos QCOMPARE(mTestView->mCurrentList->getLevel(), VideoCollectionCommon::ELevelVideos); - QCOMPARE(VideoSortFilterProxyModelData::mLastItemId, TMPXItemId::InvalidId()); + QCOMPARE(VideoProxyModelData::mLastItemId, TMPXItemId::InvalidId()); cleanup(); // activate view: @@ -562,7 +562,7 @@ videoServices->mCurrentService = VideoServices::EBrowse; videoServices->mSortRole = 0; VideoListWidgetData::reset(); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); itemId.iId1 = KVcxMvcCategoryIdCaptured; itemId.iId2 = KVcxMvcMediaTypeCategory; QCOMPARE(mTestView->initializeView(), 0); @@ -571,9 +571,9 @@ QCOMPARE(VideoListWidgetData::mActivateCount, 1); QCOMPARE(mTestView->mCollectionName, hbTrId("txt_videos_dblist_captured")); QCOMPARE(mTestView->mCurrentList->getLevel(), VideoCollectionCommon::ELevelDefaultColl); - QCOMPARE(VideoSortFilterProxyModelData::mLastItemId, itemId); - QCOMPARE(VideoSortFilterProxyModelData::mSortRole, (int)VideoCollectionCommon::KeyDateTime); - QCOMPARE(VideoSortFilterProxyModelData::mSortOrder, Qt::AscendingOrder); + QCOMPARE(VideoProxyModelData::mLastItemId, itemId); + QCOMPARE(VideoProxyModelData::mSortRole, (int)VideoCollectionCommon::KeyDateTime); + QCOMPARE(VideoProxyModelData::mSortOrder, Qt::AscendingOrder); serviceUtilXtra->decreaseReferenceCount(); videoServices->decreaseReferenceCount(); cleanup(); @@ -589,7 +589,7 @@ videoServices->mCurrentService = VideoServices::EBrowse; videoServices->mSortRole = 1; VideoListWidgetData::reset(); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); itemId.iId1 = KVcxMvcCategoryIdCaptured; itemId.iId2 = KVcxMvcMediaTypeCategory; QCOMPARE(mTestView->initializeView(), 0); @@ -598,9 +598,9 @@ QCOMPARE(VideoListWidgetData::mActivateCount, 1); QCOMPARE(mTestView->mCollectionName, hbTrId("txt_videos_dblist_captured")); QCOMPARE(mTestView->mCurrentList->getLevel(), VideoCollectionCommon::ELevelDefaultColl); - QCOMPARE(VideoSortFilterProxyModelData::mLastItemId, itemId); - QCOMPARE(VideoSortFilterProxyModelData::mSortRole, (int)VideoCollectionCommon::KeyDateTime); - QCOMPARE(VideoSortFilterProxyModelData::mSortOrder, Qt::AscendingOrder); + QCOMPARE(VideoProxyModelData::mLastItemId, itemId); + QCOMPARE(VideoProxyModelData::mSortRole, (int)VideoCollectionCommon::KeyDateTime); + QCOMPARE(VideoProxyModelData::mSortOrder, Qt::AscendingOrder); cleanup(); serviceUtilXtra->decreaseReferenceCount(); videoServices->decreaseReferenceCount(); @@ -616,7 +616,7 @@ videoServices->mCurrentService = VideoServices::EBrowse; videoServices->mSortRole = 2; VideoListWidgetData::reset(); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); itemId.iId1 = KVcxMvcCategoryIdCaptured; itemId.iId2 = KVcxMvcMediaTypeCategory; QCOMPARE(mTestView->initializeView(), 0); @@ -625,9 +625,9 @@ QCOMPARE(VideoListWidgetData::mActivateCount, 1); QCOMPARE(mTestView->mCollectionName, hbTrId("txt_videos_dblist_captured")); QCOMPARE(mTestView->mCurrentList->getLevel(), VideoCollectionCommon::ELevelDefaultColl); - QCOMPARE(VideoSortFilterProxyModelData::mLastItemId, itemId); - QCOMPARE(VideoSortFilterProxyModelData::mSortRole, (int)VideoCollectionCommon::KeyTitle); - QCOMPARE(VideoSortFilterProxyModelData::mSortOrder, Qt::AscendingOrder); + QCOMPARE(VideoProxyModelData::mLastItemId, itemId); + QCOMPARE(VideoProxyModelData::mSortRole, (int)VideoCollectionCommon::KeyTitle); + QCOMPARE(VideoProxyModelData::mSortOrder, Qt::AscendingOrder); cleanup(); serviceUtilXtra->decreaseReferenceCount(); videoServices->decreaseReferenceCount(); @@ -643,7 +643,7 @@ videoServices->mCurrentService = VideoServices::EBrowse; videoServices->mSortRole = 3; VideoListWidgetData::reset(); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); itemId.iId1 = KVcxMvcCategoryIdCaptured; itemId.iId2 = KVcxMvcMediaTypeCategory; QCOMPARE(mTestView->initializeView(), 0); @@ -652,9 +652,9 @@ QCOMPARE(VideoListWidgetData::mActivateCount, 1); QCOMPARE(mTestView->mCollectionName, hbTrId("txt_videos_dblist_captured")); QCOMPARE(mTestView->mCurrentList->getLevel(), VideoCollectionCommon::ELevelDefaultColl); - QCOMPARE(VideoSortFilterProxyModelData::mLastItemId, itemId); - QCOMPARE(VideoSortFilterProxyModelData::mSortRole, (int)VideoCollectionCommon::KeySizeValue); - QCOMPARE(VideoSortFilterProxyModelData::mSortOrder, Qt::AscendingOrder); + QCOMPARE(VideoProxyModelData::mLastItemId, itemId); + QCOMPARE(VideoProxyModelData::mSortRole, (int)VideoCollectionCommon::KeySizeValue); + QCOMPARE(VideoProxyModelData::mSortOrder, Qt::AscendingOrder); cleanup(); serviceUtilXtra->decreaseReferenceCount(); videoServices->decreaseReferenceCount(); @@ -832,16 +832,16 @@ init(false); connect(this, SIGNAL(testSignal(int)), mTestView, SLOT(startSorting())); emit testSignal(0); - QCOMPARE(VideoSortFilterProxyModelData::mDoSortingCallCount, 0); - QCOMPARE(VideoSortFilterProxyModelData::mSortRole, -1); + QCOMPARE(VideoProxyModelData::mDoSortingCallCount, 0); + QCOMPARE(VideoProxyModelData::mSortRole, -1); cleanup(); // View is not activated. init(); connect(this, SIGNAL(testSignal(int)), mTestView, SLOT(startSorting())); emit testSignal(0); - QCOMPARE(VideoSortFilterProxyModelData::mDoSortingCallCount, 0); - QCOMPARE(VideoSortFilterProxyModelData::mSortRole, -1); + QCOMPARE(VideoProxyModelData::mDoSortingCallCount, 0); + QCOMPARE(VideoProxyModelData::mSortRole, -1); cleanup(); TMPXItemId invalidId = TMPXItemId::InvalidId(); @@ -856,8 +856,8 @@ HbMenuData::mMenuAction = sortMenuAction; connect(this, SIGNAL(testSignal(int)), mTestView, SLOT(startSorting())); emit testSignal(0); - QCOMPARE(VideoSortFilterProxyModelData::mDoSortingCallCount, 0); - QCOMPARE(VideoSortFilterProxyModelData::mSortRole, -1); + QCOMPARE(VideoProxyModelData::mDoSortingCallCount, 0); + QCOMPARE(VideoProxyModelData::mSortRole, -1); cleanup(); // Good cases. @@ -866,7 +866,7 @@ sortMenu = mUiLoader->findWidget(DOCML_NAME_SORT_MENU); sortMenuAction->setMenu(sortMenu); HbMenuData::mMenuAction = sortMenuAction; - VideoSortFilterProxyModel* model = mTestView->mCurrentList->getModel(); + VideoProxyModelGeneric* model = mTestView->mCurrentList->getModel(); QVERIFY(action != 0); mUiLoader->findWidget(DOCML_NAME_OPTIONS_MENU)->setActiveAction(sortMenuAction); HbAction* sortAction = mUiLoader->findObject(DOCML_NAME_SORT_BY_NAME); @@ -883,42 +883,42 @@ connect(this, SIGNAL(testSignal(int)), mTestView, SLOT(startSorting())); emit testSignal(0); // since current list is videolist, sorting count is 2 because both all videos and collection content are sorted - QCOMPARE(VideoSortFilterProxyModelData::mDoSortingCallCount, 2); - QCOMPARE(VideoSortFilterProxyModelData::mSortRole, (int)VideoCollectionCommon::KeyTitle); - QCOMPARE(VideoSortFilterProxyModelData::mSortOrder, Qt::AscendingOrder); - QVERIFY(VideoSortFilterProxyModelData::mSortAsync); + QCOMPARE(VideoProxyModelData::mDoSortingCallCount, 2); + QCOMPARE(VideoProxyModelData::mSortRole, (int)VideoCollectionCommon::KeyTitle); + QCOMPARE(VideoProxyModelData::mSortOrder, Qt::AscendingOrder); + QVERIFY(VideoProxyModelData::mSortAsync); - VideoSortFilterProxyModelData::mDoSortingCallCount = 0; + VideoProxyModelData::mDoSortingCallCount = 0; // emit test signal again, with same parameters. Sorting should be switched to // descending order. emit testSignal(0); // since current list is videolist, sorting count is 2 because both all videos and collection content are sorted - QCOMPARE(VideoSortFilterProxyModelData::mDoSortingCallCount, 2); - QCOMPARE(VideoSortFilterProxyModelData::mSortRole, (int)VideoCollectionCommon::KeyTitle); - QCOMPARE(VideoSortFilterProxyModelData::mSortOrder, Qt::DescendingOrder); - QVERIFY(VideoSortFilterProxyModelData::mSortAsync); + QCOMPARE(VideoProxyModelData::mDoSortingCallCount, 2); + QCOMPARE(VideoProxyModelData::mSortRole, (int)VideoCollectionCommon::KeyTitle); + QCOMPARE(VideoProxyModelData::mSortOrder, Qt::DescendingOrder); + QVERIFY(VideoProxyModelData::mSortAsync); - VideoSortFilterProxyModelData::mDoSortingCallCount = 0; + VideoProxyModelData::mDoSortingCallCount = 0; // on third emit, sorting should be switched back to ascending emit testSignal(0); // since current list is videolist, sorting count is 2 because both all videos and collection content are sorted - QCOMPARE(VideoSortFilterProxyModelData::mDoSortingCallCount, 2); - QCOMPARE(VideoSortFilterProxyModelData::mSortRole, (int)VideoCollectionCommon::KeyTitle); - QCOMPARE(VideoSortFilterProxyModelData::mSortOrder, Qt::AscendingOrder); - QVERIFY(VideoSortFilterProxyModelData::mSortAsync); + QCOMPARE(VideoProxyModelData::mDoSortingCallCount, 2); + QCOMPARE(VideoProxyModelData::mSortRole, (int)VideoCollectionCommon::KeyTitle); + QCOMPARE(VideoProxyModelData::mSortOrder, Qt::AscendingOrder); + QVERIFY(VideoProxyModelData::mSortAsync); // test that after changing the sort role, the order is also switched to ascending. model->doSorting(model->sortRole(), Qt::DescendingOrder); sortAction = mUiLoader->findObject(DOCML_NAME_SORT_BY_DATE); QVERIFY(sortAction != 0); sortMenu->setActiveAction(sortAction); - VideoSortFilterProxyModelData::mDoSortingCallCount = 0; + VideoProxyModelData::mDoSortingCallCount = 0; emit testSignal(0); // since current list is videolist, sorting count is 2 because both all videos and collection content are sorted - QCOMPARE(VideoSortFilterProxyModelData::mDoSortingCallCount, 2); - QCOMPARE(VideoSortFilterProxyModelData::mSortRole, (int)VideoCollectionCommon::KeyDateTime); - QCOMPARE(VideoSortFilterProxyModelData::mSortOrder, Qt::AscendingOrder); - QVERIFY(VideoSortFilterProxyModelData::mSortAsync); + QCOMPARE(VideoProxyModelData::mDoSortingCallCount, 2); + QCOMPARE(VideoProxyModelData::mSortRole, (int)VideoCollectionCommon::KeyDateTime); + QCOMPARE(VideoProxyModelData::mSortOrder, Qt::AscendingOrder); + QVERIFY(VideoProxyModelData::mSortAsync); cleanup(); // start sorting slot: @@ -1049,20 +1049,20 @@ // selection dialog exists //////////// VideoCollectionUiLoaderData::mFailDialogLoad = false; - VideoSortFilterProxyModelData::mOpenedItemId = TMPXItemId(2, 3); + VideoProxyModelData::mOpenedItemId = TMPXItemId(2, 3); emit testSignal(); QCOMPARE(VideoListSelectionDialogData::mMultiSelectionLaunchCount, 1); QCOMPARE(VideoListSelectionDialogData::mSelectionType, (int)VideoListSelectionDialog::EDeleteVideos); - QVERIFY(VideoListSelectionDialogData::mSettedMpxId == VideoSortFilterProxyModelData::mOpenedItemId); + QVERIFY(VideoListSelectionDialogData::mSettedMpxId == VideoProxyModelData::mOpenedItemId); //////////// // test second successful activation. //////////// - VideoSortFilterProxyModelData::mOpenedItemId = TMPXItemId(3, 2); + VideoProxyModelData::mOpenedItemId = TMPXItemId(3, 2); emit testSignal(); QCOMPARE(VideoListSelectionDialogData::mMultiSelectionLaunchCount, 2); QCOMPARE(VideoListSelectionDialogData::mSelectionType, (int)VideoListSelectionDialog::EDeleteVideos); - QVERIFY(VideoListSelectionDialogData::mSettedMpxId == VideoSortFilterProxyModelData::mOpenedItemId); + QVERIFY(VideoListSelectionDialogData::mSettedMpxId == VideoProxyModelData::mOpenedItemId); cleanup(); } @@ -1315,8 +1315,8 @@ mTestView->mCurrentList = tmpList; // collection list widget has no model - VideoSortFilterProxyModel *nullModel = 0; - VideoSortFilterProxyModel *tempModel = collectionContent->getModel(); + VideoProxyModelGeneric *nullModel = 0; + VideoProxyModelGeneric *tempModel = collectionContent->getModel(); collectionContent->initialize(*nullModel, false, VideoCollectionCommon::ELevelDefaultColl); listWidget = mTestView->mCurrentList; listWidgetActivateCount = VideoListWidgetData::mActivateCount; @@ -1683,7 +1683,7 @@ QVERIFY(connect(this, SIGNAL(testSignal()), mTestView, SLOT(addVideosToCollectionSlot()))); TMPXItemId invalidId = TMPXItemId::InvalidId(); - VideoSortFilterProxyModelData::mOpenedItemId = TMPXItemId(0, 2); + VideoProxyModelData::mOpenedItemId = TMPXItemId(0, 2); // Not initalized, no mCurrentList emit testSignal(); @@ -1708,7 +1708,7 @@ mTestView->mCurrentList->mCurrentLevel = VideoCollectionCommon::ELevelCategory; emit testSignal(); QVERIFY(VideoListSelectionDialogData::mSelectionType == VideoListSelectionDialog::EAddToCollection); - QVERIFY(VideoListSelectionDialogData::mSettedMpxId == VideoSortFilterProxyModelData::mOpenedItemId); + QVERIFY(VideoListSelectionDialogData::mSettedMpxId == VideoProxyModelData::mOpenedItemId); QCOMPARE(VideoCollectionViewUtilsData::mLastError, 0); // Current level is album, video list widget load fails. @@ -1719,7 +1719,7 @@ mTestView->mCurrentList->mCurrentLevel = VideoCollectionCommon::ELevelAlbum; emit testSignal(); QVERIFY(VideoListSelectionDialogData::mSelectionType == VideoListSelectionDialog::EAddToCollection); - QVERIFY(VideoListSelectionDialogData::mSettedMpxId == VideoSortFilterProxyModelData::mOpenedItemId); + QVERIFY(VideoListSelectionDialogData::mSettedMpxId == VideoProxyModelData::mOpenedItemId); QCOMPARE(VideoCollectionViewUtilsData::mLastError, 0); // Current level is album, but model is empty. @@ -1766,7 +1766,7 @@ setRowCount(1); emit testSignal(); QVERIFY(VideoListSelectionDialogData::mSelectionType == VideoListSelectionDialog::EAddToCollection); - QVERIFY(VideoListSelectionDialogData::mSettedMpxId == VideoSortFilterProxyModelData::mOpenedItemId); + QVERIFY(VideoListSelectionDialogData::mSettedMpxId == VideoProxyModelData::mOpenedItemId); QCOMPARE(VideoCollectionViewUtilsData::mLastError, 0); disconnect(this, SIGNAL(testSignal()), mTestView, SLOT(addVideosToCollectionSlot())); @@ -1812,15 +1812,15 @@ // Open item is invalid VideoCollectionUiLoaderData::mFindFailure = false; - VideoSortFilterProxyModelData::mOpenedItemId = TMPXItemId::InvalidId(); + VideoProxyModelData::mOpenedItemId = TMPXItemId::InvalidId(); emit testSignal(); // Open item is video! - VideoSortFilterProxyModelData::mOpenedItemId = TMPXItemId(0, KVcxMvcMediaTypeVideo); + VideoProxyModelData::mOpenedItemId = TMPXItemId(0, KVcxMvcMediaTypeVideo); emit testSignal(); // Good case. - VideoSortFilterProxyModelData::mOpenedItemId = TMPXItemId(0, KVcxMvcMediaTypeAlbum); + VideoProxyModelData::mOpenedItemId = TMPXItemId(0, KVcxMvcMediaTypeAlbum); emit testSignal(); disconnect(this, SIGNAL(testSignal()), mTestView, SLOT(removeVideosFromCollectionSlot())); diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionview/tsrc/testlistwidget/inc/testlistwidget.h --- a/videocollection/videocollectionview/tsrc/testlistwidget/inc/testlistwidget.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionview/tsrc/testlistwidget/inc/testlistwidget.h Fri Sep 17 08:30:05 2010 +0300 @@ -11,11 +11,11 @@ * * Contributors: * -* Description: tester for methods in VideoSortFilterProxyModel +* Description: tester for methods in VideoProxyModelGeneric * */ -// Version : %version: 27 % +// Version : %version: 28 % #ifndef __TESTLISTWIDGET_H__ #define __TESTLISTWIDGET_H__ @@ -28,7 +28,7 @@ class DummyDataModel; class HbAbstractViewItem; class HbView; -class VideoSortFilterProxyModel; +class VideoProxyModelGeneric; class VideoCollectionWrapper; class HbMainWindow; class ListWidgetTester; @@ -45,7 +45,7 @@ public: void setRowCount(int count, - TModelType type = EModelTypeAllVideos, + VideoProxyModelGeneric *proxyModel = 0, VideoListDataModel *model = 0); // test functions for the test framework diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionview/tsrc/testlistwidget/src/testlistwidget.cpp --- a/videocollection/videocollectionview/tsrc/testlistwidget/src/testlistwidget.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionview/tsrc/testlistwidget/src/testlistwidget.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 60 % +// Version : %version: 62 % #include #include @@ -24,7 +24,7 @@ #include "hbglobal.h" #include "hblistview.h" #include "hbview.h" -#include "videosortfilterproxymodel.h" +#include "videoproxymodelgeneric.h" #include "hbscrollbar.h" #include "hbmenu.h" #include "hbmessagebox.h" @@ -40,7 +40,7 @@ #include "videothumbnailtestdata.h" #include "videolistdatamodel.h" #include "videolistdatamodeldata.h" -#include "videosortfilterproxymodeldata.h" +#include "videoproxymodeldata.h" #include "videocollectionuiloader.h" #include "videocollectionuiloaderdata.h" #include "videolistselectiondialog.h" @@ -129,16 +129,15 @@ // --------------------------------------------------------------------------- // void TestListWidget::setRowCount(int count, - VideoCollectionCommon::TModelType type, + VideoProxyModelGeneric *proxyModel, VideoListDataModel *model) { if (!model) { - VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(type); - QVERIFY(model); + proxyModel = VideoCollectionWrapper::instance().getAllVideosModel(); + QVERIFY(proxyModel); - VideoListDataModel *sourceModel = qobject_cast(model->sourceModel()); + VideoListDataModel *sourceModel = qobject_cast(proxyModel->sourceModel()); QVERIFY(sourceModel); VideoListDataModelData::setRowCount(*sourceModel, count); @@ -195,7 +194,7 @@ HbMenuData::reset(); VideoThumbnailTestData::reset(); VideoListDataModelData::reset(); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); HbMessageBoxData::reset(); } @@ -206,7 +205,7 @@ void TestListWidget::testInitialize() { VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); // succeed case ( new operator cannot be stubbed) QVERIFY(mTestWidget->initialize(*model) == 0); @@ -230,7 +229,7 @@ void TestListWidget::testActivate() { VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); // no model: fails QVERIFY(mTestWidget->activate() == -1); @@ -254,7 +253,7 @@ delete mTestWidget; mTestWidget = 0; mTestWidget = new ListWidgetTester(mTestUiLoader, mTempView); - model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + model = wrapper.getAllVideosModel(); QVERIFY(mTestWidget->initialize(*model, 0, VideoCollectionCommon::ELevelVideos) == 0); hbInstance->allMainWindows().value(0)->addView(tmpView); @@ -274,7 +273,7 @@ delete mTestWidget; mTestWidget = 0; mTestWidget = new ListWidgetTester(mTestUiLoader, mTempView); - model = wrapper.getModel(VideoCollectionCommon::EModelTypeCollectionContent); + model = wrapper.getCollectionContentModel(); tmpView->mNavigationAction = 0; QVERIFY(mTestWidget->initialize(*model) == 0); QVERIFY(mTestWidget->activate(VideoCollectionCommon::ELevelAlbum) == 0); @@ -343,7 +342,7 @@ void TestListWidget::testDeactivate() { VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); HbListView::mLatestVisibility = true; VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 1; @@ -392,7 +391,7 @@ void TestListWidget::testGetLevel() { VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); mTestWidget->initialize(*model); @@ -407,7 +406,7 @@ void TestListWidget::testGetModel() { VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); QVERIFY(mTestWidget->getModel() == 0); @@ -426,7 +425,7 @@ { VideoServices *videoServices = VideoServices::instance(); VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); QSignalSpy spysignal(mTestWidget, SIGNAL(collectionOpened(bool, const QString&, const TMPXItemId&))); QSignalSpy spysignalFileUri(mTestWidget, SIGNAL(fileUri(const QString&))); @@ -435,14 +434,14 @@ mTestWidget->initialize(*model); mTestWidget->activate(); - VideoSortFilterProxyModelData::mLastItemId = TMPXItemId::InvalidId(); + VideoProxyModelData::mLastItemId = TMPXItemId::InvalidId(); TMPXItemId savedId = TMPXItemId(1,1); - VideoSortFilterProxyModelData::mItemIds.clear(); - VideoSortFilterProxyModelData::mItemIds.append(savedId); + VideoProxyModelData::mItemIds.clear(); + VideoProxyModelData::mItemIds.append(savedId); QVariant data = QString("test"); VideoListDataModelData::setData(VideoCollectionCommon::KeyTitle, data); setRowCount(2); - VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(0,0)); + VideoProxyModelData::mItemIds.append(TMPXItemId(0,0)); QModelIndex fetchIndex = model->index(0, 0, QModelIndex()); @@ -452,7 +451,7 @@ QVERIFY(spysignal.count() == 0); QVERIFY(spysignalFileUri.count() == 0); QVERIFY(spysignalActivated.count() == 1); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); + QVERIFY(VideoProxyModelData::mLastItemId == TMPXItemId::InvalidId()); spysignal.clear(); spysignalFileUri.clear(); spysignalActivated.clear(); @@ -464,7 +463,7 @@ QVERIFY(spysignal.count() == 0); QVERIFY(spysignalFileUri.count() == 0); QVERIFY(spysignalActivated.count() == 0); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); + QVERIFY(VideoProxyModelData::mLastItemId == TMPXItemId::InvalidId()); // current level is ELevelCategory mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelCategory; @@ -475,7 +474,7 @@ QVERIFY(spysignal.count() == 0); QVERIFY(spysignalFileUri.count() == 0); QVERIFY(spysignalActivated.count() == 0); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); + QVERIFY(VideoProxyModelData::mLastItemId == TMPXItemId::InvalidId()); // --> variant is valid, collectionOpened -signal should be emitted @@ -485,7 +484,7 @@ QVERIFY(spysignal.count() == 1); QVERIFY(spysignalFileUri.count() == 0); QVERIFY(spysignalActivated.count() == 0); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); + QVERIFY(VideoProxyModelData::mLastItemId == TMPXItemId::InvalidId()); spysignal.clear(); spysignalFileUri.clear(); @@ -502,7 +501,7 @@ QVERIFY(spysignal.count() == 0); QVERIFY(spysignalFileUri.count() == 0); QVERIFY(spysignalActivated.count() == 0); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); + QVERIFY(VideoProxyModelData::mLastItemId == TMPXItemId::InvalidId()); // current level is not ELevelCategory // mVideoServices, variant gotten is valid @@ -513,7 +512,7 @@ QVERIFY(spysignal.count() == 0); QVERIFY(spysignalFileUri.count() == 1); QVERIFY(spysignalActivated.count() == 0); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); + QVERIFY(VideoProxyModelData::mLastItemId == TMPXItemId::InvalidId()); spysignal.clear(); spysignalFileUri.clear(); @@ -527,7 +526,7 @@ QVERIFY(spysignal.count() == 0); QVERIFY(spysignalFileUri.count() == 0); QVERIFY(spysignalActivated.count() == 0); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == savedId); + QVERIFY(VideoProxyModelData::mLastItemId == savedId); // context menu is visible if (!mTestWidget->mContextMenu) @@ -535,13 +534,13 @@ mTestWidget->mContextMenu = new HbMenu; } mTestWidget->mContextMenu->show(); - VideoSortFilterProxyModelData::mLastItemId = TMPXItemId::InvalidId(); + VideoProxyModelData::mLastItemId = TMPXItemId::InvalidId(); fetchIndex = model->index(0, 0, QModelIndex()); mTestWidget->callEmiteActivated(fetchIndex); QVERIFY(spysignal.count() == 0); QVERIFY(spysignalFileUri.count() == 0); QVERIFY(spysignalActivated.count() == 0); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); + QVERIFY(VideoProxyModelData::mLastItemId == TMPXItemId::InvalidId()); // final cleanup videoServices->decreaseReferenceCount(); @@ -554,7 +553,7 @@ void TestListWidget::testLongPressedSlot() { VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); QVariant data = QString("test"); // correct data to index 0 @@ -597,7 +596,7 @@ mTestWidget->mItem->mModelIndex = HbListView::mCurrentIndex ; // model is null - VideoSortFilterProxyModel *tmp = mTestWidget->mModel; + VideoProxyModelGeneric *tmp = mTestWidget->mModel; mTestWidget->mModel = 0; mTestWidget->callLongPressedSlot(item, point); QVERIFY(HbMenuData::mExecPoint != point); @@ -606,30 +605,30 @@ VideoServices *videoServices = VideoServices::instance(); // gotten id != KVcxMvcMediaTypeVideo, service exists true and id != KVcxMvcMediaTypeAlbum - VideoSortFilterProxyModelData::mItemIds.clear(); - VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(1,1)); + VideoProxyModelData::mItemIds.clear(); + VideoProxyModelData::mItemIds.append(TMPXItemId(1,1)); mTestWidget->mVideoServices = videoServices; mTestWidget->callLongPressedSlot(item, point); QVERIFY(HbMenuData::mExecPoint == point); // gotten id != KVcxMvcMediaTypeVideo, service does not exists and id != KVcxMvcMediaTypeAlbum - VideoSortFilterProxyModelData::mItemIds.clear(); - VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(1,1)); + VideoProxyModelData::mItemIds.clear(); + VideoProxyModelData::mItemIds.append(TMPXItemId(1,1)); mTestWidget->mVideoServices = 0; mTestWidget->callLongPressedSlot(item, point); QVERIFY(HbMenuData::mExecPoint == point); // gotten id != KVcxMvcMediaTypeVideo, service service does not exists and id == KVcxMvcMediaTypeAlbum - VideoSortFilterProxyModelData::mItemIds.clear(); - VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(1,2)); + VideoProxyModelData::mItemIds.clear(); + VideoProxyModelData::mItemIds.append(TMPXItemId(1,2)); mTestWidget->mVideoServices = 0; mTestWidget->callLongPressedSlot(item, point); QVERIFY(HbMenuData::mExecPoint == point); HbMenuData::mExecPoint = QPointF(); // gotten id == KVcxMvcMediaTypeVideo - VideoSortFilterProxyModelData::mItemIds.clear(); - VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(1,02)); + VideoProxyModelData::mItemIds.clear(); + VideoProxyModelData::mItemIds.append(TMPXItemId(1,02)); mTestWidget->mVideoServices = 0; mTestWidget->callLongPressedSlot(item, point); QVERIFY(HbMenuData::mExecPoint == point); @@ -734,9 +733,9 @@ void TestListWidget::testSetContextMenu() { VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); VideoListDataModel *sourceModel = qobject_cast(model->sourceModel()); - VideoSortFilterProxyModelData::mItemIds.clear(); + VideoProxyModelData::mItemIds.clear(); mTestWidget->initialize(*model); setRowCount(1); @@ -746,7 +745,7 @@ TMPXItemId itemId; QPointF point(1,1); itemId.iId2 = 0; - VideoSortFilterProxyModelData::mItemIds.append(itemId); + VideoProxyModelData::mItemIds.append(itemId); HbAbstractViewItem *item = new HbAbstractViewItem(); item->mModelIndex = model->index(0, 0, QModelIndex()); @@ -818,7 +817,7 @@ QVERIFY(visibleCount == 1); // service does not exists , mpxId.iId2 == KVcxMvcMediaTypeAlbum - VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(1,KVcxMvcMediaTypeAlbum)); + VideoProxyModelData::mItemIds.append(TMPXItemId(1,KVcxMvcMediaTypeAlbum)); HbListView::mCurrentIndex = model->index(1, 0, QModelIndex()); item->mModelIndex = model->index(1, 0, QModelIndex()); mTestWidget->mVideoServices = 0; @@ -860,7 +859,7 @@ cleanup(); init(); setRowCount(1); - model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + model = wrapper.getAllVideosModel(); mTestWidget->mVideoServices = videoServices; videoServices->mCurrentService = VideoServices::EUriFetcher; mTestWidget->initialize(*model, videoServices); @@ -868,7 +867,7 @@ mTestWidget->mItem->mModelIndex = HbListView::mCurrentIndex ; mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelAlbum; - VideoSortFilterProxyModelData::mItemIds.append(itemId); + VideoProxyModelData::mItemIds.append(itemId); mTestWidget->callLongPressedSlot(item, point); iter = mTestWidget->mContextMenuActions.begin(); @@ -909,7 +908,7 @@ //dodelayed calls create context menu, which is already tested at // testSetContextMenu -method, these tests are just for coverity's sake VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); mTestWidget->initialize(*model); delete mTestWidget->mContextMenu; @@ -937,10 +936,10 @@ void TestListWidget::testDeleteItemSlot() { VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); HbMessageBoxData::mLatestTxt = ""; - VideoSortFilterProxyModelData::mLastIndex = QModelIndex(); + VideoProxyModelData::mLastIndex = QModelIndex(); mTestWidget->initialize(*model); connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(deleteItemSlot())); @@ -948,12 +947,12 @@ // no model VideoListDataModelData::mDataAccessCount = 0; - VideoSortFilterProxyModel *tmp = mTestWidget->mModel; + VideoProxyModelGeneric *tmp = mTestWidget->mModel; mTestWidget->mModel = 0; emit testSignal(); QVERIFY(VideoListDataModelData::dataAccessCount() == 0); QVERIFY(HbMessageBoxData::mLatestTxt.isEmpty()); - QVERIFY(!VideoSortFilterProxyModelData::mLastIndex.isValid()); + QVERIFY(!VideoProxyModelData::mLastIndex.isValid()); setRowCount(1); mTestWidget->mModel = tmp; @@ -964,7 +963,7 @@ emit testSignal(); QVERIFY(VideoListDataModelData::dataAccessCount() == 1); QVERIFY(HbMessageBoxData::mLatestTxt.isEmpty()); - QVERIFY(!VideoSortFilterProxyModelData::mLastIndex.isValid()); + QVERIFY(!VideoProxyModelData::mLastIndex.isValid()); setRowCount(0); // data is valid @@ -980,7 +979,7 @@ box->emitDialogFinished(mTestWidget, SLOT(deleteItemDialogFinished(int)), HbMessageBox::No); QVERIFY(VideoListDataModelData::dataAccessCount() == 1); QVERIFY(!HbMessageBoxData::mLatestTxt.isEmpty()); - QVERIFY(!VideoSortFilterProxyModelData::mLastIndex.isValid()); + QVERIFY(!VideoProxyModelData::mLastIndex.isValid()); HbMessageBoxData::mLatestTxt = ""; setRowCount(1); data = QString("test"); @@ -988,13 +987,13 @@ // messagebox question returns true VideoListDataModelData::mDataAccessCount = 0; - VideoSortFilterProxyModelData::mDeleteItemsFails = false; + VideoProxyModelData::mDeleteItemsFails = false; HbMessageBoxData::mQuestionReturnValue = true; emit testSignal(); box->emitDialogFinished(mTestWidget, SLOT(deleteItemDialogFinished(int)), HbMessageBox::Yes); QVERIFY(VideoListDataModelData::dataAccessCount() == 1); QVERIFY(!HbMessageBoxData::mLatestTxt.isEmpty()); - QVERIFY(VideoSortFilterProxyModelData::mLastIndex.row() == 0); + QVERIFY(VideoProxyModelData::mLastIndex.row() == 0); disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(deleteItemSlot())); } @@ -1006,23 +1005,23 @@ void TestListWidget::testRenameSlot() { VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); HbInputDialog *dialog = new HbInputDialog(); connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(renameSlot())); - VideoSortFilterProxyModelData::reset(); - VideoSortFilterProxyModelData::mLastIndex = QModelIndex(); + VideoProxyModelData::reset(); + VideoProxyModelData::mLastIndex = QModelIndex(); mTestWidget->initialize(*model); // Good case - VideoSortFilterProxyModelData::mLastItemNameInRename = ""; + VideoProxyModelData::mLastItemNameInRename = ""; HbInputDialog::mValueReturnValue = "renamedVideo"; HbInputDialog::mValueCallCount = 0; HbInputDialog::mOpenCallCount = 0; setRowCount(1); - VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(0, KVcxMvcMediaTypeAlbum)); + VideoProxyModelData::mItemIds.append(TMPXItemId(0, KVcxMvcMediaTypeAlbum)); QVariant data = QString("albumName"); VideoListDataModelData::setData(VideoCollectionCommon::KeyTitle, data); mTestWidget->mCurrentIndex = model->index(0, 0, QModelIndex()); @@ -1036,13 +1035,13 @@ HbInputDialog::mValueReturnValue = "albumName"; HbInputDialog::mValueCallCount = 0; HbInputDialog::mOpenCallCount = 0; - VideoSortFilterProxyModelData::mLastItemNameInRename = ""; + VideoProxyModelData::mLastItemNameInRename = ""; data = QString("albumName"); VideoListDataModelData::setData(VideoCollectionCommon::KeyTitle, data); mTestWidget->mCurrentIndex = model->index(0, 0, QModelIndex()); emit testSignal(); dialog->emitDialogFinished(mTestWidget, SLOT(renameDialogFinished(HbAction *)), 0); - QVERIFY(VideoSortFilterProxyModelData::mLastItemNameInRename == ""); + QVERIFY(VideoProxyModelData::mLastItemNameInRename == ""); QCOMPARE(HbInputDialog::mOpenCallCount, 1); QVERIFY(HbInputDialog::mValueCallCount == 1); @@ -1050,18 +1049,18 @@ HbInputDialog::mValueReturnValue = ""; HbInputDialog::mValueCallCount = 0; HbInputDialog::mOpenCallCount = 0; - VideoSortFilterProxyModelData::mLastItemNameInRename = ""; + VideoProxyModelData::mLastItemNameInRename = ""; data = QString("albumName"); VideoListDataModelData::setData(VideoCollectionCommon::KeyTitle, data); mTestWidget->mCurrentIndex = model->index(0, 0, QModelIndex()); emit testSignal(); dialog->emitDialogFinished(mTestWidget, SLOT(renameDialogFinished(HbAction *)), 1); - QVERIFY(VideoSortFilterProxyModelData::mLastItemNameInRename == ""); + QVERIFY(VideoProxyModelData::mLastItemNameInRename == ""); QCOMPARE(HbInputDialog::mOpenCallCount, 1); QVERIFY(HbInputDialog::mValueCallCount == 0); // New name is empty. - VideoSortFilterProxyModelData::mLastItemNameInRename = ""; + VideoProxyModelData::mLastItemNameInRename = ""; HbInputDialog::mValueReturnValue = ""; HbInputDialog::mValueCallCount = 0; HbInputDialog::mOpenCallCount = 0; @@ -1070,14 +1069,14 @@ mTestWidget->mCurrentIndex = model->index(0, 0, QModelIndex()); emit testSignal(); dialog->emitDialogFinished(mTestWidget, SLOT(renameDialogFinished(HbAction *)), 0); - QVERIFY(VideoSortFilterProxyModelData::mLastItemNameInRename == ""); + QVERIFY(VideoProxyModelData::mLastItemNameInRename == ""); QCOMPARE(HbInputDialog::mOpenCallCount, 1); QVERIFY(HbInputDialog::mValueCallCount == 1); // Item is video - VideoSortFilterProxyModelData::mItemIds.clear(); - VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(0, KVcxMvcMediaTypeVideo)); - VideoSortFilterProxyModelData::mLastItemNameInRename = ""; + VideoProxyModelData::mItemIds.clear(); + VideoProxyModelData::mItemIds.append(TMPXItemId(0, KVcxMvcMediaTypeVideo)); + VideoProxyModelData::mLastItemNameInRename = ""; HbInputDialog::mValueReturnValue = "renamedVideo"; HbInputDialog::mValueCallCount = 0; HbInputDialog::mOpenCallCount = 0; @@ -1088,37 +1087,67 @@ dialog->emitDialogFinished(mTestWidget, SLOT(renameDialogFinished(HbAction *)), 0); QCOMPARE(HbInputDialog::mOpenCallCount, 1); QVERIFY(HbInputDialog::mValueCallCount == 1); - QVERIFY(VideoSortFilterProxyModelData::mLastItemNameInRename == "renamedVideo"); + QVERIFY(VideoProxyModelData::mLastItemNameInRename == "renamedVideo"); + // Item is album + VideoProxyModelData::mItemIds.clear(); + VideoProxyModelData::mItemIds.append(TMPXItemId(0, KVcxMvcMediaTypeAlbum)); + VideoProxyModelData::mLastItemNameInRename = ""; + HbInputDialog::mValueReturnValue = "renamedAlbum"; + HbInputDialog::mValueCallCount = 0; + HbInputDialog::mOpenCallCount = 0; + data = QString("oldAlbumName"); + VideoListDataModelData::setData(VideoCollectionCommon::KeyTitle, data); + mTestWidget->mCurrentIndex = model->index(0, 0, QModelIndex()); + emit testSignal(); + dialog->emitDialogFinished(mTestWidget, SLOT(renameDialogFinished(HbAction *)), 0); + QCOMPARE(HbInputDialog::mOpenCallCount, 1); + QVERIFY(HbInputDialog::mValueCallCount == 1); + QVERIFY(VideoProxyModelData::mLastItemNameInRename == "renamedAlbum"); + + // Item is category + VideoProxyModelData::mItemIds.clear(); + VideoProxyModelData::mItemIds.append(TMPXItemId(0, KVcxMvcMediaTypeCategory)); + VideoProxyModelData::mLastItemNameInRename = ""; + HbInputDialog::mValueReturnValue = "notallowed"; + HbInputDialog::mValueCallCount = 0; + HbInputDialog::mOpenCallCount = 0; + data = QString("oldCategoryName"); + VideoListDataModelData::setData(VideoCollectionCommon::KeyTitle, data); + mTestWidget->mCurrentIndex = model->index(0, 0, QModelIndex()); + emit testSignal(); + QCOMPARE(HbInputDialog::mOpenCallCount, 0); + QVERIFY(VideoProxyModelData::mLastItemNameInRename == ""); + // No model - VideoSortFilterProxyModelData::mLastItemNameInRename = ""; + VideoProxyModelData::mLastItemNameInRename = ""; HbInputDialog::mValueReturnValue = ""; HbInputDialog::mValueCallCount = 0; HbInputDialog::mOpenCallCount = 0; - VideoSortFilterProxyModelData::mItemIds.clear(); - VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(0, KVcxMvcMediaTypeAlbum)); + VideoProxyModelData::mItemIds.clear(); + VideoProxyModelData::mItemIds.append(TMPXItemId(0, KVcxMvcMediaTypeAlbum)); data = QString("albumName"); VideoListDataModelData::setData(VideoCollectionCommon::KeyTitle, data); mTestWidget->mCurrentIndex = model->index(0, 0, QModelIndex()); - VideoSortFilterProxyModel *tmp = mTestWidget->mModel; + VideoProxyModelGeneric *tmp = mTestWidget->mModel; mTestWidget->mModel = 0; emit testSignal(); mTestWidget->mModel = tmp; - QVERIFY(VideoSortFilterProxyModelData::mLastItemNameInRename == ""); + QVERIFY(VideoProxyModelData::mLastItemNameInRename == ""); QCOMPARE(HbInputDialog::mOpenCallCount, 0); // Variant data is invalid - VideoSortFilterProxyModelData::mLastItemNameInRename = ""; + VideoProxyModelData::mLastItemNameInRename = ""; HbInputDialog::mValueReturnValue = "renamedVideo"; HbInputDialog::mValueCallCount = 0; HbInputDialog::mOpenCallCount = 0; - VideoSortFilterProxyModelData::mItemIds.clear(); - VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(0, KVcxMvcMediaTypeAlbum)); + VideoProxyModelData::mItemIds.clear(); + VideoProxyModelData::mItemIds.append(TMPXItemId(0, KVcxMvcMediaTypeAlbum)); data = QVariant(); VideoListDataModelData::setData(VideoCollectionCommon::KeyTitle, data); mTestWidget->mCurrentIndex = model->index(0, 0, QModelIndex()); emit testSignal(); - QVERIFY(VideoSortFilterProxyModelData::mLastItemNameInRename == ""); + QVERIFY(VideoProxyModelData::mLastItemNameInRename == ""); QCOMPARE(HbInputDialog::mOpenCallCount, 0); disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(renameSlot())); @@ -1134,13 +1163,13 @@ // Just verify here, that the openItemSlot calls doEmitActivated. VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); mTestWidget->initialize(*model); connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(openItemSlot())); setRowCount(1); TMPXItemId savedId = TMPXItemId(1,1); - VideoSortFilterProxyModelData::mItemIds.clear(); - VideoSortFilterProxyModelData::mItemIds.append(savedId); + VideoProxyModelData::mItemIds.clear(); + VideoProxyModelData::mItemIds.append(savedId); HbListView::mCurrentIndex = model->index(0, 0, QModelIndex()); // Making the context menu visible ensures that the doEmitActivated is called @@ -1154,7 +1183,7 @@ emit testSignal(); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == savedId); + QVERIFY(VideoProxyModelData::mLastItemId == savedId); disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(openItemSlot())); } @@ -1166,18 +1195,18 @@ void TestListWidget::testPlayItemSlot() { VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); mTestWidget->initialize(*model); connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(playItemSlot())); setRowCount(1); TMPXItemId savedId = TMPXItemId(1,1); - VideoSortFilterProxyModelData::mItemIds.clear(); - VideoSortFilterProxyModelData::mItemIds.append(savedId); + VideoProxyModelData::mItemIds.clear(); + VideoProxyModelData::mItemIds.append(savedId); HbListView::mCurrentIndex = model->index(0, 0, QModelIndex()); emit testSignal(); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == savedId); + QVERIFY(VideoProxyModelData::mLastItemId == savedId); disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(playItemSlot())); } @@ -1189,7 +1218,7 @@ void TestListWidget::testAddToCollectionSlot() { VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); VideoListSelectionDialogData::mSelectionType = -1; VideoListSelectionDialogData::mSettedMpxId = TMPXItemId::InvalidId(); @@ -1197,8 +1226,8 @@ connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(addToCollectionSlot())); setRowCount(1); TMPXItemId savedId = TMPXItemId(1,1); - VideoSortFilterProxyModelData::mItemIds.clear(); - VideoSortFilterProxyModelData::mItemIds.append(savedId); + VideoProxyModelData::mItemIds.clear(); + VideoProxyModelData::mItemIds.append(savedId); HbListView::mCurrentIndex = model->index(0, 0, QModelIndex()); // no model @@ -1215,15 +1244,15 @@ VideoCollectionUiLoaderData::mFindFailureNameList.clear(); // invalid id at current index - VideoSortFilterProxyModelData::mItemIds.clear(); - VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId::InvalidId()); + VideoProxyModelData::mItemIds.clear(); + VideoProxyModelData::mItemIds.append(TMPXItemId::InvalidId()); emit testSignal(); QVERIFY(VideoListSelectionDialogData::mSelectionType == -1 ); QVERIFY(VideoListSelectionDialogData::mSettedMpxId == TMPXItemId::InvalidId()); // valid id at current index - VideoSortFilterProxyModelData::mItemIds.clear(); - VideoSortFilterProxyModelData::mItemIds.append(savedId); + VideoProxyModelData::mItemIds.clear(); + VideoProxyModelData::mItemIds.append(savedId); emit testSignal(); QVERIFY(VideoListSelectionDialogData::mSelectionType == VideoListSelectionDialog::ESelectCollection ); QVERIFY(VideoListSelectionDialogData::mSettedMpxId == savedId); @@ -1239,45 +1268,45 @@ void TestListWidget::testRemoveFromCollectionSlot() { VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); - VideoSortFilterProxyModelData::mRemoveItemsFromAlbumReturnValue = 0; - VideoSortFilterProxyModelData::mLastItemId = TMPXItemId::InvalidId(); - VideoSortFilterProxyModelData::mItemIds.clear(); + VideoProxyModelData::mRemoveItemsFromAlbumReturnValue = 0; + VideoProxyModelData::mLastItemId = TMPXItemId::InvalidId(); + VideoProxyModelData::mItemIds.clear(); connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(removeFromCollectionSlot())); setRowCount(2); TMPXItemId savedId = TMPXItemId(1,1); - VideoSortFilterProxyModelData::mItemIds.clear(); + VideoProxyModelData::mItemIds.clear(); // invalid id at index 0 - VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId::InvalidId()); - VideoSortFilterProxyModelData::mItemIds.append(savedId); + VideoProxyModelData::mItemIds.append(TMPXItemId::InvalidId()); + VideoProxyModelData::mItemIds.append(savedId); HbListView::mCurrentIndex = model->index(1, 0, QModelIndex()); // no model emit testSignal(); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); + QVERIFY(VideoProxyModelData::mLastItemId == TMPXItemId::InvalidId()); mTestWidget->initialize(*model); - VideoSortFilterProxyModelData::mOpenedItemId = TMPXItemId::InvalidId(); + VideoProxyModelData::mOpenedItemId = TMPXItemId::InvalidId(); // collection id is invalid emit testSignal(); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); - VideoSortFilterProxyModelData::mOpenedItemId = TMPXItemId(1,2); + QVERIFY(VideoProxyModelData::mLastItemId == TMPXItemId::InvalidId()); + VideoProxyModelData::mOpenedItemId = TMPXItemId(1,2); // media at current index is invalid HbListView::mCurrentIndex = model->index(0, 0, QModelIndex()); emit testSignal(); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); + QVERIFY(VideoProxyModelData::mLastItemId == TMPXItemId::InvalidId()); // all is ok HbListView::mCurrentIndex = model->index(1, 0, QModelIndex()); emit testSignal(); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId(1,2)); - // ids are to be saved at VideoSortFilterProxyModelData::mItemIds - QVERIFY(VideoSortFilterProxyModelData::mItemIds.at(0) == savedId); + QVERIFY(VideoProxyModelData::mLastItemId == TMPXItemId(1,2)); + // ids are to be saved at VideoProxyModelData::mItemIds + QVERIFY(VideoProxyModelData::mItemIds.at(0) == savedId); disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(removeFromCollectionSlot())); } @@ -1288,13 +1317,13 @@ // void TestListWidget::testRemoveCollectionSlot() { - VideoSortFilterProxyModelData::mRemoveAlbumsFails = false; + VideoProxyModelData::mRemoveAlbumsFails = false; VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); HbMessageBoxData::mQuestionReturnValue = true; HbMessageBoxData::mLatestTxt = ""; - VideoSortFilterProxyModelData::mLastIndex = QModelIndex(); + VideoProxyModelData::mLastIndex = QModelIndex(); setRowCount(1); HbListView::mCurrentIndex = model->index(0, 0, QModelIndex()); @@ -1304,15 +1333,15 @@ setRowCount(2); TMPXItemId savedId = TMPXItemId(1,1); - VideoSortFilterProxyModelData::mItemIds.clear(); + VideoProxyModelData::mItemIds.clear(); // invalid id at index 0 - VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId::InvalidId()); - VideoSortFilterProxyModelData::mItemIds.append(savedId); + VideoProxyModelData::mItemIds.append(TMPXItemId::InvalidId()); + VideoProxyModelData::mItemIds.append(savedId); HbListView::mCurrentIndex = model->index(1, 0, QModelIndex()); // no model emit testSignal(); - QVERIFY(!VideoSortFilterProxyModelData::mLastIndex.isValid()); + QVERIFY(!VideoProxyModelData::mLastIndex.isValid()); QVERIFY(HbMessageBoxData::mLatestTxt.isEmpty()); mTestWidget->initialize(*model); @@ -1320,24 +1349,24 @@ // invalid data VideoListDataModelData::setData(VideoCollectionCommon::KeyTitle, QVariant()); emit testSignal(); - QVERIFY(!VideoSortFilterProxyModelData::mLastIndex.isValid()); + QVERIFY(!VideoProxyModelData::mLastIndex.isValid()); QVERIFY(HbMessageBoxData::mLatestTxt.isEmpty()); // valid data VideoListDataModelData::setData(VideoCollectionCommon::KeyTitle, "test"); emit testSignal(); box->emitDialogFinished(mTestWidget, SLOT(removeCollectionDialogFinished(int)), HbMessageBox::Yes); - QVERIFY(VideoSortFilterProxyModelData::mLastIndex.isValid()); - QVERIFY(VideoSortFilterProxyModelData::mLastIndex.row() == 1); + QVERIFY(VideoProxyModelData::mLastIndex.isValid()); + QVERIFY(VideoProxyModelData::mLastIndex.row() == 1); QVERIFY(!HbMessageBoxData::mLatestTxt.isEmpty()); // msg box return false (for coverity) - VideoSortFilterProxyModelData::mLastIndex = QModelIndex(); + VideoProxyModelData::mLastIndex = QModelIndex(); HbMessageBoxData::mLatestTxt = ""; HbMessageBoxData::mQuestionReturnValue = false; emit testSignal(); box->emitDialogFinished(mTestWidget, SLOT(removeCollectionDialogFinished(int)), HbMessageBox::No); - QVERIFY(!VideoSortFilterProxyModelData::mLastIndex.isValid()); + QVERIFY(!VideoProxyModelData::mLastIndex.isValid()); QVERIFY(!HbMessageBoxData::mLatestTxt.isEmpty()); disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(removeCollectionSlot())); @@ -1350,21 +1379,21 @@ void TestListWidget::testOpenDetailsSlot() { VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); QSignalSpy spysignal(mTestWidget, SIGNAL(command(int))); HbMessageBoxData::mLatestTxt = ""; - VideoSortFilterProxyModelData::mLastIndex = QModelIndex(); + VideoProxyModelData::mLastIndex = QModelIndex(); setRowCount(0); mTestWidget->initialize(*model); connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(openDetailsSlot())); // no model - VideoSortFilterProxyModel *tmp = mTestWidget->mModel; + VideoProxyModelGeneric *tmp = mTestWidget->mModel; mTestWidget->mModel = 0; emit testSignal(); QVERIFY(spysignal.count() == 0); - QVERIFY(!VideoSortFilterProxyModelData::mLastIndex.isValid()); + QVERIFY(!VideoProxyModelData::mLastIndex.isValid()); mTestWidget->mModel = tmp; // detail fetch fails @@ -1372,24 +1401,24 @@ QVariant data = QString("test"); VideoListDataModelData::setData(Qt::DisplayRole, data); mTestWidget->mCurrentIndex = model->index(0, 0, QModelIndex()); - VideoSortFilterProxyModelData::mDetailsReturnValue = -1; + VideoProxyModelData::mDetailsReturnValue = -1; emit testSignal(); QVERIFY(spysignal.count() == 0); - QVERIFY(VideoSortFilterProxyModelData::mLastIndex.row() == 0); + QVERIFY(VideoProxyModelData::mLastIndex.row() == 0); // detail fetch succeeds - VideoSortFilterProxyModelData::mDetailsReturnValue = 0; - VideoSortFilterProxyModelData::mLastIndex = QModelIndex(); + VideoProxyModelData::mDetailsReturnValue = 0; + VideoProxyModelData::mLastIndex = QModelIndex(); emit testSignal(); QVERIFY(spysignal.count() == 1); QVERIFY(spysignal.at(0).at(0).isValid()); QVERIFY(spysignal.at(0).at(0).toInt() == MpxHbVideoCommon::ActivateVideoDetailsView); - QVERIFY(VideoSortFilterProxyModelData::mLastIndex.row() == 0); + QVERIFY(VideoProxyModelData::mLastIndex.row() == 0); disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(openDetailsSlot())); } - + // --------------------------------------------------------------------------- // testBack // --------------------------------------------------------------------------- @@ -1397,7 +1426,7 @@ void TestListWidget::testBack() { VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); QSignalSpy spysignal(mTestWidget, SIGNAL(collectionOpened(bool, const QString&, const TMPXItemId&))); connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(back())); @@ -1438,7 +1467,7 @@ { VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = true; VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); mTestWidget->initialize(*model); connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(scrollingEndedSlot())); @@ -1485,7 +1514,7 @@ void TestListWidget::testScrollPositionChangedSlot() { VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); mTestWidget->initialize(*model); const QPointF point; @@ -1529,7 +1558,7 @@ void TestListWidget::testRowsInsertedSlot() { VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); mTestWidget->initialize(*model); @@ -1555,7 +1584,7 @@ void TestListWidget::testRowsRemovedSlot() { VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); mTestWidget->initialize(*model); diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionview/tsrc/testvideocollectionuiloader/src/testvideocollectionuiloader.cpp --- a/videocollection/videocollectionview/tsrc/testvideocollectionuiloader/src/testvideocollectionuiloader.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionview/tsrc/testvideocollectionuiloader/src/testvideocollectionuiloader.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -27,6 +27,7 @@ #include #include +#include "videolistwidgetdata.h" #include "testvideocollectionuiloader.h" #include "videohintwidget.h" #include "videocollectionwrapperdata.h" @@ -741,6 +742,7 @@ QVERIFY(found); i++; } + QCOMPARE(VideoListWidgetData::mInitializeCount, 3); // Getting proxymodel fails. cleanup(); @@ -748,7 +750,9 @@ mTestObject->addData(params, this, SLOT(handleObjectReady(QObject*, const QString&))); - VideoCollectionWrapperData::mGetModelFails = true; + VideoCollectionWrapperData::mGetAllVideosModelFails = true; + VideoCollectionWrapperData::mGetCollectionsModelFails = true; + VideoCollectionWrapperData::mGetCollectionContentModelFails = true; mTestObject->loadPhase(VideoCollectionUiLoaderParam::LoadPhasePrimary); mTestObject->loadPhase(VideoCollectionUiLoaderParam::LoadPhaseSecondary); QTest::qWait(5000); // 5 seconds @@ -769,6 +773,7 @@ i++; } params.clear(); + QCOMPARE(VideoListWidgetData::mInitializeCount, 0); } // --------------------------------------------------------------------------- diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionview/tsrc/testvideocollectionviewutils/src/testvideocollectionviewutils.cpp --- a/videocollection/videocollectionview/tsrc/testvideocollectionviewutils/src/testvideocollectionviewutils.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionview/tsrc/testvideocollectionviewutils/src/testvideocollectionviewutils.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -24,7 +24,7 @@ #include "hblabel.h" #include "hbaction.h" #include "videocollectionwrapper.h" -#include "videosortfilterproxymodeldata.h" +#include "videoproxymodeldata.h" #include "videoactivitystate.h" #include "videocollectioncommon.h" #include "centralrepository.h" @@ -623,58 +623,57 @@ // null model VideoCollectionViewUtils::sortModel(0, false, target); - VideoSortFilterProxyModel *model = - VideoCollectionWrapper::instance().getModel(VideoCollectionCommon::EModelTypeGeneric); + VideoProxyModelGeneric *model = + VideoCollectionWrapper::instance().getGenericModel(); // target == invalid -> default values used as sort -call VideoCollectionViewUtils::sortModel(model, false, target); - QVERIFY(VideoSortFilterProxyModelData::mDoSortingCallCount == 1); - QVERIFY(VideoSortFilterProxyModelData::mSortRole == VideoCollectionCommon::KeyDateTime); - QVERIFY(VideoSortFilterProxyModelData::mSortOrder == Qt::AscendingOrder); - QVERIFY(VideoSortFilterProxyModelData::mSortAsync == false); + QVERIFY(VideoProxyModelData::mDoSortingCallCount == 1); + QVERIFY(VideoProxyModelData::mSortRole == VideoCollectionCommon::KeyDateTime); + QVERIFY(VideoProxyModelData::mSortOrder == Qt::AscendingOrder); + QVERIFY(VideoProxyModelData::mSortAsync == false); QVERIFY(testObject.mVideosSortRole == -1); QVERIFY(testObject.mVideosSortOrder == Qt::AscendingOrder); QVERIFY(testObject.mCollectionsSortRole == -1); QVERIFY(testObject.mCollectionsSortOrder == Qt::AscendingOrder); - VideoSortFilterProxyModelData::mDoSortingCallCount = 0; - VideoSortFilterProxyModelData::mSortRole = -1; - VideoSortFilterProxyModelData::mSortOrder = Qt::AscendingOrder; - VideoSortFilterProxyModelData::mSortAsync = true; + VideoProxyModelData::mDoSortingCallCount = 0; + VideoProxyModelData::mSortRole = -1; + VideoProxyModelData::mSortOrder = Qt::AscendingOrder; + VideoProxyModelData::mSortAsync = true; // target == VideoCollectionCommon::ELevelVideos target = VideoCollectionCommon::ELevelVideos; VideoCollectionViewUtils::sortModel(model, false, target); - QVERIFY(VideoSortFilterProxyModelData::mDoSortingCallCount == 1); - QVERIFY(VideoSortFilterProxyModelData::mSortRole == VideoCollectionCommon::KeyDateTime); - QVERIFY(VideoSortFilterProxyModelData::mSortOrder == Qt::DescendingOrder); - QVERIFY(VideoSortFilterProxyModelData::mSortAsync == false); + QVERIFY(VideoProxyModelData::mDoSortingCallCount == 1); + QVERIFY(VideoProxyModelData::mSortRole == VideoCollectionCommon::KeyDateTime); + QVERIFY(VideoProxyModelData::mSortOrder == Qt::DescendingOrder); + QVERIFY(VideoProxyModelData::mSortAsync == false); QVERIFY(testObject.mVideosSortRole == VideoCollectionCommon::KeyDateTime); QVERIFY(testObject.mVideosSortOrder == Qt::DescendingOrder); QVERIFY(testObject.mCollectionsSortRole == -1); QVERIFY(testObject.mCollectionsSortOrder == Qt::AscendingOrder); - VideoSortFilterProxyModelData::mDoSortingCallCount = 0; - VideoSortFilterProxyModelData::mSortRole = -1; - VideoSortFilterProxyModelData::mSortOrder = Qt::AscendingOrder; - VideoSortFilterProxyModelData::mSortAsync = true; + VideoProxyModelData::mDoSortingCallCount = 0; + VideoProxyModelData::mSortRole = -1; + VideoProxyModelData::mSortOrder = Qt::AscendingOrder; + VideoProxyModelData::mSortAsync = true; // target == VideoCollectionCommon::ELevelCategory target = VideoCollectionCommon::ELevelCategory; VideoCollectionViewUtils::sortModel(model, false, target); - QVERIFY(VideoSortFilterProxyModelData::mDoSortingCallCount == 1); - QVERIFY(VideoSortFilterProxyModelData::mSortRole == VideoCollectionCommon::KeyTitle); - QVERIFY(VideoSortFilterProxyModelData::mSortOrder == Qt::DescendingOrder); - QVERIFY(VideoSortFilterProxyModelData::mSortAsync == false); + QVERIFY(VideoProxyModelData::mDoSortingCallCount == 1); + QVERIFY(VideoProxyModelData::mSortRole == VideoCollectionCommon::KeyTitle); + QVERIFY(VideoProxyModelData::mSortOrder == Qt::DescendingOrder); + QVERIFY(VideoProxyModelData::mSortAsync == false); QVERIFY(testObject.mVideosSortRole == VideoCollectionCommon::KeyDateTime); QVERIFY(testObject.mVideosSortOrder == Qt::DescendingOrder); QVERIFY(testObject.mCollectionsSortRole == VideoCollectionCommon::KeyTitle); QVERIFY(testObject.mCollectionsSortOrder == Qt::DescendingOrder); - } // ----------------------------------------------------------------------------- diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionview/tsrc/testvideolistselectiondialog/inc/testvideolistselectiondialog.h --- a/videocollection/videocollectionview/tsrc/testvideolistselectiondialog/inc/testvideolistselectiondialog.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionview/tsrc/testvideolistselectiondialog/inc/testvideolistselectiondialog.h Fri Sep 17 08:30:05 2010 +0300 @@ -26,7 +26,7 @@ class VideoListSelectionDialog; class VideoCollectionUiLoader; class VideoListDataModel; -class VideoSortFilterProxyModel; +class VideoProxyModelGeneric; class VideoListWidget; class VideoListSelectionDialogTesterHelper; @@ -36,7 +36,7 @@ private: - void setRowCount(int count, VideoCollectionCommon::TModelType type = VideoCollectionCommon::EModelTypeAllVideos, VideoListDataModel *model = 0); + void setRowCount(int count, VideoProxyModelGeneric *proxyModel = 0, VideoListDataModel *model = 0); // test functions for the test framework @@ -150,7 +150,7 @@ /** * dummy model */ - VideoSortFilterProxyModel *mModel; + VideoProxyModelGeneric *mModel; /** * dummy widget @@ -161,6 +161,7 @@ * flag indicating if last call to init succeeded. */ bool mInitOk; + }; diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionview/tsrc/testvideolistselectiondialog/inc/videolistselectiondialogtester.h --- a/videocollection/videocollectionview/tsrc/testvideolistselectiondialog/inc/videolistselectiondialogtester.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionview/tsrc/testvideolistselectiondialog/inc/videolistselectiondialogtester.h Fri Sep 17 08:30:05 2010 +0300 @@ -43,18 +43,18 @@ public: VideoListSelectionDialogTesterHelper(VideoListSelectionDialog *testable = 0) - : mTestable(testable) {}; + : mTestable(testable), mSignalsConnected(false) {}; ~VideoListSelectionDialogTesterHelper() {}; bool connectSignals() { - if(!mTestable) + if(!mTestable || mSignalsConnected) { return false; } - // disconnect first to make sure there signals are not connected twice - disconnectSignals(); + mSignalsConnected = true; + if(!connect(this, SIGNAL(markAllSignal(int)), mTestable, SLOT(markAllStateChangedSlot(int)))) { return false; @@ -91,8 +91,9 @@ void disconnectSignals() { - if(mTestable) + if(mTestable && mSignalsConnected) { + mSignalsConnected = false; disconnect(this, SIGNAL(markAllSignal(int)), mTestable, SLOT(markAllStateChangedSlot(int))); disconnect(this, SIGNAL(selectionChangedSignal(const QItemSelection&, const QItemSelection&)), mTestable, SLOT(selectionChangedSlot(const QItemSelection&, const QItemSelection&))); @@ -142,6 +143,11 @@ } VideoListSelectionDialog *mTestable; + + /** + * flag indicating if signals are connected. + */ + bool mSignalsConnected; }; #endif diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionview/tsrc/testvideolistselectiondialog/src/testvideolistselectiondialog.cpp --- a/videocollection/videocollectionview/tsrc/testvideolistselectiondialog/src/testvideolistselectiondialog.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionview/tsrc/testvideolistselectiondialog/src/testvideolistselectiondialog.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -32,7 +32,7 @@ #include "videocollectionuiloader.h" #include "videolistdatamodel.h" -#include "videosortfilterproxymodel.h" +#include "videoproxymodelgeneric.h" #include "videolistwidget.h" #include "videocollectionwrapper.h" #include "videocollectioncommon.h" @@ -42,7 +42,7 @@ #include "videocollectionwrapperdata.h" #include "videocollectionuiloaderdata.h" #include "videolistwidgetdata.h" -#include "videosortfilterproxymodeldata.h" +#include "videoproxymodeldata.h" #include "videocollectionviewutilsdata.h" #define private public @@ -90,15 +90,17 @@ // setRowCount // --------------------------------------------------------------------------- // -void TestVideoListSelectionDialog::setRowCount(int count, VideoCollectionCommon::TModelType type, VideoListDataModel *model) +void TestVideoListSelectionDialog::setRowCount(int count, VideoProxyModelGeneric *proxyModel, VideoListDataModel *model) { if (!model) { - VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); - VideoSortFilterProxyModel *model = wrapper.getModel(type); - QVERIFY(model); + if(!proxyModel) + { + proxyModel = VideoCollectionWrapper::instance().getAllVideosModel(); + QVERIFY(proxyModel); + } - VideoListDataModel *sourceModel = qobject_cast(model->sourceModel()); + VideoListDataModel *sourceModel = qobject_cast(proxyModel->sourceModel()); QVERIFY(sourceModel); VideoListDataModelData::setRowCount(*sourceModel, count); @@ -142,7 +144,7 @@ mTestUiLoader = new VideoCollectionUiLoader(); mTestObject = new VideoListSelectionDialog(mTestUiLoader); - mModel = VideoCollectionWrapper::instance().getModel(VideoCollectionCommon::EModelTypeGeneric); + mModel = VideoCollectionWrapper::instance().getGenericModel(); mTestHelper->mTestable = mTestObject; QVERIFY(mTestHelper->connectSignals()); @@ -189,7 +191,7 @@ mTestObject = 0; // Getting model fails - VideoCollectionWrapperData::mGetModelFails = true; + VideoCollectionWrapperData::mGetGenericModelFails = true; mTestObject = new VideoListSelectionDialog(mTestUiLoader); QVERIFY(mTestObject->mModel == 0); QVERIFY(mTestObject->mListWidget == 0); @@ -198,7 +200,7 @@ mTestObject = 0; // List widget initialize fails - VideoCollectionWrapperData::mGetModelFails = false; + VideoCollectionWrapperData::mGetGenericModelFails = false; VideoListWidgetData::mInitializeReturnValue = -1; mTestObject = new VideoListSelectionDialog(mTestUiLoader); QVERIFY(mTestObject->mModel != 0); @@ -248,12 +250,12 @@ QVERIFY(mTestObject->mCheckBox != 0); QVERIFY(mTestObject->mPrimaryAction != 0); QVERIFY(mTestObject->mSecondaryAction != 0); - QVERIFY(VideoSortFilterProxyModelData::mGenericFilterId == mpxId); - QVERIFY(VideoSortFilterProxyModelData::mGenericFilterValue); + QVERIFY(VideoProxyModelData::mGenericFilterId == mpxId); + QVERIFY(VideoProxyModelData::mGenericFilterValue); QVERIFY(mTestObject->mModelReady == false); QVERIFY(mTestObject->mAlbumListReady == false); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); // second setup (for coverity) mTestObject->setupContent(VideoListSelectionDialog::EDeleteVideos, mpxId); @@ -273,14 +275,14 @@ QVERIFY(mTestObject->mCheckBox != 0); QVERIFY(mTestObject->mPrimaryAction != 0); QVERIFY(mTestObject->mSecondaryAction != 0); - QVERIFY(VideoSortFilterProxyModelData::mGenericFilterId == mpxId); - QVERIFY(VideoSortFilterProxyModelData::mGenericFilterValue); + QVERIFY(VideoProxyModelData::mGenericFilterId == mpxId); + QVERIFY(VideoProxyModelData::mGenericFilterValue); QVERIFY(mTestObject->mModelReady == false); QVERIFY(mTestObject->mAlbumListReady == false); delete mTestObject; mTestObject = new VideoListSelectionDialog(mTestUiLoader); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); // No data. type ESelectCollection. Default mpx item setRowCount(0); @@ -302,14 +304,14 @@ QVERIFY(mTestObject->mCheckBox != 0); QVERIFY(mTestObject->mPrimaryAction != 0); QVERIFY(mTestObject->mSecondaryAction != 0); - QVERIFY(VideoSortFilterProxyModelData::mGenericFilterId == mpxId); - QVERIFY(!VideoSortFilterProxyModelData::mGenericFilterValue); + QVERIFY(VideoProxyModelData::mGenericFilterId == mpxId); + QVERIFY(!VideoProxyModelData::mGenericFilterValue); QVERIFY(mTestObject->mModelReady == false); QVERIFY(mTestObject->mAlbumListReady == false); delete mTestObject; mTestObject = new VideoListSelectionDialog(mTestUiLoader); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); // No data. type EAddToCollection:. Default mpx item setRowCount(0); @@ -331,8 +333,8 @@ QVERIFY(mTestObject->mCheckBox != 0); QVERIFY(mTestObject->mPrimaryAction != 0); QVERIFY(mTestObject->mSecondaryAction != 0); - QVERIFY(VideoSortFilterProxyModelData::mGenericFilterId == mpxId); - QVERIFY(!VideoSortFilterProxyModelData::mGenericFilterValue); + QVERIFY(VideoProxyModelData::mGenericFilterId == mpxId); + QVERIFY(!VideoProxyModelData::mGenericFilterValue); QVERIFY(mTestObject->mModelReady == false); QVERIFY(mTestObject->mAlbumListReady == false); @@ -356,14 +358,14 @@ QVERIFY(mTestObject->mCheckBox != 0); QVERIFY(mTestObject->mPrimaryAction != 0); QVERIFY(mTestObject->mSecondaryAction != 0); - QVERIFY(VideoSortFilterProxyModelData::mGenericFilterId == mpxId); - QVERIFY(!VideoSortFilterProxyModelData::mGenericFilterValue); + QVERIFY(VideoProxyModelData::mGenericFilterId == mpxId); + QVERIFY(!VideoProxyModelData::mGenericFilterValue); QVERIFY(mTestObject->mModelReady == false); QVERIFY(mTestObject->mAlbumListReady == false); delete mTestObject; mTestObject = new VideoListSelectionDialog(mTestUiLoader); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); // No data. type ERemoveFromCollection:. Default mpx item setRowCount(0); @@ -385,14 +387,14 @@ QVERIFY(mTestObject->mCheckBox != 0); QVERIFY(mTestObject->mPrimaryAction != 0); QVERIFY(mTestObject->mSecondaryAction != 0); - QVERIFY(VideoSortFilterProxyModelData::mGenericFilterId == mpxId); - QVERIFY(VideoSortFilterProxyModelData::mGenericFilterValue); + QVERIFY(VideoProxyModelData::mGenericFilterId == mpxId); + QVERIFY(VideoProxyModelData::mGenericFilterValue); QVERIFY(mTestObject->mModelReady == false); QVERIFY(mTestObject->mAlbumListReady == false); delete mTestObject; mTestObject = new VideoListSelectionDialog(mTestUiLoader); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); // Some data, mpx item type is album setRowCount(10); @@ -414,14 +416,14 @@ QVERIFY(mTestObject->mCheckBox != 0); QVERIFY(mTestObject->mPrimaryAction != 0); QVERIFY(mTestObject->mSecondaryAction != 0); - QVERIFY(VideoSortFilterProxyModelData::mGenericFilterId == mpxId); - QVERIFY(VideoSortFilterProxyModelData::mGenericFilterValue); + QVERIFY(VideoProxyModelData::mGenericFilterId == mpxId); + QVERIFY(VideoProxyModelData::mGenericFilterValue); QVERIFY(mTestObject->mModelReady == false); QVERIFY(mTestObject->mAlbumListReady == false); delete mTestObject; mTestObject = new VideoListSelectionDialog(mTestUiLoader); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); // Some data, mpx item type is invalid: category mpxId = TMPXItemId(0, KVcxMvcMediaTypeCategory); @@ -442,14 +444,14 @@ QVERIFY(mTestObject->mCheckBox != 0); QVERIFY(mTestObject->mPrimaryAction != 0); QVERIFY(mTestObject->mSecondaryAction != 0); - QVERIFY(VideoSortFilterProxyModelData::mGenericFilterId == mpxId); - QVERIFY(VideoSortFilterProxyModelData::mGenericFilterValue); + QVERIFY(VideoProxyModelData::mGenericFilterId == mpxId); + QVERIFY(VideoProxyModelData::mGenericFilterValue); QVERIFY(mTestObject->mModelReady == false); QVERIFY(mTestObject->mAlbumListReady == false); delete mTestObject; mTestObject = new VideoListSelectionDialog(mTestUiLoader); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); // Some data, mpx item type is invalid id mpxId = TMPXItemId::InvalidId(); @@ -470,12 +472,12 @@ QVERIFY(mTestObject->mCheckBox != 0); QVERIFY(mTestObject->mPrimaryAction != 0); QVERIFY(mTestObject->mSecondaryAction != 0); - QVERIFY(VideoSortFilterProxyModelData::mGenericFilterId == mpxId); - QVERIFY(VideoSortFilterProxyModelData::mGenericFilterValue); + QVERIFY(VideoProxyModelData::mGenericFilterId == mpxId); + QVERIFY(VideoProxyModelData::mGenericFilterValue); QVERIFY(mTestObject->mModelReady == false); QVERIFY(mTestObject->mAlbumListReady == false); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); // some data, second initialization without widget and model, for coverity delete mTestObject->mListWidget; mTestObject->mListWidget = 0; @@ -498,8 +500,8 @@ QVERIFY(mTestObject->mCheckBox != 0); QVERIFY(mTestObject->mPrimaryAction != 0); QVERIFY(mTestObject->mSecondaryAction != 0); - QVERIFY(VideoSortFilterProxyModelData::mGenericFilterId == mpxId); - QVERIFY(VideoSortFilterProxyModelData::mGenericFilterValue); + QVERIFY(VideoProxyModelData::mGenericFilterId == mpxId); + QVERIFY(VideoProxyModelData::mGenericFilterValue); QVERIFY(mTestObject->mModelReady == false); QVERIFY(mTestObject->mAlbumListReady == false); } @@ -514,14 +516,14 @@ // initDialog fails because model get fails. QVERIFY(mTestObject->mModel != 0); - VideoSortFilterProxyModel *backup = mTestObject->mModel; + VideoProxyModelGeneric *backup = mTestObject->mModel; VideoListWidget *backupWidget = mTestObject->mListWidget; mTestObject->mModel = 0; mTestObject->mListWidget = 0; - VideoCollectionWrapperData::mGetModelFails = true; + VideoCollectionWrapperData::mGetGenericModelFails = true; mpxId = TMPXItemId(0, KVcxMvcMediaTypeVideo); mTestObject->setupContent(VideoListSelectionDialog::EDeleteVideos, mpxId); - VideoCollectionWrapperData::mGetModelFails = false; + VideoCollectionWrapperData::mGetGenericModelFails = false; QVERIFY(mTestObject->mModel == 0); QVERIFY(mTestObject->mListWidget == 0); QVERIFY(mTestObject->mListContainer == 0); @@ -671,11 +673,11 @@ // finished with secondary action VideoCollectionViewUtilsData::mLastError = -1; HbDialog::execReturnPrimary = false; - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); mTestObject->exec(); QVERIFY(VideoCollectionViewUtilsData::mLastError == -1); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); - QVERIFY(!VideoSortFilterProxyModelData::mItemIds.count()); + QVERIFY(VideoProxyModelData::mLastItemId == TMPXItemId::InvalidId()); + QVERIFY(!VideoProxyModelData::mItemIds.count()); HbDialog::execReturnPrimary = true; @@ -686,17 +688,17 @@ mTestObject->setupContent(VideoListSelectionDialog::ESelectCollection, mpxId); mTestObject->mSelectedVideos.insert(TMPXItemId(1,0)); mTestObject->mSelectedVideos.insert(TMPXItemId(2,0)); - VideoSortFilterProxyModelData::reset(); - VideoSortFilterProxyModelData::mAddItemsInAlbumReturnValue = 0; + VideoProxyModelData::reset(); + VideoProxyModelData::mAddItemsInAlbumReturnValue = 0; mTestObject->exec(); // type of selection has changed QVERIFY(mTestObject->mTypeOfSelection == VideoListSelectionDialog::EAddToCollection); // videos added into collection QVERIFY(VideoCollectionViewUtilsData::mLastError == VideoCollectionCommon::statusVideosAddedToCollection); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == mpxId); - QVERIFY(VideoSortFilterProxyModelData::mItemIds.count() == 2); - QVERIFY(VideoSortFilterProxyModelData::mItemIds.at(0) == TMPXItemId(1,0)); - QVERIFY(VideoSortFilterProxyModelData::mItemIds.at(1) == TMPXItemId(2,0)); + QVERIFY(VideoProxyModelData::mLastItemId == mpxId); + QVERIFY(VideoProxyModelData::mItemIds.count() == 2); + QVERIFY(VideoProxyModelData::mItemIds.at(0) == TMPXItemId(1,0)); + QVERIFY(VideoProxyModelData::mItemIds.at(1) == TMPXItemId(2,0)); HbInputDialog *dialog = new HbInputDialog(); @@ -707,23 +709,23 @@ mTestObject->setupContent(VideoListSelectionDialog::ESelectCollection, mpxId); mTestObject->mSelectedVideos.insert(TMPXItemId(1,0)); mTestObject->mSelectedVideos.insert(TMPXItemId(2,0)); - VideoSortFilterProxyModelData::reset(); - VideoSortFilterProxyModelData::mNewAlbumId = TMPXItemId::InvalidId(); + VideoProxyModelData::reset(); + VideoProxyModelData::mNewAlbumId = TMPXItemId::InvalidId(); mTestObject->exec(); dialog->emitDialogFinished(mTestObject, SLOT(newAlbumNameDialogFinished(HbAction *)), 1); // No selected. // type of selection does not change QVERIFY(mTestObject->mTypeOfSelection == VideoListSelectionDialog::EAddToCollection); // since there's no selected videos, status code does not change QVERIFY(VideoCollectionViewUtilsData::mLastError == -1); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); - QVERIFY(!VideoSortFilterProxyModelData::mItemIds.count()); + QVERIFY(VideoProxyModelData::mLastItemId == TMPXItemId::InvalidId()); + QVERIFY(!VideoProxyModelData::mItemIds.count()); // query for new album name sets selected mTestObject->setupContent(VideoListSelectionDialog::ESelectCollection, mpxId); mTestObject->mSelectedVideos.insert(TMPXItemId(1,0)); mTestObject->mSelectedVideos.insert(TMPXItemId(2,0)); - VideoSortFilterProxyModelData::reset(); - VideoSortFilterProxyModelData::mNewAlbumId = TMPXItemId(1,2); + VideoProxyModelData::reset(); + VideoProxyModelData::mNewAlbumId = TMPXItemId(1,2); HbInputDialog::mValueReturnValue = QVariant(QString("testname")); mTestObject->exec(); dialog->emitDialogFinished(mTestObject, SLOT(newAlbumNameDialogFinished(HbAction *)), 0); // Yes selected. @@ -731,10 +733,10 @@ QVERIFY(mTestObject->mTypeOfSelection == VideoListSelectionDialog::EAddToCollection); // videos added into collection QVERIFY(VideoCollectionViewUtilsData::mLastError == VideoCollectionCommon::statusVideosAddedToCollection); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == VideoSortFilterProxyModelData::mNewAlbumId); - QVERIFY(VideoSortFilterProxyModelData::mItemIds.count() == 2); - QVERIFY(VideoSortFilterProxyModelData::mItemIds.at(0) == TMPXItemId(1,0)); - QVERIFY(VideoSortFilterProxyModelData::mItemIds.at(1) == TMPXItemId(2,0)); + QVERIFY(VideoProxyModelData::mLastItemId == VideoProxyModelData::mNewAlbumId); + QVERIFY(VideoProxyModelData::mItemIds.count() == 2); + QVERIFY(VideoProxyModelData::mItemIds.at(0) == TMPXItemId(1,0)); + QVERIFY(VideoProxyModelData::mItemIds.at(1) == TMPXItemId(2,0)); //////////// // mTypeOfSelection == EAddToCollection @@ -743,48 +745,48 @@ mTestObject->setupContent(VideoListSelectionDialog::EAddToCollection, TMPXItemId::InvalidId()); mTestObject->mSelectedVideos.insert(TMPXItemId(1,0)); mTestObject->mSelectedVideos.insert(TMPXItemId(2,0)); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); mTestObject->exec(); QVERIFY(mTestObject->mTypeOfSelection == VideoListSelectionDialog::EAddToCollection); QVERIFY(VideoCollectionViewUtilsData::mLastError == -1); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); - QVERIFY(!VideoSortFilterProxyModelData::mItemIds.count()); + QVERIFY(VideoProxyModelData::mLastItemId == TMPXItemId::InvalidId()); + QVERIFY(!VideoProxyModelData::mItemIds.count()); // no selected videos mpxId = TMPXItemId(1, KVcxMvcMediaTypeAlbum); mTestObject->setupContent(VideoListSelectionDialog::EAddToCollection, mpxId); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); mTestObject->exec(); QVERIFY(mTestObject->mTypeOfSelection == VideoListSelectionDialog::EAddToCollection); QVERIFY(VideoCollectionViewUtilsData::mLastError == -1); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); - QVERIFY(!VideoSortFilterProxyModelData::mItemIds.count()); + QVERIFY(VideoProxyModelData::mLastItemId == TMPXItemId::InvalidId()); + QVERIFY(!VideoProxyModelData::mItemIds.count()); // selected album exist, selected videos exists, add items fails mTestObject->setupContent(VideoListSelectionDialog::EAddToCollection, mpxId); mTestObject->mSelectedVideos.insert(TMPXItemId(1,0)); mTestObject->mSelectedVideos.insert(TMPXItemId(2,0)); - VideoSortFilterProxyModelData::reset(); - VideoSortFilterProxyModelData::mAddItemsInAlbumReturnValue = -1; + VideoProxyModelData::reset(); + VideoProxyModelData::mAddItemsInAlbumReturnValue = -1; mTestObject->exec(); QVERIFY(mTestObject->mTypeOfSelection == VideoListSelectionDialog::EAddToCollection); QVERIFY(VideoCollectionViewUtilsData::mLastError == -1); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); - QVERIFY(!VideoSortFilterProxyModelData::mItemIds.count()); + QVERIFY(VideoProxyModelData::mLastItemId == TMPXItemId::InvalidId()); + QVERIFY(!VideoProxyModelData::mItemIds.count()); // selected album exist, selected videos exists, add items succeeds mTestObject->setupContent(VideoListSelectionDialog::EAddToCollection, mpxId); mTestObject->mSelectedVideos.insert(TMPXItemId(1,0)); mTestObject->mSelectedVideos.insert(TMPXItemId(2,0)); - VideoSortFilterProxyModelData::reset(); - VideoSortFilterProxyModelData::mAddItemsInAlbumReturnValue = 0; + VideoProxyModelData::reset(); + VideoProxyModelData::mAddItemsInAlbumReturnValue = 0; mTestObject->exec(); QVERIFY(mTestObject->mTypeOfSelection == VideoListSelectionDialog::EAddToCollection); QVERIFY(VideoCollectionViewUtilsData::mLastError == VideoCollectionCommon::statusVideosAddedToCollection); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == mpxId); - QVERIFY(VideoSortFilterProxyModelData::mItemIds.count() == 2); - QVERIFY(VideoSortFilterProxyModelData::mItemIds.at(0) == TMPXItemId(1,0)); - QVERIFY(VideoSortFilterProxyModelData::mItemIds.at(1) == TMPXItemId(2,0)); + QVERIFY(VideoProxyModelData::mLastItemId == mpxId); + QVERIFY(VideoProxyModelData::mItemIds.count() == 2); + QVERIFY(VideoProxyModelData::mItemIds.at(0) == TMPXItemId(1,0)); + QVERIFY(VideoProxyModelData::mItemIds.at(1) == TMPXItemId(2,0)); VideoCollectionViewUtilsData::mLastError = -1; // selected album exist, selected videos exists, name for selected album exist @@ -792,8 +794,8 @@ mTestObject->setupContent(VideoListSelectionDialog::ESelectCollection, mpxId); mTestObject->mSelectedVideos.insert(TMPXItemId(1,0)); mTestObject->mSelectedVideos.insert(TMPXItemId(2,0)); - VideoSortFilterProxyModelData::reset(); - VideoSortFilterProxyModelData::mNewAlbumId = TMPXItemId(1,2); + VideoProxyModelData::reset(); + VideoProxyModelData::mNewAlbumId = TMPXItemId(1,2); mTestObject->exec(); dialog->emitDialogFinished(mTestObject, SLOT(newAlbumNameDialogFinished(HbAction *)), 0); // Yes selected. // type of selection has changed @@ -801,10 +803,10 @@ // videos added into collection QVERIFY(VideoCollectionViewUtilsData::mLastError == VideoCollectionCommon::statusVideosAddedToCollection); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == mpxId); - QVERIFY(VideoSortFilterProxyModelData::mItemIds.count() == 2); - QVERIFY(VideoSortFilterProxyModelData::mItemIds.at(0) == TMPXItemId(1,0)); - QVERIFY(VideoSortFilterProxyModelData::mItemIds.at(1) == TMPXItemId(2,0)); + QVERIFY(VideoProxyModelData::mLastItemId == mpxId); + QVERIFY(VideoProxyModelData::mItemIds.count() == 2); + QVERIFY(VideoProxyModelData::mItemIds.at(0) == TMPXItemId(1,0)); + QVERIFY(VideoProxyModelData::mItemIds.at(1) == TMPXItemId(2,0)); ///// // mTypeOfSelection == ERemoveFromCollection @@ -813,47 +815,47 @@ mTestObject->setupContent(VideoListSelectionDialog::ERemoveFromCollection, TMPXItemId::InvalidId()); mTestObject->mSelectedVideos.insert(TMPXItemId(1,0)); mTestObject->mSelectedVideos.insert(TMPXItemId(2,0)); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); mTestObject->exec(); QVERIFY(mTestObject->mTypeOfSelection == VideoListSelectionDialog::ERemoveFromCollection); QVERIFY(VideoCollectionViewUtilsData::mLastError == -1); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); - QVERIFY(!VideoSortFilterProxyModelData::mItemIds.count()); + QVERIFY(VideoProxyModelData::mLastItemId == TMPXItemId::InvalidId()); + QVERIFY(!VideoProxyModelData::mItemIds.count()); // no selected videos mpxId = TMPXItemId(1, KVcxMvcMediaTypeAlbum); mTestObject->setupContent(VideoListSelectionDialog::ERemoveFromCollection, mpxId); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); mTestObject->exec(); QVERIFY(mTestObject->mTypeOfSelection == VideoListSelectionDialog::ERemoveFromCollection); QVERIFY(VideoCollectionViewUtilsData::mLastError == -1); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); - QVERIFY(!VideoSortFilterProxyModelData::mItemIds.count()); + QVERIFY(VideoProxyModelData::mLastItemId == TMPXItemId::InvalidId()); + QVERIFY(!VideoProxyModelData::mItemIds.count()); // selected videos exists, removeitemsFromAlbum fails mTestObject->setupContent(VideoListSelectionDialog::ERemoveFromCollection, mpxId); mTestObject->mSelectedVideos.insert(TMPXItemId(1,0)); mTestObject->mSelectedVideos.insert(TMPXItemId(2,0)); - VideoSortFilterProxyModelData::reset(); - VideoSortFilterProxyModelData::mRemoveItemsFromAlbumReturnValue = -1; + VideoProxyModelData::reset(); + VideoProxyModelData::mRemoveItemsFromAlbumReturnValue = -1; mTestObject->exec(); QVERIFY(mTestObject->mTypeOfSelection == VideoListSelectionDialog::ERemoveFromCollection); QVERIFY(VideoCollectionViewUtilsData::mLastError == -1); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); - QVERIFY(!VideoSortFilterProxyModelData::mItemIds.count()); + QVERIFY(VideoProxyModelData::mLastItemId == TMPXItemId::InvalidId()); + QVERIFY(!VideoProxyModelData::mItemIds.count()); mTestObject->setupContent(VideoListSelectionDialog::ERemoveFromCollection, mpxId); mTestObject->mSelectedVideos.insert(TMPXItemId(1,0)); mTestObject->mSelectedVideos.insert(TMPXItemId(2,0)); - VideoSortFilterProxyModelData::reset(); - VideoSortFilterProxyModelData::mRemoveItemsFromAlbumReturnValue = 0; + VideoProxyModelData::reset(); + VideoProxyModelData::mRemoveItemsFromAlbumReturnValue = 0; mTestObject->exec(); QVERIFY(mTestObject->mTypeOfSelection == VideoListSelectionDialog::ERemoveFromCollection); QVERIFY(VideoCollectionViewUtilsData::mLastError == VideoCollectionCommon::statusVideosRemovedFromCollection); - QVERIFY(VideoSortFilterProxyModelData::mLastItemId == mpxId); - QVERIFY(VideoSortFilterProxyModelData::mItemIds.count() == 2); - QVERIFY(VideoSortFilterProxyModelData::mItemIds.at(0) == TMPXItemId(1,0)); - QVERIFY(VideoSortFilterProxyModelData::mItemIds.at(1) == TMPXItemId(2,0)); + QVERIFY(VideoProxyModelData::mLastItemId == mpxId); + QVERIFY(VideoProxyModelData::mItemIds.count() == 2); + QVERIFY(VideoProxyModelData::mItemIds.at(0) == TMPXItemId(1,0)); + QVERIFY(VideoProxyModelData::mItemIds.at(1) == TMPXItemId(2,0)); ///// // mTypeOfSelection == EDeleteVideos @@ -861,7 +863,7 @@ mTestObject->setupContent(VideoListSelectionDialog::EDeleteVideos, mpxId); mTestObject->mSelectedVideos.insert(TMPXItemId(1,0)); mTestObject->mSelectedVideos.insert(TMPXItemId(2,0)); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); mTestObject->exec(); QVERIFY(mTestObject->mTypeOfSelection == VideoListSelectionDialog::EDeleteVideos); QVERIFY(VideoCollectionViewUtilsData::mLastError == VideoCollectionCommon::statusDeleteInProgress); @@ -871,11 +873,11 @@ VideoCollectionViewUtilsData::mLastError = -1; mTestObject->mSelectedVideos.insert(TMPXItemId(1,0)); mTestObject->mSelectedVideos.insert(TMPXItemId(2,0)); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); mTestObject->exec(); QVERIFY(mTestObject->mTypeOfSelection == 500); QVERIFY(VideoCollectionViewUtilsData::mLastError == -1); - QVERIFY(!VideoSortFilterProxyModelData::mItemIds.count()); + QVERIFY(!VideoProxyModelData::mItemIds.count()); } @@ -883,7 +885,7 @@ { VideoCollectionWrapperData::reset(); VideoListWidgetData::reset(); - VideoSortFilterProxyModelData::reset(); + VideoProxyModelData::reset(); mTestHelper->mTestable = mTestObject; mTestHelper->connectSignals(); @@ -1168,8 +1170,8 @@ QCOMPARE(mTestObject->mSelectedVideos.count(), 0); setRowCount(10); - VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(0,0)); - VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(1,2)); + VideoProxyModelData::mItemIds.append(TMPXItemId(0,0)); + VideoProxyModelData::mItemIds.append(TMPXItemId(1,2)); // videos selected, other one's type is not video QItemSelection selected; @@ -1206,11 +1208,11 @@ mTestObject->mSelectedAlbumId = TMPXItemId(1,2); // fetching collections model unsucceeds - VideoCollectionWrapperData::mGetModelFails = true; + VideoCollectionWrapperData::mGetCollectionsModelFails = true; mTestHelper->emitFinishedSlot(mTestObject->mPrimaryAction); QVERIFY(VideoCollectionViewUtilsData::mLastStatusAdditional.isValid()); QVERIFY(!VideoCollectionViewUtilsData::mLastStatusAdditional.toString().length()); - VideoCollectionWrapperData::mGetModelFails = false; + VideoCollectionWrapperData::mGetCollectionsModelFails = false; // invalid index for selected album mTestHelper->emitFinishedSlot(mTestObject->mPrimaryAction); @@ -1219,7 +1221,7 @@ // succeed case: // need to add album ib into selected list, because stub proxy overwrites - // VideoSortFilterProxyModelData::mItemIds at removeitems removeItemsFromAlbum -method + // VideoProxyModelData::mItemIds at removeitems removeItemsFromAlbum -method // and we need valid index for id QString testname("testname"); VideoListDataModelData::mData[VideoCollectionCommon::KeyTitle] = testname; diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/inc/videocollectionwrapper.h --- a/videocollection/videocollectionwrapper/inc/videocollectionwrapper.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/inc/videocollectionwrapper.h Fri Sep 17 08:30:05 2010 +0300 @@ -27,7 +27,7 @@ // FORWARD DECLARATIONS class VideoCollectionWrapperPrivate; -class VideoSortFilterProxyModel; +class VideoProxyModelGeneric; /** @@ -39,7 +39,7 @@ * @code * #include "videocollectioncommon.h" * #include "videocollectionwrapper.h" - * #include "videosortfilterproxymodel.h" + * #include "videoproxymodelgeneric.h" * * ... * //// @@ -47,7 +47,7 @@ * //// * VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); * // getting all videos model - * VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + * VideoProxyModelGeneric *model = wrapper.getAllVideosModel(); * ... * //// * // Opening collection and start fetching video item data @@ -80,16 +80,38 @@ static VideoCollectionWrapper &instance(); /** - * Returns pointer to model. Null if creation fails or if + * Returns pointer to generic video model. Null if creation fails or if * application is closing. * - * @param type of the model + * @return address to model or NULL if fails or if application is closing. + */ + VideoProxyModelGeneric* getGenericModel(); + + /** + * Returns pointer to all videos model. Null if creation fails or if + * application is closing. * * @return address to model or NULL if fails or if application is closing. */ - VideoSortFilterProxyModel* getModel(VideoCollectionCommon::TModelType type); + VideoProxyModelGeneric* getAllVideosModel(); /** + * Returns pointer to collections model. Null if creation fails or if + * application is closing. + * + * @return address to model or NULL if fails or if application is closing. + */ + VideoProxyModelGeneric* getCollectionsModel(); + + /** + * Returns pointer to collection content model. Null if creation fails or if + * application is closing. + * + * @return address to model or NULL if fails or if application is closing. + */ + VideoProxyModelGeneric* getCollectionContentModel(); + + /** * Method can be used by client to emit status signal * containing status code from particular async status. * diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/inc/videocollectionwrapper_p.h --- a/videocollection/videocollectionwrapper/inc/videocollectionwrapper_p.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/inc/videocollectionwrapper_p.h Fri Sep 17 08:30:05 2010 +0300 @@ -11,7 +11,7 @@ * * Contributors: * -* Description: VideoCollectionWrapperPrivate class definition +* Description: VideoCollectionWrapperPrivate class definition * */ @@ -29,7 +29,10 @@ class CMPXMediaArray; class CMPXMedia; class VideoListDataModel; -class VideoSortFilterProxyModel; +class VideoProxyModelGeneric; +class VideoProxyModelAllVideos; +class VideoProxyModelCollections; +class VideoProxyModelContent; class VideoCollectionWrapperPrivate : public QObject { @@ -51,55 +54,138 @@ * Destructor */ ~VideoCollectionWrapperPrivate(); + + /** + * Returns the pointer into generic video model. Creates the model if it doesn't + * exist yet. + * + * Noter that if application has signaled aboutToQuit -signal indicating closing, all + * previously created models have been removed and new ones will not be created + * anymore + * + * @return address of model, NULL if creation did not succeed or if application is closing. + */ + VideoProxyModelGeneric* getGenericModel(); /** - * Returns the pointer into model. Creates the model if it doesn't exists yet. + * Returns the pointer into all videos model. Creates the model if it doesn't exist yet. * * Noter that if application has signaled aboutToQuit -signal indicating closing, all * previously created models have been removed and new ones will not be created * anymore - * - * @param type type of model + * + * @return address of model, NULL if creation did not succeed or if application is closing. + */ + + VideoProxyModelGeneric* getAllVideosModel(); + + /** + * Returns the pointer into collections model. Creates the model if it doesn't exist yet. + * + * Noter that if application has signaled aboutToQuit -signal indicating closing, all + * previously created models have been removed and new ones will not be created + * anymore + * * @return address of model, NULL if creation did not succeed or if application is closing. */ - VideoSortFilterProxyModel* getModel(VideoCollectionCommon::TModelType &type); + + VideoProxyModelGeneric* getCollectionsModel(); + + /** + * Returns the pointer into collection content model. Creates the model if it doesn't + * exist yet. + * + * Noter that if application has signaled aboutToQuit -signal indicating closing, all + * previously created models have been removed and new ones will not be created + * anymore + * + * @return address of model, NULL if creation did not succeed or if application is closing. + */ + VideoProxyModelGeneric* getCollectionContentModel(); private slots: - - + /** * Signaled when UI environment is about to be destroyed. * All models needs to be cleaned up before of that. * */ void aboutToQuitSlot(); - + private: + /** + * Creates proxy model and returns the pointer. + * + * Noter that if application has signaled aboutToQuit -signal indicating closing, all + * previously created models have been removed and new ones will not be created + * anymore. + * + * @return address of model, NULL if creation did not succeed or if application is closing. + */ + template + T *initProxyModelModel() + { + if(mAboutToClose) + { + return 0; + } + + if(!initSourceModel()) + { + return 0; + } + + T *model = 0; + + model = new T(); + + if(model->initialize(mSourceModel) || + !connect(model, SIGNAL(shortDetailsReady(TMPXItemId)), + mSourceModel, SIGNAL(shortDetailsReady(TMPXItemId)))) + { + delete model; + model = 0; + } + + return model; + } + +private: + + /** + * Initializes source model. + * + * @return true if initialization succeeds, otherwise false. + */ + bool initSourceModel(); + +private: + + /** + * data model for collection content + */ + QPointer mGenericModel; + /** * data model for all videos */ - QPointer mAllVideosModel; + QPointer mAllVideosModel; /** * data model for collections */ - QPointer mCollectionsModel; + QPointer mCollectionsModel; /** * data model for collection content */ - QPointer mCollectionContentModel; - - /** - * data model for collection content - */ - QPointer mGenericModel; + QPointer mCollectionContentModel; /** * source model */ - QPointer mSourceModel; + QPointer mSourceModel; /** * flag to indicate, that object is to be deallocated, so no @@ -111,6 +197,3 @@ #endif // __VIDEOCOLLECTIONWRAPPERPRIVATE_H__ // End of file - - - diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/inc/videodatacontainer.h --- a/videocollection/videocollectionwrapper/inc/videodatacontainer.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/inc/videodatacontainer.h Fri Sep 17 08:30:05 2010 +0300 @@ -173,8 +173,3 @@ }; #endif // __VIDEODATACONTAINER_H__ - - - - - diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/inc/videoproxymodelallvideos.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/inc/videoproxymodelallvideos.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: VideoProxyModelAllVideos class definition +* +*/ + +#ifndef VIDEOPROXYMODELALLVIDEOS_H +#define VIDEOPROXYMODELALLVIDEOS_H + +// INCLUDES +#include +#include +#include "videocollectioncommon.h" +#include "videoproxymodelgeneric.h" + +// CLASS DECLARATION +class VideoProxyModelAllVideos : public VideoProxyModelGeneric +{ + Q_OBJECT + +public: + + /** + * Contructor. + * + * @param QObject parent object. + */ + VideoProxyModelAllVideos(QObject *parent = 0); + + /** + * Destructor. + * + */ + virtual ~VideoProxyModelAllVideos(); + +public: + + /** + * Gets the currently opened item. + * + * @param None. + * @return TMPXItemId. + */ + TMPXItemId getOpenItem() const; + +protected: // from QSortFilterProxyModel + + /** + * Filtering functionality. Called by the fw. + * + * @param source_row row to check + * @param source_parent row's parent + * + * @return bool row accepted(true) or not accepted(false) + */ + bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const; + +}; + +#endif // VIDEOPROXYMODELALLVIDEOS_H diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/inc/videoproxymodelcollections.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/inc/videoproxymodelcollections.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: VideoProxyModelCollections class definition +* +*/ + +#ifndef VIDEOPROXYMODELCOLLETIONS_H +#define VIDEOPROXYMODELCOLLETIONS_H + +// INCLUDES +#include +#include +#include "videocollectioncommon.h" +#include "videoproxymodelgeneric.h" + +// CLASS DECLARATION +class VideoProxyModelCollections : public VideoProxyModelGeneric +{ + Q_OBJECT + +public: + + /** + * Contructor. + * + * @param QObject parent object. + */ + VideoProxyModelCollections(QObject *parent = 0); + + /** + * Destructor. + * + */ + virtual ~VideoProxyModelCollections(); + +protected: // from QSortFilterProxyModel + + /** + * Compares items based in the role setted before sorting. + * + */ + bool lessThan(const QModelIndex & left, const QModelIndex & right) const; + + /** + * Filtering functionality. Called by the fw. + * + * @param source_row row to check + * @param source_parent row's parent + * + * @return bool row accepted(true) or not accepted(false) + */ + bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const; + +}; + +#endif // VIDEOPROXYMODELCOLLETIONS_H diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/inc/videoproxymodelcontent.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/inc/videoproxymodelcontent.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,93 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: VideoProxyModelContent class definition +* +*/ + +#ifndef VIDEOPROXYMODELCONTENT_H +#define VIDEOPROXYMODELCONTENT_H + +// INCLUDES +#include +#include +#include "videocollectioncommon.h" +#include "videoproxymodelgeneric.h" + +// CLASS DECLARATION +class VideoProxyModelContent : public VideoProxyModelGeneric +{ + Q_OBJECT + +public: + + /** + * Contructor. + * + * @param QObject parent object. + */ + VideoProxyModelContent(QObject *parent = 0); + + /** + * Destructor. + * + */ + virtual ~VideoProxyModelContent(); + +public: + + /** + * Gets the currently opened item. + * + * @param None. + * @return TMPXItemId. + */ + TMPXItemId getOpenItem() const; + +protected: + + /** + * Connects all signals emitted from or throught this object. + * + * @return bool + */ + bool connectSignals(); + + /** + * Disconnects all signals. + */ + void disconnectSignals(); + +protected: // from QSortFilterProxyModel + + /** + * Filtering functionality. Called by the FW. + * + * @param source_row row to check + * @param source_parent row's parent + * + * @return bool row accepted(true) or not accepted(false) + */ + bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const; + +private slots: + + /** + * Signaled when particular album content has changed and + * refiltering is required. + */ + void albumChangedSlot(); + +}; + +#endif // VIDEOPROXYMODELCONTENT_H diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/inc/videoproxymodelgeneric.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/inc/videoproxymodelgeneric.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,345 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: VideoProxyModelGeneric class definition +* +*/ + +#ifndef VIDEOPROXYMODELGENERIC_H +#define VIDEOPROXYMODELGENERIC_H + +// INCLUDES +#include +#include +#include +#include "videocollectionexport.h" +#include "videocollectioncommon.h" + +// FORWARD DECLARATIONS +class QTimer; +class VideoListDataModel; +class VideoCollectionClient; + +// CLASS DECLARATION +class VIDEOCOLLECTION_DLL_EXPORT VideoProxyModelGeneric : public QSortFilterProxyModel +{ + Q_OBJECT + +public: + + /** + * Contructor. + * + * @param QObject parent object. + */ + VideoProxyModelGeneric(QObject *parent = 0); + + /** + * Destructor. + * + */ + virtual ~VideoProxyModelGeneric(); + + /** + * Initializes model. Sets the given sourceModel as source model + * for this proxy model. + * + * @param sourceModel the source model + * + * @return int 0 if initialization was ok. + */ + virtual int initialize(VideoListDataModel *sourceModel); + +public: + + /** + * First call opens the collection at the defined level. Subsequent calls only change the level. + * This starts populating the model data from the MyVideos collection plugin. + * + * @param level The level where the collection is opened. + * @return 0 if opening was successful, negative if not. + */ + int open(VideoCollectionCommon::TCollectionLevels level); + + /** + * Starts sorting. If async parameter is defined as true uses idle timer: + * starts timer with zero interval. When system has time to run timer sort() + * -method is called. If async is false, then the sort() -method is called + * immediatelly. + * + * @param sortingRole The role that sorting is done by. + * @param sortingOrder The sorting order, e.g. ascending or descending. + * @param async Defines if the sorting is done asyncronously or not. Default + * is true. + */ + void doSorting(int sortingRole, Qt::SortOrder order, bool async = true); + + /** + * To get current actice sorting parameters of the model + * + * @param sortingRole The role that sorting is done by. + * @param sortingOrder The sorting order, e.g. ascending or descending. + */ + void getSorting(int &sortingRole, Qt::SortOrder &order); + + /** + * Method to delete items at provided indeces + * + * @param indexList list of indeces. + * @return int 0 succeeds, -1 does not succeed. + */ + int deleteItems(const QModelIndexList &indexList); + + /** + * Opens the defined item. This is quite abstract as depending + * on the type of the item, the behaviour or result could be + * quite different. + * + * @param item id id of the item to be opened + * @return int 0 succeeds, <0 if opening does not succeed. + */ + virtual int openItem(TMPXItemId mediaId); + + /** + * Return to collection level + * + */ + int back(); + + /** + * Starts fetching full details for the defined item. + * + * @param index index of the item from where to get details from + * @return int 0 succeeds, < 0 if detail fetching startup does not succeed. + */ + int fetchItemDetails(const QModelIndex &index); + + /** + * Method checks that model exists and asks for mpx id from + * given object. + * + * @param index index of the item in UI. + * @return TMPXItemId mpx id if succeeds TMPXItemId::InvalidId() in case of error + * + */ + const TMPXItemId& getMediaIdAtIndex(const QModelIndex &index) const; + + /** + * returns qmodelindex of item id provided. + * + * @param item id + * @return QModelIndex; + */ + QModelIndex indexOfId(const TMPXItemId &id); + + /** + * Method checks that model exists and asks for file path from + * given object. + * + * @param mediaId id of the item. + * @return QString file path if succeeds, empty string in case of error. + * + */ + QString getMediaFilePathForId(const TMPXItemId &mediaId); + + /** + * Add a new album. + * + * @param title, Album title. + * @param mediaIds, Media items to add in the album. + * @return TMPXItemId id of created album TMPXItemId:::InvalidId() in case of failure + */ + TMPXItemId addNewAlbum(const QString &title); + + /** + * Remove an album. + * + * @param indexList, list of album indexes to be removed. + * @return 0 if no errors. + */ + int removeAlbums(const QModelIndexList &indexList); + + /** + * Add items in an existing album. + * + * @param albumId, Album where to add items. + * @param mediaIds, list of item ids + * @return 0 if no errors. + */ + int addItemsInAlbum(TMPXItemId &albumId, const QList &mediaIds); + + /** + * Removes items from existing album. + * + * @param albumId, Album where to add items. + * @param mediaIds, list of item ids + * @return 0 if no errors. + */ + int removeItemsFromAlbum(TMPXItemId &albumId, const QList &mediaIds); + + /** + * Renames a video or user defined colletion. + * + * @param itemId, id of item to be renamed. + * @param newTitle, New title for the item. + * @return 0 if no errors. + */ + int renameItem(const TMPXItemId &itemId, const QString &newTitle); + + /** + * Resolves duplicate album names and returns the resolved name. + * 'New collection' -> 'New collection (1)' -> 'New collection (2)', etc. + * + * @param albumName, Name specified by the user. + * @return Resolved name given to the album. + */ + QString resolveAlbumName(const QString& albumName) const; + + /** + * sets item id filter used in generic proxy model + * while filtering rows. + * + * If provided filterValue -flag is true, we filter off items that + * do not exist in container indicated as itemId. + * If false, filtering works other way around. + * + * + * @param filterValue item id used as filter + * @param filterValue + */ + virtual void setGenericIdFilter(const TMPXItemId &itemId, bool filterValue); + + /** + * Set album in use and invalidates filtering. + * + * @param albumId album id + */ + virtual void setAlbumInUse(const TMPXItemId &albumId); + + /** + * Gets the currently opened item. + * + * @param None. + * @return TMPXItemId. + */ + virtual TMPXItemId getOpenItem() const; + +signals: + + /** + * Signal to be emitted if detail fetching started ok + * + * @param index, index of the item + */ + void shortDetailsReady(TMPXItemId itemId); + + /** + * Notifies that model has been sorted. + */ + void modelSorted(); + +protected: + + /** + * Compares items based in the role setted before sorting. From QSortFilterProxyModel. + * + */ + virtual bool lessThan(const QModelIndex & left, const QModelIndex & right) const; + + /** + * Filtering functionality. Called by the FW. From QSortFilterProxyModel. + * + * @param source_row row to check + * @param source_parent row's parent + * + * @return bool row accepted(true) or not accepted(false) + */ + virtual bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const; + + /** + * Connects all signals emitted from or throught this object. + * + * @return bool + */ + virtual bool connectSignals(); + + /** + * Disconnects all signals. + */ + virtual void disconnectSignals(); + + /** + * Does actual sorting and emits sortingReady. + * + */ + virtual void processSorting(); + +private slots: + + /** + * Timeout slot for zero timer. Stops timer and calls processSorting. + * + */ + void processSortingSlot(); + +protected: + + /** + * Pointer to the actual model. + * Not owned. + */ + VideoListDataModel *mModel; + + /** + * Collection client. + * Not owned. + */ + VideoCollectionClient *mCollectionClient; + + /** + * Currently open level. + */ + VideoCollectionCommon::TCollectionLevels mLevel; + + /** + * Item id used as filter if model type is generic model. + */ + TMPXItemId mGenericFilterId; + + /** + * Flag used. + */ + bool mGenericFilterValue; + + /** + * Timer object. Owned. + */ + QTimer *mIdleSortTimer; + + /** + * Sort role to be setted after idle timer time outs for sorting to be able to be executed. + */ + int mWantedSortRole; + + /** + * Sort order (ascending or descending). + */ + Qt::SortOrder mWantedSortOrder; + + /* + * Default sort role for the model. + */ + int mDefaultSortRole; +}; + +#endif // VIDEOPROXYMODELGENERIC_H diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/inc/videosortfilterproxymodel.h --- a/videocollection/videocollectionwrapper/inc/videosortfilterproxymodel.h Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,375 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Videolist sort filter proxy implementation -* -*/ - -#ifndef VIDEOSORTFILTERPROXYMODEL_H -#define VIDEOSORTFILTERPROXYMODEL_H - -#include -#include -#include -#include "videocollectionexport.h" -#include "videocollectioncommon.h" - -class QTimer; -class VideoListDataModel; -class VideoCollectionClient; - -class VIDEOCOLLECTION_DLL_EXPORT VideoSortFilterProxyModel : public QSortFilterProxyModel -{ - Q_OBJECT - -public: - - /** - * Contructor. - * - * @param parent parent of this widget - * @param client Collection client pointer to use. - */ - VideoSortFilterProxyModel(VideoCollectionCommon::TModelType type, QObject *parent=0); - - /** - * Destructor. - * - */ - virtual ~VideoSortFilterProxyModel(); - - /** - * Initializes model, calls initialize to source model, and sets - * the given sourceModel as source model for this proxy model. - * - * @param collection mpx video collectionobject - * @param sourceModel the source model - * - * @return int: 0 if everything ok - */ - int initialize(VideoListDataModel *sourceModel); - -public: - - /** - * First call opens the collection at the defined level. Subsequent calls only change the level. - * This starts populating the model data from the MyVideos collection plugin. - * - * @param level The level where the collection is opened. - * @return 0 if opening was successful, negative if not. - */ - int open(VideoCollectionCommon::TCollectionLevels level); - - /** - * Starts sorting. If async parameter is defined as true uses idle timer: - * starts timer with zero interval. When system has time to run timer sort() - * -method is called. If async is false, then the sort() -method is called - * immediatelly. - * - * @param sortingRole The role that sorting is done by. - * @param sortingOrder The sorting order, e.g. ascending or descending. - * @param async Defines if the sorting is done asyncronously or not. Default - * is true. - */ - void doSorting(int sortingRole, Qt::SortOrder order, bool async = true); - - /** - * To get current actice sorting parameters of the model - * - * @param sortingRole The role that sorting is done by. - * @param sortingOrder The sorting order, e.g. ascending or descending. - */ - void getSorting(int &sortingRole, Qt::SortOrder &order); - - - /** - * Method to delete items at provided indeces - * - * @param indexList list of indeces. - * @return int 0 succeeds, -1 does not succeed. - */ - int deleteItems(const QModelIndexList &indexList); - - /** - * Opens the defined item. This is quite abstract as depending - * on the type of the item, the behaviour or result could be - * quite different. - * - * @param item id id of the item to be opened - * @return int 0 succeeds, <0 if opening does not succeed. - */ - int openItem(TMPXItemId mediaId); - - /** - * Return to collection level - * - */ - int back(); - - /** - * Starts fetching full details for the defined item. - * - * @param index index of the item from where to get details from - * @return int 0 succeeds, < 0 if detail fetching startup does not succeed. - */ - int fetchItemDetails(const QModelIndex &index); - - /** - * Method checks that model exists and asks for mpx id from - * given object. - * - * @param index index of the item in UI. - * @return TMPXItemId mpx id if succeeds TMPXItemId::InvalidId() in case of error - * - */ - const TMPXItemId& getMediaIdAtIndex(const QModelIndex &index) const; - - /** - * returns qmodelindex of item id provided. - * - * @param item id - * @return QModelIndex; - */ - QModelIndex indexOfId(const TMPXItemId &id); - - /** - * Method checks that model exists and asks for file path from - * given object. - * - * @param mediaId id of the item. - * @return QString file path if succeeds, empty string in case of error. - * - */ - QString getMediaFilePathForId(const TMPXItemId &mediaId); - - /** - * Add a new album. - * - * @param title, Album title. - * @param mediaIds, Media items to add in the album. - * @return TMPXItemId id of created album TMPXItemId:::InvalidId() in case of failure - */ - TMPXItemId addNewAlbum(const QString &title); - - /** - * Remove an album. - * - * @param indexList, list of album indexes to be removed. - * @return 0 if no errors. - */ - int removeAlbums(const QModelIndexList &indexList); - - /** - * Add items in an existing album. - * - * @param albumId, Album where to add items. - * @param mediaIds, list of item ids - * @return 0 if no errors. - */ - int addItemsInAlbum(TMPXItemId &albumId, const QList &mediaIds); - - /** - * Removes items from existing album. - * - * @param albumId, Album where to add items. - * @param mediaIds, list of item ids - * @return 0 if no errors. - */ - int removeItemsFromAlbum(TMPXItemId &albumId, const QList &mediaIds); - - /** - * Renames a video or user defined colletion. - * - * @param itemId, id of item to be renamed. - * @param newTitle, New title for the item. - * @return 0 if no errors. - */ - int renameItem(const TMPXItemId &itemId, const QString &newTitle); - - /** - * Resolves duplicate album names and returns the resolved name. - * 'New collection' -> 'New collection (1)' -> 'New collection (2)', etc. - * - * @param albumName, Name specified by the user. - * @return Resolved name given to the album. - */ - QString resolveAlbumName(const QString& albumName) const; - - /** - * sets item id filter used in generic proxy model - * while filtering rows. - * - * If provided filterValue -flag is true, we filter off items that - * do not exist in container indicated as itemId. - * If false, filtering works other way around. - * - * - * @param filterValue item id used as filter - * @param filterValue - */ - void setGenericIdFilter(const TMPXItemId &itemId, bool filterValue); - - /** - * Set album in use and invalidates filtering. - * - * @param albumId album id - */ - void setAlbumInUse(const TMPXItemId &albumId); - - /** - * Gets the currently opened item. - * - * @param None. - * @return TMPXItemId. - */ - TMPXItemId getOpenItem() const; - - /** - * Gets the type of model. - * - * @param None. - * @return TModelType. - */ - VideoCollectionCommon::TModelType getType(); - -signals: - - /** - * Signal to be emitted if detail fetching started ok - * - * @param index, index of the item - */ - void shortDetailsReady(TMPXItemId itemId); - - /** - * Signals that the model is ready, ie. that all data has been - * loaded from myvideoscollection. - */ - void modelReady(); - - /** - * Notifies that model's physical data structure has changed: - * - item inserted - * - item removed - */ - void modelChanged(); - - /** - * Notifies that model has been sorted. - */ - void modelSorted(); - -protected: // from QSortFilterProxyModel - - /** - * Compares items based in the role setted before sorting. - * - */ - bool lessThan ( const QModelIndex & left, const QModelIndex & right ) const; - - /** - * Filtering functionality. Called by the fw. - * - * @param source_row row to chexk - * @param source_parent row's parent - * - * @return bool row accepted(true) or not accepted(false) - */ - bool filterAcceptsRow ( int source_row, const QModelIndex & source_parent ) const; - -private slots: - - /** - * Timeout slot for zero timer. Stops timer and calls sort(). - * After call is finished, emits sortingReady. - * - */ - void processSorting(); - - /** - * signaled when particular album content has changed and - * refiltering is required - */ - void albumChangedSlot(); - -private: - - /** - * disabled contructor - */ - VideoSortFilterProxyModel(QObject *parent=0); - - /** - * connects all signals emitted from or throught this object - * - * @return bool - */ - bool connectSignals(); - - /** - * disconnects all signals - */ - void disconnectSignals(); - -private: - - /** - * Pointer to the actual model. - * Not owned. - */ - VideoListDataModel *mModel; - - /** - * Collection client. - * Not owned. - */ - VideoCollectionClient *mCollectionClient; - - /** - * type of data excepted - */ - VideoCollectionCommon::TModelType mType; - - /** - * Currently open level. - */ - VideoCollectionCommon::TCollectionLevels mLevel; - - /** - * item id used as filter if model type is generic model - */ - TMPXItemId mGenericFilterId; - - /** - * flag used - */ - bool mGenericFilterValue; - - /** - * Timer object. Owned. - */ - QTimer *mIdleSortTimer; - - /** - * sort role to be setted after idle timer time outs for sorting to be able to be executed - */ - int mWantedSortRole; - - /** - * sort order (ascending or descending). - */ - Qt::SortOrder mWantedSortOrder; - -}; - -#endif //VIDEOSORTFILTERPROXYMODEL_H diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/inc/videothumbnaildata.h --- a/videocollection/videocollectionwrapper/inc/videothumbnaildata.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/inc/videothumbnaildata.h Fri Sep 17 08:30:05 2010 +0300 @@ -27,7 +27,7 @@ // FORWARD DECLARATIONS class VideoThumbnailDataPrivate; -class VideoSortFilterProxyModel; +class VideoProxyModelGeneric; // CLASS DECLARATIONS @@ -95,7 +95,7 @@ * @param fetchIndex index where to start the background thumbnail fetching. * */ - void startBackgroundFetching(VideoSortFilterProxyModel *model, int fetchIndex); + void startBackgroundFetching(VideoProxyModelGeneric *model, int fetchIndex); /** * Enables or disables thumbnail background fetching. Default is enabled. diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/inc/videothumbnaildata_p.h --- a/videocollection/videocollectionwrapper/inc/videothumbnaildata_p.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/inc/videothumbnaildata_p.h Fri Sep 17 08:30:05 2010 +0300 @@ -31,7 +31,7 @@ // FORWARD DECLARATIONS class VideoCollectionWrapper; -class VideoSortFilterProxyModel; +class VideoProxyModelGeneric; class QModelIndex; class QTimer; class VideoThumbnailFetcher; @@ -86,7 +86,7 @@ * @param model model of the items for the fetching. * @param fetchIndex index where to start the background thumbnail fetching. */ - void startBackgroundFetching(VideoSortFilterProxyModel *model, int fetchIndex); + void startBackgroundFetching(VideoProxyModelGeneric *model, int fetchIndex); /** * Enables or disables thumbnail background fetching. @@ -193,10 +193,10 @@ * * @param iconName name of the file or resource. * - * @return HbIcon the icon load from resource or file. + * @return QIcon the icon load from resource or file. * */ - HbIcon loadIcon(QString iconName); + QIcon *loadIcon(QString iconName); /** * Starts timer that continues the background thumbnail fetching at timeout. @@ -254,7 +254,7 @@ private: // Data - VideoThumbnailFetcher *mThumbnailFetcher; + VideoThumbnailFetcher *mThumbnailFetcher; /** * Local cache for thumbnail data: @@ -262,19 +262,19 @@ * - data is the actual thumbnail data. * If thumbnail data is not yet fetched, QIcon is default thumbnail. */ - QCache mThumbnailData; + QCache mThumbnailData; /** * Local hash for default thumbnails. * - key is mpx item id defining default tn type - * - data is the actual thumbnail data. + * - data is the actual thumbnail data. */ - QHash mDefaultThumbnails; + QHash mDefaultThumbnails; /** * Current model, set at call to startBackgroundFetching. */ - QPointer mCurrentModel; + QPointer mCurrentModel; /** * Current index for background thumbnail fetching. diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/src/videocollectionwrapper.cpp --- a/videocollection/videocollectionwrapper/src/videocollectionwrapper.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/src/videocollectionwrapper.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,14 +15,14 @@ * */ -// Version : %version: 31 % +// Version : %version: 32 % // INCLUDE FILES #include #include "videocollectionwrapper.h" #include "videocollectionwrapper_p.h" -#include "videosortfilterproxymodel.h" +#include "videoproxymodelgeneric.h" #include "videocollectiontrace.h" // ----------------------------------------------------------------------------- @@ -59,15 +59,57 @@ } // ----------------------------------------------------------------------------- -// CVideoCollectionWrapper::getModel() +// CVideoCollectionWrapper::getGenericModel() // ----------------------------------------------------------------------------- // -VideoSortFilterProxyModel* VideoCollectionWrapper::getModel(VideoCollectionCommon::TModelType type) +VideoProxyModelGeneric* VideoCollectionWrapper::getGenericModel() +{ + FUNC_LOG; + if(d) + { + return d->getGenericModel(); + } + return 0; +} + +// ----------------------------------------------------------------------------- +// CVideoCollectionWrapper::getAllVideosModel() +// ----------------------------------------------------------------------------- +// +VideoProxyModelGeneric* VideoCollectionWrapper::getAllVideosModel() { FUNC_LOG; if(d) { - return d->getModel(type); + return d->getAllVideosModel(); + } + return 0; +} + +// ----------------------------------------------------------------------------- +// CVideoCollectionWrapper::getCollectionsModel() +// ----------------------------------------------------------------------------- +// +VideoProxyModelGeneric* VideoCollectionWrapper::getCollectionsModel() +{ + FUNC_LOG; + if(d) + { + return d->getCollectionsModel(); + } + return 0; +} + +// ----------------------------------------------------------------------------- +// CVideoCollectionWrapper::getCollectionContentModel() +// ----------------------------------------------------------------------------- +// +VideoProxyModelGeneric* VideoCollectionWrapper::getCollectionContentModel() +{ + FUNC_LOG; + if(d) + { + return d->getCollectionContentModel(); } return 0; } diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/src/videocollectionwrapper_p.cpp --- a/videocollection/videocollectionwrapper/src/videocollectionwrapper_p.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/src/videocollectionwrapper_p.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 27 % +// Version : %version: 30 % // INCLUDE FILES #include @@ -25,7 +25,10 @@ #include "videocollectionwrapper.h" #include "videocollectionwrapper_p.h" #include "videolistdatamodel.h" -#include "videosortfilterproxymodel.h" +#include "videoproxymodelgeneric.h" +#include "videoproxymodelallvideos.h" +#include "videoproxymodelcollections.h" +#include "videoproxymodelcontent.h" #include "videocollectionclient.h" #include "videocollectioncommon.h" #include "videocollectiontrace.h" @@ -37,13 +40,13 @@ // VideoCollectionWrapperPrivate::VideoCollectionWrapperPrivate() // ----------------------------------------------------------------------------- // -VideoCollectionWrapperPrivate::VideoCollectionWrapperPrivate() - : mAllVideosModel( 0 ) - , mCollectionsModel( 0 ) - , mCollectionContentModel( 0 ) - , mGenericModel( 0 ) - , mSourceModel( 0 ) - , mAboutToClose( false ) +VideoCollectionWrapperPrivate::VideoCollectionWrapperPrivate() : + mGenericModel( 0 ), + mAllVideosModel( 0 ), + mCollectionsModel( 0 ), + mCollectionContentModel( 0 ), + mSourceModel( 0 ), + mAboutToClose( false ) { FUNC_LOG; // NOP @@ -58,85 +61,83 @@ FUNC_LOG; } +// ----------------------------------------------------------------------------- +// VideoCollectionWrapperPrivate::getGenericModel() +// ----------------------------------------------------------------------------- +// +VideoProxyModelGeneric* VideoCollectionWrapperPrivate::getGenericModel() +{ + FUNC_LOG; + if(!mGenericModel) + { + mGenericModel = initProxyModelModel(); + } + return mGenericModel; +} // ----------------------------------------------------------------------------- -// VideoCollectionWrapperPrivate::getModel() +// VideoCollectionWrapperPrivate::getAllVideosModel() +// ----------------------------------------------------------------------------- +// +VideoProxyModelGeneric* VideoCollectionWrapperPrivate::getAllVideosModel() +{ + FUNC_LOG; + if(!mAllVideosModel) + { + mAllVideosModel = initProxyModelModel(); + } + return mAllVideosModel; +} + +// ----------------------------------------------------------------------------- +// VideoCollectionWrapperPrivate::getCollectionsModel() // ----------------------------------------------------------------------------- // -VideoSortFilterProxyModel* VideoCollectionWrapperPrivate::getModel(VideoCollectionCommon::TModelType &type) +VideoProxyModelGeneric* VideoCollectionWrapperPrivate::getCollectionsModel() +{ + FUNC_LOG; + if(!mCollectionsModel) + { + mCollectionsModel = initProxyModelModel(); + } + return mCollectionsModel; +} + +// ----------------------------------------------------------------------------- +// VideoCollectionWrapperPrivate::getCollectionContentModel() +// ----------------------------------------------------------------------------- +// +VideoProxyModelGeneric* VideoCollectionWrapperPrivate::getCollectionContentModel() { - FUNC_LOG; - INFO_1("VideoCollectionWrapperPrivate::getModel() type: %d", type); - - if(mAboutToClose) + FUNC_LOG; + if(!mCollectionContentModel) { - return 0; + mCollectionContentModel = initProxyModelModel(); } + return mCollectionContentModel; +} + +// ----------------------------------------------------------------------------- +// VideoCollectionWrapperPrivate::initSourceModel() +// ----------------------------------------------------------------------------- +// +bool VideoCollectionWrapperPrivate::initSourceModel() +{ + FUNC_LOG; - VideoSortFilterProxyModel *model = 0; if(!mSourceModel) { mSourceModel = new VideoListDataModel(); - if(!mSourceModel || mSourceModel->initialize() < 0 || + if(mSourceModel->initialize() < 0 || !connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuitSlot())) ) { - ERROR(-1, "VideoCollectionWrapperPrivate::getModel() sourceModel setup failed."); - return 0; + delete mSourceModel; + mSourceModel = 0; + ERROR(-1, "VideoCollectionWrapperPrivate::initSourceModel() sourceModel setup failed."); + return false; } } - bool needsInitialization = false; - if(type == VideoCollectionCommon::EModelTypeAllVideos) - { - if(!mAllVideosModel) - { - mAllVideosModel = new VideoSortFilterProxyModel(type); - needsInitialization = true; - } - model = mAllVideosModel; - } - else if(type == VideoCollectionCommon::EModelTypeCollections) - { - if(!mCollectionsModel) - { - mCollectionsModel = new VideoSortFilterProxyModel(type); - needsInitialization = true; - } - model = mCollectionsModel; - } - else if(type == VideoCollectionCommon::EModelTypeCollectionContent) - { - if(!mCollectionContentModel) - { - mCollectionContentModel = new VideoSortFilterProxyModel(type); - needsInitialization = true; - } - model = mCollectionContentModel; - } - else if(type == VideoCollectionCommon::EModelTypeGeneric) - { - if(!mGenericModel) - { - mGenericModel = new VideoSortFilterProxyModel(type); - needsInitialization = true; - } - model = mGenericModel; - } - - if(needsInitialization) - { - if(model && model->initialize(mSourceModel) < 0) - { - ERROR(-1, "VideoCollectionWrapperPrivate::getModel() no model or init failed."); - delete model; - return 0; - } - if(!connect(model, SIGNAL(shortDetailsReady(TMPXItemId)), mSourceModel, SIGNAL(shortDetailsReady(TMPXItemId)))) - { - delete model; - return 0; - } - } - return model; + return true; } // ----------------------------------------------------------------------------- diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/src/videolistdatamodel_p.cpp --- a/videocollection/videocollectionwrapper/src/videolistdatamodel_p.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/src/videolistdatamodel_p.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 38.1.6 % +// Version : %version: 38.1.7 % // INCLUDE FILES #include @@ -126,10 +126,30 @@ // const QString VideoListDataModelPrivate::getVideoNameFromIndex(const int &index ) const { - QString txt; CMPXMedia* media = mMediaData.fromIndex(index); - VideoCollectionUtils::instance().mediaValue(media, KMPXMediaGeneralTitle, txt ); - return txt; + QString text; + + TMPXItemId mpxId( 0, 0 ); + VideoCollectionUtils::instance().mediaValue(media, KMPXMediaGeneralId, mpxId ); + + //Localize default categories + if(mpxId.iId2 == KVcxMvcMediaTypeCategory) + { + switch(mpxId.iId1) + { + case KVcxMvcCategoryIdDownloads: + text = hbTrId("txt_videos_dblist_downloaded"); + break; + case KVcxMvcCategoryIdCaptured: + text = hbTrId("txt_videos_dblist_captured"); + break; + } + } + else + { + VideoCollectionUtils::instance().mediaValue(media, KMPXMediaGeneralTitle, text ); + } + return text; } // ----------------------------------------------------------------------------- diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/src/videoproxymodelallvideos.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/src/videoproxymodelallvideos.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,93 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: VideoProxyModelAllVideos implementation +* +*/ + +// Version : + +// INCLUDE FILES +#include +#include "videoproxymodelgeneric.h" +#include "videoproxymodelallvideos.h" +#include "videolistdatamodel.h" +#include "videocollectiontrace.h" + +// ----------------------------------------------------------------------------- +// VideoProxyModelAllVideos::VideoProxyModelGeneric +// ----------------------------------------------------------------------------- +// +VideoProxyModelAllVideos::VideoProxyModelAllVideos(QObject *parent) : +VideoProxyModelGeneric(parent) +{ + FUNC_LOG_ADDR(this); +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelAllVideos::~VideoProxyModelAllVideos +// ----------------------------------------------------------------------------- +// +VideoProxyModelAllVideos::~VideoProxyModelAllVideos() +{ + FUNC_LOG_ADDR(this); +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelAllVideos::filterAcceptsRow +// ----------------------------------------------------------------------------- +// +bool VideoProxyModelAllVideos::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const +{ + Q_UNUSED(source_parent); + + if(!sourceModel()) + { + return false; + } + + if(source_row < 0 || source_row >= sourceModel()->rowCount()) + { + return false; + } + + TMPXItemId id = mModel->mediaIdAtIndex(source_row); + + if(id.iId2 == KVcxMvcMediaTypeVideo) + { + return true; + } + + return false; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelAllVideos::getOpenItem() +// ----------------------------------------------------------------------------- +// +TMPXItemId VideoProxyModelAllVideos::getOpenItem() const +{ + FUNC_LOG_ADDR(this); + TMPXItemId itemId = TMPXItemId::InvalidId(); + + if(mModel && mCollectionClient) + { + INFO_1("VideoProxyModelAllVideos::getOpenItem() [0x%x] all videos is open.", this); + itemId.iId1 = KVcxMvcCategoryIdAll; + itemId.iId2 = KVcxMvcMediaTypeCategory; + } + + return itemId; +} + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/src/videoproxymodelcollections.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/src/videoproxymodelcollections.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,133 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: VideoProxyModelCollections implementation +* +*/ + +// Version : + +// INCLUDE FILES +#include +#include "videoproxymodelgeneric.h" +#include "videoproxymodelcollections.h" +#include "videolistdatamodel.h" +#include "videocollectiontrace.h" + +// ----------------------------------------------------------------------------- +// VideoProxyModelCollections::VideoProxyModelCollections +// ----------------------------------------------------------------------------- +// +VideoProxyModelCollections::VideoProxyModelCollections(QObject *parent) : +VideoProxyModelGeneric(parent) +{ + FUNC_LOG_ADDR(this); + mDefaultSortRole = VideoCollectionCommon::KeyTitle; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelCollections::~VideoProxyModelCollections +// ----------------------------------------------------------------------------- +// +VideoProxyModelCollections::~VideoProxyModelCollections() +{ + FUNC_LOG_ADDR(this); +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelCollections::lessThan +// ----------------------------------------------------------------------------- +// +bool VideoProxyModelCollections::lessThan(const QModelIndex &left, + const QModelIndex &right) const +{ + if (!mModel) + { + return false; + } + int index = left.row(); + TMPXItemId leftId = mModel->mediaIdAtIndex(index); + index = right.row(); + TMPXItemId rightId = mModel->mediaIdAtIndex(index); + + // Default categories are always first in the following order: + // Recently played (missing currently) + // Captured + // Downloaded + // Podcasts (missing currently) + bool lessThan(false); + bool proceedDataSorting(false); + if(leftId.iId2 == KVcxMvcMediaTypeCategory && + rightId.iId2 == KVcxMvcMediaTypeCategory) + { + if(leftId.iId1 == KVcxMvcCategoryIdCaptured) + { + lessThan = true; + } + else if(leftId.iId1 == KVcxMvcCategoryIdDownloads) + { + if(rightId.iId1 != KVcxMvcCategoryIdCaptured) + { + lessThan = true; + } + } + } + else if(leftId.iId2 == KVcxMvcMediaTypeCategory || + rightId.iId2 == KVcxMvcMediaTypeCategory) + { + lessThan = (leftId.iId2 == KVcxMvcMediaTypeCategory); + } + else + { + proceedDataSorting = true; + } + + if(!proceedDataSorting) + { + return mWantedSortOrder == Qt::AscendingOrder ? lessThan : !lessThan; + } + + // It wasn't collection or they were in correct order, continue sorting with generic rules. + lessThan = VideoProxyModelGeneric::lessThan(left, right); + + return lessThan; +} +// ----------------------------------------------------------------------------- +// VideoProxyModelCollections::filterAcceptsRow +// ----------------------------------------------------------------------------- +// +bool VideoProxyModelCollections::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const +{ + Q_UNUSED(source_parent); + + if(!sourceModel()) + { + return false; + } + + if(source_row < 0 || source_row >= sourceModel()->rowCount()) + { + return false; + } + + TMPXItemId id = mModel->mediaIdAtIndex(source_row); + + if(mLevel == VideoCollectionCommon::ELevelCategory && id.iId2 != KVcxMvcMediaTypeVideo) + { + return true; + } + + return false; +} + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/src/videoproxymodelcontent.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/src/videoproxymodelcontent.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,141 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: VideoProxyModelContent implementation +* +*/ + +// Version : + +// INCLUDE FILES +#include "videoproxymodelgeneric.h" +#include "videoproxymodelcontent.h" +#include "videolistdatamodel.h" +#include "videocollectiontrace.h" + +// ----------------------------------------------------------------------------- +// VideoProxyModelContent::VideoProxyModelGeneric +// ----------------------------------------------------------------------------- +// +VideoProxyModelContent::VideoProxyModelContent(QObject *parent) : +VideoProxyModelGeneric(parent) +{ + FUNC_LOG_ADDR(this); +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelContent::~VideoProxyModelContent +// ----------------------------------------------------------------------------- +// +VideoProxyModelContent::~VideoProxyModelContent() +{ + FUNC_LOG_ADDR(this); +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelContent::connectSignals +// ----------------------------------------------------------------------------- +// +bool VideoProxyModelContent::connectSignals() +{ + FUNC_LOG_ADDR(this); + + if(!VideoProxyModelGeneric::connectSignals()) + { + return false; + } + + if(!connect(mModel, SIGNAL(albumChanged()), + this, SLOT(albumChangedSlot()))) + { + return false; + } + + return true; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelContent::disconnectSignals +// ----------------------------------------------------------------------------- +// +void VideoProxyModelContent::disconnectSignals() +{ + FUNC_LOG_ADDR(this); + + VideoProxyModelGeneric::disconnectSignals(); + + disconnect(mModel, SIGNAL(albumChanged()), + this, SLOT(albumChangedSlot())); +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelContent::filterAcceptsRow +// ----------------------------------------------------------------------------- +// +bool VideoProxyModelContent::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const +{ + Q_UNUSED(source_parent); + + if(!sourceModel()) + { + return false; + } + + if(source_row < 0 || source_row >= sourceModel()->rowCount()) + { + return false; + } + + TMPXItemId id = mModel->mediaIdAtIndex(source_row); + + // Accept item if it belongs to the open album. + if(mModel->belongsToAlbum(id)) + { + return true; + } + + return false; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelContent::getOpenItem() +// ----------------------------------------------------------------------------- +// +TMPXItemId VideoProxyModelContent::getOpenItem() const +{ + FUNC_LOG_ADDR(this); + TMPXItemId itemId = TMPXItemId::InvalidId(); + + if(mModel && mCollectionClient) + { + INFO_1("VideoProxyModelContent::getOpenItem() [0x%x] category or album is open.", this); + itemId = mModel->albumInUse(); + } + + return itemId; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelContent::albumChangedSlot() +// ----------------------------------------------------------------------------- +// +void VideoProxyModelContent::albumChangedSlot() +{ + FUNC_LOG_ADDR(this); + // Sort and invalidate filtering, otherwise newly created album content won't sort. + invalidateFilter(); + setSortRole(mWantedSortRole); + sort(0, mWantedSortOrder); +} + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/src/videoproxymodelgeneric.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/src/videoproxymodelgeneric.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,699 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: VideoProxyModelGeneric implementation +* +*/ + +// Version : + +// INCLUDE FILES +#include +#include +#include +#include +#include + +#include "videothumbnaildata.h" +#include "videocollectioncommon.h" +#include "videoproxymodelgeneric.h" +#include "videolistdatamodel.h" +#include "videocollectionclient.h" +#include "videocollectionwrapper.h" +#include "videocollectiontrace.h" + +const TMPXItemId INVALID_ID = TMPXItemId::InvalidId(); + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::VideoProxyModelGeneric +// ----------------------------------------------------------------------------- +// +VideoProxyModelGeneric::VideoProxyModelGeneric(QObject *parent) : +QSortFilterProxyModel(parent), +mModel(0), +mCollectionClient(0), +mLevel(VideoCollectionCommon::ELevelInvalid), +mGenericFilterId(TMPXItemId::InvalidId()), +mGenericFilterValue(false), +mIdleSortTimer(0), +mWantedSortRole(VideoCollectionCommon::KeyDateTime), +mWantedSortOrder(Qt::AscendingOrder), +mDefaultSortRole(VideoCollectionCommon::KeyTitle) +{ + FUNC_LOG_ADDR(this); +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::~VideoProxyModelGeneric +// ----------------------------------------------------------------------------- +// +VideoProxyModelGeneric::~VideoProxyModelGeneric() +{ + FUNC_LOG_ADDR(this); +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::initialize +// ----------------------------------------------------------------------------- +// +int VideoProxyModelGeneric::initialize(VideoListDataModel *sourceModel) +{ + FUNC_LOG_ADDR(this); + if(!sourceModel) + { + return -1; + } + mModel = sourceModel; + if(!connectSignals()) + { + ERROR_1(-1, "VideoProxyModelGeneric::initialize() [0x%x] failed to connect signals.", this); + disconnectSignals(); + mModel = 0; + return -1; + } + mCollectionClient = sourceModel->getCollectionClient(); + if(!mCollectionClient) + { + mModel = 0; + return -1; + } + setSourceModel(sourceModel); + return 0; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::connectSignals +// ----------------------------------------------------------------------------- +// +bool VideoProxyModelGeneric::connectSignals() +{ + FUNC_LOG_ADDR(this); + + if(!connect(mModel, SIGNAL(modelChanged()), + this, SLOT(invalidate()))) + { + return false; + } + + return true; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::disconnectSignals +// ----------------------------------------------------------------------------- +// +void VideoProxyModelGeneric::disconnectSignals() +{ + FUNC_LOG_ADDR(this); + + disconnect(mModel, SIGNAL(modelChanged()), this, SLOT(invalidate())); +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::open +// ----------------------------------------------------------------------------- +// +int VideoProxyModelGeneric::open(VideoCollectionCommon::TCollectionLevels level) +{ + FUNC_LOG_ADDR(this); + INFO_2("VideoProxyModelGeneric::open() [0x%x] level: %d", this, level); + + if(!mCollectionClient) + { + return -1; + } + + if(mLevel != level) + { + INFO_1("VideoProxyModelGeneric::open() [0x%x] opening different level, invalidating.", this); + mLevel = level; + invalidateFilter(); + // sorting call required here to setup correct sort order in cases where source model allready + // contains items but proxy is not yet updated. (invalidate -call does not work since it updates proxy and + // calls sort in different order for us to use) + sort(0, mWantedSortOrder); + } + // need to call open every time to make sure all items are + // inserted to UI ( recent open might have been cancelled) + return mCollectionClient->startOpenCollection(level); +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::doSorting +// ----------------------------------------------------------------------------- +// +void VideoProxyModelGeneric::doSorting(int sortingRole, Qt::SortOrder order, + bool async) +{ + FUNC_LOG_ADDR(this); + INFO_3("VideoProxyModelGeneric::doSorting() [0x%x] sortingRole: %d, order: %d", this, sortingRole, order); + + if(sortingRole != VideoCollectionCommon::KeyTitle && + sortingRole != VideoCollectionCommon::KeySizeValue && + sortingRole != VideoCollectionCommon::KeyDateTime && + sortingRole != VideoCollectionCommon::KeyNumberOfItems) + { + mWantedSortRole = mDefaultSortRole; + } + else + { + mWantedSortRole = sortingRole; + } + + mWantedSortOrder = order; + + if(async) + { + if(mIdleSortTimer) + { + if(mIdleSortTimer->isActive()) + { + mIdleSortTimer->stop(); + } + } + else + { + mIdleSortTimer = new QTimer(this); + connect(mIdleSortTimer, SIGNAL(timeout()), + this, SLOT(processSortingSlot())); + } + mIdleSortTimer->start(0); + } + else + { + processSorting(); + } +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::getSorting +// ----------------------------------------------------------------------------- +// +void VideoProxyModelGeneric::getSorting(int &sortingRole, Qt::SortOrder &order) +{ + FUNC_LOG_ADDR(this); + sortingRole = mWantedSortRole; + order = mWantedSortOrder; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::deleteItems +// ----------------------------------------------------------------------------- +// +int VideoProxyModelGeneric::deleteItems(const QModelIndexList &indexList) +{ + FUNC_LOG_ADDR(this); + + // Disable thumbnail fetching while items are removed from the model. + VideoThumbnailData::instance().enableBackgroundFetching(false); + + if(mModel) + { + QModelIndexList mappedList; + for(int i = 0; i < indexList.count(); ++i) + { + mappedList.append(mapToSource(indexList.at(i))); + } + + if(mModel->removeRows(mappedList)) + { + // Start fetching thumbnails at start of the model. + VideoThumbnailData::instance().enableBackgroundFetching(true); + VideoThumbnailData::instance().startBackgroundFetching(0, 0); + return 0; + } + } + + VideoThumbnailData::instance().enableBackgroundFetching(true); + return -1; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::openItem +// ----------------------------------------------------------------------------- +// +int VideoProxyModelGeneric::openItem(TMPXItemId mediaId) +{ + FUNC_LOG_ADDR(this); + if(mediaId != TMPXItemId::InvalidId() && mCollectionClient) + { + if(mCollectionClient->openItem(mediaId) == 0) + { + if(mediaId.iId2 != KVcxMvcMediaTypeVideo) + { + mLevel = VideoCollectionCommon::ELevelAlbum; + mModel->setAlbumInUse(mediaId); + INFO_1("VideoProxyModelGeneric::open() [0x%x] opening album or category, invalidating.", this); + invalidateFilter(); + // sorting call required here to setup correct sort order in cases where source model allready + // contains items but proxy is not yet updated. (invalidate -call does not work since it updates proxy and + // calls sort in different order for us to use) + sort(0, mWantedSortOrder); + } + return 0; + } + } + return -1; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::back +// ----------------------------------------------------------------------------- +// +int VideoProxyModelGeneric::back() +{ + FUNC_LOG_ADDR(this); + if(mCollectionClient && mCollectionClient->back() == 0) + { + if(mLevel == VideoCollectionCommon::ELevelAlbum) + { + mLevel = VideoCollectionCommon::ELevelCategory; + } + else + { + mLevel = VideoCollectionCommon::ELevelVideos; + } + return 0; + } + return -1; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::fetchItemDetails +// ----------------------------------------------------------------------------- +// +int VideoProxyModelGeneric::fetchItemDetails(const QModelIndex &index) +{ + FUNC_LOG_ADDR(this); + // no need to map index beforehand, because + // getMediaIdAtIndex maps it + TMPXItemId mpxId1 = getMediaIdAtIndex(index); + if(mpxId1 != TMPXItemId::InvalidId() && mCollectionClient) + { + if(mCollectionClient->getVideoDetails(mpxId1) == 0) + { + emit shortDetailsReady(mpxId1); + return 0; + } + } + return -1; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::lessThan +// ----------------------------------------------------------------------------- +// +bool VideoProxyModelGeneric::lessThan(const QModelIndex &left, + const QModelIndex &right) const +{ + if (!mModel) + { + return false; + } + + // Do comparisation based on the role: + // VideoCollectionCommon::KeyTitle, + // VideoCollectionCommon::KeySizeValue, + // VideoCollectionCommon::KeyNumberOfItems, + // VideoCollectionCommon::KeyDateValue + // + // If role does not match, do not sort + int sRole = sortRole(); + QVariant leftData = sourceModel()->data(left, sRole); + QVariant rightData = sourceModel()->data(right, sRole); + + if(!leftData.isValid() || !rightData.isValid()) + { + return false; + } + if(sRole == VideoCollectionCommon::KeyTitle) + { + QString leftString = leftData.toString().toUpper(); + QString rightString = rightData.toString().toUpper(); + return QString::localeAwareCompare(leftString, rightString) < 0; + } + else if(sRole == VideoCollectionCommon::KeySizeValue || + sRole == VideoCollectionCommon::KeyNumberOfItems) + { + quint32 leftSize = leftData.toUInt(); + quint32 rightSize = rightData.toUInt(); + return leftSize < rightSize; + } + else if(sRole == VideoCollectionCommon::KeyDateTime) + { + QDateTime leftDateTime = leftData.toDateTime(); + QDateTime rightDateTime = rightData.toDateTime(); + // datetime sorting role has inverted sorting order compared to other roles + return rightDateTime < leftDateTime; + } + return false; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::filterAcceptsRow +// ----------------------------------------------------------------------------- +// +bool VideoProxyModelGeneric::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const +{ + Q_UNUSED(source_parent); + + if(!sourceModel()) + { + return false; + } + + if(source_row < 0 || source_row >= sourceModel()->rowCount()) + { + return false; + } + TMPXItemId id = mModel->mediaIdAtIndex(source_row); + if(id == TMPXItemId::InvalidId()) + { + return false; + } + + if(mLevel == VideoCollectionCommon::ELevelVideos && id.iId2 == KVcxMvcMediaTypeVideo) + { + // filter items that belong to that album setted as filter id + // if there's no filter or setted filter is "all videos", we accept everything + if(mGenericFilterId == TMPXItemId::InvalidId() || + (mGenericFilterId.iId1 == KVcxMvcCategoryIdAll && + mGenericFilterId.iId2 == KVcxMvcMediaTypeCategory) || + mGenericFilterValue == mModel->belongsToAlbum(id, mGenericFilterId)) + { + return true; + } + } + else if(mLevel == VideoCollectionCommon::ELevelCategory && id.iId2 == KVcxMvcMediaTypeAlbum) + { + // we do not filter albums yet + return true; + } + + return false; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::getMediaIdAtIndex() +// ----------------------------------------------------------------------------- +// +const TMPXItemId& VideoProxyModelGeneric::getMediaIdAtIndex(const QModelIndex &index) const +{ + if(index.isValid()) + { + int rowIndex = mapToSource(index).row(); + if(mModel) + { + return mModel->mediaIdAtIndex(rowIndex); + } + } + return INVALID_ID; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::indexOfId() +// ----------------------------------------------------------------------------- +// +QModelIndex VideoProxyModelGeneric::indexOfId(const TMPXItemId &id) +{ + QModelIndex sourceIndex; + if(!mModel || id == TMPXItemId::InvalidId()) + { + return sourceIndex; + } + sourceIndex = mModel->indexOfId(id); + return mapFromSource(sourceIndex); +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::getMediaFilePathForId() +// ----------------------------------------------------------------------------- +// +QString VideoProxyModelGeneric::getMediaFilePathForId(const TMPXItemId &mediaId) +{ + QString filePath; + if(mModel) + { + filePath = mModel->mediaFilePathForId(mediaId); + } + return filePath; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::addNewAlbum() +// ----------------------------------------------------------------------------- +// +TMPXItemId VideoProxyModelGeneric::addNewAlbum(const QString &title) +{ + FUNC_LOG_ADDR(this); + TMPXItemId id = TMPXItemId::InvalidId(); + + if (mCollectionClient) + { + id = mCollectionClient->addNewAlbum(title); + } + + return id; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::removeAlbums() +// ----------------------------------------------------------------------------- +// +int VideoProxyModelGeneric::removeAlbums(const QModelIndexList &indexList) +{ + FUNC_LOG_ADDR(this); + int err(-1); + + if (mCollectionClient) + { + TMPXItemId mpxId; + QList ids; + + for(int i = 0; i < indexList.count(); ++i) + { + mpxId = getMediaIdAtIndex(indexList.at(i)); + if(mpxId != TMPXItemId::InvalidId() && + mpxId.iId2 == KVcxMvcMediaTypeAlbum) + { + ids.append(getMediaIdAtIndex(indexList.at(i))); + } + } + + if (ids.count()) + { + err = mCollectionClient->removeAlbums(ids); + } + } + + return err; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::resolveAlbumName() +// ----------------------------------------------------------------------------- +// +QString VideoProxyModelGeneric::resolveAlbumName( + const QString& albumName) const +{ + FUNC_LOG_ADDR(this); + QString resolvedName = albumName.trimmed(); + + // for checking names, we need to use collection list proxy model + // to get all existing album names including default ones + VideoProxyModelGeneric *collectionModel = + VideoCollectionWrapper::instance().getCollectionsModel(); + if(!collectionModel || !mModel) + { + return resolvedName; + } + + int i(0); + QModelIndex proxyIndex = collectionModel->index(i, 0); + QSet names; + QVariant data; + // create set of existing names + while (proxyIndex.isValid()) + { + data = mModel->data(collectionModel->mapToSource(proxyIndex), + VideoCollectionCommon::KeyTitle); + if (data.isValid()) + { + names.insert(data.toString()); + } + proxyIndex = collectionModel->index(++i, 0, QModelIndex()); + } + i = 0; + QString firstMatch(""); + // find a name that does not yet exists + while(names.contains(resolvedName)) + { + if (!firstMatch.length()) + { + firstMatch = resolvedName; + } + ++i; + resolvedName = tr("%1 (%2)").arg(firstMatch).arg(i); + } + return resolvedName; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::addItemsInAlbum() +// ----------------------------------------------------------------------------- +// +int VideoProxyModelGeneric::addItemsInAlbum(TMPXItemId &albumId, + const QList &mediaIds) +{ + FUNC_LOG_ADDR(this); + int err(-1); + + if (mCollectionClient) + { + // add items in album + err = mCollectionClient->addItemsInAlbum(albumId, mediaIds); + } + + return err; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::removeItemsFromAlbum() +// ----------------------------------------------------------------------------- +// +int VideoProxyModelGeneric::removeItemsFromAlbum(TMPXItemId &albumId, + const QList &mediaIds) +{ + FUNC_LOG_ADDR(this); + int err(-1); + + // Disable thumbnail fetching while items are removed from the model. + VideoThumbnailData::instance().enableBackgroundFetching(false); + + if (mModel) + { + // remove items in album + err = mModel->removeItemsFromAlbum(albumId, mediaIds); + if(err > 0) + { + // if there really were items to be removed, invalid filter + INFO_1("VideoProxyModelGeneric::removeItemsFromAlbum() [0x%x] items removed, invaliding.", this); + invalidateFilter(); + err = 0; + } + } + + VideoThumbnailData::instance().enableBackgroundFetching(true); + return err; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::renameItem() +// ----------------------------------------------------------------------------- +// +int VideoProxyModelGeneric::renameItem(const TMPXItemId &itemId, const QString &newTitle) +{ + FUNC_LOG_ADDR(this); + int err(-1); + + if(mCollectionClient) + { + return mCollectionClient->renameItem(itemId, newTitle); + } + return err; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::getOpenItem() +// ----------------------------------------------------------------------------- +// +TMPXItemId VideoProxyModelGeneric::getOpenItem() const +{ + FUNC_LOG_ADDR(this); + TMPXItemId itemId = TMPXItemId::InvalidId(); + return itemId; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::setGenericIdFilter() +// ----------------------------------------------------------------------------- +// +void VideoProxyModelGeneric::setGenericIdFilter(const TMPXItemId &itemId, bool filterValue) +{ + FUNC_LOG_ADDR(this); + INFO_3("VideoProxyModelGeneric::setGenericIdFilter() [0x%x] itemId.iId2: %d, filterValue: %d", this, itemId.iId2, filterValue); + mGenericFilterId = itemId; + mGenericFilterValue = filterValue; + INFO_1("VideoProxyModelGeneric::setGenericIdFilter() [0x%x] invalidating.", this); + invalidateFilter(); +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::setAlbumInUse() +// ----------------------------------------------------------------------------- +// +void VideoProxyModelGeneric::setAlbumInUse(const TMPXItemId &albumId) +{ + FUNC_LOG_ADDR(this); + if(mModel) + { + INFO_1("VideoProxyModelGeneric::setAlbumInUse() [0x%x] invalidating.", this); + mModel->setAlbumInUse(albumId); + invalidateFilter(); + } +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::processSortingSlot +// ----------------------------------------------------------------------------- +// +void VideoProxyModelGeneric::processSortingSlot() +{ + FUNC_LOG_ADDR(this); + if(mIdleSortTimer) + { + mIdleSortTimer->stop(); + } + processSorting(); +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::processSorting +// ----------------------------------------------------------------------------- +// +void VideoProxyModelGeneric::processSorting() +{ + FUNC_LOG_ADDR(this); + + if(sortRole() != mWantedSortRole) + { + setSortRole(mWantedSortRole); + } + + if(sortColumn() == -1 || sortOrder() != mWantedSortOrder) + { + // if sorting column is not yet setted, it indicates + // that we've setted the sorting order for the first time + // and sorting has not yet been done. After we have called sort once, + // the sort columnt gets updated and following sorts gets executed + // by setSortRole -call as long as role changes. + + // Another case is when we need to change the sort order, as there is + // no other way of setting the sort order than calling sort(). + sort(0, mWantedSortOrder); + } + + emit modelSorted(); +} + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/src/videosortfilterproxymodel.cpp --- a/videocollection/videocollectionwrapper/src/videosortfilterproxymodel.cpp Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,824 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Videosortfilterproxymodel implementation -* -*/ - -// Version : %version: 66.1.9 % - -// INCLUDE FILES -#include -#include -#include -#include -#include - -#include "videothumbnaildata.h" -#include "videocollectioncommon.h" -#include "videosortfilterproxymodel.h" -#include "videolistdatamodel.h" -#include "videocollectionclient.h" -#include "videocollectionwrapper.h" -#include "videocollectiontrace.h" - -const TMPXItemId INVALID_ID = TMPXItemId::InvalidId(); - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::VideoSortFilterProxyModel -// ----------------------------------------------------------------------------- -// -VideoSortFilterProxyModel::VideoSortFilterProxyModel(VideoCollectionCommon::TModelType type, QObject *parent) : -QSortFilterProxyModel(parent), -mModel(0), -mCollectionClient(0), -mType(type), -mLevel(VideoCollectionCommon::ELevelInvalid), -mGenericFilterId(TMPXItemId::InvalidId()), -mGenericFilterValue(false), -mIdleSortTimer(0), -mWantedSortRole(VideoCollectionCommon::KeyDateTime), -mWantedSortOrder(Qt::AscendingOrder) -{ - FUNC_LOG_ADDR(this); - INFO_2("VideoSortFilterProxyModel::VideoSortFilterProxyModel() [0x%x]: type: %d", this, type); -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::~VideoSortFilterProxyModel -// ----------------------------------------------------------------------------- -// -VideoSortFilterProxyModel::~VideoSortFilterProxyModel() -{ - FUNC_LOG_ADDR(this); -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::initialize -// ----------------------------------------------------------------------------- -// -int VideoSortFilterProxyModel::initialize(VideoListDataModel *sourceModel) -{ - FUNC_LOG_ADDR(this); - if(!sourceModel) - { - return -1; - } - - if(!mModel) - { - mModel = sourceModel; - if(!connectSignals()) - { - ERROR_1(-1, "VideoSortFilterProxyModel::initialize() [0x%x] failed to connect signals.", this); - disconnectSignals(); - mModel = 0; - return -1; - } - mCollectionClient = mModel->getCollectionClient(); - setSourceModel(sourceModel); - } - return 0; -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::connectSignals -// ----------------------------------------------------------------------------- -// -bool VideoSortFilterProxyModel::connectSignals() -{ - FUNC_LOG_ADDR(this); - - if(!connect(mModel, SIGNAL(modelChanged()), - this, SLOT(invalidate()))) - { - return false; - } - if(mType == VideoCollectionCommon::EModelTypeCollectionContent) - { - if(!connect(mModel, SIGNAL(albumChanged()), - this, SLOT(albumChangedSlot()))) - { - return false; - } - } - - return true; -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::disconnectSignals -// ----------------------------------------------------------------------------- -// -void VideoSortFilterProxyModel::disconnectSignals() -{ - FUNC_LOG_ADDR(this); - disconnect(mModel, SIGNAL(modelChanged()), this, SLOT(invalidate())); - if(mType == VideoCollectionCommon::EModelTypeCollectionContent) - { - disconnect(mModel, SIGNAL(albumChanged()), this, SLOT(albumChangedSlot())); - } - if(mType == VideoCollectionCommon::EModelTypeCollections) - { - disconnect(mModel, SIGNAL(itemModified(const TMPXItemId &)), - this, SLOT(itemModifiedSlot(const TMPXItemId &))); - } -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::open -// ----------------------------------------------------------------------------- -// -int VideoSortFilterProxyModel::open(VideoCollectionCommon::TCollectionLevels level) -{ - FUNC_LOG_ADDR(this); - INFO_2("VideoSortFilterProxyModel::open() [0x%x] level: %d", this, level); - - if(!mCollectionClient) - { - return -1; - } - - if(mLevel != level) - { - INFO_1("VideoSortFilterProxyModel::open() [0x%x] opening different level, invalidating.", this); - mLevel = level; - invalidateFilter(); - // sorting call required here to setup correct sort order in cases where source model allready - // contains items but proxy is not yet updated. (invalidate -call does not work since it updates proxy and - // calls sort in different order for us to use) - sort(0, mWantedSortOrder); - } - // need to call open every time to make sure all items are - // inserted to UI ( recent open might have been cancelled) - return mCollectionClient->startOpenCollection(level); -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::doSorting -// ----------------------------------------------------------------------------- -// -void VideoSortFilterProxyModel::doSorting(int sortingRole, Qt::SortOrder order, - bool async) -{ - FUNC_LOG_ADDR(this); - INFO_3("VideoSortFilterProxyModel::doSorting() [0x%x] sortingRole: %d, order: %d", this, sortingRole, order); - - if(sortingRole != VideoCollectionCommon::KeyTitle && - sortingRole != VideoCollectionCommon::KeySizeValue && - sortingRole != VideoCollectionCommon::KeyDateTime && - sortingRole != VideoCollectionCommon::KeyNumberOfItems) - { - // default sorting order is by date for other models but collections. - if(mType != VideoCollectionCommon::EModelTypeCollections) - { - mWantedSortRole = VideoCollectionCommon::KeyDateTime; - } - else - { - mWantedSortRole = VideoCollectionCommon::KeyTitle; - } - } - else - { - mWantedSortRole = sortingRole; - } - - mWantedSortOrder = order; - - if(async) - { - if(mIdleSortTimer) - { - if(mIdleSortTimer->isActive()) - { - mIdleSortTimer->stop(); - } - } - else - { - mIdleSortTimer = new QTimer(this); - connect(mIdleSortTimer, SIGNAL(timeout()), this, SLOT(processSorting())); - } - mIdleSortTimer->start(0); - } - else - { - processSorting(); - } -} -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::getSorting -// ----------------------------------------------------------------------------- -// -void VideoSortFilterProxyModel::getSorting(int &sortingRole, Qt::SortOrder &order) -{ - FUNC_LOG_ADDR(this); - sortingRole = mWantedSortRole; - order = mWantedSortOrder; -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::deleteItems -// ----------------------------------------------------------------------------- -// -int VideoSortFilterProxyModel::deleteItems(const QModelIndexList &indexList) -{ - FUNC_LOG_ADDR(this); - - // Disable thumbnail fetching while items are removed from the model. - VideoThumbnailData::instance().enableBackgroundFetching(false); - - if(mModel) - { - QModelIndexList mappedList; - for(int i = 0; i < indexList.count(); ++i) - { - mappedList.append(mapToSource(indexList.at(i))); - } - - if(mModel->removeRows(mappedList)) - { - // Start fetching thumbnails at start of the model. - VideoThumbnailData::instance().enableBackgroundFetching(true); - VideoThumbnailData::instance().startBackgroundFetching(0, 0); - return 0; - } - } - - VideoThumbnailData::instance().enableBackgroundFetching(true); - return -1; -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::openItem -// ----------------------------------------------------------------------------- -// -int VideoSortFilterProxyModel::openItem(TMPXItemId mediaId) -{ - FUNC_LOG_ADDR(this); - if(mediaId != TMPXItemId::InvalidId() && mCollectionClient) - { - if(mCollectionClient->openItem(mediaId) == 0) - { - if(mediaId.iId2 != KVcxMvcMediaTypeVideo) - { - mLevel = VideoCollectionCommon::ELevelAlbum; - mModel->setAlbumInUse(mediaId); - INFO_1("VideoSortFilterProxyModel::open() [0x%x] opening album or category, invalidating.", this); - invalidateFilter(); - // sorting call required here to setup correct sort order in cases where source model allready - // contains items but proxy is not yet updated. (invalidate -call does not work since it updates proxy and - // calls sort in different order for us to use) - sort(0, mWantedSortOrder); - } - return 0; - } - } - return -1; -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::back -// ----------------------------------------------------------------------------- -// -int VideoSortFilterProxyModel::back() -{ - FUNC_LOG_ADDR(this); - if(mCollectionClient && mCollectionClient->back() == 0) - { - if(mLevel == VideoCollectionCommon::ELevelAlbum) - { - mLevel = VideoCollectionCommon::ELevelCategory; - } - else - { - mLevel = VideoCollectionCommon::ELevelVideos; - } - return 0; - } - return -1; -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::fetchItemDetails -// ----------------------------------------------------------------------------- -// -int VideoSortFilterProxyModel::fetchItemDetails(const QModelIndex &index) -{ - FUNC_LOG_ADDR(this); - // no need to map index beforehand, because - // getMediaIdAtIndex maps it - TMPXItemId mpxId1 = getMediaIdAtIndex(index); - if(mpxId1 != TMPXItemId::InvalidId() && mCollectionClient) - { - if(mCollectionClient->getVideoDetails(mpxId1) == 0) - { - emit shortDetailsReady(mpxId1); - return 0; - } - } - return -1; -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::processSorting -// ----------------------------------------------------------------------------- -// -void VideoSortFilterProxyModel::processSorting() -{ - FUNC_LOG_ADDR(this); - if(mIdleSortTimer) - { - mIdleSortTimer->stop(); - } - - if(sortRole() != mWantedSortRole) - { - setSortRole(mWantedSortRole); - } - - if(sortColumn() == -1 || sortOrder() != mWantedSortOrder) - { - // if sorting column is not yet setted, it indicates - // that we've setted the sorting order for the first time - // and sorting has not yet been done. After we have called sort once, - // the sort columnt gets updated and following sorts gets executed - // by setSortRole -call as long as role changes. - - // Another case is when we need to change the sort order, as there is - // no other way of setting the sort order than calling sort(). - sort(0, mWantedSortOrder); - } - - emit modelSorted(); -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::lessThan -// ----------------------------------------------------------------------------- -// -bool VideoSortFilterProxyModel::lessThan(const QModelIndex &left, - const QModelIndex &right) const -{ - if (!mModel) - { - return false; - } - int index = left.row(); - TMPXItemId leftId = mModel->mediaIdAtIndex(index); - index = right.row(); - TMPXItemId rightId = mModel->mediaIdAtIndex(index); - - // Default categories are always first in the following order: - // Recently played (missing currently) - // Captured - // Downloaded - // Podcasts (missing currently) - bool lessThan(false); - bool proceedDataSorting(false); - if(leftId.iId2 == KVcxMvcMediaTypeCategory && - rightId.iId2 == KVcxMvcMediaTypeCategory) - { - if(leftId.iId1 == KVcxMvcCategoryIdCaptured) - { - lessThan = true; - } - - else if(leftId.iId1 == KVcxMvcCategoryIdDownloads) - { - if(rightId.iId1 != KVcxMvcCategoryIdCaptured) - { - lessThan = true; - } - } - } - else if(leftId.iId2 == KVcxMvcMediaTypeCategory || - rightId.iId2 == KVcxMvcMediaTypeCategory) - { - lessThan = (leftId.iId2 == KVcxMvcMediaTypeCategory); - } - else - { - proceedDataSorting = true; - } - - if(!proceedDataSorting) - { - return mWantedSortOrder == Qt::AscendingOrder ? lessThan : !lessThan; - } - - // Do comparisation based on the role: - // VideoCollectionCommon::KeyTitle, - // VideoCollectionCommon::KeySizeValue, - // VideoCollectionCommon::KeyNumberOfItems, - // VideoCollectionCommon::KeyDateValue - // - // If role does not match, do not sort - int sRole = sortRole(); - QVariant leftData = sourceModel()->data(left, sRole); - QVariant rightData = sourceModel()->data(right, sRole); - - if(!leftData.isValid() || !rightData.isValid()) - { - return false; - } - if(sRole == VideoCollectionCommon::KeyTitle) - { - QString leftString = leftData.toString().toUpper(); - QString rightString = rightData.toString().toUpper(); - return QString::localeAwareCompare(leftString, rightString) < 0; - } - else if(sRole == VideoCollectionCommon::KeySizeValue || - sRole == VideoCollectionCommon::KeyNumberOfItems) - { - quint32 leftSize = leftData.toUInt(); - quint32 rightSize = rightData.toUInt(); - return leftSize < rightSize; - } - else if(sRole == VideoCollectionCommon::KeyDateTime) - { - QDateTime leftDateTime = leftData.toDateTime(); - QDateTime rightDateTime = rightData.toDateTime(); - // datetime sorting role has inverted sorting order compared to other roles - return rightDateTime < leftDateTime; - } - return false; -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::filterAcceptsRow -// ----------------------------------------------------------------------------- -// -bool VideoSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const -{ - Q_UNUSED(source_parent); - - if(!sourceModel()) - { - return false; - } - - if(source_row < 0 || source_row >= sourceModel()->rowCount()) - { - return false; - } - TMPXItemId id = mModel->mediaIdAtIndex(source_row); - if(id == TMPXItemId::InvalidId()) - { - return false; - } - - if (mType == VideoCollectionCommon::EModelTypeAllVideos) - { - if(id.iId2 == KVcxMvcMediaTypeVideo) - { - return true; - } - } - else if(mType == VideoCollectionCommon::EModelTypeCollections) - { - if(mLevel == VideoCollectionCommon::ELevelCategory && id.iId2 != KVcxMvcMediaTypeVideo) - { - return true; - } - } - else if (mType == VideoCollectionCommon::EModelTypeCollectionContent) - { - // if item belongs to the open album, accept it - if (mModel->belongsToAlbum(id)) - { - return true; - } - } - else if(mType == VideoCollectionCommon::EModelTypeGeneric) - { - if(mLevel == VideoCollectionCommon::ELevelVideos && id.iId2 == KVcxMvcMediaTypeVideo) - { - // filter items that belong to that album setted as filter id - // if there's no filter or setted filter is "all videos", we accept everything - if(mGenericFilterId == TMPXItemId::InvalidId() || - (mGenericFilterId.iId1 == KVcxMvcCategoryIdAll && - mGenericFilterId.iId2 == KVcxMvcMediaTypeCategory) || - mGenericFilterValue == mModel->belongsToAlbum(id, mGenericFilterId)) - { - return true; - } - } - else if(mLevel == VideoCollectionCommon::ELevelCategory && id.iId2 == KVcxMvcMediaTypeAlbum) - { - // we do not filter albums yet - return true; - } - } - - return false; -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::getMediaIdAtIndex() -// ----------------------------------------------------------------------------- -// -const TMPXItemId& VideoSortFilterProxyModel::getMediaIdAtIndex(const QModelIndex &index) const -{ - if(index.isValid()) - { - int rowIndex = mapToSource(index).row(); - if(mModel) - { - return mModel->mediaIdAtIndex(rowIndex); - } - } - return INVALID_ID; -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::indexOfId() -// ----------------------------------------------------------------------------- -// -QModelIndex VideoSortFilterProxyModel::indexOfId(const TMPXItemId &id) -{ - QModelIndex sourceIndex; - if(!mModel || id == TMPXItemId::InvalidId()) - { - return sourceIndex; - } - sourceIndex = mModel->indexOfId(id); - return mapFromSource(sourceIndex); -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::getMediaFilePathForId() -// ----------------------------------------------------------------------------- -// -QString VideoSortFilterProxyModel::getMediaFilePathForId(const TMPXItemId &mediaId) -{ - QString filePath; - if(mModel) - { - filePath = mModel->mediaFilePathForId(mediaId); - } - return filePath; -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::addNewAlbum() -// ----------------------------------------------------------------------------- -// -TMPXItemId VideoSortFilterProxyModel::addNewAlbum(const QString &title) -{ - FUNC_LOG_ADDR(this); - TMPXItemId id = TMPXItemId::InvalidId(); - - if (mCollectionClient) - { - id = mCollectionClient->addNewAlbum(title); - } - - return id; -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::removeAlbums() -// ----------------------------------------------------------------------------- -// -int VideoSortFilterProxyModel::removeAlbums(const QModelIndexList &indexList) -{ - FUNC_LOG_ADDR(this); - int err(-1); - - if (mCollectionClient) - { - TMPXItemId mpxId; - QList ids; - - for(int i = 0; i < indexList.count(); ++i) - { - mpxId = getMediaIdAtIndex(indexList.at(i)); - if((mpxId != TMPXItemId::InvalidId()) && (mpxId.iId2 == KVcxMvcMediaTypeAlbum)) - { - ids.append(getMediaIdAtIndex(indexList.at(i))); - } - } - - if (ids.count()) - { - err = mCollectionClient->removeAlbums(ids); - } - } - - return err; -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::resolveAlbumName() -// ----------------------------------------------------------------------------- -// -QString VideoSortFilterProxyModel::resolveAlbumName( - const QString& albumName) const -{ - FUNC_LOG_ADDR(this); - QString resolvedName = albumName.trimmed(); - - // for checking names, we need to use collection list proxy model - // to get all existing album names including default ones - VideoSortFilterProxyModel *collectionModel = - VideoCollectionWrapper::instance().getModel( - VideoCollectionCommon::EModelTypeCollections); - if(!collectionModel || !mModel) - { - return resolvedName; - } - - int i(0); - QModelIndex proxyIndex = collectionModel->index(i, 0); - QSet names; - QVariant data; - // create set of existing names - while (proxyIndex.isValid()) - { - data = mModel->data(collectionModel->mapToSource(proxyIndex), VideoCollectionCommon::KeyTitle); - if (data.isValid()) - { - names.insert(data.toString()); - } - proxyIndex = collectionModel->index(++i, 0, QModelIndex()); - } - i = 0; - QString firstMatch(""); - // find a name that does not yet exists - while(names.contains(resolvedName)) - { - if (!firstMatch.length()) - { - firstMatch = resolvedName; - } - ++i; - resolvedName = tr("%1 (%2)").arg(firstMatch).arg(i); - } - return resolvedName; -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::addItemsInAlbum() -// ----------------------------------------------------------------------------- -// -int VideoSortFilterProxyModel::addItemsInAlbum(TMPXItemId &albumId, - const QList &mediaIds) -{ - FUNC_LOG_ADDR(this); - int err(-1); - - if (mCollectionClient) - { - // add items in album - err = mCollectionClient->addItemsInAlbum(albumId, mediaIds); - } - - return err; -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::removeItemsFromAlbum() -// ----------------------------------------------------------------------------- -// -int VideoSortFilterProxyModel::removeItemsFromAlbum(TMPXItemId &albumId, - const QList &mediaIds) -{ - FUNC_LOG_ADDR(this); - int err(-1); - - // Disable thumbnail fetching while items are removed from the model. - VideoThumbnailData::instance().enableBackgroundFetching(false); - - if (mModel) - { - // remove items in album - err = mModel->removeItemsFromAlbum(albumId, mediaIds); - if(err > 0) - { - // if there really were items to be removed, invalid filter - INFO_1("VideoSortFilterProxyModel::removeItemsFromAlbum() [0x%x] items removed, invaliding.", this); - invalidateFilter(); - err = 0; - } - } - - VideoThumbnailData::instance().enableBackgroundFetching(true); - return err; -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::renameItem() -// ----------------------------------------------------------------------------- -// -int VideoSortFilterProxyModel::renameItem(const TMPXItemId &itemId, const QString &newTitle) -{ - FUNC_LOG_ADDR(this); - int err(-1); - - if(mCollectionClient) - { - return mCollectionClient->renameItem(itemId, newTitle); - } - return err; -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::getOpenItem() -// ----------------------------------------------------------------------------- -// -TMPXItemId VideoSortFilterProxyModel::getOpenItem() const -{ - FUNC_LOG_ADDR(this); - TMPXItemId itemId = TMPXItemId::InvalidId(); - - if(mModel && mCollectionClient) - { - if(mType == VideoCollectionCommon::EModelTypeAllVideos) - { - INFO_1("VideoSortFilterProxyModel::getOpenItem() [0x%x] all videos is open.", this); - itemId.iId1 = KVcxMvcCategoryIdAll; - itemId.iId2 = KVcxMvcMediaTypeCategory; - } - else if(mType == VideoCollectionCommon::EModelTypeCollectionContent) - { - INFO_1("VideoSortFilterProxyModel::getOpenItem() [0x%x] category or album is open.", this); - itemId = mModel->albumInUse(); - } - } - - return itemId; -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::setGenericIdFilter() -// ----------------------------------------------------------------------------- -// -void VideoSortFilterProxyModel::setGenericIdFilter(const TMPXItemId &itemId, bool filterValue) -{ - FUNC_LOG_ADDR(this); - if(mType == VideoCollectionCommon::EModelTypeGeneric) - { - INFO_3("VideoSortFilterProxyModel::setGenericIdFilter() [0x%x] itemId.iId2: %d, filterValue: %d", this, itemId.iId2, filterValue); - mGenericFilterId = itemId; - mGenericFilterValue = filterValue; - INFO_1("VideoSortFilterProxyModel::setGenericIdFilter() [0x%x] invalidating.", this); - invalidateFilter(); - } -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::setAlbumInUse() -// ----------------------------------------------------------------------------- -// -void VideoSortFilterProxyModel::setAlbumInUse(const TMPXItemId &albumId) -{ - FUNC_LOG_ADDR(this); - if(mModel) - { - INFO_1("VideoSortFilterProxyModel::setAlbumInUse() [0x%x] invalidating.", this); - mModel->setAlbumInUse(albumId); - invalidateFilter(); - } -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::albumChangedSlot() -// ----------------------------------------------------------------------------- -// -void VideoSortFilterProxyModel::albumChangedSlot() -{ - FUNC_LOG_ADDR(this); - // ignore if not collection content model - if (mType == VideoCollectionCommon::EModelTypeCollectionContent) - { - INFO_1("VideoSortFilterProxyModel::albumChangedSlot() [0x%x] invalidating.", this); - // sort and invalidate filtering, otherwise newly created album content won't sort - invalidateFilter(); - setSortRole(mWantedSortRole); - sort(0, mWantedSortOrder); - } -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::getType() -// ----------------------------------------------------------------------------- -// -VideoCollectionCommon::TModelType VideoSortFilterProxyModel::getType() -{ - FUNC_LOG_ADDR(this); - return mType; -} - -// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/src/videothumbnaildata.cpp --- a/videocollection/videocollectionwrapper/src/videothumbnaildata.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/src/videothumbnaildata.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 26.1.2 % +// Version : %version: 26.1.3 % // INCLUDE FILES #include "videocollectiontrace.h" @@ -84,7 +84,7 @@ // VideoThumbnailData::startBackgroundFetching() // ----------------------------------------------------------------------------- // -void VideoThumbnailData::startBackgroundFetching(VideoSortFilterProxyModel *model, int fetchIndex) +void VideoThumbnailData::startBackgroundFetching(VideoProxyModelGeneric *model, int fetchIndex) { INFO_2("VideoThumbnailData::startBackgroundFetching() model: 0x%x, fetchIndex: %d", model, fetchIndex); d_ptr->startBackgroundFetching(model, fetchIndex); diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/src/videothumbnaildata_p.cpp --- a/videocollection/videocollectionwrapper/src/videothumbnaildata_p.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/src/videothumbnaildata_p.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 24.1.3 % +// Version : %version: 24.1.5 % // INCLUDE FILES #include @@ -30,7 +30,7 @@ #include "videothumbnaildata_p.h" #include "videocollectionwrapper.h" -#include "videosortfilterproxymodel.h" +#include "videoproxymodelgeneric.h" #include "videothumbnailfetcher.h" #include "videocollectiontrace.h" @@ -182,10 +182,6 @@ FUNC_LOG; if(!mSignalsConnected) { - VideoSortFilterProxyModel *model = - VideoCollectionWrapper::instance().getModel(VideoCollectionCommon::EModelTypeAllVideos); - if(!model) - return -1; if(!connect(mThumbnailFetcher, SIGNAL(thumbnailReady( QPixmap , const TMPXItemId &, int )), this, SLOT(thumbnailReadySlot( QPixmap , const TMPXItemId &, int))) || !connect(mThumbnailFetcher, SIGNAL(allThumbnailsFetched()), @@ -228,6 +224,7 @@ int VideoThumbnailDataPrivate::startFetchingThumbnails(const QList &indexes, int priority) { FUNC_LOG; + if(!mCurrentModel || !mThumbnailFetcher) { return -1; @@ -410,19 +407,26 @@ // const QIcon* VideoThumbnailDataPrivate::defaultThumbnail(const TMPXItemId &mediaId) { + FUNC_LOG; + + if(!mBackgroundFetchingEnabled) + { + return 0; + } + const TMPXItemId defaultIdVideo(KMaxTUint32-1, KVcxMvcMediaTypeVideo); const TMPXItemId defaultIdAlbum(KMaxTUint32-1, KVcxMvcMediaTypeAlbum); const TMPXItemId defaultIdDownloads(KVcxMvcCategoryIdDownloads, KVcxMvcMediaTypeCategory); const TMPXItemId defaultIdCaptured(KVcxMvcCategoryIdCaptured, KVcxMvcMediaTypeCategory); // Default thumbnail for video - if(mediaId.iId2 == KVcxMvcMediaTypeVideo) + if(mediaId.iId2 == KVcxMvcMediaTypeVideo) { if(!mDefaultThumbnails.contains(defaultIdVideo)) { mDefaultThumbnails[defaultIdVideo] = loadIcon("qtg_large_video"); } - return &mDefaultThumbnails[defaultIdVideo].qicon(); + return mDefaultThumbnails[defaultIdVideo]; } else { @@ -433,7 +437,7 @@ { mDefaultThumbnails[defaultIdAlbum] = loadIcon("qtg_large_video_collection"); } - return &mDefaultThumbnails[defaultIdAlbum].qicon(); + return mDefaultThumbnails[defaultIdAlbum]; } // Thumbnails for default collections. @@ -445,7 +449,7 @@ { mDefaultThumbnails[defaultIdDownloads] = loadIcon("qtg_large_video_download"); } - return &mDefaultThumbnails[defaultIdDownloads].qicon(); + return mDefaultThumbnails[defaultIdDownloads]; } case KVcxMvcCategoryIdCaptured: @@ -454,16 +458,12 @@ { mDefaultThumbnails[defaultIdCaptured] = loadIcon("qtg_large_video_capture"); } - return &mDefaultThumbnails[defaultIdCaptured].qicon(); + return mDefaultThumbnails[defaultIdCaptured]; } default: { - if(!mDefaultThumbnails.contains(defaultIdAlbum)) - { - mDefaultThumbnails[defaultIdAlbum] = loadIcon("qtg_large_video_collection"); - } - return &mDefaultThumbnails[defaultIdAlbum].qicon(); + return 0; } } } @@ -473,50 +473,30 @@ // VideoThumbnailDataPrivate::loadIcon() // ----------------------------------------------------------------------------- // -HbIcon VideoThumbnailDataPrivate::loadIcon(QString iconName) -{ - HbIcon icon(iconName); +QIcon *VideoThumbnailDataPrivate::loadIcon(QString iconName) +{ + FUNC_LOG; - if(!icon.isNull()) + HbIcon resource(iconName); + QIcon *icon = 0; + + if(!resource.isNull()) { + // Set matching height, width is adjusted automaticly. + resource.setHeight(DEFAULT_THUMBNAIL_HEIGHT); + QPixmap dest = QPixmap(DEFAULT_THUMBNAIL_WIDTH, DEFAULT_THUMBNAIL_HEIGHT); - - // Scale the icon into the thumbnail area. - QPixmap source = icon.pixmap(); - // Smooth scaling is very expensive (size^2). Therefore we reduce the size - // to 2x of the destination size and using fast transformation before doing final smooth scaling. - if(source.size().width() > (6*dest.width()) || source.size().height() > (6*dest.height())) - { - QSize intermediate_size = QSize( dest.width() * 2, dest.height() * 2 ); - source = source.scaled(intermediate_size, Qt::KeepAspectRatio, Qt::FastTransformation ); - } - QPixmap scaled = source.scaled(dest.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); - - // Center the icon. - int xDiff = 0; - int yDiff = 0; - if(dest.width() > scaled.width()) - { - xDiff = (dest.width() - scaled.width()) / 2; - } - if(dest.height() > scaled.height()) - { - yDiff = (dest.height() - scaled.height()) / 2; - } - // Paint it. QPainter painter(&dest); painter.setCompositionMode(QPainter::CompositionMode_Source); - painter.fillRect(dest.rect(), Qt::transparent); - painter.drawPixmap(xDiff, yDiff, scaled.width(), scaled.height(), scaled); + painter.fillRect(dest.rect(), Qt::transparent); + resource.paint(&painter, dest.rect()); painter.end(); - return HbIcon(dest); + icon = new QIcon(dest); } - else - { - return HbIcon(); - } + + return icon; } // ----------------------------------------------------------------------------- @@ -590,6 +570,13 @@ // Clear data. mReadyThumbnailMediaIds.clear(); mThumbnailData.clear(); + + QHash::const_iterator iter = mDefaultThumbnails.constBegin(); + while(iter != mDefaultThumbnails.constEnd()) + { + delete *iter; + iter++; + } mDefaultThumbnails.clear(); } @@ -597,7 +584,7 @@ // VideoThumbnailDataPrivate::startBackgroundFetching() // ----------------------------------------------------------------------------- // -void VideoThumbnailDataPrivate::startBackgroundFetching(VideoSortFilterProxyModel *model, int fetchIndex) +void VideoThumbnailDataPrivate::startBackgroundFetching(VideoProxyModelGeneric *model, int fetchIndex) { FUNC_LOG; diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/src/videothumbnailfetcher.cpp --- a/videocollection/videocollectionwrapper/src/videothumbnailfetcher.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/src/videothumbnailfetcher.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 6 % +// Version : %version: 6.1.1 % // INCLUDE FILES #include @@ -47,7 +47,7 @@ { FUNC_LOG; mThumbnailManager = new ThumbnailManager(); - mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailMedium); + mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailSmall); mThumbnailManager->setQualityPreference(ThumbnailManager::OptimizeForPerformance); mThumbnailManager->setMode(ThumbnailManager::CropToAspectRatio); diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/src/testvideocollectionwrapper_p.cpp --- a/videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/src/testvideocollectionwrapper_p.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/src/testvideocollectionwrapper_p.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -18,13 +18,14 @@ // INCLUDES +#include #include #include #include "testvideocollectionwrapper_p.h" #include "videocollectionwrapper.h" #include "videocollectioncommon.h" #include "videolistdatamodel.h" -#include "videosortfilterproxymodel.h" +#include "videoproxymodelgeneric.h" #include "videocollectionclient.h" #include "vcxmyvideosdefs.h" @@ -86,37 +87,23 @@ { QVERIFY(mTestObject); - VideoSortFilterProxyModel *proxyGotten = 0; - - // source model init fails + VideoProxyModelGeneric *proxyGotten = 0; + VideoListDataModel::mInitFails = true; - VideoCollectionCommon::TModelType type = VideoCollectionCommon::EModelTypeAllVideos; - proxyGotten = mTestObject->getModel(type); - QVERIFY(!proxyGotten); + // Test source model init fails - VideoListDataModel::mInitFails = false; - VideoSortFilterProxyModel::setInitFailure(true); - - // VideoCollectionWrapper::EAllvideos -> init fails - type = VideoCollectionCommon::EModelTypeAllVideos; - proxyGotten = mTestObject->getModel(type); + proxyGotten = mTestObject->getGenericModel(); QVERIFY(!proxyGotten); - // VideoCollectionWrapper::ECollections -> init fails - type = VideoCollectionCommon::EModelTypeAllVideos; - proxyGotten = mTestObject->getModel(type); + proxyGotten = mTestObject->getAllVideosModel(); QVERIFY(!proxyGotten); - // VideoCollectionWrapper::EGeneric -> init fails - type = VideoCollectionCommon::EModelTypeGeneric; - proxyGotten = mTestObject->getModel(type); + proxyGotten = mTestObject->getCollectionsModel(); QVERIFY(!proxyGotten); - type = VideoCollectionCommon::EModelTypeCollectionContent; - proxyGotten = mTestObject->getModel(type); + proxyGotten = mTestObject->getCollectionContentModel(); QVERIFY(!proxyGotten); } - // ----------------------------------------------------------------------------- // testGetModelSucceed @@ -125,52 +112,54 @@ void TestVideCollectionWrapper_p::testGetModelSucceed() { QVERIFY(mTestObject); - - VideoSortFilterProxyModel *proxyGotten = 0; - VideoSortFilterProxyModel::setInitFailure(false); - VideoCollectionCommon::TModelType type = VideoCollectionCommon::EModelTypeAllVideos; + + VideoListDataModel::mInitFails = false; + + VideoProxyModelGeneric *proxyGotten = 0; + VideoProxyModelGeneric *proxyGotten2 = 0; - // VideoCollectionWrapper::EAllvideos - type = VideoCollectionCommon::EModelTypeAllVideos; - proxyGotten = mTestObject->getModel(type); + proxyGotten = mTestObject->getAllVideosModel(); QVERIFY(proxyGotten); - QVERIFY(proxyGotten->mType == type); - proxyGotten = mTestObject->getModel(type); - QVERIFY(proxyGotten); - QVERIFY(proxyGotten->mType == type); + + QString name = proxyGotten->metaObject()->className(); + QString expectedName = QString("VideoProxyModelAllVideos"); + QVERIFY(name == expectedName); + // again + proxyGotten2 = mTestObject->getAllVideosModel(); + QCOMPARE(proxyGotten, proxyGotten2); delete proxyGotten; proxyGotten = 0; - - // VideoCollectionWrapper::ECollections - type = VideoCollectionCommon::EModelTypeCollections; - proxyGotten = mTestObject->getModel(type); - QVERIFY(proxyGotten); - QVERIFY(proxyGotten->mType == type); - proxyGotten = mTestObject->getModel(type); + + proxyGotten = mTestObject->getCollectionsModel(); QVERIFY(proxyGotten); - QVERIFY(proxyGotten->mType == type); - delete proxyGotten; - proxyGotten = 0; - - // VideoCollectionWrapper::EGeneric - type = VideoCollectionCommon::EModelTypeGeneric; - proxyGotten = mTestObject->getModel(type); - QVERIFY(proxyGotten); - QVERIFY(proxyGotten->mType == type); - proxyGotten = mTestObject->getModel(type); - QVERIFY(proxyGotten); - QVERIFY(proxyGotten->mType == type); + name = proxyGotten->metaObject()->className(); + expectedName = QString("VideoProxyModelCollections"); + QVERIFY(name == expectedName); + // again + proxyGotten2 = mTestObject->getCollectionsModel(); + QCOMPARE(proxyGotten, proxyGotten2); delete proxyGotten; proxyGotten = 0; - // VideoCollectionWrapper::ECollectionContent - type = VideoCollectionCommon::EModelTypeCollectionContent; - proxyGotten = mTestObject->getModel(type); + proxyGotten = mTestObject->getCollectionContentModel(); QVERIFY(proxyGotten); - QVERIFY(proxyGotten->mType == type); - proxyGotten = mTestObject->getModel(type); + name = proxyGotten->metaObject()->className(); + expectedName = QString("VideoProxyModelContent"); + QVERIFY(name == expectedName); + // again + proxyGotten2 = mTestObject->getCollectionContentModel(); + QCOMPARE(proxyGotten, proxyGotten2); + delete proxyGotten; + proxyGotten = 0; + + proxyGotten = mTestObject->getGenericModel(); QVERIFY(proxyGotten); - QVERIFY(proxyGotten->mType == type); + name = proxyGotten->metaObject()->className(); + expectedName = QString("VideoProxyModelGeneric"); + QVERIFY(name == expectedName); + // again + proxyGotten2 = mTestObject->getGenericModel(); + QCOMPARE(proxyGotten, proxyGotten2); delete proxyGotten; proxyGotten = 0; } @@ -184,22 +173,24 @@ QVERIFY(mTestObject); connect(this, SIGNAL(testSignal()), mTestObject, SLOT(aboutToQuitSlot())); - VideoSortFilterProxyModel *proxyGotten = 0; - VideoSortFilterProxyModel::setInitFailure(false); - VideoCollectionCommon::TModelType type = VideoCollectionCommon::EModelTypeAllVideos; - proxyGotten = mTestObject->getModel(type); + VideoProxyModelGeneric *proxyGotten = 0; + proxyGotten = mTestObject->getAllVideosModel(); QVERIFY(proxyGotten); QVERIFY(!mTestObject->mSourceModel.isNull()); - emit testSignal(); - QVERIFY(mTestObject->mSourceModel.isNull()); emit testSignal(); QVERIFY(mTestObject->mSourceModel.isNull()); + proxyGotten = mTestObject->getAllVideosModel(); + QVERIFY(!proxyGotten); + emit testSignal(); + QVERIFY(mTestObject->mSourceModel.isNull()); + proxyGotten = mTestObject->getAllVideosModel(); + QVERIFY(!proxyGotten); + disconnect(this, SIGNAL(testSignal()), mTestObject, SLOT(aboutToQuitSlot())); } - // End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/stub/inc/videocollectionwrapper.h --- a/videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/stub/inc/videocollectionwrapper.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/stub/inc/videocollectionwrapper.h Fri Sep 17 08:30:05 2010 +0300 @@ -24,12 +24,5 @@ public: // Constructor - enum TModelType - { - EAllVideos, - ECollections, - EGeneric, - ECollectionContent - }; }; #endif // __VIDEOCOLLECTIONWRAPPER_H__ diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/stub/inc/videoproxymodelallvideos.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/stub/inc/videoproxymodelallvideos.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: stub VideoProxyModelAllVideos for VideoCollectionWrapperPrivate unit tests +* +*/ + +#ifndef VIDEOPROXYMODELALLVIDEOS_H +#define VIDEOPROXYMODELALLVIDEOS_H + +#include + +class VideoProxyModelAllVideos : public VideoProxyModelGeneric +{ + Q_OBJECT + +signals: + + void shortDetailsReady(TMPXItemId); + +public: + + /** + * Contructor. + * + * @param parent parent of this widget + */ + VideoProxyModelAllVideos(QObject *parent=0); + + /** + * Destructor. + * + */ + virtual ~VideoProxyModelAllVideos(); + +public: + + static int mAllVideosModelConstructCallCount; +}; + +#endif // VIDEOPROXYMODELALLVIDEOS_H diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/stub/inc/videoproxymodelcollections.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/stub/inc/videoproxymodelcollections.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: stub VideoProxyModelCollections for VideoCollectionWrapperPrivate unit tests +* +*/ + +#ifndef VIDEOPROXYMODELCOLLETIONS_H +#define VIDEOPROXYMODELCOLLETIONS_H + +#include + +class VideoProxyModelCollections : public VideoProxyModelGeneric +{ + Q_OBJECT + +signals: + + void shortDetailsReady(TMPXItemId); + +public: + + /** + * Contructor. + * + * @param parent parent of this widget + */ + VideoProxyModelCollections(QObject *parent=0); + + /** + * Destructor. + * + */ + virtual ~VideoProxyModelCollections(); + +public: + + static int mCollectionsModelConstructCallCount; +}; + +#endif // VIDEOPROXYMODELCOLLETIONS_H diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/stub/inc/videoproxymodelcontent.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/stub/inc/videoproxymodelcontent.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: stub VideoProxyModelContent for VideoCollectionWrapperPrivate unit tests +* +*/ + +#ifndef VIDEOPROXYMODELCONTENT_H +#define VIDEOPROXYMODELCONTENT_H + +#include + +class VideoProxyModelContent : public VideoProxyModelGeneric +{ + Q_OBJECT + +signals: + + void shortDetailsReady(TMPXItemId); + +public: + + /** + * Contructor. + * + * @param parent parent of this widget + * @param client Collection client pointer to use. + */ + VideoProxyModelContent(QObject *parent=0); + + /** + * Destructor. + * + */ + virtual ~VideoProxyModelContent(); + +public: + + static int mContentModelConstructCallCount; +}; + +#endif // VIDEOPROXYMODELCONTENT_H diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/stub/inc/videoproxymodelgeneric.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/stub/inc/videoproxymodelgeneric.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: stub VideoProxyModelGeneric for VideoCollectionWrapperPrivate unit tests +* +*/ + +#ifndef VIDEOPROXYMODELGENERIC_H +#define VIDEOPROXYMODELGENERIC_H + +#include +#include + +class QTimer; +class VideoListDataModel; +class VideoCollectionClient; + +class VideoProxyModelGeneric : public QObject +{ + Q_OBJECT + +signals: + + void shortDetailsReady(TMPXItemId); + +public: + + /** + * Contructor. + * + * @param parent parent of this widget + */ + VideoProxyModelGeneric(QObject *parent=0); + + /** + * Destructor. + * + */ + virtual ~VideoProxyModelGeneric(); + + /** + * Initialize. + */ + int initialize(VideoListDataModel *sourceModel); + +public: + + /** + * Pointer to the actual model. + * Not owned. + */ + VideoListDataModel *mModel; + + static int mGenericModelConstructCallCount; +}; + +#endif // VIDEOPROXYMODELGENERIC_H diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/stub/inc/videosortfilterproxymodel.h --- a/videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/stub/inc/videosortfilterproxymodel.h Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: stub Videosortfilterproxymodel for VideoCollectionWrapperPrivate unit tests -* -*/ - -#ifndef VIDEOSORTFILTERPROXYMODEL_H -#define VIDEOSORTFILTERPROXYMODEL_H - -#include -#include - -class QTimer; -class VideoListDataModel; -class VideoCollectionClient; - -class VideoSortFilterProxyModel : public QObject -{ - Q_OBJECT - -signals: - - void shortDetailsReady(TMPXItemId); - -public: - - /** - * Contructor. - * - * @param parent parent of this widget - * @param client Collection client pointer to use. - */ - VideoSortFilterProxyModel( int type, QObject *parent=0); - - /** - * Destructor. - * - */ - virtual ~VideoSortFilterProxyModel(); - - /** - * Initializes model, calls initialize to source model, and sets - * the given sourceModel as source model for this proxy model. - * - * @param collection mpx video collectionobject - * @param sourceModel the source model - * - * @return int: 0 if everything ok - */ - int initialize(VideoListDataModel *sourceModel); - -public: - - - /** - * sets gInitFails - * - * @param bool - */ - static void setInitFailure(bool fails); - - - /** - * Pointer to the actual model. - * Not owned. - */ - VideoListDataModel *mModel; - - /** - * type - */ - int mType; - -}; - - - -#endif //VIDEOSORTFILTERPROXYMODEL_H diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/stub/src/videoproxymodelallvideos.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/stub/src/videoproxymodelallvideos.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: stub VideoProxyModelGeneric for VideoCollectionWrapperPrivate unit tests +* +*/ + +#include +#include +#include + +#include "videocollectioncommon.h" +#include "videoproxymodelallvideos.h" +#include "videolistdatamodel.h" +#include "videocollectionclient.h" + +int VideoProxyModelAllVideos::mAllVideosModelConstructCallCount = 0; + +// ----------------------------------------------------------------------------- +// VideoProxyModelAllVideos::VideoProxyModelAllVideos +// ----------------------------------------------------------------------------- +// +VideoProxyModelAllVideos::VideoProxyModelAllVideos(QObject *parent) : +VideoProxyModelGeneric(parent) +{ +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelAllVideos::~VideoProxyModelAllVideos +// ----------------------------------------------------------------------------- +// +VideoProxyModelAllVideos::~VideoProxyModelAllVideos() +{ +} + +// end of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/stub/src/videoproxymodelcollections.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/stub/src/videoproxymodelcollections.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: stub VideoProxyModelGeneric for VideoCollectionWrapperPrivate unit tests +* +*/ + +#include +#include +#include + +#include "videocollectioncommon.h" +#include "videoproxymodelcollections.h" +#include "videolistdatamodel.h" +#include "videocollectionclient.h" + +int VideoProxyModelCollections::mCollectionsModelConstructCallCount = 0; + +// ----------------------------------------------------------------------------- +// VideoProxyModelCollections::VideoProxyModelCollections +// ----------------------------------------------------------------------------- +// +VideoProxyModelCollections::VideoProxyModelCollections(QObject *parent) : +VideoProxyModelGeneric(parent) +{ +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelCollections::~VideoProxyModelCollections +// ----------------------------------------------------------------------------- +// +VideoProxyModelCollections::~VideoProxyModelCollections() +{ +} + +// end of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/stub/src/videoproxymodelcontent.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/stub/src/videoproxymodelcontent.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: stub VideoProxyModelGeneric for VideoCollectionWrapperPrivate unit tests +* +*/ + +#include +#include +#include + +#include "videocollectioncommon.h" +#include "videoproxymodelcontent.h" +#include "videolistdatamodel.h" +#include "videocollectionclient.h" + +int VideoProxyModelContent::mContentModelConstructCallCount = 0; + +// ----------------------------------------------------------------------------- +// VideoProxyModelContent::VideoProxyModelContent +// ----------------------------------------------------------------------------- +// +VideoProxyModelContent::VideoProxyModelContent(QObject *parent) : +VideoProxyModelGeneric(parent) +{ +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelContent::~VideoProxyModelContent +// ----------------------------------------------------------------------------- +// +VideoProxyModelContent::~VideoProxyModelContent() +{ +} + +// end of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/stub/src/videoproxymodelgeneric.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/stub/src/videoproxymodelgeneric.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: stub VideoProxyModelGeneric for VideoCollectionWrapperPrivate unit tests +* +*/ + +#include +#include +#include + +#include "videocollectioncommon.h" +#include "videoproxymodelgeneric.h" +#include "videolistdatamodel.h" +#include "videocollectionclient.h" + +int VideoProxyModelGeneric::mGenericModelConstructCallCount = 0; + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::VideoProxyModelGeneric +// ----------------------------------------------------------------------------- +// +VideoProxyModelGeneric::VideoProxyModelGeneric(QObject *parent) : +QObject(parent), +mModel(0) +{ +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::~VideoProxyModelGeneric +// ----------------------------------------------------------------------------- +// +VideoProxyModelGeneric::~VideoProxyModelGeneric() +{ +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::initialize +// ----------------------------------------------------------------------------- +// +int VideoProxyModelGeneric::initialize(VideoListDataModel *sourceModel) +{ + mModel = sourceModel; + return 0; +} + +// end of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/stub/src/videosortfilterproxymodel.cpp --- a/videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/stub/src/videosortfilterproxymodel.cpp Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: stub Videosortfilterproxymodel for VideoCollectionWrapperPrivate unit tests -* -*/ - -#include -#include -#include - -#include "videocollectioncommon.h" -#include "videosortfilterproxymodel.h" -#include "videolistdatamodel.h" -#include "videocollectionclient.h" - -bool gInitFails = false; - -bool gFetchMediaIDFails = false; - -bool gFailDeleteFile = false; - -// ----------------------------------------------------------------------------- -// setInitFailure -// ----------------------------------------------------------------------------- -// -void VideoSortFilterProxyModel::setInitFailure(bool fails) -{ - gInitFails = fails; -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::VideoSortFilterProxyModel -// ----------------------------------------------------------------------------- -// -VideoSortFilterProxyModel::VideoSortFilterProxyModel(int type, QObject *parent) : - QObject(parent), - mModel(0), - mType(type) -{ -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::~VideoSortFilterProxyModel -// ----------------------------------------------------------------------------- -// -VideoSortFilterProxyModel::~VideoSortFilterProxyModel() -{ -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::initialize -// ----------------------------------------------------------------------------- -// -int VideoSortFilterProxyModel::initialize(VideoListDataModel *sourceModel) -{ - mModel = sourceModel; - return gInitFails ? -1 : 0; -} -// end of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/testvideocollectionwrapper_p.pro --- a/videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/testvideocollectionwrapper_p.pro Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/tsrc/testvideocollectionwrapper_p/testvideocollectionwrapper_p.pro Fri Sep 17 08:30:05 2010 +0300 @@ -25,12 +25,18 @@ # Input HEADERS += inc/testvideocollectionwrapper_p.h \ - stub/inc/videosortfilterproxymodel.h \ + stub/inc/videoproxymodelgeneric.h \ + stub/inc/videoproxymodelallvideos.h \ + stub/inc/videoproxymodelcollections.h \ + stub/inc/videoproxymodelcontent.h \ stub/inc/videolistdatamodel.h \ stub/inc/videocollectionwrapper.h \ ../../inc/videocollectionwrapper_p.h SOURCES += src/testvideocollectionwrapper_p.cpp \ - stub/src/videosortfilterproxymodel.cpp \ + stub/src/videoproxymodelgeneric.cpp \ + stub/src/videoproxymodelallvideos.cpp \ + stub/src/videoproxymodelcollections.cpp \ + stub/src/videoproxymodelcontent.cpp \ stub/src/videolistdatamodel.cpp \ ../../src/videocollectionwrapper_p.cpp diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelallvideos/inc/testvideoproxymodelallvideos.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelallvideos/inc/testvideoproxymodelallvideos.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,75 @@ +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: tester for methods in VideoProxyModelAllVideos +* +*/ + +#ifndef __TESTVIDEOPROXYMODELALLVIDEOS_H__ +#define __TESTVIDEOPROXYMODELALLVIDEOS_H__ + + +// INCLUDES +#include +#include + +class FilterProxyTester; + +class TestVideoProxyModelAllVideos : public QObject +{ + Q_OBJECT + + // test functions for the test framework + +signals: + +private slots: + + /** + * will be called before each testfunction is executed. + * + */ + void init(); + + /** + * will be called after every testfunction. + * + */ + void cleanup(); + + /** + * Tests filterAcceptsRow. + */ + void testFilterAcceptsRow(); + + /** + * Tests getOpenItem. + */ + void testGetOpenItem(); + +private: + + /** + * tester object inherited from the actual test object + * implemented to be able to call protected objects + */ + FilterProxyTester *mTestObject; + +}; + +#endif // __TESTVIDEOPROXYMODELALLVIDEOS_H__ + +// End of file + + + diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelallvideos/src/testvideoproxymodelallvideos.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelallvideos/src/testvideoproxymodelallvideos.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,156 @@ +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: tester for methods in VideoProxyModelAllVideos +* +*/ + +#include +#include +#include + +#include +#include "videoproxymodelgeneric.h" + +#define private public +#include "videoproxymodelallvideos.h" +#undef private + +#include "videolistdatamodel.h" +#include "filterproxytester.h" +#include "videocollectioncommon.h" +#include "testvideoproxymodelallvideos.h" + +// --------------------------------------------------------------------------- +// main +// --------------------------------------------------------------------------- +// +int main(int argc, char *argv[]) +{ + HbApplication app(argc, argv); + + TestVideoProxyModelAllVideos tv; + + int res; + if(argc > 1) + { + res = QTest::qExec(&tv, argc, argv); + } + else + { + char *pass[3]; + pass[0] = argv[0]; + pass[1] = "-o"; + pass[2] = "c:\\data\\testVideoProxyModelAllVideos.txt"; + res = QTest::qExec(&tv, 3, pass); + } + + return res; +} + +// --------------------------------------------------------------------------- +// init +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelAllVideos::init() +{ + qRegisterMetaType("TMPXItemId"); + + mTestObject = new FilterProxyTester(); +} + +// --------------------------------------------------------------------------- +// cleanup +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelAllVideos::cleanup() +{ + delete mTestObject; + mTestObject = 0; +} + +// --------------------------------------------------------------------------- +// testFilterAcceptsRow +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelAllVideos::testFilterAcceptsRow() +{ + // No source model + VideoListDataModel *model = 0; + mTestObject->mModel = model; + VideoListDataModel::mMediaIdAtIndexReturnValue = TMPXItemId::InvalidId(); + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mRowCountReturnValue = 0; + QVERIFY(mTestObject->callFilterAcceptsRow(0, QModelIndex()) == false); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 0); + + // Source row < 0 + model = new VideoListDataModel(); + mTestObject->mModel = model; + VideoListDataModel::mMediaIdAtIndexReturnValue = TMPXItemId::InvalidId(); + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mRowCountReturnValue = 0; + QVERIFY(mTestObject->callFilterAcceptsRow(-1, QModelIndex()) == false); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 0); + + // Source row > model row count + VideoListDataModel::mMediaIdAtIndexReturnValue = TMPXItemId::InvalidId(); + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mRowCountReturnValue = 0; + QVERIFY(mTestObject->callFilterAcceptsRow(10, QModelIndex()) == false); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 0); + + // Item id is not video + VideoListDataModel::mMediaIdAtIndexReturnValue = TMPXItemId(0, KVcxMvcMediaTypeAlbum); + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mRowCountReturnValue = 1; + QVERIFY(mTestObject->callFilterAcceptsRow(0, QModelIndex()) == false); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 1); + + // Good case + VideoListDataModel::mMediaIdAtIndexReturnValue = TMPXItemId(0, KVcxMvcMediaTypeVideo); + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mRowCountReturnValue = 1; + QVERIFY(mTestObject->callFilterAcceptsRow(0, QModelIndex()) == true); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 1); +} + +// --------------------------------------------------------------------------- +// testGetOpenItem +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelAllVideos::testGetOpenItem() +{ + TMPXItemId returned = TMPXItemId(1, 1); + + // No model + VideoListDataModel *model = 0; + mTestObject->mModel = model; + returned = mTestObject->getOpenItem(); + QVERIFY(returned == TMPXItemId::InvalidId()); + + // No collection client + model = new VideoListDataModel(); + mTestObject->mModel = model; + mTestObject->mCollectionClient = 0; + returned = mTestObject->getOpenItem(); + QVERIFY(returned == TMPXItemId::InvalidId()); + + // Good case. + mTestObject->mModel = model; + mTestObject->mCollectionClient = 1; + returned = mTestObject->getOpenItem(); + QVERIFY(returned == TMPXItemId(KVcxMvcCategoryIdAll, KVcxMvcMediaTypeCategory)); +} + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelallvideos/stub/inc/filterproxytester.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelallvideos/stub/inc/filterproxytester.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,67 @@ + +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Helper class to test protected members from the proxy model +* +*/ + +#ifndef __FILTERLISTPROXY_TESTER_H +#define __FILTERLISTPROXY_TESTER_H + +#include +#include + +#include "videocollectioncommon.h" + +#include "videoproxymodelgeneric.h" + +#define private public +#include "videoproxymodelallvideos.h" +#undef private + +class FilterProxyTester : public VideoProxyModelAllVideos +{ + + Q_OBJECT + +public: // Constructors and destructor + + /** + * Constructor + * + */ + FilterProxyTester(QObject *parent = 0); + + /** + * destructor + * + */ + virtual ~FilterProxyTester(); + +public: // helper methods for test + + /** + * Helper methor to call protected lessThan. + * + */ + bool callLessThan( const QModelIndex & left, const QModelIndex & right ) const; + + /** + * Helper methor to call protected filterAcceptsRow. + * + */ + bool callFilterAcceptsRow( int source_row, const QModelIndex & source_parent ) const; +}; + +#endif // __FILTERLISTPROXY_TESTER_H diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelallvideos/stub/inc/videolistdatamodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelallvideos/stub/inc/videolistdatamodel.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,66 @@ + +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Stub collection client to be used when unit testing the proxy model. +* +*/ + +#ifndef __STUB_VIDEOLISTDATAMODELFORPROXY_H +#define __STUB_VIDEOLISTDATAMODELFORPROXY_H + +#include +#include +#include +#include +#include "videocollectioncommon.h" + +class VideoListDataModel : public QObject +{ + Q_OBJECT + +public: // Constructors and destructor + + /** + * Constructor + * + */ + VideoListDataModel(QObject *parent = NULL); + + /** + * destructor + * + */ + virtual ~VideoListDataModel(); + + /** + * Stub method. + */ + TMPXItemId mediaIdAtIndex(int index); + + /** + * Stub method. + */ + const int rowCount() const; + +public: + + static TMPXItemId mMediaIdAtIndexReturnValue; + static int mMediaIdAtIndexCallCount; + static int mRowCountReturnValue; + +}; + +#endif // __STUB_VIDEOLISTDATAMODELFORPROXY_H + + diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelallvideos/stub/inc/videoproxymodelgeneric.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelallvideos/stub/inc/videoproxymodelgeneric.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,129 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: stub VideoProxyModelGeneric class definition +* +*/ + +#ifndef VIDEOPROXYMODELGENERIC_H +#define VIDEOPROXYMODELGENERIC_H + +// INCLUDES +#include +#include +#include + +class VideoListDataModel; + +// CLASS DECLARATION +class VideoProxyModelGeneric : public QObject +{ + Q_OBJECT + +public: + + /** + * Contructor. + * + * @param QObject parent object. + */ + VideoProxyModelGeneric(QObject *parent = 0); + + /** + * Destructor. + * + */ + virtual ~VideoProxyModelGeneric(); + +public: + + /** + * Opens the defined item. This is quite abstract as depending + * on the type of the item, the behaviour or result could be + * quite different. + * + * @param item id id of the item to be opened + * @return int 0 succeeds, <0 if opening does not succeed. + */ + virtual int openItem(TMPXItemId mediaId); + + /** + * Gets the currently opened item. + * + * @param None. + * @return TMPXItemId. + */ + virtual TMPXItemId getOpenItem() const; + + /** + * Compares items based in the role setted before sorting. From QSortFilterProxyModel. + * + */ + virtual bool lessThan(const QModelIndex & left, const QModelIndex & right) const; + + /** + * Filtering functionality. Called by the FW. From QSortFilterProxyModel. + * + * @param source_row row to check + * @param source_parent row's parent + * + * @return bool row accepted(true) or not accepted(false) + */ + virtual bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const; + + /** + * Connects all signals emitted from or throught this object. + * + * @return bool + */ + virtual bool connectSignals(); + + /** + * Disconnects all signals. + */ + void disconnectSignals(); + + /** + * Does actual sorting and emits sortingReady. + * + */ + virtual void processSorting(); + + /** + * Returns sourceModel; + */ + virtual const VideoListDataModel *sourceModel() const; + +public: + static int mOpenItemCallCount; + static int mGetOpenItemCallCount; + static int mLessThanCallCount; + static int mFilterAcceptsRowCallCount; + static int mConnectSignalsCallCount; + static int mDisconnectSignalsCallCount; + static int mProcessSortingCallCount; + +public: + + /** + * Pointer to the actual model. + */ + VideoListDataModel *mModel; + + /** + * Collection client. + */ + int mCollectionClient; +}; + +#endif // VIDEOPROXYMODELGENERIC_H diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelallvideos/stub/src/filterproxytester.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelallvideos/stub/src/filterproxytester.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,62 @@ + +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Helper class to test protected members from the proxy model +* +*/ + +// INCLUDES + +#include "filterproxytester.h" + +// --------------------------------------------------------------------------- +// FilterProxyTester +// --------------------------------------------------------------------------- +// +FilterProxyTester::FilterProxyTester(QObject *parent) : +VideoProxyModelAllVideos(parent) +{ + // NOP +} + +// --------------------------------------------------------------------------- +// ~FilterProxyTester +// --------------------------------------------------------------------------- +// +FilterProxyTester::~FilterProxyTester() +{ + +} + +// --------------------------------------------------------------------------- +// callLessThan +// --------------------------------------------------------------------------- +// +bool FilterProxyTester::callLessThan( const QModelIndex & left, const QModelIndex & right ) const +{ + return VideoProxyModelAllVideos::lessThan(left, right); +} + + +// --------------------------------------------------------------------------- +// callLessThan +// --------------------------------------------------------------------------- +// +bool FilterProxyTester::callFilterAcceptsRow( int source_row, const QModelIndex & source_parent ) const +{ + return VideoProxyModelAllVideos::filterAcceptsRow(source_row, source_parent); +} + + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelallvideos/stub/src/videolistdatamodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelallvideos/stub/src/videolistdatamodel.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,68 @@ +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Stub model to be used when unit testing the proxy model. +* +*/ + + +// INCLUDES +#include "videolistdatamodel.h" + +TMPXItemId VideoListDataModel::mMediaIdAtIndexReturnValue; +int VideoListDataModel::mMediaIdAtIndexCallCount = 0; +int VideoListDataModel::mRowCountReturnValue = 0; + +// --------------------------------------------------------------------------- +// VideoListDataModel +// --------------------------------------------------------------------------- +// +VideoListDataModel::VideoListDataModel(QObject *parent) +{ + Q_UNUSED(parent); +} + +// --------------------------------------------------------------------------- +// ~VideoListDataModel +// --------------------------------------------------------------------------- +// +VideoListDataModel::~VideoListDataModel() +{ + +} + +// --------------------------------------------------------------------------- +// mediaIdAtIndex +// --------------------------------------------------------------------------- +// +TMPXItemId VideoListDataModel::mediaIdAtIndex(int index) +{ + Q_UNUSED(index); + mMediaIdAtIndexCallCount++; + return mMediaIdAtIndexReturnValue; +} + +// --------------------------------------------------------------------------- +// rowCount +// --------------------------------------------------------------------------- +// +const int VideoListDataModel::rowCount() const +{ + return mRowCountReturnValue; +} + + +// End of file + + + diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelallvideos/stub/src/videoproxymodelgeneric.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelallvideos/stub/src/videoproxymodelgeneric.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,142 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: VideoProxyModelGeneric implementation +* +*/ + +// Version : + +// INCLUDE FILES +#include +#include +#include +#include +#include + +#include "videolistdatamodel.h" +#include "videocollectioncommon.h" +#include "videoproxymodelgeneric.h" + +const TMPXItemId INVALID_ID = TMPXItemId::InvalidId(); + +int VideoProxyModelGeneric::mOpenItemCallCount = 0; +int VideoProxyModelGeneric::mGetOpenItemCallCount = 0; +int VideoProxyModelGeneric::mLessThanCallCount = 0; +int VideoProxyModelGeneric::mFilterAcceptsRowCallCount = 0; +int VideoProxyModelGeneric::mConnectSignalsCallCount = 0; +int VideoProxyModelGeneric::mDisconnectSignalsCallCount = 0; +int VideoProxyModelGeneric::mProcessSortingCallCount = 0; + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::VideoProxyModelGeneric +// ----------------------------------------------------------------------------- +// +VideoProxyModelGeneric::VideoProxyModelGeneric(QObject *parent) : + mModel(0), + mCollectionClient(0) +{ + Q_UNUSED(parent); +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::~VideoProxyModelGeneric +// ----------------------------------------------------------------------------- +// +VideoProxyModelGeneric::~VideoProxyModelGeneric() +{ + delete mModel; + mModel = 0; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::openItem +// ----------------------------------------------------------------------------- +// +int VideoProxyModelGeneric::openItem(TMPXItemId mediaId) +{ + Q_UNUSED(mediaId); + mOpenItemCallCount++; + return -1; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::getOpenItem() +// ----------------------------------------------------------------------------- +// +TMPXItemId VideoProxyModelGeneric::getOpenItem() const +{ + mGetOpenItemCallCount++; + TMPXItemId itemId = TMPXItemId::InvalidId(); + return itemId; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::lessThan +// ----------------------------------------------------------------------------- +// +bool VideoProxyModelGeneric::lessThan(const QModelIndex &left, + const QModelIndex &right) const +{ + Q_UNUSED(left); + Q_UNUSED(right); + mLessThanCallCount++; + return false; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::filterAcceptsRow +// ----------------------------------------------------------------------------- +// +bool VideoProxyModelGeneric::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const +{ + Q_UNUSED(source_row); + Q_UNUSED(source_parent); + mFilterAcceptsRowCallCount++; + return false; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::connectSignals +// ----------------------------------------------------------------------------- +// +bool VideoProxyModelGeneric::connectSignals() +{ + mConnectSignalsCallCount++; + return true; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::disconnectSignals +// ----------------------------------------------------------------------------- +// +void VideoProxyModelGeneric::disconnectSignals() +{ + mDisconnectSignalsCallCount++; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::processSorting +// ----------------------------------------------------------------------------- +// +void VideoProxyModelGeneric::processSorting() +{ + mProcessSortingCallCount++; +} + +const VideoListDataModel *VideoProxyModelGeneric::sourceModel() const +{ + return mModel; +} + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelallvideos/testvideoproxymodelallvideos.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelallvideos/testvideoproxymodelallvideos.pro Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,41 @@ +TEMPLATE = app +TARGET = +DEFINES += BUILD_VIDEOCOLLECTION_DLL + +DEPENDPATH += . \ + inc \ + src \ + stub/inc \ + stub/src + +INCLUDEPATH += . \ + stub/inc \ + /epoc32/include/domain \ + /epoc32/include/domain/middleware \ + /epoc32/include/domain/applications \ + /epoc32/include/osextensions \ + /epoc32/include/middleware \ + /epoc32/include/osextensions/stdapis/stlport \ + ../../../inc + +CONFIG += qtestlib \ + Hb \ + symbian_test + +LIBS += -lestor.dll \ + -lfbscli.dll \ + -lbitgdi.dll \ + -lgdi.dll + +# Input +HEADERS += inc/testvideoproxymodelallvideos.h \ + stub/inc/filterproxytester.h \ + stub/inc/videoproxymodelgeneric.h \ + stub/inc/videolistdatamodel.h \ + ../../inc/videoproxymodelallvideos.h + +SOURCES += src/testvideoproxymodelallvideos.cpp \ + stub/src/filterproxytester.cpp \ + stub/src/videoproxymodelgeneric.cpp \ + stub/src/videolistdatamodel.cpp \ + ../../src/videoproxymodelallvideos.cpp diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcollections/inc/testvideoproxymodelcollections.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcollections/inc/testvideoproxymodelcollections.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,72 @@ +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: tester for methods in VideoProxyModelCollections +* +*/ + +#ifndef __TESTVIDEOPROXYMODELCOLLETIONS_H__ +#define __TESTVIDEOPROXYMODELCOLLETIONS_H__ + + +// INCLUDES +#include +#include + +class FilterProxyTester; + +class TestVideoProxyModelCollections : public QObject +{ + Q_OBJECT + + // test functions for the test framework + +signals: + +private slots: + + /** + * will be called before each testfunction is executed. + * + */ + void init(); + + /** + * will be called after every testfunction. + * + */ + void cleanup(); + + /** + * Tests lessThan. + */ + void testLessThan(); + + /** + * Tests filterAcceptsRow. + */ + void testFilterAcceptsRow(); + +private: + + /** + * tester object inherited from the actual test object + * implemented to be able to call protected objects + */ + FilterProxyTester *mTestObject; + +}; + +#endif // __TESTVIDEOPROXYMODELCOLLETIONS_H__ + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcollections/src/testvideoproxymodelcollections.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcollections/src/testvideoproxymodelcollections.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,248 @@ +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: tester for methods in VideoProxyModelCollections +* +*/ + +#include +#include +#include + +#include +#include "videoproxymodelgeneric.h" +#include "videolistdatamodel.h" + +#define private public +#include "videoproxymodelcollections.h" +#undef private + +#include "filterproxytester.h" +#include "videocollectioncommon.h" +#include "testvideoproxymodelcollections.h" + +// --------------------------------------------------------------------------- +// main +// --------------------------------------------------------------------------- +// +int main(int argc, char *argv[]) +{ + HbApplication app(argc, argv); + + TestVideoProxyModelCollections tv; + + int res; + if(argc > 1) + { + res = QTest::qExec(&tv, argc, argv); + } + else + { + char *pass[3]; + pass[0] = argv[0]; + pass[1] = "-o"; + pass[2] = "c:\\data\\testVideoProxyModelCollections.txt"; + res = QTest::qExec(&tv, 3, pass); + } + + return res; +} + +// --------------------------------------------------------------------------- +// init +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelCollections::init() +{ + qRegisterMetaType("TMPXItemId"); + + mTestObject = new FilterProxyTester(); +} + +// --------------------------------------------------------------------------- +// cleanup +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelCollections::cleanup() +{ + delete mTestObject; + mTestObject = 0; +} + +// --------------------------------------------------------------------------- +// testLessThan +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelCollections::testLessThan() +{ + QModelIndex left; + QModelIndex right; + + // No model. + QVERIFY(mTestObject->callLessThan(left, right) == false); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 0); + + // Set model. + VideoListDataModel *model = 0; + model = new VideoListDataModel(); + mTestObject->mModel = model; + + // Default categories are always first in the following order: + // Recently played (missing currently) + // Captured + // Downloaded + // Podcasts (missing currently) + + // Items are not categories. + VideoProxyModelGeneric::mLessThanCallCount = 0; + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mMediaIdAtIndexReturnValues.append(TMPXItemId(0, KVcxMvcMediaTypeVideo)); + VideoListDataModel::mMediaIdAtIndexReturnValues.append(TMPXItemId(1, KVcxMvcMediaTypeAlbum)); + QVERIFY(mTestObject->callLessThan(left, right) == true); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 2); + QCOMPARE(VideoProxyModelGeneric::mLessThanCallCount, 1); + + // Both are categories, left is captured + VideoProxyModelGeneric::mLessThanCallCount = 0; + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mMediaIdAtIndexReturnValues.append( + TMPXItemId(KVcxMvcCategoryIdCaptured, KVcxMvcMediaTypeCategory)); + VideoListDataModel::mMediaIdAtIndexReturnValues.append( + TMPXItemId(KVcxMvcCategoryIdDownloads, KVcxMvcMediaTypeCategory)); + QVERIFY(mTestObject->callLessThan(left, right) == true); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 2); + QCOMPARE(VideoProxyModelGeneric::mLessThanCallCount, 0); + + // Both are categories, left is downloads, right some other + VideoProxyModelGeneric::mLessThanCallCount = 0; + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mMediaIdAtIndexReturnValues.append( + TMPXItemId(KVcxMvcCategoryIdDownloads, KVcxMvcMediaTypeCategory)); + VideoListDataModel::mMediaIdAtIndexReturnValues.append( + TMPXItemId(KVcxMvcCategoryIdOther, KVcxMvcMediaTypeCategory)); + QVERIFY(mTestObject->callLessThan(left, right) == true); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 2); + QCOMPARE(VideoProxyModelGeneric::mLessThanCallCount, 0); + + // Both are categories, left is downloads, right captured + VideoProxyModelGeneric::mLessThanCallCount = 0; + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mMediaIdAtIndexReturnValues.append( + TMPXItemId(KVcxMvcCategoryIdDownloads, KVcxMvcMediaTypeCategory)); + VideoListDataModel::mMediaIdAtIndexReturnValues.append( + TMPXItemId(KVcxMvcCategoryIdCaptured, KVcxMvcMediaTypeCategory)); + QVERIFY(mTestObject->callLessThan(left, right) == false); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 2); + QCOMPARE(VideoProxyModelGeneric::mLessThanCallCount, 0); + + // Only left is category + VideoProxyModelGeneric::mLessThanCallCount = 0; + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mMediaIdAtIndexReturnValues.append( + TMPXItemId(KVcxMvcCategoryIdDownloads, KVcxMvcMediaTypeCategory)); + VideoListDataModel::mMediaIdAtIndexReturnValues.append( + TMPXItemId(1, KVcxMvcMediaTypeVideo)); + QVERIFY(mTestObject->callLessThan(left, right) == true); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 2); + QCOMPARE(VideoProxyModelGeneric::mLessThanCallCount, 0); + + // Only right is category + VideoProxyModelGeneric::mLessThanCallCount = 0; + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mMediaIdAtIndexReturnValues.append( + TMPXItemId(1, KVcxMvcMediaTypeVideo)); + VideoListDataModel::mMediaIdAtIndexReturnValues.append( + TMPXItemId(KVcxMvcCategoryIdDownloads, KVcxMvcMediaTypeCategory)); + QVERIFY(mTestObject->callLessThan(left, right) == false); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 2); + QCOMPARE(VideoProxyModelGeneric::mLessThanCallCount, 0); + + // Sort order is descending. Both are categories, left is captured. + mTestObject->mWantedSortOrder = Qt::DescendingOrder; + VideoProxyModelGeneric::mLessThanCallCount = 0; + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mMediaIdAtIndexReturnValues.append( + TMPXItemId(KVcxMvcCategoryIdCaptured, KVcxMvcMediaTypeCategory)); + VideoListDataModel::mMediaIdAtIndexReturnValues.append( + TMPXItemId(KVcxMvcCategoryIdDownloads, KVcxMvcMediaTypeCategory)); + QVERIFY(mTestObject->callLessThan(left, right) == false); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 2); + QCOMPARE(VideoProxyModelGeneric::mLessThanCallCount, 0); +} + +// --------------------------------------------------------------------------- +// testFilterAcceptsRow +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelCollections::testFilterAcceptsRow() +{ + // No source model + VideoListDataModel *model = 0; + mTestObject->mModel = model; + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mRowCountReturnValue = 0; + QVERIFY(mTestObject->callFilterAcceptsRow(0, QModelIndex()) == false); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 0); + + // Source row < 0 + model = new VideoListDataModel(); + mTestObject->mModel = model; + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mRowCountReturnValue = 0; + QVERIFY(mTestObject->callFilterAcceptsRow(-1, QModelIndex()) == false); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 0); + + // Source row > model row count + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mRowCountReturnValue = 0; + QVERIFY(mTestObject->callFilterAcceptsRow(10, QModelIndex()) == false); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 0); + + // Current level is not category + mTestObject->mLevel = VideoCollectionCommon::ELevelVideos; + VideoListDataModel::mMediaIdAtIndexReturnValues.clear(); + VideoListDataModel::mMediaIdAtIndexReturnValues.append(TMPXItemId(0, KVcxMvcMediaTypeAlbum)); + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mRowCountReturnValue = 1; + QVERIFY(mTestObject->callFilterAcceptsRow(0, QModelIndex()) == false); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 1); + + // Item id is not an album + mTestObject->mLevel = VideoCollectionCommon::ELevelCategory; + VideoListDataModel::mMediaIdAtIndexReturnValues.clear(); + VideoListDataModel::mMediaIdAtIndexReturnValues.append(TMPXItemId(0, KVcxMvcMediaTypeVideo)); + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mRowCountReturnValue = 1; + QVERIFY(mTestObject->callFilterAcceptsRow(0, QModelIndex()) == false); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 1); + + // Item is album + mTestObject->mLevel = VideoCollectionCommon::ELevelCategory; + VideoListDataModel::mMediaIdAtIndexReturnValues.clear(); + VideoListDataModel::mMediaIdAtIndexReturnValues.append(TMPXItemId(0, KVcxMvcMediaTypeAlbum)); + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mRowCountReturnValue = 1; + QVERIFY(mTestObject->callFilterAcceptsRow(0, QModelIndex()) == true); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 1); + + // Item is category + mTestObject->mLevel = VideoCollectionCommon::ELevelCategory; + VideoListDataModel::mMediaIdAtIndexReturnValues.clear(); + VideoListDataModel::mMediaIdAtIndexReturnValues.append(TMPXItemId(0, KVcxMvcMediaTypeCategory)); + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mRowCountReturnValue = 1; + QVERIFY(mTestObject->callFilterAcceptsRow(0, QModelIndex()) == true); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 1); +} + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcollections/stub/inc/filterproxytester.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcollections/stub/inc/filterproxytester.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,67 @@ + +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Helper class to test protected members from the proxy model +* +*/ + +#ifndef __FILTERLISTPROXY_TESTER_H +#define __FILTERLISTPROXY_TESTER_H + +#include +#include + +#include "videocollectioncommon.h" + +#include "videoproxymodelgeneric.h" + +#define private public +#include "videoproxymodelcollections.h" +#undef private + +class FilterProxyTester : public VideoProxyModelCollections +{ + + Q_OBJECT + +public: // Constructors and destructor + + /** + * Constructor + * + */ + FilterProxyTester(QObject *parent = 0); + + /** + * destructor + * + */ + virtual ~FilterProxyTester(); + +public: // helper methods for test + + /** + * Helper methor to call protected lessThan. + * + */ + bool callLessThan( const QModelIndex & left, const QModelIndex & right ) const; + + /** + * Helper methor to call protected filterAcceptsRow. + * + */ + bool callFilterAcceptsRow( int source_row, const QModelIndex & source_parent ) const; +}; + +#endif // __FILTERLISTPROXY_TESTER_H diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcollections/stub/inc/videolistdatamodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcollections/stub/inc/videolistdatamodel.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,65 @@ + +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Stub collection client to be used when unit testing the proxy model. +* +*/ + +#ifndef __STUB_VIDEOLISTDATAMODELFORPROXY_H +#define __STUB_VIDEOLISTDATAMODELFORPROXY_H + +#include +#include +#include +#include +#include "videocollectioncommon.h" + +class VideoListDataModel : public QObject +{ + Q_OBJECT + +public: // Constructors and destructor + + /** + * Constructor + * + */ + VideoListDataModel(QObject *parent = NULL); + + /** + * destructor + * + */ + virtual ~VideoListDataModel(); + + /** + * Stub method. + */ + TMPXItemId mediaIdAtIndex(int index); + + /** + * Stub method. + */ + const int rowCount() const; + +public: + static QList mMediaIdAtIndexReturnValues; + static int mMediaIdAtIndexCallCount; + static int mRowCountReturnValue; + +}; + +#endif // __STUB_VIDEOLISTDATAMODELFORPROXY_H + + diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcollections/stub/inc/videoproxymodelgeneric.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcollections/stub/inc/videoproxymodelgeneric.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,146 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: stub VideoProxyModelGeneric class definition +* +*/ + +#ifndef VIDEOPROXYMODELGENERIC_H +#define VIDEOPROXYMODELGENERIC_H + +// INCLUDES +#include +#include +#include + +#include "videocollectioncommon.h" + +class VideoListDataModel; + +// CLASS DECLARATION +class VideoProxyModelGeneric : public QObject +{ + Q_OBJECT + +public: + + /** + * Contructor. + * + * @param QObject parent object. + */ + VideoProxyModelGeneric(QObject *parent = 0); + + /** + * Destructor. + * + */ + virtual ~VideoProxyModelGeneric(); + +public: + + /** + * Opens the defined item. This is quite abstract as depending + * on the type of the item, the behaviour or result could be + * quite different. + * + * @param item id id of the item to be opened + * @return int 0 succeeds, <0 if opening does not succeed. + */ + virtual int openItem(TMPXItemId mediaId); + + /** + * Gets the currently opened item. + * + * @param None. + * @return TMPXItemId. + */ + virtual TMPXItemId getOpenItem() const; + + /** + * Compares items based in the role setted before sorting. From QSortFilterProxyModel. + * + */ + virtual bool lessThan(const QModelIndex & left, const QModelIndex & right) const; + + /** + * Filtering functionality. Called by the FW. From QSortFilterProxyModel. + * + * @param source_row row to check + * @param source_parent row's parent + * + * @return bool row accepted(true) or not accepted(false) + */ + virtual bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const; + + /** + * Connects all signals emitted from or throught this object. + * + * @return bool + */ + virtual bool connectSignals(); + + /** + * Disconnects all signals. + */ + void disconnectSignals(); + + /** + * Does actual sorting and emits sortingReady. + * + */ + virtual void processSorting(); + + /** + * Returns sourceModel; + */ + virtual const VideoListDataModel *sourceModel() const; + +public: + static int mOpenItemCallCount; + static int mGetOpenItemCallCount; + static int mLessThanCallCount; + static int mFilterAcceptsRowCallCount; + static int mConnectSignalsCallCount; + static int mDisconnectSignalsCallCount; + static int mProcessSortingCallCount; + +public: + + /** + * Pointer to the actual model. + */ + VideoListDataModel *mModel; + + /** + * Collection client. + */ + int mCollectionClient; + + /** + * Currently open level. + */ + VideoCollectionCommon::TCollectionLevels mLevel; + + /** + * Sort order (ascending or descending). + */ + Qt::SortOrder mWantedSortOrder; + + /* + * Default sort role for the model. + */ + int mDefaultSortRole; +}; + +#endif // VIDEOPROXYMODELGENERIC_H diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcollections/stub/src/filterproxytester.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcollections/stub/src/filterproxytester.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,61 @@ + +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Helper class to test protected members from the proxy model +* +*/ + +// INCLUDES + +#include "filterproxytester.h" + +// --------------------------------------------------------------------------- +// FilterProxyTester +// --------------------------------------------------------------------------- +// +FilterProxyTester::FilterProxyTester(QObject *parent) : +VideoProxyModelCollections(parent) +{ + // NOP +} + +// --------------------------------------------------------------------------- +// ~FilterProxyTester +// --------------------------------------------------------------------------- +// +FilterProxyTester::~FilterProxyTester() +{ + +} + +// --------------------------------------------------------------------------- +// callLessThan +// --------------------------------------------------------------------------- +// +bool FilterProxyTester::callLessThan( const QModelIndex & left, const QModelIndex & right ) const +{ + return VideoProxyModelCollections::lessThan(left, right); +} + + +// --------------------------------------------------------------------------- +// callLessThan +// --------------------------------------------------------------------------- +// +bool FilterProxyTester::callFilterAcceptsRow( int source_row, const QModelIndex & source_parent ) const +{ + return VideoProxyModelCollections::filterAcceptsRow(source_row, source_parent); +} + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcollections/stub/src/videolistdatamodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcollections/stub/src/videolistdatamodel.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,72 @@ +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Stub model to be used when unit testing the proxy model. +* +*/ + + +// INCLUDES +#include "videolistdatamodel.h" + +QList VideoListDataModel::mMediaIdAtIndexReturnValues; +int VideoListDataModel::mMediaIdAtIndexCallCount = 0; +int VideoListDataModel::mRowCountReturnValue = 0; + +// --------------------------------------------------------------------------- +// VideoListDataModel +// --------------------------------------------------------------------------- +// +VideoListDataModel::VideoListDataModel(QObject *parent) +{ + Q_UNUSED(parent); +} + +// --------------------------------------------------------------------------- +// ~VideoListDataModel +// --------------------------------------------------------------------------- +// +VideoListDataModel::~VideoListDataModel() +{ + +} + +// --------------------------------------------------------------------------- +// mediaIdAtIndex +// --------------------------------------------------------------------------- +// +TMPXItemId VideoListDataModel::mediaIdAtIndex(int index) +{ + Q_UNUSED(index); + mMediaIdAtIndexCallCount++; + if(!mMediaIdAtIndexReturnValues.isEmpty()) + { + return mMediaIdAtIndexReturnValues.takeFirst(); + } + TMPXItemId::InvalidId(); +} + +// --------------------------------------------------------------------------- +// rowCount +// --------------------------------------------------------------------------- +// +const int VideoListDataModel::rowCount() const +{ + return mRowCountReturnValue; +} + + +// End of file + + + diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcollections/stub/src/videoproxymodelgeneric.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcollections/stub/src/videoproxymodelgeneric.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,145 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: VideoProxyModelGeneric implementation +* +*/ + +// Version : + +// INCLUDE FILES +#include +#include +#include +#include +#include + +#include "videolistdatamodel.h" +#include "videocollectioncommon.h" +#include "videoproxymodelgeneric.h" + +const TMPXItemId INVALID_ID = TMPXItemId::InvalidId(); + +int VideoProxyModelGeneric::mOpenItemCallCount = 0; +int VideoProxyModelGeneric::mGetOpenItemCallCount = 0; +int VideoProxyModelGeneric::mLessThanCallCount = 0; +int VideoProxyModelGeneric::mFilterAcceptsRowCallCount = 0; +int VideoProxyModelGeneric::mConnectSignalsCallCount = 0; +int VideoProxyModelGeneric::mDisconnectSignalsCallCount = 0; +int VideoProxyModelGeneric::mProcessSortingCallCount = 0; + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::VideoProxyModelGeneric +// ----------------------------------------------------------------------------- +// +VideoProxyModelGeneric::VideoProxyModelGeneric(QObject *parent) : + mModel(0), + mCollectionClient(0), + mLevel(VideoCollectionCommon::ELevelInvalid), + mWantedSortOrder(Qt::AscendingOrder), + mDefaultSortRole(0) +{ + Q_UNUSED(parent); +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::~VideoProxyModelGeneric +// ----------------------------------------------------------------------------- +// +VideoProxyModelGeneric::~VideoProxyModelGeneric() +{ + delete mModel; + mModel = 0; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::openItem +// ----------------------------------------------------------------------------- +// +int VideoProxyModelGeneric::openItem(TMPXItemId mediaId) +{ + Q_UNUSED(mediaId); + mOpenItemCallCount++; + return -1; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::getOpenItem() +// ----------------------------------------------------------------------------- +// +TMPXItemId VideoProxyModelGeneric::getOpenItem() const +{ + mGetOpenItemCallCount++; + TMPXItemId itemId = TMPXItemId::InvalidId(); + return itemId; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::lessThan +// ----------------------------------------------------------------------------- +// +bool VideoProxyModelGeneric::lessThan(const QModelIndex &left, + const QModelIndex &right) const +{ + Q_UNUSED(left); + Q_UNUSED(right); + mLessThanCallCount++; + return true; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::filterAcceptsRow +// ----------------------------------------------------------------------------- +// +bool VideoProxyModelGeneric::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const +{ + Q_UNUSED(source_row); + Q_UNUSED(source_parent); + mFilterAcceptsRowCallCount++; + return false; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::connectSignals +// ----------------------------------------------------------------------------- +// +bool VideoProxyModelGeneric::connectSignals() +{ + mConnectSignalsCallCount++; + return true; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::disconnectSignals +// ----------------------------------------------------------------------------- +// +void VideoProxyModelGeneric::disconnectSignals() +{ + mDisconnectSignalsCallCount++; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::processSorting +// ----------------------------------------------------------------------------- +// +void VideoProxyModelGeneric::processSorting() +{ + mProcessSortingCallCount++; +} + +const VideoListDataModel *VideoProxyModelGeneric::sourceModel() const +{ + return mModel; +} + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcollections/testvideoproxymodelcollections.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcollections/testvideoproxymodelcollections.pro Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,41 @@ +TEMPLATE = app +TARGET = +DEFINES += BUILD_VIDEOCOLLECTION_DLL + +DEPENDPATH += . \ + inc \ + src \ + stub/inc \ + stub/src + +INCLUDEPATH += . \ + stub/inc \ + /epoc32/include/domain \ + /epoc32/include/domain/middleware \ + /epoc32/include/domain/applications \ + /epoc32/include/osextensions \ + /epoc32/include/middleware \ + /epoc32/include/osextensions/stdapis/stlport \ + ../../../inc + +CONFIG += qtestlib \ + Hb \ + symbian_test + +LIBS += -lestor.dll \ + -lfbscli.dll \ + -lbitgdi.dll \ + -lgdi.dll + +# Input +HEADERS += inc/testvideoproxymodelcollections.h \ + stub/inc/filterproxytester.h \ + stub/inc/videoproxymodelgeneric.h \ + stub/inc/videolistdatamodel.h \ + ../../inc/videoproxymodelcollections.h + +SOURCES += src/testvideoproxymodelcollections.cpp \ + stub/src/filterproxytester.cpp \ + stub/src/videoproxymodelgeneric.cpp \ + stub/src/videolistdatamodel.cpp \ + ../../src/videoproxymodelcollections.cpp diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcontent/inc/testvideoproxymodelcontent.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcontent/inc/testvideoproxymodelcontent.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,87 @@ +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: tester for methods in VideoProxyModelContent +* +*/ + +#ifndef __TESTVIDEOPROXYMODELCONTENT_H__ +#define __TESTVIDEOPROXYMODELCONTENT_H__ + + +// INCLUDES +#include +#include + +class FilterProxyTester; + +class TestVideoProxyModelContent : public QObject +{ + Q_OBJECT + + // test functions for the test framework + +signals: + +private slots: + + /** + * will be called before each testfunction is executed. + * + */ + void init(); + + /** + * will be called after every testfunction. + * + */ + void cleanup(); + + /** + * Tests connectSignals + */ + void testConnectSignals(); + + /** + * Tests disconnectSignals + */ + void testDisconnectSignals(); + + /** + * Tests filterAcceptsRow + */ + void testFilterAcceptsRow(); + + /** + * Tests getOpenItem + */ + void testGetOpenItem(); + + /** + * Tests albumChangedSlot + */ + void testAlbumChangedSlot(); + +private: + + /** + * tester object inherited from the actual test object + * implemented to be able to call protected objects + */ + FilterProxyTester *mTestObject; + +}; + +#endif // __TESTVIDEOPROXYMODELCONTENT_H__ + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcontent/src/testvideoproxymodelcontent.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcontent/src/testvideoproxymodelcontent.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,227 @@ +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: tester for methods in VideoProxyModelContent +* +*/ + +#include +#include +#include + +#include "videoproxymodelgeneric.h" + +#define private public +#include "videoproxymodelcontent.h" +#undef private + +#include "videolistdatamodel.h" +#include "filterproxytester.h" +#include "videocollectioncommon.h" +#include "testvideoproxymodelcontent.h" + +// --------------------------------------------------------------------------- +// main +// --------------------------------------------------------------------------- +// +int main(int argc, char *argv[]) +{ + HbApplication app(argc, argv); + + TestVideoProxyModelContent tv; + + int res; + if(argc > 1) + { + res = QTest::qExec(&tv, argc, argv); + } + else + { + char *pass[3]; + pass[0] = argv[0]; + pass[1] = "-o"; + pass[2] = "c:\\data\\testVideoProxyModelContent.txt"; + res = QTest::qExec(&tv, 3, pass); + } + + return res; +} + +// --------------------------------------------------------------------------- +// init +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelContent::init() +{ + qRegisterMetaType("TMPXItemId"); + + mTestObject = new FilterProxyTester(); +} + +// --------------------------------------------------------------------------- +// cleanup +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelContent::cleanup() +{ + delete mTestObject; + mTestObject = 0; +} + +// --------------------------------------------------------------------------- +// testConnectSignals +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelContent::testConnectSignals() +{ + // Base class connect returns false. + VideoProxyModelGeneric::mConnectSignalsCallCount = 0; + VideoProxyModelGeneric::mConnectSignalsReturnValue = false; + QVERIFY(mTestObject->callConnectSignals() == false); + QCOMPARE(VideoProxyModelGeneric::mConnectSignalsCallCount, 1); + + // No model. + VideoProxyModelGeneric::mConnectSignalsCallCount = 0; + VideoProxyModelGeneric::mConnectSignalsReturnValue = true; + QVERIFY(mTestObject->callConnectSignals() == false); + QCOMPARE(VideoProxyModelGeneric::mConnectSignalsCallCount, 1); + + // Model exists. + VideoProxyModelGeneric::mConnectSignalsCallCount = 0; + VideoProxyModelGeneric::mConnectSignalsReturnValue = true; + VideoListDataModel *model = new VideoListDataModel(); + mTestObject->mModel = model; + QVERIFY(mTestObject->callConnectSignals() == true); + QCOMPARE(VideoProxyModelGeneric::mConnectSignalsCallCount, 1); +} + +// --------------------------------------------------------------------------- +// testDisconnectSignals +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelContent::testDisconnectSignals() +{ + // No model + VideoProxyModelGeneric::mDisconnectSignalsCallCount = 0; + mTestObject->callDisconnectSignals(); + QCOMPARE(VideoProxyModelGeneric::mDisconnectSignalsCallCount, 1); + + // Model exists. + VideoProxyModelGeneric::mDisconnectSignalsCallCount = 0; + VideoListDataModel *model = new VideoListDataModel(); + mTestObject->mModel = model; + mTestObject->callDisconnectSignals(); + QCOMPARE(VideoProxyModelGeneric::mDisconnectSignalsCallCount, 1); +} + +// --------------------------------------------------------------------------- +// testFilterAcceptsRow +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelContent::testFilterAcceptsRow() +{ + // No source model + VideoListDataModel *model = 0; + mTestObject->mModel = model; + VideoListDataModel::mMediaIdAtIndexReturnValue = TMPXItemId::InvalidId(); + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mRowCountReturnValue = 0; + QVERIFY(mTestObject->callFilterAcceptsRow(0, QModelIndex()) == false); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 0); + + // Source row < 0 + model = new VideoListDataModel(); + mTestObject->mModel = model; + VideoListDataModel::mMediaIdAtIndexReturnValue = TMPXItemId::InvalidId(); + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mRowCountReturnValue = 0; + QVERIFY(mTestObject->callFilterAcceptsRow(-1, QModelIndex()) == false); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 0); + + // Source row > model row count + VideoListDataModel::mMediaIdAtIndexReturnValue = TMPXItemId::InvalidId(); + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mRowCountReturnValue = 0; + QVERIFY(mTestObject->callFilterAcceptsRow(10, QModelIndex()) == false); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 0); + + // Doesn't belong to album + VideoListDataModel::mBelongsToAlbumReturnValue = false; + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mRowCountReturnValue = 1; + QVERIFY(mTestObject->callFilterAcceptsRow(0, QModelIndex()) == false); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 1); + + // Good case + VideoListDataModel::mBelongsToAlbumReturnValue = true; + VideoListDataModel::mMediaIdAtIndexCallCount = 0; + VideoListDataModel::mRowCountReturnValue = 1; + QVERIFY(mTestObject->callFilterAcceptsRow(0, QModelIndex()) == true); + QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 1); +} + +// --------------------------------------------------------------------------- +// testGetOpenItem +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelContent::testGetOpenItem() +{ + TMPXItemId returned = TMPXItemId(1, 1); + + // No model + VideoListDataModel::mAlbumInUseReturnValue = TMPXItemId(2, 2); + VideoListDataModel *model = 0; + mTestObject->mModel = model; + returned = mTestObject->getOpenItem(); + QVERIFY(returned == TMPXItemId::InvalidId()); + + // No collection client + returned = TMPXItemId(1, 1); + VideoListDataModel::mAlbumInUseReturnValue = TMPXItemId(2, 2); + model = new VideoListDataModel(); + mTestObject->mModel = model; + mTestObject->mCollectionClient = 0; + returned = mTestObject->getOpenItem(); + QVERIFY(returned == TMPXItemId::InvalidId()); + + // Good case. + returned = TMPXItemId(1, 1); + VideoListDataModel::mAlbumInUseReturnValue = TMPXItemId(2, 2); + mTestObject->mModel = model; + mTestObject->mCollectionClient = 1; + returned = mTestObject->getOpenItem(); + QVERIFY(returned == TMPXItemId(2, 2)); +} + +// --------------------------------------------------------------------------- +// testAlbumChangedSlot +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelContent::testAlbumChangedSlot() +{ + VideoProxyModelGeneric::mLastSortRole = -1; + mTestObject->mWantedSortRole = 5; + mTestObject->mWantedSortOrder = Qt::DescendingOrder; + VideoProxyModelGeneric::mLastSortedOrder = Qt::AscendingOrder; + + VideoListDataModel *model = new VideoListDataModel(); + mTestObject->mModel = model; + mTestObject->callConnectSignals(); + emit model->emitAlbumChanged(); + mTestObject->callDisconnectSignals(); + QCOMPARE(VideoProxyModelGeneric::mInvalidateFilterCallCount, 1); + QVERIFY(VideoProxyModelGeneric::mLastSortedOrder == Qt::DescendingOrder); + QCOMPARE(VideoProxyModelGeneric::mLastSortRole, 5); +} + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcontent/stub/inc/filterproxytester.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcontent/stub/inc/filterproxytester.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,81 @@ + +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Helper class to test protected members from the proxy model +* +*/ + +#ifndef __FILTERLISTPROXY_TESTER_H +#define __FILTERLISTPROXY_TESTER_H + +#include +#include + +#include "videocollectioncommon.h" + +#include "videoproxymodelgeneric.h" + +#define private public +#include "videoproxymodelcontent.h" +#undef private + +class FilterProxyTester : public VideoProxyModelContent +{ + + Q_OBJECT + +public: // Constructors and destructor + + /** + * Constructor + * + */ + FilterProxyTester(QObject *parent = 0); + + /** + * destructor + * + */ + virtual ~FilterProxyTester(); + +public: // helper methods for test + + /** + * Helper methor to call protected lessThan. + * + */ + bool callLessThan( const QModelIndex & left, const QModelIndex & right ) const; + + /** + * Helper methor to call protected filterAcceptsRow. + * + */ + bool callFilterAcceptsRow( int source_row, const QModelIndex & source_parent ) const; + + /** + * Helper methor to call protected connectSignals. + * + */ + bool callConnectSignals(); + + /** + * Helper methor to call protected disconnectSignals. + * + */ + void callDisconnectSignals(); + + +}; + +#endif // __FILTERLISTPROXY_TESTER_H diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcontent/stub/inc/videolistdatamodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcontent/stub/inc/videolistdatamodel.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,87 @@ + +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Stub collection client to be used when unit testing the proxy model. +* +*/ + +#ifndef __STUB_VIDEOLISTDATAMODELFORPROXY_H +#define __STUB_VIDEOLISTDATAMODELFORPROXY_H + +#include +#include +#include +#include +#include "videocollectioncommon.h" + +class VideoListDataModel : public QObject +{ + Q_OBJECT + +public: // Constructors and destructor + + /** + * Constructor + * + */ + VideoListDataModel(QObject *parent = NULL); + + /** + * destructor + * + */ + virtual ~VideoListDataModel(); + + /** + * Stub method. + */ + TMPXItemId mediaIdAtIndex(int index); + + /** + * Stub method. + */ + const int rowCount() const; + + /** + * Stub method. + */ + bool belongsToAlbum(TMPXItemId &id); + + /** + * Stub method. + */ + TMPXItemId albumInUse(); + + /** + * Helper methor to emit albumChanged signal. + * + */ + void emitAlbumChanged(); + +signals: + void albumChanged(); + +public: + + static TMPXItemId mMediaIdAtIndexReturnValue; + static int mMediaIdAtIndexCallCount; + static int mRowCountReturnValue; + static bool mBelongsToAlbumReturnValue; + static TMPXItemId mAlbumInUseReturnValue; + +}; + +#endif // __STUB_VIDEOLISTDATAMODELFORPROXY_H + + diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcontent/stub/inc/videoproxymodelgeneric.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcontent/stub/inc/videoproxymodelgeneric.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,163 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: stub VideoProxyModelGeneric class definition +* +*/ + +#ifndef VIDEOPROXYMODELGENERIC_H +#define VIDEOPROXYMODELGENERIC_H + +// INCLUDES +#include +#include +#include + +class VideoListDataModel; + +// CLASS DECLARATION +class VideoProxyModelGeneric : public QObject +{ + Q_OBJECT + +public: + + /** + * Contructor. + * + * @param QObject parent object. + */ + VideoProxyModelGeneric(QObject *parent = 0); + + /** + * Destructor. + * + */ + virtual ~VideoProxyModelGeneric(); + +public: + + /** + * Opens the defined item. This is quite abstract as depending + * on the type of the item, the behaviour or result could be + * quite different. + * + * @param item id id of the item to be opened + * @return int 0 succeeds, <0 if opening does not succeed. + */ + virtual int openItem(TMPXItemId mediaId); + + /** + * Gets the currently opened item. + * + * @param None. + * @return TMPXItemId. + */ + virtual TMPXItemId getOpenItem() const; + + /** + * Compares items based in the role setted before sorting. From QSortFilterProxyModel. + * + */ + virtual bool lessThan(const QModelIndex & left, const QModelIndex & right) const; + + /** + * Filtering functionality. Called by the FW. From QSortFilterProxyModel. + * + * @param source_row row to check + * @param source_parent row's parent + * + * @return bool row accepted(true) or not accepted(false) + */ + virtual bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const; + + /** + * Connects all signals emitted from or throught this object. + * + * @return bool + */ + virtual bool connectSignals(); + + /** + * Disconnects all signals. + */ + void disconnectSignals(); + + /** + * Does actual sorting and emits sortingReady. + * + */ + virtual void processSorting(); + + /** + * Returns sourceModel; + */ + virtual const VideoListDataModel *sourceModel() const; + + /** + * Stub method. + */ + void invalidateFilter(); + + /** + * Stub method. + */ + void sort(int column, Qt::SortOrder order); + + /** + * Stub method. + */ + void setSortRole(int sortRole); + +public: + static int mOpenItemCallCount; + static int mGetOpenItemCallCount; + static int mLessThanCallCount; + static int mFilterAcceptsRowCallCount; + static int mConnectSignalsCallCount; + static bool mConnectSignalsReturnValue; + static int mDisconnectSignalsCallCount; + static int mProcessSortingCallCount; + static int mInvalidateFilterCallCount; + static Qt::SortOrder mLastSortedOrder; + static int mLastSortRole; + +public: + + /** + * Pointer to the actual model. + */ + VideoListDataModel *mModel; + + /** + * Collection client. + */ + int mCollectionClient; + + /** + * Sort order (ascending or descending). + */ + Qt::SortOrder mWantedSortOrder; + + /* + * Sort role. + */ + int mWantedSortRole; + + /* + * Default sort role for the model. + */ + int mDefaultSortRole; +}; + +#endif // VIDEOPROXYMODELGENERIC_H diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcontent/stub/src/filterproxytester.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcontent/stub/src/filterproxytester.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,79 @@ + +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Helper class to test protected members from the proxy model +* +*/ + +// INCLUDES + +#include "filterproxytester.h" + +// --------------------------------------------------------------------------- +// FilterProxyTester +// --------------------------------------------------------------------------- +// +FilterProxyTester::FilterProxyTester(QObject *parent) : +VideoProxyModelContent(parent) +{ + // NOP +} + +// --------------------------------------------------------------------------- +// ~FilterProxyTester +// --------------------------------------------------------------------------- +// +FilterProxyTester::~FilterProxyTester() +{ + +} + +// --------------------------------------------------------------------------- +// callLessThan +// --------------------------------------------------------------------------- +// +bool FilterProxyTester::callLessThan( const QModelIndex & left, const QModelIndex & right ) const +{ + return VideoProxyModelContent::lessThan(left, right); +} + + +// --------------------------------------------------------------------------- +// callLessThan +// --------------------------------------------------------------------------- +// +bool FilterProxyTester::callFilterAcceptsRow( int source_row, const QModelIndex & source_parent ) const +{ + return VideoProxyModelContent::filterAcceptsRow(source_row, source_parent); +} + +// --------------------------------------------------------------------------- +// callConnectSignals +// --------------------------------------------------------------------------- +// +bool FilterProxyTester::callConnectSignals() +{ + return connectSignals(); +} + +// --------------------------------------------------------------------------- +// callDisconnectSignals +// --------------------------------------------------------------------------- +// +void FilterProxyTester::callDisconnectSignals() +{ + disconnectSignals(); +} + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcontent/stub/src/videolistdatamodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcontent/stub/src/videolistdatamodel.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,94 @@ +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Stub model to be used when unit testing the proxy model. +* +*/ + + +// INCLUDES +#include "videolistdatamodel.h" + +TMPXItemId VideoListDataModel::mMediaIdAtIndexReturnValue; +int VideoListDataModel::mMediaIdAtIndexCallCount = 0; +int VideoListDataModel::mRowCountReturnValue = 0; +bool VideoListDataModel::mBelongsToAlbumReturnValue = true; +TMPXItemId VideoListDataModel::mAlbumInUseReturnValue = TMPXItemId::InvalidId(); + +// --------------------------------------------------------------------------- +// VideoListDataModel +// --------------------------------------------------------------------------- +// +VideoListDataModel::VideoListDataModel(QObject *parent) +{ + Q_UNUSED(parent); +} + +// --------------------------------------------------------------------------- +// ~VideoListDataModel +// --------------------------------------------------------------------------- +// +VideoListDataModel::~VideoListDataModel() +{ + +} + +// --------------------------------------------------------------------------- +// mediaIdAtIndex +// --------------------------------------------------------------------------- +// +TMPXItemId VideoListDataModel::mediaIdAtIndex(int index) +{ + Q_UNUSED(index); + mMediaIdAtIndexCallCount++; + return mMediaIdAtIndexReturnValue; +} + +// --------------------------------------------------------------------------- +// rowCount +// --------------------------------------------------------------------------- +// +const int VideoListDataModel::rowCount() const +{ + return mRowCountReturnValue; +} + +// --------------------------------------------------------------------------- +// mediaIdAtIndex +// --------------------------------------------------------------------------- +// +bool VideoListDataModel::belongsToAlbum(TMPXItemId &id) +{ + return mBelongsToAlbumReturnValue; +} + +// --------------------------------------------------------------------------- +// albumInUse +// --------------------------------------------------------------------------- +// +TMPXItemId VideoListDataModel::albumInUse() +{ + return mAlbumInUseReturnValue; +} + + +// --------------------------------------------------------------------------- +// emitAlbumChanged +// --------------------------------------------------------------------------- +// +void VideoListDataModel::emitAlbumChanged() +{ + emit albumChanged(); +} +// End of file + diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcontent/stub/src/videoproxymodelgeneric.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcontent/stub/src/videoproxymodelgeneric.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,181 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: VideoProxyModelGeneric implementation +* +*/ + +// Version : + +// INCLUDE FILES +#include +#include +#include +#include +#include + +#include "videolistdatamodel.h" +#include "videocollectioncommon.h" +#include "videoproxymodelgeneric.h" + +const TMPXItemId INVALID_ID = TMPXItemId::InvalidId(); + +int VideoProxyModelGeneric::mOpenItemCallCount = 0; +int VideoProxyModelGeneric::mGetOpenItemCallCount = 0; +int VideoProxyModelGeneric::mLessThanCallCount = 0; +int VideoProxyModelGeneric::mFilterAcceptsRowCallCount = 0; +int VideoProxyModelGeneric::mConnectSignalsCallCount = 0; +int VideoProxyModelGeneric::mDisconnectSignalsCallCount = 0; +int VideoProxyModelGeneric::mProcessSortingCallCount = 0; +int VideoProxyModelGeneric::mInvalidateFilterCallCount = 0; +Qt::SortOrder VideoProxyModelGeneric::mLastSortedOrder = Qt::AscendingOrder; +int VideoProxyModelGeneric::mLastSortRole = 0; +bool VideoProxyModelGeneric::mConnectSignalsReturnValue = true; + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::VideoProxyModelGeneric +// ----------------------------------------------------------------------------- +// +VideoProxyModelGeneric::VideoProxyModelGeneric(QObject *parent) : + mModel(0), + mCollectionClient(0), + mWantedSortOrder(Qt::AscendingOrder), + mWantedSortRole(0), + mDefaultSortRole(0) +{ + Q_UNUSED(parent); +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::~VideoProxyModelGeneric +// ----------------------------------------------------------------------------- +// +VideoProxyModelGeneric::~VideoProxyModelGeneric() +{ + delete mModel; + mModel = 0; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::openItem +// ----------------------------------------------------------------------------- +// +int VideoProxyModelGeneric::openItem(TMPXItemId mediaId) +{ + Q_UNUSED(mediaId); + mOpenItemCallCount++; + return -1; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::getOpenItem() +// ----------------------------------------------------------------------------- +// +TMPXItemId VideoProxyModelGeneric::getOpenItem() const +{ + mGetOpenItemCallCount++; + TMPXItemId itemId = TMPXItemId::InvalidId(); + return itemId; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::lessThan +// ----------------------------------------------------------------------------- +// +bool VideoProxyModelGeneric::lessThan(const QModelIndex &left, + const QModelIndex &right) const +{ + Q_UNUSED(left); + Q_UNUSED(right); + mLessThanCallCount++; + return false; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::filterAcceptsRow +// ----------------------------------------------------------------------------- +// +bool VideoProxyModelGeneric::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const +{ + Q_UNUSED(source_row); + Q_UNUSED(source_parent); + mFilterAcceptsRowCallCount++; + return false; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::connectSignals +// ----------------------------------------------------------------------------- +// +bool VideoProxyModelGeneric::connectSignals() +{ + mConnectSignalsCallCount++; + return mConnectSignalsReturnValue; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::disconnectSignals +// ----------------------------------------------------------------------------- +// +void VideoProxyModelGeneric::disconnectSignals() +{ + mDisconnectSignalsCallCount++; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::processSorting +// ----------------------------------------------------------------------------- +// +void VideoProxyModelGeneric::processSorting() +{ + mProcessSortingCallCount++; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::processSorting +// ----------------------------------------------------------------------------- +// +const VideoListDataModel *VideoProxyModelGeneric::sourceModel() const +{ + return mModel; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::processSorting +// ----------------------------------------------------------------------------- +// +void VideoProxyModelGeneric::invalidateFilter() +{ + mInvalidateFilterCallCount++; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::processSorting +// ----------------------------------------------------------------------------- +// +void VideoProxyModelGeneric::sort(int column, Qt::SortOrder order) +{ + Q_UNUSED(column); + mLastSortedOrder = order; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::processSorting +// ----------------------------------------------------------------------------- +// +void VideoProxyModelGeneric::setSortRole(int sortRole) +{ + mLastSortRole = sortRole; +} + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcontent/testvideoproxymodelcontent.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelcontent/testvideoproxymodelcontent.pro Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,41 @@ +TEMPLATE = app +TARGET = +DEFINES += BUILD_VIDEOCOLLECTION_DLL + +DEPENDPATH += . \ + inc \ + src \ + stub/inc \ + stub/src + +INCLUDEPATH += . \ + stub/inc \ + /epoc32/include/domain \ + /epoc32/include/domain/middleware \ + /epoc32/include/domain/applications \ + /epoc32/include/osextensions \ + /epoc32/include/middleware \ + /epoc32/include/osextensions/stdapis/stlport \ + ../../../inc + +CONFIG += qtestlib \ + Hb \ + symbian_test + +LIBS += -lestor.dll \ + -lfbscli.dll \ + -lbitgdi.dll \ + -lgdi.dll + +# Input +HEADERS += inc/testvideoproxymodelcontent.h \ + stub/inc/filterproxytester.h \ + stub/inc/videoproxymodelgeneric.h \ + stub/inc/videolistdatamodel.h \ + ../../inc/videoproxymodelcontent.h + +SOURCES += src/testvideoproxymodelcontent.cpp \ + stub/src/filterproxytester.cpp \ + stub/src/videoproxymodelgeneric.cpp \ + stub/src/videolistdatamodel.cpp \ + ../../src/videoproxymodelcontent.cpp diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/inc/testvideoproxymodelgeneric.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/inc/testvideoproxymodelgeneric.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,284 @@ +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: tester for methods in VideoProxyModelGeneric +* +*/ + +#ifndef __TESTVIDEOPROXYMODELGENERIC_H__ +#define __TESTVIDEOPROXYMODELGENERIC_H__ + + +// INCLUDES +#include +#include + +class VideoListDataModel; +class FilterProxyTester; +class VideoCollectionClient; +class VideoProxyModelGeneric; + +class TestVideoProxyModelGeneric : public QObject +{ + Q_OBJECT + + // test functions for the test framework + +signals: + + /** + * test signal + */ + void testSignal(); + + /** + * test signal + */ + void testSignalMpxId(const TMPXItemId &id); + +private slots: + + /** + * will be called before each testfunction is executed. + * + */ + void init(); + + /** + * will be called after every testfunction. + * + */ + void cleanup(); + + /** + * Tests initialize. + */ + void testInitialize(); + + /** + * Test open. + */ + void testOpen(); + + /** + * Test deleteItems with valid data. + */ + void testDeleteItems(); + + /** + * Test deleteItems with NULL model. + */ + void testDeleteItemsModelNull(); + + /** + * Test deleteItems when removeRows fails. + */ + void testDeleteItemsRemoveRowsFail(); + + /** + * Test openItem when getMediaId fails. + */ + void testOpenItemInvalidId(); + + /** + * Test openItem when collection is NULL. + */ + void testOpenItemCollectionNull(); + + /** + * Test openItem when openVideo fails. + */ + void testOpenItemOpenVideoFails(); + + /** + * Test openItem with valid data. + */ + void testOpenItem(); + + /** + * Test back with valid data. + */ + void testBack(); + + /** + * Test fetchItemDetails with valid data. + */ + void testFetchItemDetails(); + + /** + * Test fetchItemDetails when getMediaId fails. + */ + void testFetchItemDetailsGetMediaIdFail(); + + /** + * Test fetchItemDetails when getVideoDetails fails. + */ + void testFetchItemDetailsGetVideoDetailsFails(); + + /** + * Test lessThan when there's no mModel. + */ + void testLessThanNoModel(); + + /** + * Calls sure lessThan with Qt::DisplayRole setted on + * tests that return values are correct for presetted items + */ + void testLessThanName(); + + /** + * Calls sure lessThan with VideoCollectionCommon::KeySizeValue setted on + * tests that return values are correct for presetted items + */ + void testLessThanSize(); + + /** + * Calls sure lessThan with VideoCollectionCommon::KeyDate setted on + * tests that return values are correct for presetted items + */ + void testLessThanDateTime(); + + /** + * Calls less than with media objects of combined default / user created + * collections + */ + void testLessThanDefaults(); + + /** + * Calls sure lessThan with invalid role, + * same indexes and for invalid data + * tests that return values are correct for presetted items + */ + void testLessThanInvalid(); + + /** + * Calls doSorting. + * tests that sorting is done only once + */ + void testDoSorting(); + + /** + * Calls filterAcceptsRow. using type EAllVideos for model + * Tests that return values are correct with items with varying statuses. + * + */ + void testFilterAcceptsRowVideos(); + + /** + * Calls filterAcceptsRow. using type differ than EAllVideos for model + * Tests that return values are correct with items with varying statuses. + * + */ + void testFilterAcceptsNoVideoTypes(); + + /** + * Test getMediaFilePathForId. + */ + void testGetMediaFilePathForId(); + + /** + * Tests calling addNewCollection when initialize has not been called. + */ + void testAddNewCollectionNoCollectionClient(); + + /** + * Tests calling addNewCollection where collection client returns 0. + */ + void testAddNewCollectionSucceed(); + + /** + * tests resolveAlbumName + */ + void testResolveAlbumName(); + + /** + * tests addItemsInAlbum + */ + void testAddItemsInAlbum(); + + /** + * tests removeItemsFromAlbum + */ + void testRemoveItemsFromAlbum(); + + /** + * tests getOpenItem + */ + void testGetOpenItem(); + + /** + * tests removeAlbums + */ + void testRemoveAlbums(); + + /** + * tests albumChangedSlot + */ + //void testAlbumChangedSlot(); + + /** + * tests indexOfId + */ + void testIndexOfId(); + + /** + * tests setGenericIdFilter + */ + void testSetGenericIdFilter(); + + /** + * tests setAlbumInUse + */ + void testSetAlbumInUse(); + + /** + * tests renameItem + */ + void testRenameItem(); + + /** + * tests disconnectSignals + */ + void testDisconnectSignals(); + +private: + + /** + * stub videolist model + */ + VideoListDataModel *mStubModel; + + /** + * stub CVideoCollectionClient. + */ + VideoCollectionClient *mCollectionClient; + + /** + * tester object inherited from the actual test object + * implemented to be able to call protected objects + */ + FilterProxyTester *mTestObject; + + /** + * dummy collections content proxy + */ + VideoProxyModelGeneric *mCollectionModel; +}; + + +#endif // __TESTVIDEOPROXYMODELGENERIC_H__ + +// End of file + + + diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/src/testvideoproxymodelgeneric.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/src/testvideoproxymodelgeneric.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,1534 @@ +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: tester for methods in VideoProxyModelGeneric +* +*/ + +#include +#include +#include + +#define private public +#include "videoproxymodelgeneric.h" +#undef private + +#include "filterproxytester.h" +#include "videocollectionwrapper.h" +#include "videocollectioncommon.h" +#include "testvideoproxymodelgeneric.h" +#include "videolistdatamodel.h" +#include "videocollectionclient.h" +#include "videocollectioncommon.h" +#include "videothumbnaildata.h" + +// --------------------------------------------------------------------------- +// main +// --------------------------------------------------------------------------- +// +int main(int argc, char *argv[]) +{ + HbApplication app(argc, argv); + + TestVideoProxyModelGeneric tv; + + int res; + if(argc > 1) + { + res = QTest::qExec(&tv, argc, argv); + } + else + { + char *pass[3]; + pass[0] = argv[0]; + pass[1] = "-o"; + pass[2] = "c:\\data\\testVideoProxyModelGeneric.txt"; + res = QTest::qExec(&tv, 3, pass); + } + + return res; +} + +// --------------------------------------------------------------------------- +// init +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::init() +{ + qRegisterMetaType("TMPXItemId"); + + VideoListDataModel::mInitFails = false; + VideoListDataModel::mRemoveRowsFails = false; + VideoListDataModel::mGetMediaIdAtIndexFails = false; + VideoListDataModel::mGetCollectionClientFails = false; + VideoCollectionClient::mFailMediaPlayback = false; + VideoCollectionClient::mFailMediaDetails = false; + VideoCollectionClient::mFailInit = false; + VideoCollectionClient::mFailAddNewCollection = false; + VideoCollectionClient::mSortOrderSetCount = 0; + VideoCollectionClient::mAddNewCollectionName = QString(); + VideoCollectionClient::mAddNewCollectionThumb = QString(); + VideoCollectionClient::mAddNewCollectionIds = QList(); + VideoThumbnailData::mStartBackgroundFetchingCallCount = 0; + + mCollectionClient = new VideoCollectionClient(); + mStubModel = new VideoListDataModel(); + mTestObject = new FilterProxyTester(); + mCollectionModel = new VideoProxyModelGeneric(); +} + +// --------------------------------------------------------------------------- +// cleanup +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::cleanup() +{ + delete mCollectionClient; + mCollectionClient = 0; + + delete mTestObject; + mTestObject = 0; + + delete mCollectionModel; + mCollectionModel = 0; + + delete mStubModel; + mStubModel = 0; +} + +// --------------------------------------------------------------------------- +// testInitialize +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testInitialize() +{ + // Test without model. + mTestObject = new FilterProxyTester(); + QCOMPARE(mCollectionModel->initialize(0), -1); + QVERIFY(mTestObject->getModel() == 0); + QVERIFY(mTestObject->getClient() == 0); + + // Test when collection client get fails. + VideoListDataModel::mGetCollectionClientFails = true; + QCOMPARE(mTestObject->initialize(mStubModel), -1); + QVERIFY(mTestObject->getModel() == 0); + QVERIFY(mTestObject->getClient() == 0); + + VideoListDataModel::mGetCollectionClientFails = false; + QCOMPARE(mTestObject->initialize(mStubModel), 0); +} + +// --------------------------------------------------------------------------- +// testOpen +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testOpen() +{ + // no mCollectionClient + QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelInvalid) == -1); + + QCOMPARE(mTestObject->initialize(mStubModel), 0); + + // First open. + QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == 0); + // Open again with same level. + QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == 0); + // Fail open. + VideoCollectionClient::mFailStartOpen = true; + QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == -1); +} + +// --------------------------------------------------------------------------- +// testDeleteItems +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testDeleteItems() +{ + // No model. + QModelIndexList list; + QCOMPARE(mTestObject->deleteItems(list), -1); + + // Ok cases. + VideoThumbnailData::mEnableBackgroundThumbnailFetchingCallCount = 0; + VideoCollectionClient::mFailStartOpen = false; + QCOMPARE(mTestObject->initialize(mStubModel), 0); + QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == 0); + QString name1 = "cc"; + QString name2 = "bb"; + QString name3 = "aa"; + QString name4 = "11"; + QString name5 = "12"; + + mStubModel->appendData(name1); // to source model index 0, proxy index after sort 4 + mStubModel->appendData(name2); // to source model index 1, proxy index after sort 3 + mStubModel->appendData(name3); // to source model index 2, proxy index after sort 2 + mStubModel->appendData(name4); // to source model index 3, proxy index after sort 0 + mStubModel->appendData(name5); // to source model index 4, proxy index after sort 1 + + // Sort to make sure that list order is different compared to source model + mTestObject->doSorting(VideoCollectionCommon::KeyTitle, Qt::AscendingOrder); + // Need to wait for awhile to make sure zero-counter gets + // processing time. + QTest::qWait(500); + QVERIFY(mTestObject->sortRole() == VideoCollectionCommon::KeyTitle); + + // Build list. + int count = mTestObject->rowCount(); + QModelIndex index; + for(int i = 0; i < 5; ++i) + { + index = mTestObject->index(i,0); + list.append(index); + } + + // Empty list. + QModelIndexList emptyList; + VideoThumbnailData::mStartBackgroundFetchingCallCount = 0; + QVERIFY(mTestObject->deleteItems(emptyList) == 0); + QCOMPARE(VideoThumbnailData::mEnableBackgroundThumbnailFetchingCallCount, 2); + QVERIFY(VideoThumbnailData::mBackgroundThumbnailFetchingEnabled == true); + + // List has items. + VideoThumbnailData::mStartBackgroundFetchingCallCount = 0; + VideoThumbnailData::mEnableBackgroundThumbnailFetchingCallCount = 0; + QVERIFY(mTestObject->deleteItems(list) == 0); + QCOMPARE(VideoThumbnailData::mEnableBackgroundThumbnailFetchingCallCount, 2); + QVERIFY(VideoThumbnailData::mBackgroundThumbnailFetchingEnabled == true); + QCOMPARE(mStubModel->mLastDeletedIndexRow, 0); + QCOMPARE(VideoThumbnailData::mStartBackgroundFetchingCallCount, 1); +} + +// --------------------------------------------------------------------------- +// testDeleteItemsModelNull +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testDeleteItemsModelNull() +{ + mStubModel->appendData("Test"); + + QModelIndex index = mStubModel->index(0, 0); + QModelIndexList list; + list.append(index); + + QVERIFY(mTestObject->deleteItems(list) == -1); +} + +// --------------------------------------------------------------------------- +// testDeleteItemsRemoveRowsFail +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testDeleteItemsRemoveRowsFail() +{ + VideoListDataModel::mRemoveRowsFails = true; + VideoCollectionClient::mFailStartOpen = false; + QCOMPARE(mTestObject->initialize(mStubModel), 0); + QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == 0); + + mStubModel->appendData("Test"); + + QCOMPARE(mTestObject->initialize(mStubModel), 0); + + QModelIndex index = mTestObject->index(0, 0); + QModelIndexList list; + list.append(index); + + QVERIFY(mTestObject->deleteItems(list) == -1); +} + +// --------------------------------------------------------------------------- +// testOpenItemInvalidId +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testOpenItemInvalidId() +{ + VideoListDataModel::mGetMediaIdAtIndexFails = true; + VideoCollectionClient::mFailStartOpen = false; + QCOMPARE(mTestObject->initialize(mStubModel), 0); + QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == 0); + + mStubModel->appendData("Test"); + + QCOMPARE(mTestObject->initialize(mStubModel), 0); + QModelIndex index = mTestObject->index(0, 0); + TMPXItemId itemId = TMPXItemId::InvalidId(); + + QVERIFY(mTestObject->openItem(itemId) == -1); +} + +// --------------------------------------------------------------------------- +// testOpenItemCollectionNull +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testOpenItemCollectionNull() +{ + mStubModel->appendData("Test"); + + TMPXItemId itemId(1,0); + + QVERIFY(mTestObject->openItem(itemId) == -1); +} + +// --------------------------------------------------------------------------- +// testOpenItemOpenVideoFails +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testOpenItemOpenVideoFails() +{ + VideoCollectionClient::mFailMediaPlayback = true; + + mStubModel->appendData("Test"); + QCOMPARE(mTestObject->initialize(mStubModel), 0); + TMPXItemId itemId(1,0); + + QVERIFY(mTestObject->openItem(itemId) == -1); + + VideoCollectionClient::mFailMediaPlayback = false; +} + +// --------------------------------------------------------------------------- +// testOpenItem +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testOpenItem() +{ + mStubModel->appendData("Test"); + QCOMPARE(mTestObject->initialize(mStubModel), 0); + TMPXItemId itemId(1,0); + + // open video + QVERIFY(mTestObject->openItem(itemId) == 0); + + // open category or album + itemId = TMPXItemId(1,2); + QVERIFY(mTestObject->openItem(itemId) == 0); +} + +// --------------------------------------------------------------------------- +// testBack +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testBack() +{ + QVERIFY(mTestObject->back() == -1); + + QCOMPARE(mTestObject->initialize(mStubModel), 0); + + QVERIFY(mTestObject->back() == 0); + + mTestObject->open(VideoCollectionCommon::ELevelAlbum); + QVERIFY(mTestObject->back() == 0); + + // back fails + VideoCollectionClient::mBackReturnValue = -1; + QVERIFY(mTestObject->back() == -1); + + VideoCollectionClient::mBackReturnValue = 0; +} + +// --------------------------------------------------------------------------- +// testFetchItemDetails +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testFetchItemDetails() +{ + QModelIndex index; + // no collection client + QVERIFY(mTestObject->fetchItemDetails(index) == -1); + + // Ok + VideoCollectionClient::mFailStartOpen = false; + QCOMPARE(mTestObject->initialize(mStubModel), 0); + mTestObject->open(VideoCollectionCommon::ELevelVideos); + mStubModel->appendData("Test"); + index = mTestObject->index(0, 0); + QSignalSpy fetchSpy(mTestObject, SIGNAL(shortDetailsReady(TMPXItemId))); + + QList arguments; + QVERIFY(mTestObject->fetchItemDetails(index) == 0); + + QVERIFY(fetchSpy.count() == 1); + arguments = fetchSpy.takeFirst(); + QVERIFY(arguments.at(0).toInt() == 0); + arguments.clear(); + fetchSpy.clear(); +} + +// --------------------------------------------------------------------------- +// testFetchItemDetails +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testFetchItemDetailsGetMediaIdFail() +{ + VideoListDataModel::mGetMediaIdAtIndexFails = true; + QSignalSpy fetchSpy(mTestObject, SIGNAL(shortDetailsReady(TMPXItemId))); + mStubModel->appendData("Test"); + QModelIndex index = mTestObject->index(0, 0); + + // no model + QVERIFY(mTestObject->fetchItemDetails(index) == -1); + + QCOMPARE(mTestObject->initialize(mStubModel), 0); + QVERIFY(mTestObject->fetchItemDetails(index) == -1); + QVERIFY(fetchSpy.count() == 0); +} + +// --------------------------------------------------------------------------- +// testFetchItemDetails +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testFetchItemDetailsGetVideoDetailsFails() +{ + VideoCollectionClient::mFailMediaDetails = true; + + QCOMPARE(mTestObject->initialize(mStubModel), 0); + mTestObject->open(VideoCollectionCommon::ELevelVideos); + mStubModel->appendData("Test"); + + QSignalSpy fetchSpy(mTestObject, SIGNAL(shortDetailsReady(TMPXItemId))); + QModelIndex index = mTestObject->index(0, 0); + + QVERIFY(mTestObject->fetchItemDetails(index) == -1); + + QVERIFY(fetchSpy.count() == 0); +} + +// --------------------------------------------------------------------------- +// testLessThanProxyModelNotInitialized +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testLessThanNoModel() +{ + // "normal" comparisation + QString name1 = "cc"; + QString name2 = "bb"; + QString name3 = "aa"; + QString name4 = "11"; + QString name5 = "11"; + + mStubModel->appendData(name1); // to index 0, position 4 + mStubModel->appendData(name2); // to index 1, position 3 + mStubModel->appendData(name3); // to index 2, position 2 + mStubModel->appendData(name4); // to index 3, position 0 or 1 + mStubModel->appendData(name5); // to index 4, position 0 or 1 + + mTestObject->setSortRole(VideoCollectionCommon::KeyTitle); + + QModelIndex left = mStubModel->index(0,0); + QModelIndex right = mStubModel->index(1,0); + + QVERIFY(!mTestObject->callLessThan(left, right)); +} +// --------------------------------------------------------------------------- +// testLessThanName +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testLessThanName() +{ + VideoCollectionClient::mFailStartOpen = false; + QCOMPARE(mTestObject->initialize(mStubModel), 0); + QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == 0); + + // "normal" comparisation + QString name1 = "cc"; + QString name2 = "bb"; + QString name3 = "aa"; + QString name4 = "11"; + QString name5 = "11"; + + mStubModel->appendData(name1); // to index 0, position 4 + mStubModel->appendData(name2); // to index 1, position 3 + mStubModel->appendData(name3); // to index 2, position 2 + mStubModel->appendData(name4); // to index 3, position 0 or 1 + mStubModel->appendData(name5); // to index 4, position 0 or 1 + + mTestObject->setSortRole(VideoCollectionCommon::KeyTitle); + + QModelIndex left = mStubModel->index(0,0); + QModelIndex right = mStubModel->index(1,0); + + QVERIFY(!mTestObject->callLessThan(left, right)); + + left = mStubModel->index(1,0); + right = mStubModel->index(2,0); + + QVERIFY(!mTestObject->callLessThan(left, right)); + + left = mStubModel->index(2,0); + right = mStubModel->index(3,0); + + QVERIFY(!mTestObject->callLessThan(left, right)); + + left = mStubModel->index(3,0); + right = mStubModel->index(4,0); + QVERIFY(!mTestObject->callLessThan(left, right)); + + left = mStubModel->index(4,0); + right = mStubModel->index(0,0); + + QVERIFY(mTestObject->callLessThan(left, right)); + + // reset model + mStubModel->removeAll();; + + // case sensitive check + name1 = "cc"; + name2 = "CC"; + name3 = "cC"; + name4 = "aa"; + name5 = "Aa"; + QString name6 = "2Aa"; + QString name7 = "1Aa"; + QString name8 = "1cc"; + mStubModel->removeAll(); + mStubModel->appendData(name1); // to index 0, position can be 5, 6 or 7 + mStubModel->appendData(name2); // to index 1, position can be 5, 6 or 7 + mStubModel->appendData(name3); // to index 2, position can be 5, 6 or 7 + mStubModel->appendData(name4); // to index 3, position can be 3 or 4 + mStubModel->appendData(name5); // to index 4, position can be 3 or 4 + mStubModel->appendData(name6); // to index 5, position is 2 + mStubModel->appendData(name7); // to index 6, position is 0 + mStubModel->appendData(name8); // to index 7, position is 1 + + mTestObject->setSortRole(VideoCollectionCommon::KeyTitle); + + left = mStubModel->index(0,0); // "cc" + right = mStubModel->index(1,0); // "CC" + + QVERIFY(!mTestObject->callLessThan(left, right)); + + left = mStubModel->index(1,0); // "CC" + right = mStubModel->index(2,0); // "cC" + + QVERIFY(!mTestObject->callLessThan(left, right)); + + left = mStubModel->index(2,0); // "cC" + right = mStubModel->index(3,0); // "aa" + + QVERIFY(!mTestObject->callLessThan(left, right)); + + left = mStubModel->index(3,0); // "aa" + right = mStubModel->index(2,0); // "cC" + + QVERIFY(mTestObject->callLessThan(left, right)); + + left = mStubModel->index(3,0); // "aa" + right = mStubModel->index(4,0); // "Aa" + QVERIFY(!mTestObject->callLessThan(left, right)); + + left = mStubModel->index(4,0); // "Aa" + right = mStubModel->index(5,0); // "2Aa" + + QVERIFY(!mTestObject->callLessThan(left, right)); + + left = mStubModel->index(5,0); // "2Aa" + right = mStubModel->index(6,0); // "1Aa" + QVERIFY(!mTestObject->callLessThan(left, right)); + + left = mStubModel->index(6,0); // "1Aa" + right = mStubModel->index(7,0); // "1cc" + QVERIFY(mTestObject->callLessThan(left, right)); + + left = mStubModel->index(5,0); // "2Aa" + right = mStubModel->index(7,0); // "1cc" + QVERIFY(!mTestObject->callLessThan(left, right)); + + left = mStubModel->index(7,0); // "1cc" + right = mStubModel->index(0,0); // "cc" + QVERIFY(mTestObject->callLessThan(left, right)); +} + +// --------------------------------------------------------------------------- +// testLessThanSize +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testLessThanSize() +{ + VideoCollectionClient::mFailStartOpen = false; + QCOMPARE(mTestObject->initialize(mStubModel), 0); + QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == 0); + + quint32 size1 = 300; + quint32 size2 = 200; + quint32 size3 = 100; + quint32 size4 = 99; + quint32 size5 = 99; + + mStubModel->appendData(size1); // to index 0 + mStubModel->appendData(size2); // to index 1 + mStubModel->appendData(size3); // to index 2 + mStubModel->appendData(size4); // to index 3 + mStubModel->appendData(size5); // to index 4 + + mTestObject->setSortRole(VideoCollectionCommon::KeySizeValue); + + QModelIndex left = mStubModel->index(0,0); + QModelIndex right = mStubModel->index(1,0); + + QVERIFY(!mTestObject->callLessThan(left, right)); + + left = mStubModel->index(1,0); + right = mStubModel->index(2,0); + + QVERIFY(!mTestObject->callLessThan(left, right)); + + left = mStubModel->index(2,0); + right = mStubModel->index(3,0); + + QVERIFY(!mTestObject->callLessThan(left, right)); + + left = mStubModel->index(3,0); + right = mStubModel->index(4,0); + + QVERIFY(!mTestObject->callLessThan(left, right)); + + left = mStubModel->index(4,0); + right = mStubModel->index(0,0); + + QVERIFY(mTestObject->callLessThan(left, right)); +} + +// --------------------------------------------------------------------------- +// testLessThanDate +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testLessThanDateTime() +{ + VideoCollectionClient::mFailStartOpen = false; + QCOMPARE(mTestObject->initialize(mStubModel), 0); + QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == 0); + + QDateTime date1(QDate(2010, 11, 5), QTime(0,0)); + QDateTime date2(QDate(2009, 9, 5), QTime(0,0)); + QDateTime date3(QDate(2009, 9, 4), QTime(0,0)); + QDateTime date4(QDate(2008, 9, 6), QTime(0,0)); + QDateTime date5(QDate(2008, 9, 6), QTime(0,0)); + + mStubModel->appendData(date1); // to index 0 + mStubModel->appendData(date2); // to index 1 + mStubModel->appendData(date3); // to index 2 + mStubModel->appendData(date4); // to index 3 + mStubModel->appendData(date5); // to index 4 + + mTestObject->setSortRole(VideoCollectionCommon::KeyDateTime); + + QModelIndex left = mStubModel->index(0,0); + QModelIndex right = mStubModel->index(1,0); + + QVERIFY(mTestObject->callLessThan(left, right)); + + left = mStubModel->index(1,0); + right = mStubModel->index(2,0); + + QVERIFY(mTestObject->callLessThan(left, right)); + + left = mStubModel->index(2,0); + right = mStubModel->index(3,0); + + QVERIFY(mTestObject->callLessThan(left, right)); + + left = mStubModel->index(3,0); + right = mStubModel->index(4,0); + + QVERIFY(!mTestObject->callLessThan(left, right)); + + left = mStubModel->index(4,0); + right = mStubModel->index(0,0); + + QVERIFY(!mTestObject->callLessThan(left, right)); +} + +// --------------------------------------------------------------------------- +// testLessThanDefaults +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testLessThanDefaults() +{ + /* CATEGORIES MODEL + VideoCollectionClient::mFailStartOpen = false; + QCOMPARE(mTestObject->initialize(mStubModel), 0); + QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelCategory) == 0); + + // Default categories (KVcxMvcMediaTypeCategory) + // are always first in the following order: + // Recently played (missing currently + // Captured (KVcxMvcCategoryIdCaptured) + // Downloaded (KVcxMvcCategoryIdDownloads) + // Podcasts (missing currently) + mStubModel->appendData(TMPXItemId(20, KVcxMvcMediaTypeAlbum)); // to source index 0 + mStubModel->appendData(TMPXItemId(KVcxMvcCategoryIdDownloads, KVcxMvcMediaTypeCategory)); // to source index 1 + mStubModel->appendData(TMPXItemId(KVcxMvcCategoryIdCaptured, KVcxMvcMediaTypeCategory)); // to source index 2 + mStubModel->appendData(TMPXItemId(100, KVcxMvcMediaTypeCategory)); // to source index 3 + mStubModel->appendData(TMPXItemId(101, KVcxMvcMediaTypeCategory)); // to source index 4 + + // left & right are KVcxMvcMediaTypeCategory + // -> left == KVcxMvcCategoryIdCaptured + QModelIndex left = mStubModel->index(2,0); + QModelIndex right = mStubModel->index(1,0); + // call doSorting to setup sorting order + mTestObject->setWantedSortOrder(Qt::AscendingOrder); + QVERIFY(mTestObject->callLessThan(left, right)); + // call doSorting to setup sorting order + mTestObject->setWantedSortOrder(Qt::DescendingOrder); + QVERIFY(!mTestObject->callLessThan(left, right)); + + // -> left == KVcxMvcCategoryIdDownloads + left = mStubModel->index(1,0); + // -> right == KVcxMvcCategoryIdCaptured + right = mStubModel->index(2,0); + mTestObject->setWantedSortOrder(Qt::AscendingOrder); + QVERIFY(!mTestObject->callLessThan(left, right)); + mTestObject->setWantedSortOrder(Qt::DescendingOrder); + QVERIFY(mTestObject->callLessThan(left, right)); + + // -> right != KVcxMvcCategoryIdCaptured + right = mStubModel->index(3,0); + mTestObject->setWantedSortOrder(Qt::AscendingOrder); + QVERIFY(mTestObject->callLessThan(left, right)); + mTestObject->setWantedSortOrder(Qt::DescendingOrder); + QVERIFY(!mTestObject->callLessThan(left, right)); + + // both are KVcxMvcMediaTypeCategory but netiher KVcxMvcCategoryIdCaptured + // nor KVcxMvcCategoryIdDownloads + left = mStubModel->index(3,0); + right = mStubModel->index(4,0); + mTestObject->setWantedSortOrder(Qt::AscendingOrder); + QVERIFY(!mTestObject->callLessThan(left, right)); + mTestObject->setWantedSortOrder(Qt::DescendingOrder); + QVERIFY(mTestObject->callLessThan(left, right)); + + // Left is KVcxMvcMediaTypeCategory and right is not + left = mStubModel->index(1,0); + right = mStubModel->index(0,0); + mTestObject->setWantedSortOrder(Qt::AscendingOrder); + QVERIFY(mTestObject->callLessThan(left, right)); + mTestObject->setWantedSortOrder(Qt::DescendingOrder); + QVERIFY(!mTestObject->callLessThan(left, right)); + + // right is KVcxMvcMediaTypeCategory and left is not + left = mStubModel->index(0,0); + right = mStubModel->index(1,0); + mTestObject->setWantedSortOrder(Qt::AscendingOrder); + QVERIFY(!mTestObject->callLessThan(left, right)); + mTestObject->setWantedSortOrder(Qt::DescendingOrder); + QVERIFY(mTestObject->callLessThan(left, right));*/ +} + +// --------------------------------------------------------------------------- +// testLessThanInvalid +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testLessThanInvalid() +{ + VideoCollectionClient::mFailStartOpen = false; + QCOMPARE(mTestObject->initialize(mStubModel), 0); + QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == 0); + + // invalid role + mTestObject->setSortRole(10000); + + QModelIndex left = mStubModel->index(0,0); + QModelIndex right = mStubModel->index(0,0); + + QVERIFY(!mTestObject->callLessThan(left, right)); + + // invalid role but valid data. + + QString name1 = "cc"; + QString name2 = "bb"; + QString name3 = "aa"; + + mStubModel->appendData(name1); // to index 0, position 4 + mStubModel->appendData(name2); // to index 1, position 3 + mStubModel->appendData(name3); // to index 2, position 2 + + mTestObject->setSortRole(INVALID_ROLE_FOR_SORTING); + + left = mStubModel->index(0,0); + right = mStubModel->index(1,0); + + QVERIFY(!mTestObject->callLessThan(left, right)); + + // invalid left index + mTestObject->setSortRole(VideoCollectionCommon::KeyTitle); + + left = QModelIndex(); + right = mStubModel->index(0,0); + + QVERIFY(!mTestObject->callLessThan(left, right)); + + // invalid right index + mTestObject->setSortRole(VideoCollectionCommon::KeyTitle); + User::Heap().__DbgMarkStart(); + left = mStubModel->index(0,0); + right = QModelIndex(); + + QVERIFY(!mTestObject->callLessThan(left, right)); + + // both invalid + mTestObject->setSortRole(VideoCollectionCommon::KeyTitle); + User::Heap().__DbgMarkStart(); + left = QModelIndex(); + right = QModelIndex(); + + QVERIFY(!mTestObject->callLessThan(left, right)); + + // both same index, use size + quint32 size1 = 99; + + mStubModel->appendData(size1); // to index 0 + + mTestObject->setSortRole(VideoCollectionCommon::KeySizeValue); + mTestObject->setSortRole(VideoCollectionCommon::KeyTitle); + + left = mStubModel->index(0,0); + right = mStubModel->index(0,0); + QVERIFY(!mTestObject->callLessThan(left, right)); +} + +// --------------------------------------------------------------------------- +// testDoSorting +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testDoSorting() +{ + VideoCollectionClient::mFailStartOpen = false; + QCOMPARE(mTestObject->initialize(mStubModel), 0); + QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == 0); + + // these signals are emitted during sorting procedure from the fw + QSignalSpy spyAboutToChange(mTestObject, SIGNAL(layoutAboutToBeChanged())); + QSignalSpy spyChanged(mTestObject, SIGNAL(layoutChanged())); + QSignalSpy spySorted(mTestObject, SIGNAL(modelSorted())); + + QString name1 = "cc"; + QString name2 = "bb"; + QString name3 = "aa"; + QString name4 = "11"; + QString name5 = "11"; + QDateTime date1(QDate(2010, 11, 5), QTime(0,0)); + QDateTime date2(QDate(2009, 9, 5), QTime(0,0)); + QDateTime date3(QDate(2009, 9, 4), QTime(0,0)); + QDateTime date4(QDate(2008, 9, 6), QTime(0,0)); + QDateTime date5(QDate(2008, 9, 6), QTime(0,0)); + quint32 size1 = 300; + quint32 size2 = 200; + quint32 size3 = 100; + quint32 size4 = 99; + quint32 size5 = 99; + + mStubModel->appendData(name1); // to index 0, position 4 + mStubModel->appendData(name2); // to index 1, position 3 + mStubModel->appendData(name3); // to index 2, position 2 + mStubModel->appendData(name4); // to index 3, position 0 or 1 + mStubModel->appendData(name5); // to index 4, position 0 or 1 + + mStubModel->appendData(date1); // to index 0 + mStubModel->appendData(date2); // to index 1 + mStubModel->appendData(date3); // to index 2 + mStubModel->appendData(date4); // to index 3 + mStubModel->appendData(date5); // to index 4 + + mStubModel->appendData(size1); // to index 0 + mStubModel->appendData(size2); // to index 1 + mStubModel->appendData(size3); // to index 2 + mStubModel->appendData(size4); // to index 3 + mStubModel->appendData(size5); // to index 4 + + int sortingRole; + Qt::SortOrder sortingOrder; + + // first sort call, includes timer creation and setup + mTestObject->doSorting(VideoCollectionCommon::KeyTitle, Qt::AscendingOrder); + // need to wait for awhile to make sure zero-counter gets + // processing time. + QTest::qWait(500); + QCOMPARE(spyAboutToChange.count(), 1); + QCOMPARE(spyChanged.count(), 1); + QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeyTitle); + QCOMPARE(mTestObject->sortOrder(), Qt::AscendingOrder); + QCOMPARE(spySorted.count(), 1); + mTestObject->getSorting(sortingRole, sortingOrder); + QCOMPARE(sortingRole, (int)VideoCollectionCommon::KeyTitle); + QCOMPARE(sortingOrder, Qt::AscendingOrder); + + // reset spys + spyAboutToChange.clear(); + spyChanged.clear(); + spySorted.clear(); + + // second sort call, should use same timer appropriately + mTestObject->doSorting(VideoCollectionCommon::KeyTitle, Qt::DescendingOrder); + QTest::qWait(500); + QCOMPARE(spyAboutToChange.count(), 1); + QCOMPARE(spyChanged.count(), 1); + QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeyTitle); + QCOMPARE(mTestObject->sortOrder(), Qt::DescendingOrder); + QCOMPARE(spySorted.count(), 1); + mTestObject->getSorting(sortingRole, sortingOrder); + QCOMPARE(sortingRole, (int)VideoCollectionCommon::KeyTitle); + QCOMPARE(sortingOrder, Qt::DescendingOrder); + + // reset spys + spyAboutToChange.clear(); + spyChanged.clear(); + spySorted.clear(); + + // double call without first letting timer to timeout + VideoThumbnailData::mStartBackgroundFetchingCallCount = 0; + mTestObject->doSorting(VideoCollectionCommon::KeyTitle, Qt::DescendingOrder); + mTestObject->doSorting(VideoCollectionCommon::KeyTitle, Qt::AscendingOrder); + QTest::qWait(500); + QCOMPARE(spyAboutToChange.count(), 1); + QCOMPARE(spyChanged.count(), 1); + QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeyTitle); + QCOMPARE(mTestObject->sortOrder(), Qt::AscendingOrder); + QCOMPARE(spySorted.count(), 1); + mTestObject->getSorting(sortingRole, sortingOrder); + QCOMPARE(sortingRole, (int)VideoCollectionCommon::KeyTitle); + QCOMPARE(sortingOrder, Qt::AscendingOrder); + + spyAboutToChange.clear(); + spyChanged.clear(); + spySorted.clear(); + + // syncronous call checks + mTestObject->doSorting(VideoCollectionCommon::KeyTitle, Qt::DescendingOrder, false); + QCOMPARE(spyAboutToChange.count(), 1); + QCOMPARE(spyChanged.count(), 1); + QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeyTitle); + QCOMPARE(mTestObject->sortOrder(), Qt::DescendingOrder); + QCOMPARE(spySorted.count(), 1); + mTestObject->getSorting(sortingRole, sortingOrder); + QCOMPARE(sortingRole, (int)VideoCollectionCommon::KeyTitle); + QCOMPARE(sortingOrder, Qt::DescendingOrder); + + spyAboutToChange.clear(); + spyChanged.clear(); + spySorted.clear(); + + mTestObject->doSorting(VideoCollectionCommon::KeyTitle, Qt::AscendingOrder, false); + QCOMPARE(spyAboutToChange.count(), 1); + QCOMPARE(spyChanged.count(), 1); + QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeyTitle); + QCOMPARE(mTestObject->sortOrder(), Qt::AscendingOrder); + QCOMPARE(spySorted.count(), 1); + mTestObject->getSorting(sortingRole, sortingOrder); + QCOMPARE(sortingRole, (int)VideoCollectionCommon::KeyTitle); + QCOMPARE(sortingOrder, Qt::AscendingOrder); + + spyAboutToChange.clear(); + spyChanged.clear(); + spySorted.clear(); + + // check that layout signals are not send if the sorting values don't change. + mTestObject->doSorting(VideoCollectionCommon::KeyTitle, Qt::AscendingOrder); + QCOMPARE(spyAboutToChange.count(), 0); + QCOMPARE(spyChanged.count(), 0); + QCOMPARE(spySorted.count(), 0); + QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeyTitle); + QCOMPARE(mTestObject->sortOrder(), Qt::AscendingOrder); + mTestObject->getSorting(sortingRole, sortingOrder); + QCOMPARE(sortingRole, (int)VideoCollectionCommon::KeyTitle); + QCOMPARE(sortingOrder, Qt::AscendingOrder); + + spyAboutToChange.clear(); + spyChanged.clear(); + spySorted.clear(); + + // date role check + mTestObject->doSorting(VideoCollectionCommon::KeyDateTime, Qt::AscendingOrder); + QTest::qWait(500); + int count = spyAboutToChange.count(); + QCOMPARE(spyAboutToChange.count(), 1); + QCOMPARE(spyChanged.count(), 1); + QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeyDateTime); + QCOMPARE(spySorted.count(), 1); + mTestObject->getSorting(sortingRole, sortingOrder); + QCOMPARE(sortingRole, (int)VideoCollectionCommon::KeyDateTime); + QCOMPARE(sortingOrder, Qt::AscendingOrder); + + spyAboutToChange.clear(); + spyChanged.clear(); + spySorted.clear(); + + // size role check + mTestObject->doSorting(VideoCollectionCommon::KeySizeValue, Qt::AscendingOrder); + QTest::qWait(500); + QCOMPARE(spyAboutToChange.count(), 1); + QCOMPARE(spyChanged.count(), 1); + QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeySizeValue); + QCOMPARE(spySorted.count(), 1); + mTestObject->getSorting(sortingRole, sortingOrder); + QCOMPARE(sortingRole, (int)VideoCollectionCommon::KeySizeValue); + QCOMPARE(sortingOrder, Qt::AscendingOrder); + + spyAboutToChange.clear(); + spyChanged.clear(); + spySorted.clear(); + + // number of items role check + mTestObject->doSorting(VideoCollectionCommon::KeyNumberOfItems, Qt::AscendingOrder); + QTest::qWait(500); + QCOMPARE(spyAboutToChange.count(), 1); + QCOMPARE(spyChanged.count(), 1); + QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeyNumberOfItems); + QCOMPARE(spySorted.count(), 1); + mTestObject->getSorting(sortingRole, sortingOrder); + QCOMPARE(sortingRole, (int)VideoCollectionCommon::KeyNumberOfItems); + QCOMPARE(sortingOrder, Qt::AscendingOrder); + + spyAboutToChange.clear(); + spyChanged.clear(); + spySorted.clear(); + + // invalid role check, default will be used. + mTestObject->doSorting(-1, Qt::AscendingOrder); + QTest::qWait(500); + QCOMPARE(spyAboutToChange.count(), 1); + QCOMPARE(spyChanged.count(), 1); + QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeyTitle); + QCOMPARE(spySorted.count(), 1); + mTestObject->getSorting(sortingRole, sortingOrder); + QCOMPARE(sortingRole, (int)VideoCollectionCommon::KeyTitle); + QCOMPARE(sortingOrder, Qt::AscendingOrder); + + spyAboutToChange.clear(); + spyChanged.clear(); + spySorted.clear(); + + /* + // invalid role call, sorting should be set to date + mTestObject->mType = VideoCollectionCommon::EModelTypeAllVideos; + mTestObject->doSorting(VideoCollectionCommon::KeyTitle - 100, Qt::AscendingOrder); + QTest::qWait(500); + QCOMPARE(spyAboutToChange.count(), 1); + QCOMPARE(spyChanged.count(), 1); + QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeyDateTime); + QCOMPARE(spySorted.count(), 1); + + spyAboutToChange.clear(); + spyChanged.clear(); + spySorted.clear(); + + // invalid role call, model type is categories, sorting should be set to VideoCollectionCommon::KeyTitle + mTestObject->mType = VideoCollectionCommon::EModelTypeCollections; + mTestObject->doSorting(VideoCollectionCommon::KeyTitle - 100, Qt::AscendingOrder); + QTest::qWait(500); + QCOMPARE(spyAboutToChange.count(), 1); + QCOMPARE(spyChanged.count(), 1); + QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeyTitle); + QCOMPARE(spySorted.count(), 1); + + spyAboutToChange.clear(); + spyChanged.clear(); + spySorted.clear(); + + // sync sorting call for non -changing sort order (for coverity) + mTestObject->mType = VideoCollectionCommon::EModelTypeAllVideos; + mTestObject->mIdleSortTimer = 0; + mTestObject->doSorting(VideoCollectionCommon::KeyTitle - 100, Qt::AscendingOrder, false); + spyAboutToChange.clear(); + spyChanged.clear(); + mTestObject->doSorting(VideoCollectionCommon::KeyTitle - 100, Qt::AscendingOrder, false); + QCOMPARE(spyAboutToChange.count(), 0); + QCOMPARE(spyChanged.count(), 0); + QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeyDateTime); + spyAboutToChange.clear(); + spyChanged.clear(); + QCOMPARE(spySorted.count(), 2); + */ +} + +// --------------------------------------------------------------------------- +// testFilterAcceptsRow +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testFilterAcceptsRowVideos() +{ + // source_parent can be anything, test model doesn't use it. + QModelIndex source_parent = QModelIndex(); + + // Not initialized: no source model + QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == false); + + QCOMPARE(mTestObject->initialize(mStubModel), 0); + mTestObject->open(VideoCollectionCommon::ELevelVideos); +// mTestObject->mType = VideoCollectionCommon::EModelTypeAllVideos; + + // Test invalid row: below 0 + QVERIFY(mTestObject->callFilterAcceptsRow(-1, source_parent) == false); + + // invalid row: larger than count + mStubModel->appendData("test"); + QVERIFY(mTestObject->callFilterAcceptsRow(2, source_parent) == false); + + // correct row + QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == true); + + // correct row, but id not corresponds video + mStubModel->removeAll(); + mStubModel->appendData(TMPXItemId(1, KVcxMvcMediaTypeCategory)); + QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == false); +} + +// --------------------------------------------------------------------------- +// testFilterAcceptsNoVideoTypes +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testFilterAcceptsNoVideoTypes() +{ + // source_parent can be anything, test model doesn't use it. + QModelIndex source_parent = QModelIndex(); +// QCOMPARE(mTestObject->initialize(mStubModel), 0); + + // only one item at ondex 0 + mStubModel->appendData(TMPXItemId(1, KVcxMvcMediaTypeVideo)); +/* + // model type == VideoCollectionWrapper::ECollections + mTestObject->mType = VideoCollectionCommon::EModelTypeCollections; + // mLevel == VideoCollectionCommon::ELevelCategory, id.iId1 == KVcxMvcMediaTypeVideo + mTestObject->mLevel = VideoCollectionCommon::ELevelCategory; + QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == false); + // mLevel != VideoCollectionCommon::ELevelCategory + mTestObject->mLevel = VideoCollectionCommon::ELevelAlbum; + QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == false); + + // model type == VideoCollectionWrapper::ECollectionContent + mTestObject->mType = VideoCollectionCommon::EModelTypeCollectionContent; + // item belongs to album + VideoListDataModel::mBelongsToAlbum = true; + QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == true); + // item does not belong to album + VideoListDataModel::mBelongsToAlbum = false; + QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == false); + + // model type == VideoCollectionWrapper::EGeneric + mTestObject->mType = VideoCollectionCommon::EModelTypeGeneric; + mTestObject->mGenericFilterValue = true; + + // mLevel != VideoCollectionCommon::ELevelVideos && id.iId2 == KVcxMvcMediaTypeVideo + mTestObject->mLevel = VideoCollectionCommon::ELevelAlbum; + QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == false); + + // mLevel == VideoCollectionCommon::ELevelVideos && id.iId2 != KVcxMvcMediaTypeVideo + mTestObject->mLevel = VideoCollectionCommon::ELevelVideos; + mStubModel->removeAll(); + mStubModel->appendData(TMPXItemId(1, KVcxMvcMediaTypeCategory)); + QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == false); + + // mLevel == VideoCollectionCommon::ELevelVideos && id.iId2 == KVcxMvcMediaTypeVideo + mStubModel->removeAll(); + mStubModel->appendData(TMPXItemId(1, KVcxMvcMediaTypeVideo)); + // generic filter id == TMPXItemId::InvalidId() + mTestObject->mGenericFilterId = TMPXItemId::InvalidId(); + QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == true); + + // generic filter id == (KVcxMvcCategoryIdAll, KVcxMvcMediaTypeCategory) + mTestObject->mGenericFilterId = TMPXItemId(KVcxMvcCategoryIdAll, KVcxMvcMediaTypeCategory); + QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == true); + + // generic filter id == (100, KVcxMvcMediaTypeCategory) + mTestObject->mGenericFilterId = TMPXItemId(100, KVcxMvcMediaTypeCategory); + QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == false); + + // generic filter id == (KVcxMvcCategoryIdAll, KVcxMvcMediaTypeVideo) + mTestObject->mGenericFilterId = TMPXItemId(KVcxMvcCategoryIdAll, KVcxMvcMediaTypeVideo); + QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == false); + + // generic filter id == (100, KVcxMvcMediaTypeCategory) + VideoListDataModel::mBelongsToAlbum = true; + mTestObject->mGenericFilterId = TMPXItemId(100, KVcxMvcMediaTypeCategory); + QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == true); + + // generic filter id == (KVcxMvcCategoryIdAll, KVcxMvcMediaTypeVideo) + VideoListDataModel::mBelongsToAlbum = true; + mTestObject->mGenericFilterId = TMPXItemId(KVcxMvcCategoryIdAll, KVcxMvcMediaTypeVideo); + QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == true); + + */ +} + +// --------------------------------------------------------------------------- +// testGetMediaFilePathForId +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testGetMediaFilePathForId() +{ + // Not initialized. + VideoListDataModel::mMediaFilePathReturnValue = "testfile"; + QVERIFY(mTestObject->getMediaFilePathForId(TMPXItemId(0,0)) == ""); + + // Ok case. + QCOMPARE(mTestObject->initialize(mStubModel), 0); + VideoListDataModel::mMediaFilePathReturnValue = "testfile"; + QVERIFY(mTestObject->getMediaFilePathForId(TMPXItemId(0,0)) == "testfile"); +} + +// --------------------------------------------------------------------------- +// testAddNewCollectionNoCollectionClient +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testAddNewCollectionNoCollectionClient() +{ + QString name("testname"); + VideoCollectionClient::mNewAlbumId = TMPXItemId(1,1); + QVERIFY(mTestObject->addNewAlbum(name) == TMPXItemId::InvalidId()); + QVERIFY(VideoCollectionClient::mAddNewCollectionName != name); +} + +// --------------------------------------------------------------------------- +// testAddNewCollectionSucceed +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testAddNewCollectionSucceed() +{ + QString name("testname"); + + mTestObject->initialize(mStubModel); + VideoCollectionClient::mNewAlbumId = TMPXItemId(1,1); + QVERIFY(mTestObject->addNewAlbum(name) == TMPXItemId(1,1)); + QCOMPARE(VideoCollectionClient::mAddNewCollectionName, name); +} + +// --------------------------------------------------------------------------- +// testResolveAlbumName +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testResolveAlbumName() +{ +// mCollectionModel->mType = VideoCollectionCommon::EModelTypeCollections; + + QString name("test"); + QString resolved(""); + + // no model, same name can be used + resolved = mTestObject->resolveAlbumName(name); + QVERIFY(resolved.length()); + QVERIFY(resolved == name); + + // no collections proxy model, same name + mTestObject->initialize(mStubModel); + resolved = mTestObject->resolveAlbumName(name); + QVERIFY(resolved.length()); + QVERIFY(resolved == name); + + mCollectionModel->initialize(mStubModel); + mCollectionModel->open(VideoCollectionCommon::ELevelCategory); + VideoCollectionWrapper::instance().mProxyModel = mCollectionModel; + + // collections proxy model exists, no source model + resolved = mTestObject->resolveAlbumName(name); + QVERIFY(resolved.length()); + QVERIFY(resolved == name); + + mStubModel->appendData(TMPXItemId(1,2)); + mStubModel->appendData(name); + + int count = mCollectionModel->rowCount(); + + // invalid data from model, same name can be used + VideoListDataModel::mReturnInvalid = true; + resolved = mTestObject->resolveAlbumName(name); + QVERIFY(resolved.length()); + QVERIFY(resolved == name); + VideoListDataModel::mReturnInvalid = false; + + // same name, name to be different + resolved = mTestObject->resolveAlbumName(name); + QVERIFY(resolved.length()); + QVERIFY(resolved != name); + QVERIFY(resolved.contains("1")); + + mStubModel->appendData(TMPXItemId(2,2)); + mStubModel->appendData(resolved); + + resolved = mTestObject->resolveAlbumName(name); + QVERIFY(resolved.length()); + QVERIFY(resolved != name); + QVERIFY(resolved.contains("2")); + + // different name, no changes + name = "Another"; + resolved = mTestObject->resolveAlbumName(name); + QVERIFY(resolved == name); + + //mCollectionModel->mType = VideoCollectionCommon::EModelTypeAllVideos; +} + +// --------------------------------------------------------------------------- +// testResolveAlbumName +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testAddItemsInAlbum() +{ + TMPXItemId albumId(1,2); + QList items; + items.append(TMPXItemId(1,0)); + // no collection client + QVERIFY(mTestObject->addItemsInAlbum(albumId, items) == -1); + mTestObject->initialize(mStubModel); + QVERIFY(mTestObject->addItemsInAlbum(albumId, items) == 0); +} + +// --------------------------------------------------------------------------- +// testRemoveItemsFromAlbum +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testRemoveItemsFromAlbum() +{ + VideoListDataModel::mRemoveFrAlbumReturn = 1; + TMPXItemId albumId(1,2); + QList items; + items.append(TMPXItemId(1,0)); + VideoThumbnailData::mEnableBackgroundThumbnailFetchingCallCount = 0; + + // no model + QVERIFY(mTestObject->removeItemsFromAlbum(albumId, items) == -1); + QCOMPARE(VideoThumbnailData::mEnableBackgroundThumbnailFetchingCallCount, 2); + QVERIFY(VideoThumbnailData::mBackgroundThumbnailFetchingEnabled == true); + mTestObject->initialize(mStubModel); + + // model returns < 0 + VideoListDataModel::mRemoveFrAlbumReturn = -1; + QVERIFY(mTestObject->removeItemsFromAlbum(albumId, items) == -1); + QCOMPARE(VideoThumbnailData::mEnableBackgroundThumbnailFetchingCallCount, 4); + QVERIFY(VideoThumbnailData::mBackgroundThumbnailFetchingEnabled == true); + + VideoListDataModel::mRemoveFrAlbumReturn = 11; + // "succeed" + QVERIFY(mTestObject->removeItemsFromAlbum(albumId, items) == 0); + QCOMPARE(VideoThumbnailData::mEnableBackgroundThumbnailFetchingCallCount, 6); + QVERIFY(VideoThumbnailData::mBackgroundThumbnailFetchingEnabled == true); +} + +// --------------------------------------------------------------------------- +// testGetOpenItem +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testGetOpenItem() +{ + QVERIFY(mTestObject->getOpenItem() == TMPXItemId::InvalidId()); + +/* // no model nor collection client + VideoListDataModel *tmp = mTestObject->mModel; + mTestObject->mModel = 0; + QVERIFY(mTestObject->getOpenItem() == TMPXItemId::InvalidId()); + + mTestObject->initialize(mStubModel); + + // model exist, no collection client + VideoCollectionClient *tmpClient = mTestObject->mCollectionClient; + mTestObject->mCollectionClient = 0; + QVERIFY(mTestObject->getOpenItem() == TMPXItemId::InvalidId()); + mTestObject->mCollectionClient = tmpClient; + + // no model, collection client exists + VideoListDataModel *tmpModel = mTestObject->mModel; + mTestObject->mModel = 0; + QVERIFY(mTestObject->getOpenItem() == TMPXItemId::InvalidId()); + mTestObject->mModel = tmpModel; + + // type neither EAllVideos or ECollectionContent + QVERIFY(mTestObject->getOpenItem() == TMPXItemId::InvalidId()); + + TMPXItemId id; + // type EAllVideos + delete mTestObject; + mTestObject = new FilterProxyTester(VideoCollectionCommon::EModelTypeAllVideos); + mTestObject->initialize(mStubModel); + id = mTestObject->getOpenItem(); + QVERIFY(id != TMPXItemId::InvalidId()); + QVERIFY(id.iId1 == KVcxMvcCategoryIdAll); + QVERIFY(id.iId2 == KVcxMvcMediaTypeCategory); + + // type ECollectionContent + delete mTestObject; + mTestObject = new FilterProxyTester(VideoCollectionCommon::EModelTypeCollectionContent); + mTestObject->initialize(mStubModel); + id.iId1 = 1; + id.iId2 = KVcxMvcMediaTypeAlbum; + mTestObject->openItem(id); + id = TMPXItemId::InvalidId(); + id = mTestObject->getOpenItem(); + QVERIFY(id != TMPXItemId::InvalidId()); + QVERIFY(id.iId1 == 1); + QVERIFY(id.iId2 == KVcxMvcMediaTypeAlbum); + */ +} + +// --------------------------------------------------------------------------- +// testRemoveAlbums +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testRemoveAlbums() +{ + QModelIndexList indexList; + // no collection client + QVERIFY(mTestObject->removeAlbums(indexList) == -1); + + mTestObject->initialize(mStubModel); + QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == 0); + + // empty list provided + QVERIFY(mTestObject->removeAlbums(indexList) == -1); + + mStubModel->appendData(TMPXItemId(1,0)); + mStubModel->appendData(TMPXItemId(2,0)); + mStubModel->appendData(TMPXItemId(3,0)); + + indexList.append(mTestObject->index(0,0)); + indexList.append(mTestObject->index(1,0)); + indexList.append(mTestObject->index(2,0)); + + // no albums in model + QVERIFY(mTestObject->removeAlbums(indexList) == -1); + + indexList.clear(); + mStubModel->removeAll(); + + cleanup(); + init(); + + QCOMPARE(mTestObject->initialize(mStubModel), 0); + QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelCategory) == 0); + mStubModel->appendData(TMPXItemId(1,2)); + mStubModel->appendData(TMPXItemId(2,2)); + mStubModel->appendData(TMPXItemId(3,2)); + indexList.append(mTestObject->index(0,0)); + indexList.append(mTestObject->index(1,0)); + indexList.append(mTestObject->index(2,0)); + + // succeed + QVERIFY(mTestObject->removeAlbums(indexList) == 0); +} +/* +// --------------------------------------------------------------------------- +// testAlbumChangedSlot +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testAlbumChangedSlot() +{ + connect(this, SIGNAL(testSignal()), mTestObject, SLOT(albumChangedSlot())); + // cannot test anything here, just for the coverage + // level incorrect +// mTestObject->initialize(mStubModel); + emit testSignal(); + delete mTestObject; + mTestObject = 0; + mTestObject = new FilterProxyTester(VideoCollectionCommon::EModelTypeCollectionContent); + connect(this, SIGNAL(testSignal()), mTestObject, SLOT(albumChangedSlot())); + QVERIFY(mTestObject); +// mTestObject->initialize(mStubModel); + emit testSignal(); + disconnect(this, SIGNAL(testSignal()), mTestObject, SLOT(albumChangedSlot())); +} +*/ +// --------------------------------------------------------------------------- +// testIndexOfId +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testIndexOfId() +{ + QModelIndex index; + // no model + TMPXItemId id(1,0); + index = mTestObject->indexOfId(id); + QVERIFY(!index.isValid()); + + mTestObject->initialize(mStubModel); + mTestObject->open(VideoCollectionCommon::ELevelVideos); + + // fetching invalid + id = TMPXItemId::InvalidId(); + index = mTestObject->indexOfId(id); + QVERIFY(!index.isValid()); + + mStubModel->appendData(TMPXItemId(1,0)); + mStubModel->appendData(TMPXItemId(2,0)); + mStubModel->appendData(TMPXItemId(3,0)); + + id = TMPXItemId(2,0); + index = mTestObject->indexOfId(id); + QVERIFY(index.isValid()); + QVERIFY(index.row() == 1); +} + +// --------------------------------------------------------------------------- +// testSetGenericIdFilter +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testSetGenericIdFilter() +{ + mTestObject->initialize(mStubModel); + mTestObject->open(VideoCollectionCommon::ELevelVideos); + mTestObject->setGenericIdFilter(TMPXItemId(0,1), true); + + mStubModel->appendData(TMPXItemId(1,0)); + mStubModel->appendData(TMPXItemId(2,0)); + mStubModel->appendData(TMPXItemId(3,0)); + mTestObject->invalidate(); + QModelIndex index; + index = mTestObject->indexOfId(TMPXItemId(1,0)); + QVERIFY(index.isValid()); + QVERIFY(index.row() == 0); +} + +// --------------------------------------------------------------------------- +// testRenameAlbum +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testSetAlbumInUse() +{ + mStubModel->mAlbumInUse = TMPXItemId::InvalidId(); + + // no model + mTestObject->setAlbumInUse(TMPXItemId(1,2)); + QVERIFY(mStubModel->mAlbumInUse == TMPXItemId::InvalidId()); + + // model exists + QCOMPARE(mTestObject->initialize(mStubModel), 0); + mTestObject->setAlbumInUse(TMPXItemId(1,2)); + QVERIFY(mStubModel->mAlbumInUse == TMPXItemId(1,2)); +} + +// --------------------------------------------------------------------------- +// testRenameItem +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testRenameItem() +{ + delete mTestObject; + mTestObject = new FilterProxyTester(); + + // Not initialized. + TMPXItemId id = TMPXItemId::InvalidId(); + QString name = ""; + QVERIFY(mTestObject->renameItem(id, name) == -1); + + // Initialized. + mTestObject->initialize(mStubModel); + QVERIFY(mTestObject->renameItem(id, name) == 0); +} + +// --------------------------------------------------------------------------- +// testDisconnectSignals +// --------------------------------------------------------------------------- +// +void TestVideoProxyModelGeneric::testDisconnectSignals() +{ + QCOMPARE(mTestObject->initialize(mStubModel), 0); + mTestObject->callDisconnectSignals(); + // Cannot be verified. +} + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/stub/inc/filterproxytester.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/stub/inc/filterproxytester.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,113 @@ + +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Helper class to test protected members from videocollectionsortfilterproxy +* +*/ + +#ifndef __FILTERLISTPROXY_TESTER_H +#define __FILTERLISTPROXY_TESTER_H + +#include + +#include "videocollectioncommon.h" + +#define private public +#include "videoproxymodelgeneric.h" +#undef private + +class VideoListDataModel; + +class FilterProxyTester : public VideoProxyModelGeneric +{ + + Q_OBJECT + +public: // Constructors and destructor + + /** + * Constructor + * + */ + FilterProxyTester(QObject *parent = 0); + + /** + * destructor + * + */ + virtual ~FilterProxyTester(); + +public: // helper methods for test + + /** + * Helper method to call protected lessThan + * + */ + virtual bool callLessThan( const QModelIndex & left, const QModelIndex & right ) const; + + /** + * Helper methor to call protected filterAcceptsRow. + * + */ + virtual bool callFilterAcceptsRow( int source_row, const QModelIndex & source_parent ) const; + + /** + * Helper method to call protected disconnectSignals. + */ + void callDisconnectSignals(); + + /** + * For setting CVideoCollectionClient pointer + * + */ + int setClient(VideoCollectionClient *collectionClient); + + /** + * For getting CVideoCollectionClient pointer + * + */ + VideoCollectionClient* getClient(); + + /** + * For getting VideoListDataModel pointer + * + */ + VideoListDataModel *getModel(); + + /** + * Toggles null for internal model pointer. + * + */ + void toggleNullModel(); + + /** + * Sets null for internal collection client pointer. + * + */ + void toggleNullClient(); + + /** + * Sets wanted sort order. + * + */ + void setWantedSortOrder(Qt::SortOrder order); + +private: + + VideoListDataModel *mTmpModel; + + VideoCollectionClient *mTmpClient; +}; + +#endif // __FILTERLISTPROXY_TESTER_H diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/stub/inc/videocollectionclient.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/stub/inc/videocollectionclient.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,141 @@ + +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Stub videocollectionclient class for videocollectionsortfilterproxy unit tests +* +*/ + +#ifndef __VIDEOCOLLECTIONCLIENT_H +#define __VIDEOCOLLECTIONCLIENT_H + +//#include +#include +#include +#include + +// FORWARD DECLARATIONS +class VideoCollectionUtils; + + +class VideoCollectionClient +{ + + public: // Constructors and destructor + + /** + * constructor + * + */ + VideoCollectionClient(); + + /** + * destructor + * + */ + virtual ~VideoCollectionClient(); + + public: + + /** + * + * if mFailInit is true returns -1 + * if mFailInit is false returns 0 + * + * @return int + */ + int initialize(); + + /** + * + * if mFailStartOpen is true returns -1 + * if mFailStartOpen is false returns 0 + * + * @return int + */ + int startOpenCollection(int level); + + /** + * + * if mFailMediaPlayback is true returns -1 + * if mFailMediaPlayback is false returns 0 + * + * @return int + */ + int openItem(int mpxId1); + + /** + * + * if mFailMediaDetails is true returns -1 + * if mFailMediaDetails is false returns 0 + * + * @return int + */ + int getVideoDetails(int mpxId1); + + /** + * @return mNewAlbumId + */ + TMPXItemId addNewAlbum(QString name); + + /** + * no funtionality needed here for unit tests + */ + int addItemsInAlbum(TMPXItemId albumId, QList items); + + /** + * no funtionality needed here for unit tests + */ + int removeAlbums(const QList &items); + + /** + * saves contant id (1,2) into provided id + */ + void getCategoryId(TMPXItemId &id); + + /** + * calls collection to go back to collection level + * + */ + int back(); + + /** + * returns mRenameItemReturnValue + */ + int renameItem(const TMPXItemId &itemId, const QString &newTitle); + +public: + static bool mFailInit; + static bool mFailStartOpen; + static bool mFailMediaPlayback; + static bool mFailMediaDetails; + static bool mFailSetSort; + static bool mFailAddNewCollection; + static TMPXItemId mNewAlbumId; + static TVcxMyVideosSortingOrder mSettedSortOrder; + static int mSortOrderSetCount; + static QString mAddNewCollectionName; + static QString mAddNewCollectionThumb; + static QList mAddNewCollectionIds; + static int mRenameItemReturnValue; + static int mBackReturnValue; + +private: + + /** + * static instance from this class + */ + static VideoCollectionClient *testInstance; +}; + +#endif // __VIDEOCOLLECTIONCLIENT_H diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/stub/inc/videocollectionwrapper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/stub/inc/videocollectionwrapper.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,72 @@ + +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Stub videocollectionwrapper class for VideoProxyModelGeneric unit tests +* +*/ + +#ifndef __VIDEOCOLLECTIONWRAPPER_H__ +#define __VIDEOCOLLECTIONWRAPPER_H__ + +#include +//#include "videoproxymodelgeneric.h" +class VideoProxyModelGeneric; + +class VideoCollectionWrapper : public QObject +{ + Q_OBJECT + +public: + + enum TModelType + { + EAllVideos, + ECollections, + ECollectionContent, + EGeneric + }; + + static VideoCollectionWrapper &instance() + { + static VideoCollectionWrapper _staticWrapper; + return _staticWrapper; + } + + /** + * constructor + */ + VideoCollectionWrapper() : + mProxyModel(0) + { + } + + /** + * returns mProxyModel + */ + VideoProxyModelGeneric* getGenericModel() + { + return mProxyModel; + } + + /** + * returns mProxyModel + */ + VideoProxyModelGeneric* getCollectionsModel() + { + return mProxyModel; + } + + VideoProxyModelGeneric* mProxyModel; +}; +#endif // __VIDEOCOLLECTIONWRAPPER_H__ diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/stub/inc/videolistdatamodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/stub/inc/videolistdatamodel.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,319 @@ + +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Stub collection client to be used when unit testing videocollectionsortfilterproxy +* +*/ + +#ifndef __STUB_VIDEOLISTDATAMODELFORPROXY_H +#define __STUB_VIDEOLISTDATAMODELFORPROXY_H + +#include +#include +#include +#include +#include +#include +#include "videocollectioncommon.h" + +// CVideoListDataModel::Data returns valid variant when used this and name exists for the row. +const int INVALID_ROLE_FOR_SORTING = VideoCollectionCommon::KeyStatus+10; + +class VideoCollectionClient; + + +class VideoListDataModel : public QAbstractItemModel +{ + + Q_OBJECT + +public: // Constructors and destructor + + /** + * Constructor + * + */ + VideoListDataModel(QObject *parent = NULL); + + /** + * destructor + * + */ + virtual ~VideoListDataModel(); + + /** + * Initializes model. Sets model cache proxy and cache's plugin to + * to be this object. Creates videolist and puts it to observe + * collection client. Calls connectSignals to connect signals into + * appropriate slots + * + * @paran collection mpx video collectionobject + * + * @return int: 0 if everything ok + */ + int initialize(); + + /** + * Method calls video list data to check if there are valid media object + * at the given index. If there is, item id is returned. + * + * @param index index of the item to be opened + * @return TMPXItemId item id ( > 0), < 0 if no valid item. + */ + TMPXItemId &mediaIdAtIndex(int index) const; + + /** + * Method calls video list data to check if there are valid media object + * for the given media id. If there is, file path for is returned. + * + * @param mediaId id of the item to be opened + * @return QString file path of the media at index, empty string if not valid item. + */ + QString mediaFilePathForId(int mediaId) const; + + /** + * Called by the client when removal of videos are requested. + * Sets video status to be removed to videolistdata and + * eventually calls collection to handle the actual removing. + * + * @param indexlist list of indeces of items requested for deletion + * + * @return bool true if removal startup succeeds + */ + bool removeRows(const QModelIndexList &indexList); + + /** + * sets mAlbumInUse + */ + void setAlbumInUse(TMPXItemId itemId); + + /** + * returns mAlbumInUse + */ + TMPXItemId albumInUse(); + + /** + * returns mBelongsToAlbum + */ + bool belongsToAlbum(TMPXItemId itemId, TMPXItemId albumId = TMPXItemId::InvalidId()); + + /** + * returns mRemoveFrAlbumReturn + */ + int removeItemsFromAlbum(TMPXItemId &albumId, const QList &items); + + /** + * returns index of first occurence of provided id + */ + QModelIndex indexOfId(TMPXItemId id); + + /** + * returns collection client + */ + VideoCollectionClient* getCollectionClient(); + +public: // from QAbstractItemModel + + /** + * Returns mRowCount value + * + * @param parent - not used + * + * @return int + */ + int rowCount(const QModelIndex &parent = QModelIndex()) const; + + /** + * Method does nothing in this stub + * + * @param index - not used + * + * @return QMap empty map + */ + QMap itemData(const QModelIndex &index) const; + + /** + * Returns item value based on the role defined: + * Qt::DisplayRole: from mNames -list + * VideoCollectionCommon::KeySizeValue: from mSizes -list + * VideoCollectionCommon::KeyDate: from mDates -list + * + * @param index - item index to return + * @parema role - role indicating wanted value + * + * @return QVariant + */ + QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; + + /** + * Returns 0 always. + * + * @param parent - not used + * + * @return int + */ + int columnCount(const QModelIndex & parent = QModelIndex()) const; + + /** + * Calls QAbstractItemModel::createIndex to return appropriate QModelIndex + * + * @param row - row index + * @param column - col index + * @param parent - not used + * + * @return QModelIndex + */ + QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const; + + /** + * returns invalid QModelIndex + * + * @return QModelIndex + */ + QModelIndex parent(const QModelIndex & index) const; + + +public: // helper methods for test + + /** + * emit album changed signal + */ + void emitAlbumChanged(); + + /** + * clears mData + */ + void removeAll(); + + + /** + * adds provided id to mData + */ + void appendData(TMPXItemId data); + + /** + * appends given string to mData + * + * @param data - value to append to list + */ + void appendData(QString data); + + /** + * appends given uint to mData + * + * @param data - value to append to list + */ + void appendData(uint data); + + /** + * appends given QDate to mData + * + * @param data - value to append to list + */ + void appendData(QDateTime data); + + /** + * Appends given status to mData. + * + * @param status - value to append to list. + */ + void appendStatus(int status); + +signals: + + /** + * This signal is connected to video list's details ready + * -signal indicating that video details data is fetched ok + * + * @param id of the item + */ + void fullVideoDetailsReady(TMPXItemId); + + /** + * Signals that the model is ready, ie. loaded all data from + * myvideocollection. + */ + void modelReady(); + + /** + * signals when model's internal data has changed + */ + void modelChanged(); + + /** + * signals when album data has changed + */ + void albumChanged(); + + /** + * signals when item has been modified + */ + void itemModified(const TMPXItemId &itemId); + +public: + + static bool mInitFails; + + static bool mRemoveRowsFails; + + static bool mGetMediaIdAtIndexFails; + + static bool mBelongsToAlbum; + + static bool mReturnInvalid; + + static int mRemoveFrAlbumReturn; + + static QString mMediaFilePathReturnValue; + + static int mLastDeletedIndexRow; + + static bool mGetCollectionClientFails; + + TMPXItemId mAlbumInUse; + +private: + + class DummyData + { + public: + DummyData() : + mId(TMPXItemId::InvalidId()), + mName(""), + mSize(666), + mDate(QDateTime()), + mStatus(-1) + {} + TMPXItemId mId; + QString mName; + uint mSize; + QDateTime mDate; + int mStatus; + }; + + /** + * List of strings when fetching Qt::DisplayRole + */ + QList mData; + + /** + * colleciton client object, owned + */ + VideoCollectionClient *mCollectionClient; + +}; + +#endif // __STUB_VIDEOLISTDATAMODELFORPROXY_H + + diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/stub/inc/videothumbnaildata.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/stub/inc/videothumbnaildata.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,110 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CVideoThumbnailData class definition* +*/ + +#ifndef __VIDEOTHUMBNAILDATA_H__ +#define __VIDEOTHUMBNAILDATA_H__ + +// INCLUDES +#include +#include +#include +#include +#include + +// FORWARD DECLARATIONS +class VideoProxyModelGeneric; + +class VideoThumbnailData : public QObject +{ + /** + * defined to be able to use signals and slots + */ + Q_OBJECT + + /** + * disable copy-constructor and assignment operator + */ + Q_DISABLE_COPY(VideoThumbnailData) + +public: // Constructor + + /* + * Thumbnail fetch priorities + */ + enum VideoThumbnailPriority + { + VideoThumbnailPriorityBackground = 2000, + VideoThumbnailPriorityLow = 5000, + VideoThumbnailPriorityMedium = 10000, + VideoThumbnailPriorityHigh = 2000 + }; + + /** + * Returns singleton instance for this class. + * + * @return The singleton instance. + * + */ + static VideoThumbnailData &instance(); + + /** + * Starts background thumbnail fetching. + * + * @param fetchIndex index where to start the background thumbnail fetching. + * + */ + void startBackgroundFetching(VideoProxyModelGeneric *model, int fetchIndex); + + /** + * Enables or disables thumbnail background fetching. Default is enabled. + * + * @param enable true enables and false disables thumbnail background fetching. + */ + void enableBackgroundFetching(bool enable); + + /** + * Frees allocated data for thumbnails and cancels ongoing fetches. + */ + void freeThumbnailData(); + +private: + + /** + * Default constructor + */ + VideoThumbnailData(); + + /** + * Destructor + */ + ~VideoThumbnailData(); + +public: + static int mEnableBackgroundThumbnailFetchingCallCount; + static int mStartFetchingThumbnailsCallCount; + static int mStartFetchingThumbnailsThumbnailCount; + static int mInstanceCallCount; + static int mFreeThumbnailDataCallCount; + static int mBackgroundThumbnailFetchingEnabled; + static int mStartBackgroundFetchingCallCount; + +private: // data + + +}; +#endif // __VIDEOTHUMBNAILDATA_H__ + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/stub/src/filterproxytester.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/stub/src/filterproxytester.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,157 @@ + +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Helper class to test protected members from proxy model +* +*/ + +// INCLUDES + +#define private public +#include "videoproxymodelgeneric.h" +#undef private + +#include "filterproxytester.h" +#include "videolistdatamodel.h" + +// --------------------------------------------------------------------------- +// FilterProxyTester +// --------------------------------------------------------------------------- +// +FilterProxyTester::FilterProxyTester(QObject *parent) : +VideoProxyModelGeneric(parent), +mTmpModel(0), +mTmpClient(0) +{ + // NOP +} + +// --------------------------------------------------------------------------- +// ~FilterProxyTester +// --------------------------------------------------------------------------- +// +FilterProxyTester::~FilterProxyTester() +{ + if(!mModel) + { + toggleNullModel(); + } + + if(!mCollectionClient) + { + toggleNullClient(); + } +} + +// --------------------------------------------------------------------------- +// callLessThan +// --------------------------------------------------------------------------- +// +bool FilterProxyTester::callLessThan( const QModelIndex & left, const QModelIndex & right ) const +{ + return VideoProxyModelGeneric::lessThan(left, right); +} + +// --------------------------------------------------------------------------- +// callLessThan +// --------------------------------------------------------------------------- +// +bool FilterProxyTester::callFilterAcceptsRow( int source_row, const QModelIndex & source_parent ) const +{ + return VideoProxyModelGeneric::filterAcceptsRow(source_row, source_parent); +} + +// --------------------------------------------------------------------------- +// setClient +// --------------------------------------------------------------------------- +// +int FilterProxyTester::setClient(VideoCollectionClient *collectionClient) +{ + VideoProxyModelGeneric::mCollectionClient = collectionClient; + return 0; +} + +// --------------------------------------------------------------------------- +// getClient +// --------------------------------------------------------------------------- +// +VideoCollectionClient* FilterProxyTester::getClient() +{ + return VideoProxyModelGeneric::mCollectionClient; +} + +/** + * For getting VideoListDataModel pointer + * + */ +VideoListDataModel *FilterProxyTester::getModel() +{ + return mModel; +} + +/** + * Toggles null for internal model pointer. + * + */ +void FilterProxyTester::toggleNullModel() +{ + if(mModel) + { + mTmpModel = mModel; + mModel = 0; + } + else + { + mModel = mTmpModel; + mTmpModel = 0; + } +} + +/** + * Sets null for internal collection client pointer. + * + */ +void FilterProxyTester::toggleNullClient() +{ + if(mCollectionClient) + { + mTmpClient = mCollectionClient; + mCollectionClient = 0; + } + else + { + mCollectionClient = mTmpClient; + mTmpClient = 0; + } +} + + +/** + * Sets wanted sort order. + * + */ +void FilterProxyTester::setWantedSortOrder(Qt::SortOrder order) +{ + mWantedSortOrder = order; +} + +/** + * Helper method to call protected disconnectSignals. + */ +void FilterProxyTester::callDisconnectSignals() +{ + disconnectSignals(); +} + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/stub/src/videocollectionclient.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/stub/src/videocollectionclient.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,169 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Stub collection client to be used when unit testing videocollectionsortfilterproxy +*/ + + + +// INCLUDE FILES> +#include +#include "stub/inc/videocollectionclient.h" + +VideoCollectionClient* VideoCollectionClient::testInstance = 0; + +bool VideoCollectionClient::mFailInit = false; +bool VideoCollectionClient::mFailStartOpen = false; +bool VideoCollectionClient::mFailMediaPlayback = false; +bool VideoCollectionClient::mFailMediaDetails = false; +bool VideoCollectionClient::mFailSetSort = false; +bool VideoCollectionClient::mFailAddNewCollection = false; +TMPXItemId VideoCollectionClient::mNewAlbumId = TMPXItemId::InvalidId(); +TVcxMyVideosSortingOrder VideoCollectionClient::mSettedSortOrder = EVcxMyVideosSortingNone; +int VideoCollectionClient::mSortOrderSetCount = 0; +QString VideoCollectionClient::mAddNewCollectionName = QString(); +QString VideoCollectionClient::mAddNewCollectionThumb = QString(); +QList VideoCollectionClient::mAddNewCollectionIds = QList(); +int VideoCollectionClient::mRenameItemReturnValue = 0; +int VideoCollectionClient::mBackReturnValue = 0; + +// ----------------------------------------------------------------------------- +// VideoCollectionClient +// ----------------------------------------------------------------------------- +// +VideoCollectionClient::VideoCollectionClient() +{ + testInstance = this; +} + +// ----------------------------------------------------------------------------- +// ~CVideoCollectionClient +// ----------------------------------------------------------------------------- +// +VideoCollectionClient::~VideoCollectionClient() +{ +} + +// ----------------------------------------------------------------------------- +// initialize +// ----------------------------------------------------------------------------- +// +int VideoCollectionClient::initialize() +{ + if(mFailInit) + { + return -1; + } + return 0; +} + +// ----------------------------------------------------------------------------- +// startOpenCollection +// ----------------------------------------------------------------------------- +// +int VideoCollectionClient::startOpenCollection(int level) +{ + Q_UNUSED(level); + if(mFailStartOpen) + { + return -1; + } + return 0; +} + +// ----------------------------------------------------------------------------- +// openItem +// ----------------------------------------------------------------------------- +// +int VideoCollectionClient::openItem(int /*mpxId1*/) +{ + if(mFailMediaPlayback) + { + return -1; + } + return 0; +} + +// ----------------------------------------------------------------------------- +// addNewAlbum +// ----------------------------------------------------------------------------- +// +TMPXItemId VideoCollectionClient::addNewAlbum(QString title) +{ + mAddNewCollectionName = title; + return mNewAlbumId; +} + +// ----------------------------------------------------------------------------- +// addItemsInAlbum +// ----------------------------------------------------------------------------- +// +int VideoCollectionClient::addItemsInAlbum(TMPXItemId albumId, QList items) +{ + Q_UNUSED(albumId); + Q_UNUSED(items); + return 0; +} + +// ----------------------------------------------------------------------------- +// revoveAlbums +// ----------------------------------------------------------------------------- +// +int VideoCollectionClient::removeAlbums(const QList &items) +{ + Q_UNUSED(items); + return 0; +} + +// ----------------------------------------------------------------------------- +// deleteFile +// ----------------------------------------------------------------------------- +// +int VideoCollectionClient::getVideoDetails(int /*mpxId1*/) +{ + if(mFailMediaDetails) + { + return -1; + } + return 0; +} + +// ----------------------------------------------------------------------------- +// getCategoryId +// ----------------------------------------------------------------------------- +// +void VideoCollectionClient::getCategoryId(TMPXItemId &id) +{ + id.iId1 = 1; + id.iId2 = 2; +} + +// ----------------------------------------------------------------------------- +// back +// ----------------------------------------------------------------------------- +// +int VideoCollectionClient::back() +{ + return mBackReturnValue; +} + +// ----------------------------------------------------------------------------- +// renameItem +// ----------------------------------------------------------------------------- +// +int VideoCollectionClient::renameItem(const TMPXItemId &itemId, const QString &newTitle) +{ + Q_UNUSED(itemId); + Q_UNUSED(newTitle); + return mRenameItemReturnValue; +} diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/stub/src/videolistdatamodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/stub/src/videolistdatamodel.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,483 @@ +/** +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Stub model to be used when unit testing proxy model. +* +*/ + + +// INCLUDES +#include "videocollectionclient.h" +#include "videolistdatamodel.h" + +bool VideoListDataModel::mInitFails = false; +bool VideoListDataModel::mRemoveRowsFails = false; +bool VideoListDataModel::mGetMediaIdAtIndexFails = false; +bool VideoListDataModel::mBelongsToAlbum = false; +bool VideoListDataModel::mReturnInvalid = false; +int VideoListDataModel::mRemoveFrAlbumReturn = -1; +int VideoListDataModel::mLastDeletedIndexRow = -1; +QString VideoListDataModel::mMediaFilePathReturnValue = ""; +bool VideoListDataModel::mGetCollectionClientFails = false; + +TMPXItemId gInvalidId = TMPXItemId::InvalidId(); + +// --------------------------------------------------------------------------- +// VideoListDataModel +// --------------------------------------------------------------------------- +// +VideoListDataModel::VideoListDataModel(QObject *parent) : +QAbstractItemModel(parent), + mCollectionClient(0) +{ + +} + +// --------------------------------------------------------------------------- +// ~VideoListDataModel +// --------------------------------------------------------------------------- +// +VideoListDataModel::~VideoListDataModel() +{ + removeAll(); + + delete mCollectionClient; +} + +// ----------------------------------------------------------------------------- +// initialize +// ----------------------------------------------------------------------------- +// +int VideoListDataModel::initialize() +{ + if(mInitFails) + { + return -1; + } + return 0; +} + +// --------------------------------------------------------------------------- +// mediaIdAtIndex +// --------------------------------------------------------------------------- +// +TMPXItemId &VideoListDataModel::mediaIdAtIndex(int index) const +{ + if( mGetMediaIdAtIndexFails || index < 0 || index >= mData.count()) + { + return gInvalidId; + } + + return mData.at(index)->mId; +} + +// --------------------------------------------------------------------------- +// mediaFilePathForId +// --------------------------------------------------------------------------- +// +QString VideoListDataModel::mediaFilePathForId(int mediaId) const +{ + Q_UNUSED(mediaId); + return mMediaFilePathReturnValue; +} + +// --------------------------------------------------------------------------- +// removeRows +// --------------------------------------------------------------------------- +// +bool VideoListDataModel::removeRows(const QModelIndexList &indexList) +{ + mLastDeletedIndexRow = -1; + if( mRemoveRowsFails ) + return false; + else + { + if(indexList.count() > 0) + { + mLastDeletedIndexRow = indexList.at(indexList.count() - 1).row(); + } + QModelIndexList sortable(indexList); + qSort(sortable); + QModelIndexList::const_iterator iter = sortable.constEnd(); + QModelIndex index; + while(iter != sortable.constBegin()) + { + iter--; + index = (*iter); + beginRemoveRows(QModelIndex(), index.row(), index.row()); + + delete mData.at(index.row()); + mData.removeAt(index.row()); + + endRemoveRows(); + } + + return true; + } +} + +// --------------------------------------------------------------------------- +// getCollectionClient +// --------------------------------------------------------------------------- +// +VideoCollectionClient* VideoListDataModel::getCollectionClient() +{ + if(mGetCollectionClientFails) + { + return 0; + } + + if(!mCollectionClient) + { + mCollectionClient = new VideoCollectionClient(); + } + return mCollectionClient; +} + +// --------------------------------------------------------------------------- +// rowCount +// --------------------------------------------------------------------------- +// +int VideoListDataModel::rowCount(const QModelIndex &parent) const +{ + if (parent.isValid()) + { + return 0; + } + return mData.count(); +} + +// --------------------------------------------------------------------------- +// itemData +// --------------------------------------------------------------------------- +// +QMap VideoListDataModel::itemData(const QModelIndex &index) const +{ + Q_UNUSED(index); + QMap itemData; + + return itemData; +} + +// --------------------------------------------------------------------------- +// data +// --------------------------------------------------------------------------- +// +QVariant VideoListDataModel::data(const QModelIndex & index, int role) const +{ + QVariant returnValue = QVariant(); + if(!index.isValid()) + { + return returnValue; + } + if(mReturnInvalid) + { + return returnValue; + } + int row = index.row(); + if(role == VideoCollectionCommon::KeyTitle) + { + if(row >= 0 && row < mData.count()) + { + returnValue = mData.at(row)->mName; + } + } + else if(role == VideoCollectionCommon::KeySizeValue || + role == VideoCollectionCommon::KeyNumberOfItems) + { + if(row >= 0 && row < mData.count()) + { + returnValue = mData.at(row)->mSize; + } + } + else if(role == VideoCollectionCommon::KeyDateTime) + { + if(row >= 0 && row < mData.count()) + { + returnValue = mData.at(row)->mDate; + } + } + else if(role == VideoCollectionCommon::KeyStatus) + { + if(row >= 0 && row < mData.count()) + { + returnValue = mData.at(row)->mStatus; + } + } + else if(role == INVALID_ROLE_FOR_SORTING) + { + if(row >= 0 && row < mData.count()) + { + returnValue = mData.at(row)->mName; + } + } + return returnValue; +} + +// --------------------------------------------------------------------------- +// columnCount +// --------------------------------------------------------------------------- +// +int VideoListDataModel::columnCount(const QModelIndex & parent) const +{ + if (parent.isValid()) + { + return 0; + } + else + { + return 1; + } +} + +// --------------------------------------------------------------------------- +// index +// --------------------------------------------------------------------------- +// +QModelIndex VideoListDataModel::index(int row, int column, const QModelIndex & parent) const +{ + Q_UNUSED(parent); + if(row >= 0 && row < mData.count()) + { + return createIndex(row, column); + } + return QModelIndex(); +} + +// --------------------------------------------------------------------------- +// parent +// --------------------------------------------------------------------------- +// +QModelIndex VideoListDataModel::parent(const QModelIndex & index) const +{ + Q_UNUSED(index); + return QModelIndex(); +} + +void VideoListDataModel::removeAll() +{ + beginRemoveRows(QModelIndex(), 0,0); + QList::iterator iter = mData.begin(); + while(iter != mData.end()) + { + delete *iter; + ++iter; + } + mData.clear(); + endRemoveRows(); +} + + +// --------------------------------------------------------------------------- +// emitAlbumChanged +// --------------------------------------------------------------------------- +// +void VideoListDataModel::emitAlbumChanged() +{ + emit albumChanged(); +} + +// --------------------------------------------------------------------------- +// appendData +// --------------------------------------------------------------------------- +// +void VideoListDataModel::appendData(TMPXItemId data) +{ + DummyData* obj; + for(int i = 0; i < mData.count(); ++i) + { + obj = mData.at(i); + if(obj->mId == TMPXItemId::InvalidId() || obj->mId.iId1 == data.iId1) + { + obj->mId = data; + QModelIndex change = index(i,0); + emit dataChanged(change, change); + return; + } + } + beginInsertRows(QModelIndex(), mData.count(), mData.count()); + obj = new DummyData; + obj->mId = data; + mData.append(obj); + endInsertRows(); +} + + +// --------------------------------------------------------------------------- +// appendData +// --------------------------------------------------------------------------- +// +void VideoListDataModel::appendData(QString data) +{ + DummyData* obj; + for(int i = 0; i < mData.count(); ++i) + { + obj = mData.at(i); + if(!obj->mName.length()) + { + obj->mName = data; + QModelIndex change = index(i,0); + emit dataChanged(change, change); + return; + } + } + beginInsertRows(QModelIndex(), mData.count(), mData.count()); + obj = new DummyData; + obj->mId = TMPXItemId( mData.count(), 0); + obj->mName = data; + mData.append(obj); + endInsertRows(); +} + +// --------------------------------------------------------------------------- +// appendData +// --------------------------------------------------------------------------- +// +void VideoListDataModel::appendData(uint data) +{ + DummyData* obj; + for(int i = 0; i < mData.count(); ++i) + { + obj = mData.at(i); + if(obj->mSize == 666) + { + obj->mSize = data; + QModelIndex change = index(i,0); + emit dataChanged(change, change); + return; + } + } + beginInsertRows(QModelIndex(), mData.count(), mData.count()); + obj = new DummyData; + obj->mId = TMPXItemId( mData.count(), 0); + obj->mSize = data; + mData.append(obj); + endInsertRows(); +} + +// --------------------------------------------------------------------------- +// appendData +// --------------------------------------------------------------------------- +// +void VideoListDataModel::appendData(QDateTime data) +{ + DummyData* obj; + for(int i = 0; i < mData.count(); ++i) + { + obj = mData.at(i); + if(!obj->mDate.isValid()) + { + obj->mDate = data; + QModelIndex change = index(i,0); + emit dataChanged(change, change); + return; + } + } + beginInsertRows(QModelIndex(), mData.count(), mData.count()); + obj = new DummyData; + obj->mId = TMPXItemId( mData.count(), 0); + obj->mDate = data; + mData.append(obj); + endInsertRows(); +} + +// --------------------------------------------------------------------------- +// appendStatus +// --------------------------------------------------------------------------- +// +void VideoListDataModel::appendStatus(int status) +{ + DummyData* obj; + for(int i = 0; i < mData.count(); ++i) + { + obj = mData.at(i); + if(obj->mStatus == -1) + { + obj->mStatus = status; + QModelIndex change = index(i,0); + emit dataChanged(change, change); + return; + } + } + beginInsertRows(QModelIndex(), mData.count(), mData.count()); + obj = new DummyData; + obj->mId = TMPXItemId( mData.count(), 0); + obj->mStatus = status; + mData.append(obj); + endInsertRows(); +} + +// --------------------------------------------------------------------------- +// setAlbumInUse +// --------------------------------------------------------------------------- +// +void VideoListDataModel::setAlbumInUse(TMPXItemId itemId) +{ + mAlbumInUse = itemId; +} + +// --------------------------------------------------------------------------- +// albumInUse +// --------------------------------------------------------------------------- +// +TMPXItemId VideoListDataModel::albumInUse() +{ + return mAlbumInUse; +} + +// --------------------------------------------------------------------------- +// belongsToAlbum +// --------------------------------------------------------------------------- +// +bool VideoListDataModel::belongsToAlbum(TMPXItemId itemId, TMPXItemId albumId ) +{ + Q_UNUSED(itemId); + Q_UNUSED(albumId); + return mBelongsToAlbum; +} + +// --------------------------------------------------------------------------- +// removeItemsFromAlbum +// --------------------------------------------------------------------------- +// +int VideoListDataModel::removeItemsFromAlbum(TMPXItemId &albumId, const QList &items) +{ + Q_UNUSED(albumId); + Q_UNUSED(items); + return mRemoveFrAlbumReturn; +} + +// --------------------------------------------------------------------------- +// indexOfId +// --------------------------------------------------------------------------- +// +QModelIndex VideoListDataModel::indexOfId(TMPXItemId id) +{ + QModelIndex itemIndex; + DummyData* obj; + for(int i = 0; i < mData.count(); ++i) + { + obj = mData.at(i); + if(obj->mId == id) + { + itemIndex = index(i,0,QModelIndex()); + break; + } + } + return itemIndex; +} + +// End of file + + + diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/stub/src/videothumbnaildata.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/stub/src/videothumbnaildata.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CVideoThumbnailData class implementation +* +*/ + +// INCLUDE FILES +#include +#include +#include +#include +#include + +#include "videothumbnaildata.h" + +int VideoThumbnailData::mEnableBackgroundThumbnailFetchingCallCount = 0; +int VideoThumbnailData::mStartFetchingThumbnailsCallCount = 0; +int VideoThumbnailData::mStartFetchingThumbnailsThumbnailCount = 0; +int VideoThumbnailData::mInstanceCallCount = 0; +int VideoThumbnailData::mBackgroundThumbnailFetchingEnabled = true; +int VideoThumbnailData::mFreeThumbnailDataCallCount = 0; +int VideoThumbnailData::mStartBackgroundFetchingCallCount = 0; + +// ----------------------------------------------------------------------------- +// VideoThumbnailData::instance() +// ----------------------------------------------------------------------------- +// +VideoThumbnailData &VideoThumbnailData::instance() +{ + mInstanceCallCount++; + static VideoThumbnailData _thumbnailData; + return _thumbnailData; +} + +// ----------------------------------------------------------------------------- +// VideoThumbnailData::VideoThumbnailData() +// ----------------------------------------------------------------------------- +// +VideoThumbnailData::VideoThumbnailData() +{ + +} + +// ----------------------------------------------------------------------------- +// VideoThumbnailData::~VideoThumbnailData() +// ----------------------------------------------------------------------------- +// +VideoThumbnailData::~VideoThumbnailData() +{ + +} + +// ----------------------------------------------------------------------------- +// VideoThumbnailData::startBackgroundFetching() +// ----------------------------------------------------------------------------- +// +void VideoThumbnailData::startBackgroundFetching(VideoProxyModelGeneric *model, int fetchIndex) +{ + Q_UNUSED(model); + Q_UNUSED(fetchIndex); + mStartBackgroundFetchingCallCount++; +} + +// ----------------------------------------------------------------------------- +// VideoThumbnailData::enableBackgroundFetching() +// ----------------------------------------------------------------------------- +// +void VideoThumbnailData::enableBackgroundFetching(bool enable) +{ + mBackgroundThumbnailFetchingEnabled = enable; + mEnableBackgroundThumbnailFetchingCallCount++; +} + +// ----------------------------------------------------------------------------- +// VideoThumbnailData::freeThumbnailData() +// ----------------------------------------------------------------------------- +// +void VideoThumbnailData::freeThumbnailData() +{ + mFreeThumbnailDataCallCount++; +} + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/testvideoproxymodelgeneric.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideoproxymodelgeneric/testvideoproxymodelgeneric.pro Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,43 @@ +# ##################################################################### +# Automatically generated by qmake (2.01a) Tue 5. May 13:25:42 2009 +# ##################################################################### +TEMPLATE = app +TARGET = +DEFINES += BUILD_VIDEOCOLLECTION_DLL +DEPENDPATH += . \ + inc \ + src +INCLUDEPATH += . \ + /epoc32/include/domain \ + /epoc32/include/domain/middleware \ + /epoc32/include/domain/applications \ + /epoc32/include/osextensions \ + /epoc32/include/middleware \ + /epoc32/include/osextensions/stdapis/stlport \ + ../../../inc + +CONFIG += qtestlib \ + Hb \ + symbian_test + +LIBS += -lestor.dll \ + -lfbscli.dll \ + -lbitgdi.dll \ + -lgdi.dll + +# Input +HEADERS += inc/testvideoproxymodelgeneric.h \ + stub/inc/filterproxytester.h \ + stub/inc/videolistdatamodel.h \ + stub/inc/videocollectionclient.h \ + stub/inc/videothumbnaildata.h \ + stub/inc/videocollectionwrapper.h \ + ../../inc/videoproxymodelgeneric.h \ + ../../../inc/videocollectionexport.h + +SOURCES += src/testvideoproxymodelgeneric.cpp \ + stub/src/filterproxytester.cpp \ + stub/src/videolistdatamodel.cpp \ + stub/src/videocollectionclient.cpp \ + stub/src/videothumbnaildata.cpp \ + ../../src/videoproxymodelgeneric.cpp diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/inc/testvideosortfilterproxymodel.h --- a/videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/inc/testvideosortfilterproxymodel.h Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,290 +0,0 @@ -/** -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: tester for methods in VideoSortFilterProxyModel -* -*/ - -#ifndef __TESTVIDEOSORTFILTERPROXYMODEL_H__ -#define __TESTVIDEOSORTFILTERPROXYMODEL_H__ - - -// INCLUDES -#include -#include - -class VideoListDataModel; -class FilterProxyTester; -class VideoCollectionClient; -class VideoSortFilterProxyModel; - -class TestVideoSortFilterProxyModel : public QObject -{ - Q_OBJECT - - // test functions for the test framework - -signals: - - /** - * test signal - */ - void testSignal(); - - /** - * test signal - */ - void testSignalMpxId(const TMPXItemId &id); - -private slots: - - /** - * will be called before each testfunction is executed. - * - */ - void init(); - - /** - * will be called after every testfunction. - * - */ - void cleanup(); - - /** - * Test initialize with valid data. - */ - void testInitialize(); - - /** - * Test initialize with null model causing connect to fail. - */ - void testInitializeSignalConnectFail(); - - /** - * Test second call to initialize with valid data. - */ - void testSecondInitialize(); - - /** - * Test open. - */ - void testOpen(); - - /** - * Test deleteItems with valid data. - */ - void testDeleteItems(); - - /** - * Test deleteItems with NULL model. - */ - void testDeleteItemsModelNull(); - - /** - * Test deleteItems when removeRows fails. - */ - void testDeleteItemsRemoveRowsFail(); - - /** - * Test openItem when getMediaId fails. - */ - void testOpenItemInvalidId(); - - /** - * Test openItem when collection is NULL. - */ - void testOpenItemCollectionNull(); - - /** - * Test openItem when openVideo fails. - */ - void testOpenItemOpenVideoFails(); - - /** - * Test openItem with valid data. - */ - void testOpenItem(); - - /** - * Test back with valid data. - */ - void testBack(); - - /** - * Test fetchItemDetails with valid data. - */ - void testFetchItemDetails(); - - /** - * Test fetchItemDetails when getMediaId fails. - */ - void testFetchItemDetailsGetMediaIdFail(); - - /** - * Test fetchItemDetails when getVideoDetails fails. - */ - void testFetchItemDetailsGetVideoDetailsFails(); - - /** - * Test lessThan when there's no mModel. - */ - void testLessThanNoModel(); - - /** - * Calls sure lessThan with Qt::DisplayRole setted on - * tests that return values are correct for presetted items - */ - void testLessThanName(); - - /** - * Calls sure lessThan with VideoCollectionCommon::KeySizeValue setted on - * tests that return values are correct for presetted items - */ - void testLessThanSize(); - - /** - * Calls sure lessThan with VideoCollectionCommon::KeyDate setted on - * tests that return values are correct for presetted items - */ - void testLessThanDateTime(); - - /** - * Calls less than with media objects of combined default / user created - * collections - */ - void testLessThanDefaults(); - - /** - * Calls sure lessThan with invalid role, - * same indexes and for invalid data - * tests that return values are correct for presetted items - */ - void testLessThanInvalid(); - - /** - * Calls doSorting. - * tests that sorting is done only once - */ - void testDoSorting(); - - /** - * Calls filterAcceptsRow. using type EAllVideos for model - * Tests that return values are correct with items with varying statuses. - * - */ - void testFilterAcceptsRowVideos(); - - /** - * Calls filterAcceptsRow. using type differ than EAllVideos for model - * Tests that return values are correct with items with varying statuses. - * - */ - void testFilterAcceptsNoVideoTypes(); - - /** - * Test getMediaFilePathForId. - */ - void testGetMediaFilePathForId(); - - /** - * Tests calling addNewCollection when initialize has not been called. - */ - void testAddNewCollectionNoCollectionClient(); - - /** - * Tests calling addNewCollection where collection client returns 0. - */ - void testAddNewCollectionSucceed(); - - /** - * tests resolveAlbumName - */ - void testResolveAlbumName(); - - /** - * tests addItemsInAlbum - */ - void testAddItemsInAlbum(); - - /** - * tests removeItemsFromAlbum - */ - void testRemoveItemsFromAlbum(); - - /** - * tests getOpenItem - */ - void testGetOpenItem(); - - /** - * tests removeAlbums - */ - void testRemoveAlbums(); - - /** - * tests albumChangedSlot - */ - void testAlbumChangedSlot(); - - /** - * tests indexOfId - */ - void testIndexOfId(); - - /** - * tests setGenericIdFilter - */ - void testSetGenericIdFilter(); - - /** - * tests setAlbumInUse - */ - void testSetAlbumInUse(); - - /** - * tests renameItem - */ - void testRenameItem(); - - -private: - - /** - * stub videolist model - */ - VideoListDataModel *mStubModel; - - /** - * stub CVideoCollectionClient. - */ - VideoCollectionClient *mCollectionClient; - - /** - * tester object inherited from the actual test object - * implemented to be able to call protected objects - */ - FilterProxyTester *mTestObject; - - /** - * dummy collections content proxy - */ - VideoSortFilterProxyModel *mCollectionModel; -}; - - -#endif // __TESTVIDEOSORTFILTERPROXYMODEL_H__ - -// End of file - - - diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/src/testvideosortfilterproxymodel.cpp --- a/videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/src/testvideosortfilterproxymodel.cpp Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1522 +0,0 @@ -/** -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: tester for methods in VideoSortFilterProxyModel -* -*/ - -#include -#include -#include - -#define private public -#include "videosortfilterproxymodel.h" -#undef private - -#include "videocollectionwrapper.h" -#include "videocollectioncommon.h" -#include "testvideosortfilterproxymodel.h" -#include "videolistdatamodel.h" -#include "videocollectionclient.h" -#include "videocollectioncommon.h" -#include "videothumbnaildata.h" -#include "filterproxytester.h" - -// --------------------------------------------------------------------------- -// main -// --------------------------------------------------------------------------- -// -int main(int argc, char *argv[]) -{ - HbApplication app(argc, argv); - - TestVideoSortFilterProxyModel tv; - - int res; - if(argc > 1) - { - res = QTest::qExec(&tv, argc, argv); - } - else - { - char *pass[3]; - pass[0] = argv[0]; - pass[1] = "-o"; - pass[2] = "c:\\data\\testvideosortfilterproxymodel.txt"; - res = QTest::qExec(&tv, 3, pass); - } - - return res; -} - -// --------------------------------------------------------------------------- -// init -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::init() -{ - qRegisterMetaType("TMPXItemId"); - - VideoListDataModel::mInitFails = false; - VideoListDataModel::mRemoveRowsFails = false; - VideoListDataModel::mGetMediaIdAtIndexFails = false; - VideoCollectionClient::mFailMediaPlayback = false; - VideoCollectionClient::mFailMediaDetails = false; - VideoCollectionClient::mFailInit = false; - VideoCollectionClient::mFailAddNewCollection = false; - VideoCollectionClient::mSortOrderSetCount = 0; - VideoCollectionClient::mAddNewCollectionName = QString(); - VideoCollectionClient::mAddNewCollectionThumb = QString(); - VideoCollectionClient::mAddNewCollectionIds = QList(); - VideoThumbnailData::mStartBackgroundFetchingCallCount = 0; - - mTestObject = new FilterProxyTester(VideoCollectionCommon::EModelTypeGeneric); - QVERIFY(mTestObject); - - mStubModel = new VideoListDataModel(); - QVERIFY(mStubModel); - - mCollectionClient = new VideoCollectionClient(); - QVERIFY(mCollectionClient); - - mCollectionModel = new VideoSortFilterProxyModel(VideoCollectionCommon::EModelTypeAllVideos); -} - -// --------------------------------------------------------------------------- -// cleanup -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::cleanup() -{ - delete mCollectionClient; - mCollectionClient = 0; - - delete mStubModel; - mStubModel = 0; - - delete mTestObject; - mTestObject = 0; - - delete mCollectionModel; - mCollectionModel = 0; -} - -// --------------------------------------------------------------------------- -// testInitialize -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testInitialize() -{ - QVERIFY(mTestObject->initialize(mStubModel) == 0); -} - -// --------------------------------------------------------------------------- -// testInitializeSignalConnectFail -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testInitializeSignalConnectFail() -{ - QVERIFY(mTestObject->initialize(NULL) == -1); -} - -// --------------------------------------------------------------------------- -// testSecondInitialize -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testSecondInitialize() -{ - QVERIFY(mTestObject->initialize(mStubModel) == 0); - QVERIFY(mTestObject->initialize(mStubModel) == 0); -} - -// --------------------------------------------------------------------------- -// testOpen -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testOpen() -{ - // no mCollectionClient - QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelInvalid) == -1); - - mTestObject->initialize(mStubModel); - - // First open. - QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == 0); - // Open again with same level. - QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == 0); - // Fail open. - VideoCollectionClient::mFailStartOpen = true; - QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == -1); -} - -// --------------------------------------------------------------------------- -// testDeleteItems -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testDeleteItems() -{ - VideoThumbnailData::mEnableBackgroundThumbnailFetchingCallCount = 0; - VideoCollectionClient::mFailStartOpen = false; - QVERIFY(mTestObject->initialize(mStubModel) == 0); - QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == 0); - QString name1 = "cc"; - QString name2 = "bb"; - QString name3 = "aa"; - QString name4 = "11"; - QString name5 = "12"; - - mStubModel->appendData(name1); // to source model index 0, proxy index after sort 4 - mStubModel->appendData(name2); // to source model index 1, proxy index after sort 3 - mStubModel->appendData(name3); // to source model index 2, proxy index after sort 2 - mStubModel->appendData(name4); // to source model index 3, proxy index after sort 0 - mStubModel->appendData(name5); // to source model index 4, proxy index after sort 1 - - // sort to make sure that list order is different compared to source model - mTestObject->doSorting(VideoCollectionCommon::KeyTitle, Qt::AscendingOrder); - // need to wait for awhile to make sure zero-counter gets - // processing time. - QTest::qWait(500); - QVERIFY(mTestObject->sortRole() == VideoCollectionCommon::KeyTitle); - - int count = mTestObject->rowCount(); - QModelIndexList list; - QModelIndex index; - for(int i = 0; i < 5; ++i) - { - index = mTestObject->index(i,0); - list.append(index); - } - QModelIndexList emptyList; - VideoThumbnailData::mStartBackgroundFetchingCallCount = 0; - QVERIFY(mTestObject->deleteItems(emptyList) == 0); - QCOMPARE(VideoThumbnailData::mEnableBackgroundThumbnailFetchingCallCount, 2); - QVERIFY(VideoThumbnailData::mBackgroundThumbnailFetchingEnabled == true); - QVERIFY(mTestObject->deleteItems(list) == 0); - QCOMPARE(VideoThumbnailData::mEnableBackgroundThumbnailFetchingCallCount, 4); - QVERIFY(VideoThumbnailData::mBackgroundThumbnailFetchingEnabled == true); - QVERIFY(mStubModel->mLastDeletedIndexRow == 0); - QVERIFY(VideoThumbnailData::mStartBackgroundFetchingCallCount == 2); -} - -// --------------------------------------------------------------------------- -// testDeleteItemsModelNull -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testDeleteItemsModelNull() -{ - mStubModel->appendData("Test"); - QVERIFY(mTestObject->initialize(NULL) == -1); - - QModelIndex index = mStubModel->index(0, 0); - QModelIndexList list; - list.append(index); - - QVERIFY(mTestObject->deleteItems(list) == -1); -} - -// --------------------------------------------------------------------------- -// testDeleteItemsRemoveRowsFail -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testDeleteItemsRemoveRowsFail() -{ - VideoListDataModel::mRemoveRowsFails = true; - VideoCollectionClient::mFailStartOpen = false; - QVERIFY(mTestObject->initialize(mStubModel) == 0); - QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == 0); - - mStubModel->appendData("Test"); - - QVERIFY(mTestObject->initialize(mStubModel) == 0); - - QModelIndex index = mTestObject->index(0, 0); - QModelIndexList list; - list.append(index); - - QVERIFY(mTestObject->deleteItems(list) == -1); -} - -// --------------------------------------------------------------------------- -// testOpenItemInvalidId -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testOpenItemInvalidId() -{ - VideoListDataModel::mGetMediaIdAtIndexFails = true; - VideoCollectionClient::mFailStartOpen = false; - QVERIFY(mTestObject->initialize(mStubModel) == 0); - QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == 0); - - mStubModel->appendData("Test"); - - QVERIFY(mTestObject->initialize(mStubModel) == 0); - QModelIndex index = mTestObject->index(0, 0); - TMPXItemId itemId = TMPXItemId::InvalidId(); - - QVERIFY(mTestObject->openItem(itemId) == -1); -} - -// --------------------------------------------------------------------------- -// testOpenItemCollectionNull -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testOpenItemCollectionNull() -{ - mStubModel->appendData("Test"); - - TMPXItemId itemId(1,0); - - QVERIFY(mTestObject->openItem(itemId) == -1); -} - -// --------------------------------------------------------------------------- -// testOpenItemOpenVideoFails -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testOpenItemOpenVideoFails() -{ - VideoCollectionClient::mFailMediaPlayback = true; - - mStubModel->appendData("Test"); - QVERIFY(mTestObject->initialize(mStubModel) == 0); - TMPXItemId itemId(1,0); - - QVERIFY(mTestObject->openItem(itemId) == -1); - - VideoCollectionClient::mFailMediaPlayback = false; -} - -// --------------------------------------------------------------------------- -// testOpenItem -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testOpenItem() -{ - mStubModel->appendData("Test"); - QVERIFY(mTestObject->initialize(mStubModel) == 0); - TMPXItemId itemId(1,0); - - // open video - QVERIFY(mTestObject->openItem(itemId) == 0); - - // open category or album - itemId = TMPXItemId(1,2); - QVERIFY(mTestObject->openItem(itemId) == 0); -} - -// --------------------------------------------------------------------------- -// testBack -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testBack() -{ - QVERIFY(mTestObject->back() == -1); - - QVERIFY(mTestObject->initialize(mStubModel) == 0); - - QVERIFY(mTestObject->back() == 0); - - mTestObject->open(VideoCollectionCommon::ELevelAlbum); - QVERIFY(mTestObject->back() == 0); - - // back fails - VideoCollectionClient::mBackReturnValue = -1; - QVERIFY(mTestObject->back() == -1); - - VideoCollectionClient::mBackReturnValue = 0; -} - -// --------------------------------------------------------------------------- -// testFetchItemDetails -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testFetchItemDetails() -{ - VideoCollectionClient::mFailStartOpen = false; - mStubModel->appendData("Test"); - QVERIFY(mTestObject->initialize(mStubModel) == 0); - mTestObject->open(VideoCollectionCommon::ELevelVideos); - QSignalSpy fetchSpy(mTestObject, SIGNAL(shortDetailsReady(TMPXItemId))); - - QModelIndex index = mTestObject->index(0, 0); - - QList arguments; - QVERIFY(mTestObject->fetchItemDetails(index) == 0); - - QVERIFY(fetchSpy.count() == 1); - arguments = fetchSpy.takeFirst(); - QVERIFY(arguments.at(0).toInt() == 0); - arguments.clear(); - fetchSpy.clear(); - - // no collection client - VideoCollectionClient *tmp = mTestObject->mCollectionClient; - mTestObject->mCollectionClient = 0; - QVERIFY(mTestObject->fetchItemDetails(index) == -1); - mTestObject->mCollectionClient = tmp; -} - -// --------------------------------------------------------------------------- -// testFetchItemDetails -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testFetchItemDetailsGetMediaIdFail() -{ - VideoListDataModel::mGetMediaIdAtIndexFails = true; - QSignalSpy fetchSpy(mTestObject, SIGNAL(shortDetailsReady(TMPXItemId))); - mStubModel->appendData("Test"); - QModelIndex index = mTestObject->index(0, 0); - - // no model - QVERIFY(mTestObject->fetchItemDetails(index) == -1); - - QVERIFY(mTestObject->initialize(mStubModel) == 0); - - QVERIFY(mTestObject->fetchItemDetails(index) == -1); - - QVERIFY(fetchSpy.count() == 0); -} - -// --------------------------------------------------------------------------- -// testFetchItemDetails -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testFetchItemDetailsGetVideoDetailsFails() -{ - VideoCollectionClient::mFailMediaDetails = true; - - QVERIFY(mTestObject->initialize(mStubModel) == 0); - mTestObject->open(VideoCollectionCommon::ELevelVideos); - mStubModel->appendData("Test"); - - QSignalSpy fetchSpy(mTestObject, SIGNAL(shortDetailsReady(TMPXItemId))); - QModelIndex index = mTestObject->index(0, 0); - - QVERIFY(mTestObject->fetchItemDetails(index) == -1); - - QVERIFY(fetchSpy.count() == 0); -} - -// --------------------------------------------------------------------------- -// testLessThanProxyModelNotInitialized -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testLessThanNoModel() -{ - // "normal" comparisation - QString name1 = "cc"; - QString name2 = "bb"; - QString name3 = "aa"; - QString name4 = "11"; - QString name5 = "11"; - - mStubModel->appendData(name1); // to index 0, position 4 - mStubModel->appendData(name2); // to index 1, position 3 - mStubModel->appendData(name3); // to index 2, position 2 - mStubModel->appendData(name4); // to index 3, position 0 or 1 - mStubModel->appendData(name5); // to index 4, position 0 or 1 - - mTestObject->setSortRole(VideoCollectionCommon::KeyTitle); - - QModelIndex left = mStubModel->index(0,0); - QModelIndex right = mStubModel->index(1,0); - - QVERIFY(!mTestObject->callLessThan(left, right)); -} -// --------------------------------------------------------------------------- -// testLessThanName -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testLessThanName() -{ - VideoCollectionClient::mFailStartOpen = false; - QVERIFY(mTestObject->initialize(mStubModel) == 0); - QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == 0); - - // "normal" comparisation - QString name1 = "cc"; - QString name2 = "bb"; - QString name3 = "aa"; - QString name4 = "11"; - QString name5 = "11"; - - mStubModel->appendData(name1); // to index 0, position 4 - mStubModel->appendData(name2); // to index 1, position 3 - mStubModel->appendData(name3); // to index 2, position 2 - mStubModel->appendData(name4); // to index 3, position 0 or 1 - mStubModel->appendData(name5); // to index 4, position 0 or 1 - - mTestObject->setSortRole(VideoCollectionCommon::KeyTitle); - - QModelIndex left = mStubModel->index(0,0); - QModelIndex right = mStubModel->index(1,0); - - QVERIFY(!mTestObject->callLessThan(left, right)); - - left = mStubModel->index(1,0); - right = mStubModel->index(2,0); - - QVERIFY(!mTestObject->callLessThan(left, right)); - - left = mStubModel->index(2,0); - right = mStubModel->index(3,0); - - QVERIFY(!mTestObject->callLessThan(left, right)); - - left = mStubModel->index(3,0); - right = mStubModel->index(4,0); - QVERIFY(!mTestObject->callLessThan(left, right)); - - left = mStubModel->index(4,0); - right = mStubModel->index(0,0); - - QVERIFY(mTestObject->callLessThan(left, right)); - - // reset model - mStubModel->removeAll();; - - // case sensitive check - name1 = "cc"; - name2 = "CC"; - name3 = "cC"; - name4 = "aa"; - name5 = "Aa"; - QString name6 = "2Aa"; - QString name7 = "1Aa"; - QString name8 = "1cc"; - mStubModel->removeAll(); - mStubModel->appendData(name1); // to index 0, position can be 5, 6 or 7 - mStubModel->appendData(name2); // to index 1, position can be 5, 6 or 7 - mStubModel->appendData(name3); // to index 2, position can be 5, 6 or 7 - mStubModel->appendData(name4); // to index 3, position can be 3 or 4 - mStubModel->appendData(name5); // to index 4, position can be 3 or 4 - mStubModel->appendData(name6); // to index 5, position is 2 - mStubModel->appendData(name7); // to index 6, position is 0 - mStubModel->appendData(name8); // to index 7, position is 1 - - mTestObject->setSortRole(VideoCollectionCommon::KeyTitle); - - left = mStubModel->index(0,0); // "cc" - right = mStubModel->index(1,0); // "CC" - - QVERIFY(!mTestObject->callLessThan(left, right)); - - left = mStubModel->index(1,0); // "CC" - right = mStubModel->index(2,0); // "cC" - - QVERIFY(!mTestObject->callLessThan(left, right)); - - left = mStubModel->index(2,0); // "cC" - right = mStubModel->index(3,0); // "aa" - - QVERIFY(!mTestObject->callLessThan(left, right)); - - left = mStubModel->index(3,0); // "aa" - right = mStubModel->index(2,0); // "cC" - - QVERIFY(mTestObject->callLessThan(left, right)); - - left = mStubModel->index(3,0); // "aa" - right = mStubModel->index(4,0); // "Aa" - QVERIFY(!mTestObject->callLessThan(left, right)); - - left = mStubModel->index(4,0); // "Aa" - right = mStubModel->index(5,0); // "2Aa" - - QVERIFY(!mTestObject->callLessThan(left, right)); - - left = mStubModel->index(5,0); // "2Aa" - right = mStubModel->index(6,0); // "1Aa" - QVERIFY(!mTestObject->callLessThan(left, right)); - - left = mStubModel->index(6,0); // "1Aa" - right = mStubModel->index(7,0); // "1cc" - QVERIFY(mTestObject->callLessThan(left, right)); - - left = mStubModel->index(5,0); // "2Aa" - right = mStubModel->index(7,0); // "1cc" - QVERIFY(!mTestObject->callLessThan(left, right)); - - left = mStubModel->index(7,0); // "1cc" - right = mStubModel->index(0,0); // "cc" - QVERIFY(mTestObject->callLessThan(left, right)); -} - -// --------------------------------------------------------------------------- -// testLessThanSize -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testLessThanSize() -{ - VideoCollectionClient::mFailStartOpen = false; - QVERIFY(mTestObject->initialize(mStubModel) == 0); - QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == 0); - - quint32 size1 = 300; - quint32 size2 = 200; - quint32 size3 = 100; - quint32 size4 = 99; - quint32 size5 = 99; - - mStubModel->appendData(size1); // to index 0 - mStubModel->appendData(size2); // to index 1 - mStubModel->appendData(size3); // to index 2 - mStubModel->appendData(size4); // to index 3 - mStubModel->appendData(size5); // to index 4 - - mTestObject->setSortRole(VideoCollectionCommon::KeySizeValue); - - QModelIndex left = mStubModel->index(0,0); - QModelIndex right = mStubModel->index(1,0); - - QVERIFY(!mTestObject->callLessThan(left, right)); - - left = mStubModel->index(1,0); - right = mStubModel->index(2,0); - - QVERIFY(!mTestObject->callLessThan(left, right)); - - left = mStubModel->index(2,0); - right = mStubModel->index(3,0); - - QVERIFY(!mTestObject->callLessThan(left, right)); - - left = mStubModel->index(3,0); - right = mStubModel->index(4,0); - - QVERIFY(!mTestObject->callLessThan(left, right)); - - left = mStubModel->index(4,0); - right = mStubModel->index(0,0); - - QVERIFY(mTestObject->callLessThan(left, right)); -} - -// --------------------------------------------------------------------------- -// testLessThanDate -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testLessThanDateTime() -{ - VideoCollectionClient::mFailStartOpen = false; - QVERIFY(mTestObject->initialize(mStubModel) == 0); - QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == 0); - - QDateTime date1(QDate(2010, 11, 5), QTime(0,0)); - QDateTime date2(QDate(2009, 9, 5), QTime(0,0)); - QDateTime date3(QDate(2009, 9, 4), QTime(0,0)); - QDateTime date4(QDate(2008, 9, 6), QTime(0,0)); - QDateTime date5(QDate(2008, 9, 6), QTime(0,0)); - - mStubModel->appendData(date1); // to index 0 - mStubModel->appendData(date2); // to index 1 - mStubModel->appendData(date3); // to index 2 - mStubModel->appendData(date4); // to index 3 - mStubModel->appendData(date5); // to index 4 - - mTestObject->setSortRole(VideoCollectionCommon::KeyDateTime); - - QModelIndex left = mStubModel->index(0,0); - QModelIndex right = mStubModel->index(1,0); - - QVERIFY(mTestObject->callLessThan(left, right)); - - left = mStubModel->index(1,0); - right = mStubModel->index(2,0); - - QVERIFY(mTestObject->callLessThan(left, right)); - - left = mStubModel->index(2,0); - right = mStubModel->index(3,0); - - QVERIFY(mTestObject->callLessThan(left, right)); - - left = mStubModel->index(3,0); - right = mStubModel->index(4,0); - - QVERIFY(!mTestObject->callLessThan(left, right)); - - left = mStubModel->index(4,0); - right = mStubModel->index(0,0); - - QVERIFY(!mTestObject->callLessThan(left, right)); -} - -// --------------------------------------------------------------------------- -// testLessThanDefaults -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testLessThanDefaults() -{ - VideoCollectionClient::mFailStartOpen = false; - QVERIFY(mTestObject->initialize(mStubModel) == 0); - QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelCategory) == 0); - - // Default categories (KVcxMvcMediaTypeCategory) - // are always first in the following order: - // Recently played (missing currently - // Captured (KVcxMvcCategoryIdCaptured) - // Downloaded (KVcxMvcCategoryIdDownloads) - // Podcasts (missing currently) - mStubModel->appendData(TMPXItemId(20, KVcxMvcMediaTypeAlbum)); // to source index 0 - mStubModel->appendData(TMPXItemId(KVcxMvcCategoryIdDownloads, KVcxMvcMediaTypeCategory)); // to source index 1 - mStubModel->appendData(TMPXItemId(KVcxMvcCategoryIdCaptured, KVcxMvcMediaTypeCategory)); // to source index 2 - mStubModel->appendData(TMPXItemId(100, KVcxMvcMediaTypeCategory)); // to source index 3 - mStubModel->appendData(TMPXItemId(101, KVcxMvcMediaTypeCategory)); // to source index 4 - - // left & right are KVcxMvcMediaTypeCategory - // -> left == KVcxMvcCategoryIdCaptured - QModelIndex left = mStubModel->index(2,0); - QModelIndex right = mStubModel->index(1,0); - // call doSorting to setup sorting order - mTestObject->mWantedSortOrder = Qt::AscendingOrder; - QVERIFY(mTestObject->callLessThan(left, right)); - // call doSorting to setup sorting order - mTestObject->mWantedSortOrder = Qt::DescendingOrder; - QVERIFY(!mTestObject->callLessThan(left, right)); - - // -> left == KVcxMvcCategoryIdDownloads - left = mStubModel->index(1,0); - // -> right == KVcxMvcCategoryIdCaptured - right = mStubModel->index(2,0); - mTestObject->mWantedSortOrder = Qt::AscendingOrder; - QVERIFY(!mTestObject->callLessThan(left, right)); - mTestObject->mWantedSortOrder = Qt::DescendingOrder; - QVERIFY(mTestObject->callLessThan(left, right)); - - // -> right != KVcxMvcCategoryIdCaptured - right = mStubModel->index(3,0); - mTestObject->mWantedSortOrder = Qt::AscendingOrder; - QVERIFY(mTestObject->callLessThan(left, right)); - mTestObject->mWantedSortOrder = Qt::DescendingOrder; - QVERIFY(!mTestObject->callLessThan(left, right)); - - // both are KVcxMvcMediaTypeCategory but netiher KVcxMvcCategoryIdCaptured - // nor KVcxMvcCategoryIdDownloads - left = mStubModel->index(3,0); - right = mStubModel->index(4,0); - mTestObject->mWantedSortOrder = Qt::AscendingOrder; - QVERIFY(!mTestObject->callLessThan(left, right)); - mTestObject->mWantedSortOrder = Qt::DescendingOrder; - QVERIFY(mTestObject->callLessThan(left, right)); - - // Left is KVcxMvcMediaTypeCategory and right is not - left = mStubModel->index(1,0); - right = mStubModel->index(0,0); - mTestObject->mWantedSortOrder = Qt::AscendingOrder; - QVERIFY(mTestObject->callLessThan(left, right)); - mTestObject->mWantedSortOrder = Qt::DescendingOrder; - QVERIFY(!mTestObject->callLessThan(left, right)); - - // right is KVcxMvcMediaTypeCategory and left is not - left = mStubModel->index(0,0); - right = mStubModel->index(1,0); - mTestObject->mWantedSortOrder = Qt::AscendingOrder; - QVERIFY(!mTestObject->callLessThan(left, right)); - mTestObject->mWantedSortOrder = Qt::DescendingOrder; - QVERIFY(mTestObject->callLessThan(left, right)); -} - -// --------------------------------------------------------------------------- -// testLessThanInvalid -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testLessThanInvalid() -{ - VideoCollectionClient::mFailStartOpen = false; - QVERIFY(mTestObject->initialize(mStubModel) == 0); - QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == 0); - - // invalid role - mTestObject->setSortRole(10000); - - QModelIndex left = mStubModel->index(0,0); - QModelIndex right = mStubModel->index(0,0); - - QVERIFY(!mTestObject->callLessThan(left, right)); - - // invalid role but valid data. - - QString name1 = "cc"; - QString name2 = "bb"; - QString name3 = "aa"; - - mStubModel->appendData(name1); // to index 0, position 4 - mStubModel->appendData(name2); // to index 1, position 3 - mStubModel->appendData(name3); // to index 2, position 2 - - mTestObject->setSortRole(INVALID_ROLE_FOR_SORTING); - - left = mStubModel->index(0,0); - right = mStubModel->index(1,0); - - QVERIFY(!mTestObject->callLessThan(left, right)); - - // invalid left index - mTestObject->setSortRole(VideoCollectionCommon::KeyTitle); - - left = QModelIndex(); - right = mStubModel->index(0,0); - - QVERIFY(!mTestObject->callLessThan(left, right)); - - // invalid right index - mTestObject->setSortRole(VideoCollectionCommon::KeyTitle); - User::Heap().__DbgMarkStart(); - left = mStubModel->index(0,0); - right = QModelIndex(); - - QVERIFY(!mTestObject->callLessThan(left, right)); - - // both invalid - mTestObject->setSortRole(VideoCollectionCommon::KeyTitle); - User::Heap().__DbgMarkStart(); - left = QModelIndex(); - right = QModelIndex(); - - QVERIFY(!mTestObject->callLessThan(left, right)); - - // both same index, use size - quint32 size1 = 99; - - mStubModel->appendData(size1); // to index 0 - - mTestObject->setSortRole(VideoCollectionCommon::KeySizeValue); - mTestObject->setSortRole(VideoCollectionCommon::KeyTitle); - - left = mStubModel->index(0,0); - right = mStubModel->index(0,0); - QVERIFY(!mTestObject->callLessThan(left, right)); -} - -// --------------------------------------------------------------------------- -// testDoSorting -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testDoSorting() -{ - VideoCollectionClient::mFailStartOpen = false; - QVERIFY(mTestObject->initialize(mStubModel) == 0); - QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == 0); - - // these signals are emitted during sorting procedure from the fw - QSignalSpy spyAboutToChange(mTestObject, SIGNAL(layoutAboutToBeChanged())); - QSignalSpy spyChanged(mTestObject, SIGNAL(layoutChanged())); - QSignalSpy spySorted(mTestObject, SIGNAL(modelSorted())); - - QString name1 = "cc"; - QString name2 = "bb"; - QString name3 = "aa"; - QString name4 = "11"; - QString name5 = "11"; - QDateTime date1(QDate(2010, 11, 5), QTime(0,0)); - QDateTime date2(QDate(2009, 9, 5), QTime(0,0)); - QDateTime date3(QDate(2009, 9, 4), QTime(0,0)); - QDateTime date4(QDate(2008, 9, 6), QTime(0,0)); - QDateTime date5(QDate(2008, 9, 6), QTime(0,0)); - quint32 size1 = 300; - quint32 size2 = 200; - quint32 size3 = 100; - quint32 size4 = 99; - quint32 size5 = 99; - - mStubModel->appendData(name1); // to index 0, position 4 - mStubModel->appendData(name2); // to index 1, position 3 - mStubModel->appendData(name3); // to index 2, position 2 - mStubModel->appendData(name4); // to index 3, position 0 or 1 - mStubModel->appendData(name5); // to index 4, position 0 or 1 - - mStubModel->appendData(date1); // to index 0 - mStubModel->appendData(date2); // to index 1 - mStubModel->appendData(date3); // to index 2 - mStubModel->appendData(date4); // to index 3 - mStubModel->appendData(date5); // to index 4 - - mStubModel->appendData(size1); // to index 0 - mStubModel->appendData(size2); // to index 1 - mStubModel->appendData(size3); // to index 2 - mStubModel->appendData(size4); // to index 3 - mStubModel->appendData(size5); // to index 4 - - int sortingRole; - Qt::SortOrder sortingOrder; - - // first sort call, includes timer creation and setup - mTestObject->doSorting(VideoCollectionCommon::KeyTitle, Qt::AscendingOrder); - // need to wait for awhile to make sure zero-counter gets - // processing time. - QTest::qWait(500); - QCOMPARE(spyAboutToChange.count(), 1); - QCOMPARE(spyChanged.count(), 1); - QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeyTitle); - QCOMPARE(mTestObject->sortOrder(), Qt::AscendingOrder); - QCOMPARE(spySorted.count(), 1); - mTestObject->getSorting(sortingRole, sortingOrder); - QCOMPARE(sortingRole, (int)VideoCollectionCommon::KeyTitle); - QCOMPARE(sortingOrder, Qt::AscendingOrder); - - // reset spys - spyAboutToChange.clear(); - spyChanged.clear(); - spySorted.clear(); - - // second sort call, should use same timer appropriately - mTestObject->doSorting(VideoCollectionCommon::KeyTitle, Qt::DescendingOrder); - QTest::qWait(500); - QCOMPARE(spyAboutToChange.count(), 1); - QCOMPARE(spyChanged.count(), 1); - QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeyTitle); - QCOMPARE(mTestObject->sortOrder(), Qt::DescendingOrder); - QCOMPARE(spySorted.count(), 1); - mTestObject->getSorting(sortingRole, sortingOrder); - QCOMPARE(sortingRole, (int)VideoCollectionCommon::KeyTitle); - QCOMPARE(sortingOrder, Qt::DescendingOrder); - - // reset spys - spyAboutToChange.clear(); - spyChanged.clear(); - spySorted.clear(); - - // double call without first letting timer to timeout - VideoThumbnailData::mStartBackgroundFetchingCallCount = 0; - mTestObject->doSorting(VideoCollectionCommon::KeyTitle, Qt::DescendingOrder); - mTestObject->doSorting(VideoCollectionCommon::KeyTitle, Qt::AscendingOrder); - QTest::qWait(500); - QCOMPARE(spyAboutToChange.count(), 1); - QCOMPARE(spyChanged.count(), 1); - QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeyTitle); - QCOMPARE(mTestObject->sortOrder(), Qt::AscendingOrder); - QCOMPARE(spySorted.count(), 1); - mTestObject->getSorting(sortingRole, sortingOrder); - QCOMPARE(sortingRole, (int)VideoCollectionCommon::KeyTitle); - QCOMPARE(sortingOrder, Qt::AscendingOrder); - - spyAboutToChange.clear(); - spyChanged.clear(); - spySorted.clear(); - - // syncronous call checks - mTestObject->doSorting(VideoCollectionCommon::KeyTitle, Qt::DescendingOrder, false); - QCOMPARE(spyAboutToChange.count(), 1); - QCOMPARE(spyChanged.count(), 1); - QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeyTitle); - QCOMPARE(mTestObject->sortOrder(), Qt::DescendingOrder); - QCOMPARE(spySorted.count(), 1); - mTestObject->getSorting(sortingRole, sortingOrder); - QCOMPARE(sortingRole, (int)VideoCollectionCommon::KeyTitle); - QCOMPARE(sortingOrder, Qt::DescendingOrder); - - spyAboutToChange.clear(); - spyChanged.clear(); - spySorted.clear(); - - mTestObject->doSorting(VideoCollectionCommon::KeyTitle, Qt::AscendingOrder, false); - QCOMPARE(spyAboutToChange.count(), 1); - QCOMPARE(spyChanged.count(), 1); - QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeyTitle); - QCOMPARE(mTestObject->sortOrder(), Qt::AscendingOrder); - QCOMPARE(spySorted.count(), 1); - mTestObject->getSorting(sortingRole, sortingOrder); - QCOMPARE(sortingRole, (int)VideoCollectionCommon::KeyTitle); - QCOMPARE(sortingOrder, Qt::AscendingOrder); - - spyAboutToChange.clear(); - spyChanged.clear(); - spySorted.clear(); - - // check that layout signals are not send if the sorting values don't change. - mTestObject->doSorting(VideoCollectionCommon::KeyTitle, Qt::AscendingOrder); - QCOMPARE(spyAboutToChange.count(), 0); - QCOMPARE(spyChanged.count(), 0); - QCOMPARE(spySorted.count(), 0); - QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeyTitle); - QCOMPARE(mTestObject->sortOrder(), Qt::AscendingOrder); - mTestObject->getSorting(sortingRole, sortingOrder); - QCOMPARE(sortingRole, (int)VideoCollectionCommon::KeyTitle); - QCOMPARE(sortingOrder, Qt::AscendingOrder); - - spyAboutToChange.clear(); - spyChanged.clear(); - spySorted.clear(); - - // date role check - mTestObject->doSorting(VideoCollectionCommon::KeyDateTime, Qt::AscendingOrder); - QTest::qWait(500); - int count = spyAboutToChange.count(); - QCOMPARE(spyAboutToChange.count(), 1); - QCOMPARE(spyChanged.count(), 1); - QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeyDateTime); - QCOMPARE(spySorted.count(), 1); - mTestObject->getSorting(sortingRole, sortingOrder); - QCOMPARE(sortingRole, (int)VideoCollectionCommon::KeyDateTime); - QCOMPARE(sortingOrder, Qt::AscendingOrder); - - spyAboutToChange.clear(); - spyChanged.clear(); - spySorted.clear(); - - // size role check - mTestObject->doSorting(VideoCollectionCommon::KeySizeValue, Qt::AscendingOrder); - QTest::qWait(500); - QCOMPARE(spyAboutToChange.count(), 1); - QCOMPARE(spyChanged.count(), 1); - QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeySizeValue); - QCOMPARE(spySorted.count(), 1); - mTestObject->getSorting(sortingRole, sortingOrder); - QCOMPARE(sortingRole, (int)VideoCollectionCommon::KeySizeValue); - QCOMPARE(sortingOrder, Qt::AscendingOrder); - - spyAboutToChange.clear(); - spyChanged.clear(); - spySorted.clear(); - - // number of items role check - mTestObject->doSorting(VideoCollectionCommon::KeyNumberOfItems, Qt::AscendingOrder); - QTest::qWait(500); - QCOMPARE(spyAboutToChange.count(), 1); - QCOMPARE(spyChanged.count(), 1); - QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeyNumberOfItems); - QCOMPARE(spySorted.count(), 1); - mTestObject->getSorting(sortingRole, sortingOrder); - QCOMPARE(sortingRole, (int)VideoCollectionCommon::KeyNumberOfItems); - QCOMPARE(sortingOrder, Qt::AscendingOrder); - - spyAboutToChange.clear(); - spyChanged.clear(); - spySorted.clear(); - - // invalid role call, sorting should be set to date - mTestObject->mType = VideoCollectionCommon::EModelTypeAllVideos; - mTestObject->doSorting(VideoCollectionCommon::KeyTitle - 100, Qt::AscendingOrder); - QTest::qWait(500); - QCOMPARE(spyAboutToChange.count(), 1); - QCOMPARE(spyChanged.count(), 1); - QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeyDateTime); - QCOMPARE(spySorted.count(), 1); - - spyAboutToChange.clear(); - spyChanged.clear(); - spySorted.clear(); - - // invalid role call, model type is categories, sorting should be set to VideoCollectionCommon::KeyTitle - mTestObject->mType = VideoCollectionCommon::EModelTypeCollections; - mTestObject->doSorting(VideoCollectionCommon::KeyTitle - 100, Qt::AscendingOrder); - QTest::qWait(500); - QCOMPARE(spyAboutToChange.count(), 1); - QCOMPARE(spyChanged.count(), 1); - QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeyTitle); - QCOMPARE(spySorted.count(), 1); - - spyAboutToChange.clear(); - spyChanged.clear(); - spySorted.clear(); - - // sync sorting call for non -changing sort order (for coverity) - mTestObject->mType = VideoCollectionCommon::EModelTypeAllVideos; - mTestObject->mIdleSortTimer = 0; - mTestObject->doSorting(VideoCollectionCommon::KeyTitle - 100, Qt::AscendingOrder, false); - spyAboutToChange.clear(); - spyChanged.clear(); - mTestObject->doSorting(VideoCollectionCommon::KeyTitle - 100, Qt::AscendingOrder, false); - QCOMPARE(spyAboutToChange.count(), 0); - QCOMPARE(spyChanged.count(), 0); - QCOMPARE(mTestObject->sortRole(), (int)VideoCollectionCommon::KeyDateTime); - spyAboutToChange.clear(); - spyChanged.clear(); - QCOMPARE(spySorted.count(), 2); -} - -// --------------------------------------------------------------------------- -// testFilterAcceptsRow -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testFilterAcceptsRowVideos() -{ - // source_parent can be anything, test model doesn't use it. - QModelIndex source_parent = QModelIndex(); - - // Not initialized: no rouce model - QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == false); - - QVERIFY(mTestObject->initialize(mStubModel) == 0); - mTestObject->open(VideoCollectionCommon::ELevelVideos); - mTestObject->mType = VideoCollectionCommon::EModelTypeAllVideos; - - // Test invalid row: below 0 - QVERIFY(mTestObject->callFilterAcceptsRow(-1, source_parent) == false); - - // invalid row: larger than count - mStubModel->appendData("test"); - QVERIFY(mTestObject->callFilterAcceptsRow(2, source_parent) == false); - - // correct row - QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == true); - - // correct row, but id not corresponds video - mStubModel->removeAll(); - mStubModel->appendData(TMPXItemId(1, KVcxMvcMediaTypeCategory)); - QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == false); - -} - -// --------------------------------------------------------------------------- -// testFilterAcceptsNoVideoTypes -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testFilterAcceptsNoVideoTypes() -{ - // source_parent can be anything, test model doesn't use it. - QModelIndex source_parent = QModelIndex(); - QVERIFY(mTestObject->initialize(mStubModel) == 0); - - // only one item at ondex 0 - mStubModel->appendData(TMPXItemId(1, KVcxMvcMediaTypeVideo)); - - // model type == VideoCollectionWrapper::ECollections - mTestObject->mType = VideoCollectionCommon::EModelTypeCollections; - // mLevel == VideoCollectionCommon::ELevelCategory, id.iId1 == KVcxMvcMediaTypeVideo - mTestObject->mLevel = VideoCollectionCommon::ELevelCategory; - QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == false); - // mLevel != VideoCollectionCommon::ELevelCategory - mTestObject->mLevel = VideoCollectionCommon::ELevelAlbum; - QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == false); - - // model type == VideoCollectionWrapper::ECollectionContent - mTestObject->mType = VideoCollectionCommon::EModelTypeCollectionContent; - // item belongs to album - VideoListDataModel::mBelongsToAlbum = true; - QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == true); - // item does not belong to album - VideoListDataModel::mBelongsToAlbum = false; - QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == false); - - // model type == VideoCollectionWrapper::EGeneric - mTestObject->mType = VideoCollectionCommon::EModelTypeGeneric; - mTestObject->mGenericFilterValue = true; - - // mLevel != VideoCollectionCommon::ELevelVideos && id.iId2 == KVcxMvcMediaTypeVideo - mTestObject->mLevel = VideoCollectionCommon::ELevelAlbum; - QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == false); - - // mLevel == VideoCollectionCommon::ELevelVideos && id.iId2 != KVcxMvcMediaTypeVideo - mTestObject->mLevel = VideoCollectionCommon::ELevelVideos; - mStubModel->removeAll(); - mStubModel->appendData(TMPXItemId(1, KVcxMvcMediaTypeCategory)); - QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == false); - - // mLevel == VideoCollectionCommon::ELevelVideos && id.iId2 == KVcxMvcMediaTypeVideo - mStubModel->removeAll(); - mStubModel->appendData(TMPXItemId(1, KVcxMvcMediaTypeVideo)); - // generic filter id == TMPXItemId::InvalidId() - mTestObject->mGenericFilterId = TMPXItemId::InvalidId(); - QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == true); - - // generic filter id == (KVcxMvcCategoryIdAll, KVcxMvcMediaTypeCategory) - mTestObject->mGenericFilterId = TMPXItemId(KVcxMvcCategoryIdAll, KVcxMvcMediaTypeCategory); - QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == true); - - // generic filter id == (100, KVcxMvcMediaTypeCategory) - mTestObject->mGenericFilterId = TMPXItemId(100, KVcxMvcMediaTypeCategory); - QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == false); - - // generic filter id == (KVcxMvcCategoryIdAll, KVcxMvcMediaTypeVideo) - mTestObject->mGenericFilterId = TMPXItemId(KVcxMvcCategoryIdAll, KVcxMvcMediaTypeVideo); - QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == false); - - // generic filter id == (100, KVcxMvcMediaTypeCategory) - VideoListDataModel::mBelongsToAlbum = true; - mTestObject->mGenericFilterId = TMPXItemId(100, KVcxMvcMediaTypeCategory); - QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == true); - - // generic filter id == (KVcxMvcCategoryIdAll, KVcxMvcMediaTypeVideo) - VideoListDataModel::mBelongsToAlbum = true; - mTestObject->mGenericFilterId = TMPXItemId(KVcxMvcCategoryIdAll, KVcxMvcMediaTypeVideo); - QVERIFY(mTestObject->callFilterAcceptsRow(0, source_parent) == true); -} - -// --------------------------------------------------------------------------- -// testGetMediaFilePathForId -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testGetMediaFilePathForId() -{ - // Not initialized. - VideoListDataModel::mMediaFilePathReturnValue = "testfile"; - QVERIFY(mTestObject->getMediaFilePathForId(TMPXItemId(0,0)) == ""); - - // Ok case. - QVERIFY(mTestObject->initialize(mStubModel) == 0); - VideoListDataModel::mMediaFilePathReturnValue = "testfile"; - QVERIFY(mTestObject->getMediaFilePathForId(TMPXItemId(0,0)) == "testfile"); -} - -// --------------------------------------------------------------------------- -// testAddNewCollectionNoCollectionClient -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testAddNewCollectionNoCollectionClient() -{ - QString name("testname"); - VideoCollectionClient::mNewAlbumId = TMPXItemId(1,1); - QVERIFY(mTestObject->addNewAlbum(name) == TMPXItemId::InvalidId()); - QVERIFY(VideoCollectionClient::mAddNewCollectionName != name); -} - -// --------------------------------------------------------------------------- -// testAddNewCollectionSucceed -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testAddNewCollectionSucceed() -{ - QString name("testname"); - - mTestObject->initialize(mStubModel); - VideoCollectionClient::mNewAlbumId = TMPXItemId(1,1); - QVERIFY(mTestObject->addNewAlbum(name) == TMPXItemId(1,1)); - QCOMPARE(VideoCollectionClient::mAddNewCollectionName, name); -} - -// --------------------------------------------------------------------------- -// testResolveAlbumName -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testResolveAlbumName() -{ - mCollectionModel->mType = VideoCollectionCommon::EModelTypeCollections; - - QString name("test"); - QString resolved(""); - // no model, same name can be used - resolved = mTestObject->resolveAlbumName(name); - QVERIFY(resolved.length()); - QVERIFY(resolved == name); - - mTestObject->initialize(mStubModel); - - // no collections proxy model, same name - resolved = mTestObject->resolveAlbumName(name); - QVERIFY(resolved.length()); - QVERIFY(resolved == name); - - mCollectionModel->initialize(mStubModel); - mCollectionModel->open(VideoCollectionCommon::ELevelCategory); - VideoCollectionWrapper::instance().mProxyModel = mCollectionModel; - - // collections proxy model exists, no source model - VideoListDataModel *temp = mTestObject->mModel; - mTestObject->mModel = 0; - - resolved = mTestObject->resolveAlbumName(name); - QVERIFY(resolved.length()); - QVERIFY(resolved == name); - mTestObject->mModel = temp; - - mStubModel->appendData(TMPXItemId(1,2)); - mStubModel->appendData(name); - - int count = mCollectionModel->rowCount(); - - // invalid data from model, same name can be used - VideoListDataModel::mReturnInvalid = true; - resolved = mTestObject->resolveAlbumName(name); - QVERIFY(resolved.length()); - QVERIFY(resolved == name); - VideoListDataModel::mReturnInvalid = false; - - // same name, name to be different - resolved = mTestObject->resolveAlbumName(name); - QVERIFY(resolved.length()); - QVERIFY(resolved != name); - QVERIFY(resolved.contains("1")); - - mStubModel->appendData(TMPXItemId(2,2)); - mStubModel->appendData(resolved); - - resolved = mTestObject->resolveAlbumName(name); - QVERIFY(resolved.length()); - QVERIFY(resolved != name); - QVERIFY(resolved.contains("2")); - - // different name, no changes - name = "Another"; - resolved = mTestObject->resolveAlbumName(name); - QVERIFY(resolved == name); - - mCollectionModel->mType = VideoCollectionCommon::EModelTypeAllVideos; -} - -// --------------------------------------------------------------------------- -// testResolveAlbumName -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testAddItemsInAlbum() -{ - TMPXItemId albumId(1,2); - QList items; - items.append(TMPXItemId(1,0)); - // no collection client - QVERIFY(mTestObject->addItemsInAlbum(albumId, items) == -1); - - mTestObject->initialize(mStubModel); - - QVERIFY(mTestObject->addItemsInAlbum(albumId, items) == 0); -} - -// --------------------------------------------------------------------------- -// testRemoveItemsFromAlbum -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testRemoveItemsFromAlbum() -{ - VideoListDataModel::mRemoveFrAlbumReturn = 1; - TMPXItemId albumId(1,2); - QList items; - items.append(TMPXItemId(1,0)); - VideoThumbnailData::mEnableBackgroundThumbnailFetchingCallCount = 0; - // no model - - QVERIFY(mTestObject->removeItemsFromAlbum(albumId, items) == -1); - QCOMPARE(VideoThumbnailData::mEnableBackgroundThumbnailFetchingCallCount, 2); - QVERIFY(VideoThumbnailData::mBackgroundThumbnailFetchingEnabled == true); - mTestObject->initialize(mStubModel); - - // model returns < 0 - VideoListDataModel::mRemoveFrAlbumReturn = -1; - QVERIFY(mTestObject->removeItemsFromAlbum(albumId, items) == -1); - QCOMPARE(VideoThumbnailData::mEnableBackgroundThumbnailFetchingCallCount, 4); - QVERIFY(VideoThumbnailData::mBackgroundThumbnailFetchingEnabled == true); - - VideoListDataModel::mRemoveFrAlbumReturn = 11; - // "succeed" - QVERIFY(mTestObject->removeItemsFromAlbum(albumId, items) == 0); - QCOMPARE(VideoThumbnailData::mEnableBackgroundThumbnailFetchingCallCount, 6); - QVERIFY(VideoThumbnailData::mBackgroundThumbnailFetchingEnabled == true); -} - -// --------------------------------------------------------------------------- -// testGetOpenItem -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testGetOpenItem() -{ - // no model nor collection client - QVERIFY(mTestObject->getOpenItem() == TMPXItemId::InvalidId()); - - mTestObject->initialize(mStubModel); - - // model exist, no collection client - VideoCollectionClient *tmpClient = mTestObject->mCollectionClient; - mTestObject->mCollectionClient = 0; - QVERIFY(mTestObject->getOpenItem() == TMPXItemId::InvalidId()); - mTestObject->mCollectionClient = tmpClient; - - // no model, collection client exists - VideoListDataModel *tmpModel = mTestObject->mModel; - mTestObject->mModel = 0; - QVERIFY(mTestObject->getOpenItem() == TMPXItemId::InvalidId()); - mTestObject->mModel = tmpModel; - - // type neither EAllVideos or ECollectionContent - QVERIFY(mTestObject->getOpenItem() == TMPXItemId::InvalidId()); - - TMPXItemId id; - // type EAllVideos - delete mTestObject; - mTestObject = new FilterProxyTester(VideoCollectionCommon::EModelTypeAllVideos); - mTestObject->initialize(mStubModel); - id = mTestObject->getOpenItem(); - QVERIFY(id != TMPXItemId::InvalidId()); - QVERIFY(id.iId1 == KVcxMvcCategoryIdAll); - QVERIFY(id.iId2 == KVcxMvcMediaTypeCategory); - - // type ECollectionContent - delete mTestObject; - mTestObject = new FilterProxyTester(VideoCollectionCommon::EModelTypeCollectionContent); - mTestObject->initialize(mStubModel); - id.iId1 = 1; - id.iId2 = KVcxMvcMediaTypeAlbum; - mTestObject->openItem(id); - id = TMPXItemId::InvalidId(); - id = mTestObject->getOpenItem(); - QVERIFY(id != TMPXItemId::InvalidId()); - QVERIFY(id.iId1 == 1); - QVERIFY(id.iId2 == KVcxMvcMediaTypeAlbum); -} - -// --------------------------------------------------------------------------- -// testRemoveAlbums -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testRemoveAlbums() -{ - QModelIndexList indexList; - // no collection - QVERIFY(mTestObject->removeAlbums(indexList) == -1); - - mTestObject->initialize(mStubModel); - QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelVideos) == 0); - - // empty list provided - QVERIFY(mTestObject->removeAlbums(indexList) == -1); - - mStubModel->appendData(TMPXItemId(1,0)); - mStubModel->appendData(TMPXItemId(2,0)); - mStubModel->appendData(TMPXItemId(3,0)); - - indexList.append(mTestObject->index(0,0)); - indexList.append(mTestObject->index(1,0)); - indexList.append(mTestObject->index(2,0)); - - // no albums in model - QVERIFY(mTestObject->removeAlbums(indexList) == -1); - - indexList.clear(); - mStubModel->removeAll(); - delete mTestObject; - mTestObject = new FilterProxyTester(VideoCollectionCommon::EModelTypeCollections); - QVERIFY(mTestObject); - QVERIFY(mTestObject->initialize(mStubModel) == 0); - QVERIFY(mTestObject->open(VideoCollectionCommon::ELevelCategory) == 0); - mStubModel->appendData(TMPXItemId(1,2)); - mStubModel->appendData(TMPXItemId(2,2)); - mStubModel->appendData(TMPXItemId(3,2)); - indexList.append(mTestObject->index(0,0)); - indexList.append(mTestObject->index(1,0)); - indexList.append(mTestObject->index(2,0)); - - // succeed - QVERIFY(mTestObject->removeAlbums(indexList) == 0); -} - -// --------------------------------------------------------------------------- -// testAlbumChangedSlot -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testAlbumChangedSlot() -{ - connect(this, SIGNAL(testSignal()), mTestObject, SLOT(albumChangedSlot())); - // cannot test anything here, just for the coverage - // level incorrect - mTestObject->initialize(mStubModel); - emit testSignal(); - delete mTestObject; - mTestObject = 0; - mTestObject = new FilterProxyTester(VideoCollectionCommon::EModelTypeCollectionContent); - connect(this, SIGNAL(testSignal()), mTestObject, SLOT(albumChangedSlot())); - QVERIFY(mTestObject); - mTestObject->initialize(mStubModel); - emit testSignal(); - disconnect(this, SIGNAL(testSignal()), mTestObject, SLOT(albumChangedSlot())); -} - -// --------------------------------------------------------------------------- -// testIndexOfId -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testIndexOfId() -{ - QModelIndex index; - // no model - TMPXItemId id(1,0); - index = mTestObject->indexOfId(id); - QVERIFY(!index.isValid()); - - mTestObject->initialize(mStubModel); - mTestObject->open(VideoCollectionCommon::ELevelVideos); - - // fetching invalid - id = TMPXItemId::InvalidId(); - index = mTestObject->indexOfId(id); - QVERIFY(!index.isValid()); - - mStubModel->appendData(TMPXItemId(1,0)); - mStubModel->appendData(TMPXItemId(2,0)); - mStubModel->appendData(TMPXItemId(3,0)); - - id = TMPXItemId(2,0); - index = mTestObject->indexOfId(id); - QVERIFY(index.isValid()); - QVERIFY(index.row() == 1); -} - -// --------------------------------------------------------------------------- -// testSetGenericIdFilter -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testSetGenericIdFilter() -{ - // type VideoCollectionWrapper::EGeneric - mTestObject->initialize(mStubModel); - mTestObject->open(VideoCollectionCommon::ELevelVideos); - mTestObject->setGenericIdFilter(TMPXItemId(0,1), true); - - mStubModel->appendData(TMPXItemId(1,0)); - mStubModel->appendData(TMPXItemId(2,0)); - mStubModel->appendData(TMPXItemId(3,0)); - mTestObject->invalidate(); - QModelIndex index; - index = mTestObject->indexOfId(TMPXItemId(1,0)); - QVERIFY(index.isValid()); - QVERIFY(index.row() == 0); - - // other type - delete mTestObject; - mTestObject = new FilterProxyTester(VideoCollectionCommon::EModelTypeAllVideos); - mTestObject->initialize(mStubModel); - mTestObject->open(VideoCollectionCommon::ELevelVideos); - - mTestObject->setGenericIdFilter(TMPXItemId(1,1), true); - mTestObject->invalidate(); - index = mTestObject->indexOfId(TMPXItemId(1,0)); - QVERIFY(index.isValid()); - QVERIFY(index.row() == 0); -} - -// --------------------------------------------------------------------------- -// testRenameAlbum -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testSetAlbumInUse() -{ - mStubModel->mAlbumInUse = TMPXItemId::InvalidId(); - - // no model - mTestObject->setAlbumInUse(TMPXItemId(1,2)); - QVERIFY(mStubModel->mAlbumInUse == TMPXItemId::InvalidId()); - - // model exists - mTestObject->initialize(mStubModel); - mTestObject->setAlbumInUse(TMPXItemId(1,2)); - QVERIFY(mStubModel->mAlbumInUse == TMPXItemId(1,2)); -} - -// --------------------------------------------------------------------------- -// testRenameItem -// --------------------------------------------------------------------------- -// -void TestVideoSortFilterProxyModel::testRenameItem() -{ - delete mTestObject; - mTestObject = new FilterProxyTester(VideoCollectionCommon::EModelTypeAllVideos); - - // Not initialized. - TMPXItemId id = TMPXItemId::InvalidId(); - QString name = ""; - QVERIFY(mTestObject->renameItem(id, name) == -1); - - // Initialized. - mTestObject->initialize(mStubModel); - QVERIFY(mTestObject->renameItem(id, name) == 0); -} - -// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/stub/inc/filterproxytester.h --- a/videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/stub/inc/filterproxytester.h Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ - -/** -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Helper class to test protected members from videocollectionsortfilterproxy -* -*/ - -#ifndef __FILTERLISTPROXY_TESTER_H -#define __FILTERLISTPROXY_TESTER_H - -#include - -#include "videocollectioncommon.h" -#include "videosortfilterproxymodel.h" - -class VideoListDataModel; - -class FilterProxyTester : public VideoSortFilterProxyModel -{ - - Q_OBJECT - -public: // Constructors and destructor - - /** - * Constructor - * - */ - FilterProxyTester(VideoCollectionCommon::TModelType type, QObject *parent=0); - - /** - * destructor - * - */ - virtual ~FilterProxyTester(); - -public: // helper methods for test - - /** - * Helper method to call protected lessThan - * - */ - bool callLessThan( const QModelIndex & left, const QModelIndex & right ) const; - - /** - * Helper methor to call protected filterAcceptsRow. - * - */ - bool callFilterAcceptsRow( int source_row, const QModelIndex & source_parent ) const; - - /** - * For setting CVideoCollectionClient pointer - * - */ - int setClient(VideoCollectionClient *collectionClient); - - /** - * For getting CVideoCollectionClient pointer - * - */ - VideoCollectionClient* getClient(); - -}; - -#endif // __FILTERLISTPROXY_TESTER_H - - diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/stub/inc/videocollectionclient.h --- a/videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/stub/inc/videocollectionclient.h Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,141 +0,0 @@ - -/** -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Stub videocollectionclient class for videocollectionsortfilterproxy unit tests -* -*/ - -#ifndef __VIDEOCOLLECTIONCLIENT_H -#define __VIDEOCOLLECTIONCLIENT_H - -//#include -#include -#include -#include - -// FORWARD DECLARATIONS -class VideoCollectionUtils; - - -class VideoCollectionClient -{ - - public: // Constructors and destructor - - /** - * constructor - * - */ - VideoCollectionClient(); - - /** - * destructor - * - */ - virtual ~VideoCollectionClient(); - - public: - - /** - * - * if mFailInit is true returns -1 - * if mFailInit is false returns 0 - * - * @return int - */ - int initialize(); - - /** - * - * if mFailStartOpen is true returns -1 - * if mFailStartOpen is false returns 0 - * - * @return int - */ - int startOpenCollection(int level); - - /** - * - * if mFailMediaPlayback is true returns -1 - * if mFailMediaPlayback is false returns 0 - * - * @return int - */ - int openItem(int mpxId1); - - /** - * - * if mFailMediaDetails is true returns -1 - * if mFailMediaDetails is false returns 0 - * - * @return int - */ - int getVideoDetails(int mpxId1); - - /** - * @return mNewAlbumId - */ - TMPXItemId addNewAlbum(QString name); - - /** - * no funtionality needed here for unit tests - */ - int addItemsInAlbum(TMPXItemId albumId, QList items); - - /** - * no funtionality needed here for unit tests - */ - int removeAlbums(const QList &items); - - /** - * saves contant id (1,2) into provided id - */ - void getCategoryId(TMPXItemId &id); - - /** - * calls collection to go back to collection level - * - */ - int back(); - - /** - * returns mRenameItemReturnValue - */ - int renameItem(const TMPXItemId &itemId, const QString &newTitle); - -public: - static bool mFailInit; - static bool mFailStartOpen; - static bool mFailMediaPlayback; - static bool mFailMediaDetails; - static bool mFailSetSort; - static bool mFailAddNewCollection; - static TMPXItemId mNewAlbumId; - static TVcxMyVideosSortingOrder mSettedSortOrder; - static int mSortOrderSetCount; - static QString mAddNewCollectionName; - static QString mAddNewCollectionThumb; - static QList mAddNewCollectionIds; - static int mRenameItemReturnValue; - static int mBackReturnValue; - -private: - - /** - * static instance from this class - */ - static VideoCollectionClient *testInstance; -}; - -#endif // __VIDEOCOLLECTIONCLIENT_H diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/stub/inc/videocollectionwrapper.h --- a/videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/stub/inc/videocollectionwrapper.h Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ - -/** -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Stub videocollectionwrapper class for videosortfilterproxymodel unit tests -* -*/ - -#ifndef __VIDEOCOLLECTIONWRAPPER_H__ -#define __VIDEOCOLLECTIONWRAPPER_H__ - -#include "videosortfilterproxymodel.h" - - -class VideoCollectionWrapper -{ - -public: - - enum TModelType - { - EAllVideos, - ECollections, - ECollectionContent, - EGeneric - }; - - static VideoCollectionWrapper &instance() - { - static VideoCollectionWrapper _staticWrapper; - return _staticWrapper; - } - - /** - * constructor - */ - VideoCollectionWrapper() : - mProxyModel(0) - { - } - - /** - * returns mProxyModel - */ - VideoSortFilterProxyModel* getModel(int /*type*/) - { - return mProxyModel; - } - - VideoSortFilterProxyModel* mProxyModel; -}; -#endif // __VIDEOCOLLECTIONWRAPPER_H__ diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/stub/inc/videolistdatamodel.h --- a/videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/stub/inc/videolistdatamodel.h Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,316 +0,0 @@ - -/** -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Stub collection client to be used when unit testing videocollectionsortfilterproxy -* -*/ - -#ifndef __STUB_VIDEOLISTDATAMODELFORPROXY_H -#define __STUB_VIDEOLISTDATAMODELFORPROXY_H - -#include -#include -#include -#include -#include -#include -#include "videocollectioncommon.h" - -// CVideoListDataModel::Data returns valid variant when used this and name exists for the row. -const int INVALID_ROLE_FOR_SORTING = VideoCollectionCommon::KeyStatus+10; - -class VideoCollectionClient; - - -class VideoListDataModel : public QAbstractItemModel -{ - - Q_OBJECT - -public: // Constructors and destructor - - /** - * Constructor - * - */ - VideoListDataModel(QObject *parent = NULL); - - /** - * destructor - * - */ - virtual ~VideoListDataModel(); - - /** - * Initializes model. Sets model cache proxy and cache's plugin to - * to be this object. Creates videolist and puts it to observe - * collection client. Calls connectSignals to connect signals into - * appropriate slots - * - * @paran collection mpx video collectionobject - * - * @return int: 0 if everything ok - */ - int initialize(); - - /** - * Method calls video list data to check if there are valid media object - * at the given index. If there is, item id is returned. - * - * @param index index of the item to be opened - * @return TMPXItemId item id ( > 0), < 0 if no valid item. - */ - TMPXItemId mediaIdAtIndex(int index) const; - - /** - * Method calls video list data to check if there are valid media object - * for the given media id. If there is, file path for is returned. - * - * @param mediaId id of the item to be opened - * @return QString file path of the media at index, empty string if not valid item. - */ - QString mediaFilePathForId(int mediaId) const; - - /** - * Called by the client when removal of videos are requested. - * Sets video status to be removed to videolistdata and - * eventually calls collection to handle the actual removing. - * - * @param indexlist list of indeces of items requested for deletion - * - * @return bool true if removal startup succeeds - */ - bool removeRows(const QModelIndexList &indexList); - - /** - * sets mAlbumInUse - */ - void setAlbumInUse(TMPXItemId itemId); - - /** - * returns mAlbumInUse - */ - TMPXItemId albumInUse(); - - /** - * returns mBelongsToAlbum - */ - bool belongsToAlbum(TMPXItemId itemId, TMPXItemId albumId = TMPXItemId::InvalidId()); - - /** - * returns mRemoveFrAlbumReturn - */ - int removeItemsFromAlbum(TMPXItemId &albumId, const QList &items); - - /** - * returns index of first occurence of provided id - */ - QModelIndex indexOfId(TMPXItemId id); - - /** - * returns collection client - */ - VideoCollectionClient* getCollectionClient(); - -public: // from QAbstractItemModel - - /** - * Returns mRowCount value - * - * @param parent - not used - * - * @return int - */ - int rowCount(const QModelIndex &parent = QModelIndex()) const; - - /** - * Method does nothing in this stub - * - * @param index - not used - * - * @return QMap empty map - */ - QMap itemData(const QModelIndex &index) const; - - /** - * Returns item value based on the role defined: - * Qt::DisplayRole: from mNames -list - * VideoCollectionCommon::KeySizeValue: from mSizes -list - * VideoCollectionCommon::KeyDate: from mDates -list - * - * @param index - item index to return - * @parema role - role indicating wanted value - * - * @return QVariant - */ - QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; - - /** - * Returns 0 always. - * - * @param parent - not used - * - * @return int - */ - int columnCount(const QModelIndex & parent = QModelIndex()) const; - - /** - * Calls QAbstractItemModel::createIndex to return appropriate QModelIndex - * - * @param row - row index - * @param column - col index - * @param parent - not used - * - * @return QModelIndex - */ - QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const; - - /** - * returns invalid QModelIndex - * - * @return QModelIndex - */ - QModelIndex parent(const QModelIndex & index) const; - - -public: // helper methods for test - - /** - * emit album changed signal - */ - void emitAlbumChanged(); - - /** - * clears mData - */ - void removeAll(); - - - /** - * adds provided id to mData - */ - void appendData(TMPXItemId data); - - /** - * appends given string to mData - * - * @param data - value to append to list - */ - void appendData(QString data); - - /** - * appends given uint to mData - * - * @param data - value to append to list - */ - void appendData(uint data); - - /** - * appends given QDate to mData - * - * @param data - value to append to list - */ - void appendData(QDateTime data); - - /** - * Appends given status to mData. - * - * @param status - value to append to list. - */ - void appendStatus(int status); - -signals: - - /** - * This signal is connected to video list's details ready - * -signal indicating that video details data is fetched ok - * - * @param id of the item - */ - void fullVideoDetailsReady(TMPXItemId); - - /** - * Signals that the model is ready, ie. loaded all data from - * myvideocollection. - */ - void modelReady(); - - /** - * signals when model's internal data has changed - */ - void modelChanged(); - - /** - * signals when album data has changed - */ - void albumChanged(); - - /** - * signals when item has been modified - */ - void itemModified(const TMPXItemId &itemId); - -public: - - static bool mInitFails; - - static bool mRemoveRowsFails; - - static bool mGetMediaIdAtIndexFails; - - static bool mBelongsToAlbum; - - static bool mReturnInvalid; - - static int mRemoveFrAlbumReturn; - - static QString mMediaFilePathReturnValue; - - static int mLastDeletedIndexRow; - - TMPXItemId mAlbumInUse; - -private: - - class DummyData - { - public: - DummyData() : - mId(TMPXItemId::InvalidId()), - mName(""), - mSize(666), - mDate(QDateTime()), - mStatus(-1) - {} - TMPXItemId mId; - QString mName; - uint mSize; - QDateTime mDate; - int mStatus; - }; - - /** - * List of strings when fetching Qt::DisplayRole - */ - QList mData; - - /** - * colleciton client object, owned - */ - VideoCollectionClient *mCollectionClient; -}; - -#endif // __STUB_VIDEOLISTDATAMODELFORPROXY_H - - diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/stub/inc/videothumbnaildata.h --- a/videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/stub/inc/videothumbnaildata.h Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,110 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: CVideoThumbnailData class definition* -*/ - -#ifndef __VIDEOTHUMBNAILDATA_H__ -#define __VIDEOTHUMBNAILDATA_H__ - -// INCLUDES -#include -#include -#include -#include -#include - -// FORWARD DECLARATIONS -class VideoSortFilterProxyModel; - -class VideoThumbnailData : public QObject -{ - /** - * defined to be able to use signals and slots - */ - Q_OBJECT - - /** - * disable copy-constructor and assignment operator - */ - Q_DISABLE_COPY(VideoThumbnailData) - -public: // Constructor - - /* - * Thumbnail fetch priorities - */ - enum VideoThumbnailPriority - { - VideoThumbnailPriorityBackground = 2000, - VideoThumbnailPriorityLow = 5000, - VideoThumbnailPriorityMedium = 10000, - VideoThumbnailPriorityHigh = 2000 - }; - - /** - * Returns singleton instance for this class. - * - * @return The singleton instance. - * - */ - static VideoThumbnailData &instance(); - - /** - * Starts background thumbnail fetching. - * - * @param fetchIndex index where to start the background thumbnail fetching. - * - */ - void startBackgroundFetching(VideoSortFilterProxyModel *model, int fetchIndex); - - /** - * Enables or disables thumbnail background fetching. Default is enabled. - * - * @param enable true enables and false disables thumbnail background fetching. - */ - void enableBackgroundFetching(bool enable); - - /** - * Frees allocated data for thumbnails and cancels ongoing fetches. - */ - void freeThumbnailData(); - -private: - - /** - * Default constructor - */ - VideoThumbnailData(); - - /** - * Destructor - */ - ~VideoThumbnailData(); - -public: - static int mEnableBackgroundThumbnailFetchingCallCount; - static int mStartFetchingThumbnailsCallCount; - static int mStartFetchingThumbnailsThumbnailCount; - static int mInstanceCallCount; - static int mFreeThumbnailDataCallCount; - static int mBackgroundThumbnailFetchingEnabled; - static int mStartBackgroundFetchingCallCount; - -private: // data - - -}; -#endif // __VIDEOTHUMBNAILDATA_H__ - -// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/stub/src/filterproxytester.cpp --- a/videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/stub/src/filterproxytester.cpp Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ - -/** -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Helper class to test protected members from videocollectionsortfilterproxy -* -*/ - -// INCLUDES - -#define private public -#include "videosortfilterproxymodel.h" -#undef private - -#include "filterproxytester.h" -#include "videolistdatamodel.h" - -// --------------------------------------------------------------------------- -// FilterProxyTester -// --------------------------------------------------------------------------- -// -FilterProxyTester::FilterProxyTester(VideoCollectionCommon::TModelType type, QObject *parent) : -VideoSortFilterProxyModel(type, parent) -{ - // NOP -} - -// --------------------------------------------------------------------------- -// ~FilterProxyTester -// --------------------------------------------------------------------------- -// -FilterProxyTester::~FilterProxyTester() -{ - // NOP -} - -// --------------------------------------------------------------------------- -// callLessThan -// --------------------------------------------------------------------------- -// -bool FilterProxyTester::callLessThan( const QModelIndex & left, const QModelIndex & right ) const -{ - return VideoSortFilterProxyModel::lessThan(left, right); -} - -// --------------------------------------------------------------------------- -// callLessThan -// --------------------------------------------------------------------------- -// -bool FilterProxyTester::callFilterAcceptsRow( int source_row, const QModelIndex & source_parent ) const -{ - return VideoSortFilterProxyModel::filterAcceptsRow(source_row, source_parent); -} - -// --------------------------------------------------------------------------- -// setClient -// --------------------------------------------------------------------------- -// -int FilterProxyTester::setClient(VideoCollectionClient *collectionClient) -{ - VideoSortFilterProxyModel::mCollectionClient = collectionClient; - return 0; -} - -// --------------------------------------------------------------------------- -// getClient -// --------------------------------------------------------------------------- -// -VideoCollectionClient* FilterProxyTester::getClient() -{ - return VideoSortFilterProxyModel::mCollectionClient; -} - -// End of file - - - diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/stub/src/videocollectionclient.cpp --- a/videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/stub/src/videocollectionclient.cpp Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,169 +0,0 @@ -/* -* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Stub collection client to be used when unit testing videocollectionsortfilterproxy -*/ - - - -// INCLUDE FILES> -#include -#include "stub/inc/videocollectionclient.h" - -VideoCollectionClient* VideoCollectionClient::testInstance = 0; - -bool VideoCollectionClient::mFailInit = false; -bool VideoCollectionClient::mFailStartOpen = false; -bool VideoCollectionClient::mFailMediaPlayback = false; -bool VideoCollectionClient::mFailMediaDetails = false; -bool VideoCollectionClient::mFailSetSort = false; -bool VideoCollectionClient::mFailAddNewCollection = false; -TMPXItemId VideoCollectionClient::mNewAlbumId = TMPXItemId::InvalidId(); -TVcxMyVideosSortingOrder VideoCollectionClient::mSettedSortOrder = EVcxMyVideosSortingNone; -int VideoCollectionClient::mSortOrderSetCount = 0; -QString VideoCollectionClient::mAddNewCollectionName = QString(); -QString VideoCollectionClient::mAddNewCollectionThumb = QString(); -QList VideoCollectionClient::mAddNewCollectionIds = QList(); -int VideoCollectionClient::mRenameItemReturnValue = 0; -int VideoCollectionClient::mBackReturnValue = 0; - -// ----------------------------------------------------------------------------- -// VideoCollectionClient -// ----------------------------------------------------------------------------- -// -VideoCollectionClient::VideoCollectionClient() -{ - testInstance = this; -} - -// ----------------------------------------------------------------------------- -// ~CVideoCollectionClient -// ----------------------------------------------------------------------------- -// -VideoCollectionClient::~VideoCollectionClient() -{ -} - -// ----------------------------------------------------------------------------- -// initialize -// ----------------------------------------------------------------------------- -// -int VideoCollectionClient::initialize() -{ - if(mFailInit) - { - return -1; - } - return 0; -} - -// ----------------------------------------------------------------------------- -// startOpenCollection -// ----------------------------------------------------------------------------- -// -int VideoCollectionClient::startOpenCollection(int level) -{ - Q_UNUSED(level); - if(mFailStartOpen) - { - return -1; - } - return 0; -} - -// ----------------------------------------------------------------------------- -// openItem -// ----------------------------------------------------------------------------- -// -int VideoCollectionClient::openItem(int /*mpxId1*/) -{ - if(mFailMediaPlayback) - { - return -1; - } - return 0; -} - -// ----------------------------------------------------------------------------- -// addNewAlbum -// ----------------------------------------------------------------------------- -// -TMPXItemId VideoCollectionClient::addNewAlbum(QString title) -{ - mAddNewCollectionName = title; - return mNewAlbumId; -} - -// ----------------------------------------------------------------------------- -// addItemsInAlbum -// ----------------------------------------------------------------------------- -// -int VideoCollectionClient::addItemsInAlbum(TMPXItemId albumId, QList items) -{ - Q_UNUSED(albumId); - Q_UNUSED(items); - return 0; -} - -// ----------------------------------------------------------------------------- -// revoveAlbums -// ----------------------------------------------------------------------------- -// -int VideoCollectionClient::removeAlbums(const QList &items) -{ - Q_UNUSED(items); - return 0; -} - -// ----------------------------------------------------------------------------- -// deleteFile -// ----------------------------------------------------------------------------- -// -int VideoCollectionClient::getVideoDetails(int /*mpxId1*/) -{ - if(mFailMediaDetails) - { - return -1; - } - return 0; -} - -// ----------------------------------------------------------------------------- -// getCategoryId -// ----------------------------------------------------------------------------- -// -void VideoCollectionClient::getCategoryId(TMPXItemId &id) -{ - id.iId1 = 1; - id.iId2 = 2; -} - -// ----------------------------------------------------------------------------- -// back -// ----------------------------------------------------------------------------- -// -int VideoCollectionClient::back() -{ - return mBackReturnValue; -} - -// ----------------------------------------------------------------------------- -// renameItem -// ----------------------------------------------------------------------------- -// -int VideoCollectionClient::renameItem(const TMPXItemId &itemId, const QString &newTitle) -{ - Q_UNUSED(itemId); - Q_UNUSED(newTitle); - return mRenameItemReturnValue; -} diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/stub/src/videolistdatamodel.cpp --- a/videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/stub/src/videolistdatamodel.cpp Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,478 +0,0 @@ -/** -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Stub model to be used when unit testing videocollectionsortfilterproxy -* -*/ - - -// INCLUDES -#include "videocollectionclient.h" -#include "videolistdatamodel.h" - -bool VideoListDataModel::mInitFails = false; -bool VideoListDataModel::mRemoveRowsFails = false; -bool VideoListDataModel::mGetMediaIdAtIndexFails = false; -bool VideoListDataModel::mBelongsToAlbum = false; -bool VideoListDataModel::mReturnInvalid = false; -int VideoListDataModel::mRemoveFrAlbumReturn = -1; -int VideoListDataModel::mLastDeletedIndexRow = -1; -QString VideoListDataModel::mMediaFilePathReturnValue = ""; - -// --------------------------------------------------------------------------- -// VideoListDataModel -// --------------------------------------------------------------------------- -// -VideoListDataModel::VideoListDataModel(QObject *parent) : -QAbstractItemModel(parent), - mCollectionClient(0) -{ - -} - -// --------------------------------------------------------------------------- -// ~VideoListDataModel -// --------------------------------------------------------------------------- -// -VideoListDataModel::~VideoListDataModel() -{ - removeAll(); - - delete mCollectionClient; -} - -// ----------------------------------------------------------------------------- -// initialize -// ----------------------------------------------------------------------------- -// -int VideoListDataModel::initialize() -{ - if(mInitFails) - { - return -1; - } - return 0; -} - -// --------------------------------------------------------------------------- -// mediaIdAtIndex -// --------------------------------------------------------------------------- -// -TMPXItemId VideoListDataModel::mediaIdAtIndex(int index) const -{ - TMPXItemId id = TMPXItemId::InvalidId(); - if( mGetMediaIdAtIndexFails || index < 0 || index >= mData.count()) - { - return id; - } - - id = mData.at(index)->mId; - - return id; -} - -// --------------------------------------------------------------------------- -// mediaFilePathForId -// --------------------------------------------------------------------------- -// -QString VideoListDataModel::mediaFilePathForId(int mediaId) const -{ - Q_UNUSED(mediaId); - return mMediaFilePathReturnValue; -} - -// --------------------------------------------------------------------------- -// removeRows -// --------------------------------------------------------------------------- -// -bool VideoListDataModel::removeRows(const QModelIndexList &indexList) -{ - mLastDeletedIndexRow = -1; - if( mRemoveRowsFails ) - return false; - else - { - if(indexList.count() > 0) - { - mLastDeletedIndexRow = indexList.at(indexList.count() - 1).row(); - } - QModelIndexList sortable(indexList); - qSort(sortable); - QModelIndexList::const_iterator iter = sortable.constEnd(); - QModelIndex index; - while(iter != sortable.constBegin()) - { - iter--; - index = (*iter); - beginRemoveRows(QModelIndex(), index.row(), index.row()); - - delete mData.at(index.row()); - mData.removeAt(index.row()); - - endRemoveRows(); - } - - return true; - } -} - -// --------------------------------------------------------------------------- -// getCollectionClient -// --------------------------------------------------------------------------- -// -VideoCollectionClient* VideoListDataModel::getCollectionClient() -{ - if(!this->mCollectionClient) - { - mCollectionClient = new VideoCollectionClient(); - } - return mCollectionClient; -} - -// --------------------------------------------------------------------------- -// rowCount -// --------------------------------------------------------------------------- -// -int VideoListDataModel::rowCount(const QModelIndex &parent) const -{ - if (parent.isValid()) - { - return 0; - } - return mData.count(); -} - -// --------------------------------------------------------------------------- -// itemData -// --------------------------------------------------------------------------- -// -QMap VideoListDataModel::itemData(const QModelIndex &index) const -{ - Q_UNUSED(index); - QMap itemData; - - return itemData; -} - -// --------------------------------------------------------------------------- -// data -// --------------------------------------------------------------------------- -// -QVariant VideoListDataModel::data(const QModelIndex & index, int role) const -{ - QVariant returnValue = QVariant(); - if(!index.isValid()) - { - return returnValue; - } - if(mReturnInvalid) - { - return returnValue; - } - int row = index.row(); - if(role == VideoCollectionCommon::KeyTitle) - { - if(row >= 0 && row < mData.count()) - { - returnValue = mData.at(row)->mName; - } - } - else if(role == VideoCollectionCommon::KeySizeValue || - role == VideoCollectionCommon::KeyNumberOfItems) - { - if(row >= 0 && row < mData.count()) - { - returnValue = mData.at(row)->mSize; - } - } - else if(role == VideoCollectionCommon::KeyDateTime) - { - if(row >= 0 && row < mData.count()) - { - returnValue = mData.at(row)->mDate; - } - } - else if(role == VideoCollectionCommon::KeyStatus) - { - if(row >= 0 && row < mData.count()) - { - returnValue = mData.at(row)->mStatus; - } - } - else if(role == INVALID_ROLE_FOR_SORTING) - { - if(row >= 0 && row < mData.count()) - { - returnValue = mData.at(row)->mName; - } - } - return returnValue; -} - -// --------------------------------------------------------------------------- -// columnCount -// --------------------------------------------------------------------------- -// -int VideoListDataModel::columnCount(const QModelIndex & parent) const -{ - if (parent.isValid()) - { - return 0; - } - else - { - return 1; - } -} - -// --------------------------------------------------------------------------- -// index -// --------------------------------------------------------------------------- -// -QModelIndex VideoListDataModel::index(int row, int column, const QModelIndex & parent) const -{ - Q_UNUSED(parent); - if(row >= 0 && row < mData.count()) - { - return createIndex(row, column); - } - return QModelIndex(); -} - -// --------------------------------------------------------------------------- -// parent -// --------------------------------------------------------------------------- -// -QModelIndex VideoListDataModel::parent(const QModelIndex & index) const -{ - Q_UNUSED(index); - return QModelIndex(); -} - -void VideoListDataModel::removeAll() -{ - beginRemoveRows(QModelIndex(), 0,0); - QList::iterator iter = mData.begin(); - while(iter != mData.end()) - { - delete *iter; - ++iter; - } - mData.clear(); - endRemoveRows(); -} - - -// --------------------------------------------------------------------------- -// emitAlbumChanged -// --------------------------------------------------------------------------- -// -void VideoListDataModel::emitAlbumChanged() -{ - emit albumChanged(); -} - -// --------------------------------------------------------------------------- -// appendData -// --------------------------------------------------------------------------- -// -void VideoListDataModel::appendData(TMPXItemId data) -{ - DummyData* obj; - for(int i = 0; i < mData.count(); ++i) - { - obj = mData.at(i); - if(obj->mId == TMPXItemId::InvalidId() || obj->mId.iId1 == data.iId1) - { - obj->mId = data; - QModelIndex change = index(i,0); - emit dataChanged(change, change); - return; - } - } - beginInsertRows(QModelIndex(), mData.count(), mData.count()); - obj = new DummyData; - obj->mId = data; - mData.append(obj); - endInsertRows(); -} - - -// --------------------------------------------------------------------------- -// appendData -// --------------------------------------------------------------------------- -// -void VideoListDataModel::appendData(QString data) -{ - DummyData* obj; - for(int i = 0; i < mData.count(); ++i) - { - obj = mData.at(i); - if(!obj->mName.length()) - { - obj->mName = data; - QModelIndex change = index(i,0); - emit dataChanged(change, change); - return; - } - } - beginInsertRows(QModelIndex(), mData.count(), mData.count()); - obj = new DummyData; - obj->mId = TMPXItemId( mData.count(), 0); - obj->mName = data; - mData.append(obj); - endInsertRows(); -} - -// --------------------------------------------------------------------------- -// appendData -// --------------------------------------------------------------------------- -// -void VideoListDataModel::appendData(uint data) -{ - DummyData* obj; - for(int i = 0; i < mData.count(); ++i) - { - obj = mData.at(i); - if(obj->mSize == 666) - { - obj->mSize = data; - QModelIndex change = index(i,0); - emit dataChanged(change, change); - return; - } - } - beginInsertRows(QModelIndex(), mData.count(), mData.count()); - obj = new DummyData; - obj->mId = TMPXItemId( mData.count(), 0); - obj->mSize = data; - mData.append(obj); - endInsertRows(); -} - -// --------------------------------------------------------------------------- -// appendData -// --------------------------------------------------------------------------- -// -void VideoListDataModel::appendData(QDateTime data) -{ - DummyData* obj; - for(int i = 0; i < mData.count(); ++i) - { - obj = mData.at(i); - if(!obj->mDate.isValid()) - { - obj->mDate = data; - QModelIndex change = index(i,0); - emit dataChanged(change, change); - return; - } - } - beginInsertRows(QModelIndex(), mData.count(), mData.count()); - obj = new DummyData; - obj->mId = TMPXItemId( mData.count(), 0); - obj->mDate = data; - mData.append(obj); - endInsertRows(); -} - -// --------------------------------------------------------------------------- -// appendStatus -// --------------------------------------------------------------------------- -// -void VideoListDataModel::appendStatus(int status) -{ - DummyData* obj; - for(int i = 0; i < mData.count(); ++i) - { - obj = mData.at(i); - if(obj->mStatus == -1) - { - obj->mStatus = status; - QModelIndex change = index(i,0); - emit dataChanged(change, change); - return; - } - } - beginInsertRows(QModelIndex(), mData.count(), mData.count()); - obj = new DummyData; - obj->mId = TMPXItemId( mData.count(), 0); - obj->mStatus = status; - mData.append(obj); - endInsertRows(); -} - -// --------------------------------------------------------------------------- -// setAlbumInUse -// --------------------------------------------------------------------------- -// -void VideoListDataModel::setAlbumInUse(TMPXItemId itemId) -{ - mAlbumInUse = itemId; -} - -// --------------------------------------------------------------------------- -// albumInUse -// --------------------------------------------------------------------------- -// -TMPXItemId VideoListDataModel::albumInUse() -{ - return mAlbumInUse; -} - -// --------------------------------------------------------------------------- -// belongsToAlbum -// --------------------------------------------------------------------------- -// -bool VideoListDataModel::belongsToAlbum(TMPXItemId itemId, TMPXItemId albumId ) -{ - Q_UNUSED(itemId); - Q_UNUSED(albumId); - return mBelongsToAlbum; -} - -// --------------------------------------------------------------------------- -// removeItemsFromAlbum -// --------------------------------------------------------------------------- -// -int VideoListDataModel::removeItemsFromAlbum(TMPXItemId &albumId, const QList &items) -{ - Q_UNUSED(albumId); - Q_UNUSED(items); - return mRemoveFrAlbumReturn; -} - -// --------------------------------------------------------------------------- -// indexOfId -// --------------------------------------------------------------------------- -// -QModelIndex VideoListDataModel::indexOfId(TMPXItemId id) -{ - QModelIndex itemIndex; - DummyData* obj; - for(int i = 0; i < mData.count(); ++i) - { - obj = mData.at(i); - if(obj->mId == id) - { - itemIndex = index(i,0,QModelIndex()); - break; - } - } - return itemIndex; -} - -// End of file - - - diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/stub/src/videothumbnaildata.cpp --- a/videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/stub/src/videothumbnaildata.cpp Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: CVideoThumbnailData class implementation -* -*/ - -// INCLUDE FILES -#include -#include -#include -#include -#include - -#include "videothumbnaildata.h" - -int VideoThumbnailData::mEnableBackgroundThumbnailFetchingCallCount = 0; -int VideoThumbnailData::mStartFetchingThumbnailsCallCount = 0; -int VideoThumbnailData::mStartFetchingThumbnailsThumbnailCount = 0; -int VideoThumbnailData::mInstanceCallCount = 0; -int VideoThumbnailData::mBackgroundThumbnailFetchingEnabled = true; -int VideoThumbnailData::mFreeThumbnailDataCallCount = 0; -int VideoThumbnailData::mStartBackgroundFetchingCallCount = 0; - -// ----------------------------------------------------------------------------- -// VideoThumbnailData::instance() -// ----------------------------------------------------------------------------- -// -VideoThumbnailData &VideoThumbnailData::instance() -{ - mInstanceCallCount++; - static VideoThumbnailData _thumbnailData; - return _thumbnailData; -} - -// ----------------------------------------------------------------------------- -// VideoThumbnailData::VideoThumbnailData() -// ----------------------------------------------------------------------------- -// -VideoThumbnailData::VideoThumbnailData() -{ - -} - -// ----------------------------------------------------------------------------- -// VideoThumbnailData::~VideoThumbnailData() -// ----------------------------------------------------------------------------- -// -VideoThumbnailData::~VideoThumbnailData() -{ - -} - -// ----------------------------------------------------------------------------- -// VideoThumbnailData::startBackgroundFetching() -// ----------------------------------------------------------------------------- -// -void VideoThumbnailData::startBackgroundFetching(VideoSortFilterProxyModel *model, int fetchIndex) -{ - Q_UNUSED(model); - Q_UNUSED(fetchIndex); - mStartBackgroundFetchingCallCount++; -} - -// ----------------------------------------------------------------------------- -// VideoThumbnailData::enableBackgroundFetching() -// ----------------------------------------------------------------------------- -// -void VideoThumbnailData::enableBackgroundFetching(bool enable) -{ - mBackgroundThumbnailFetchingEnabled = enable; - mEnableBackgroundThumbnailFetchingCallCount++; -} - -// ----------------------------------------------------------------------------- -// VideoThumbnailData::freeThumbnailData() -// ----------------------------------------------------------------------------- -// -void VideoThumbnailData::freeThumbnailData() -{ - mFreeThumbnailDataCallCount++; -} - -// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/testvideosortfilterproxymodel.pro --- a/videocollection/videocollectionwrapper/tsrc/testvideosortfilterproxymodel/testvideosortfilterproxymodel.pro Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -# ##################################################################### -# Automatically generated by qmake (2.01a) Tue 5. May 13:25:42 2009 -# ##################################################################### -TEMPLATE = app -TARGET = -DEFINES += BUILD_VIDEOCOLLECTION_DLL -DEPENDPATH += . \ - inc \ - src -INCLUDEPATH += . \ - /epoc32/include/domain \ - /epoc32/include/domain/middleware \ - /epoc32/include/domain/applications \ - /epoc32/include/osextensions \ - /epoc32/include/middleware \ - /epoc32/include/osextensions/stdapis/stlport \ - ../../../inc - -CONFIG += qtestlib \ - Hb \ - symbian_test - -LIBS += -lestor.dll \ - -lfbscli.dll \ - -lbitgdi.dll \ - -lgdi.dll - -# Input -HEADERS += inc/testvideosortfilterproxymodel.h \ - stub/inc/filterproxytester.h \ - stub/inc/videolistdatamodel.h \ - stub/inc/videocollectionclient.h \ - stub/inc/videothumbnaildata.h \ - stub/inc/videocollectionwrapper.h \ - ../../inc/videosortfilterproxymodel.h \ - ../../../inc/videocollectionexport.h - -SOURCES += src/testvideosortfilterproxymodel.cpp \ - stub/src/filterproxytester.cpp \ - stub/src/videolistdatamodel.cpp \ - stub/src/videocollectionclient.cpp \ - stub/src/videothumbnaildata.cpp \ - ../../src/videosortfilterproxymodel.cpp diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata/stub/inc/videothumbnaildata_p.h --- a/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata/stub/inc/videothumbnaildata_p.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata/stub/inc/videothumbnaildata_p.h Fri Sep 17 08:30:05 2010 +0300 @@ -28,7 +28,7 @@ #include // FORWARD DECLARATIONS -class VideoSortFilterProxyModel +class VideoProxyModelGeneric { public: int ooo; @@ -129,7 +129,7 @@ * @param model * @param fetchIndex index where to start the background thumbnail fetching. */ - void startBackgroundFetching(VideoSortFilterProxyModel *model, int fetchIndex); + void startBackgroundFetching(VideoProxyModelGeneric *model, int fetchIndex); /** * Enables thumbnail creation. diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata/stub/src/videothumbnaildata_p.cpp --- a/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata/stub/src/videothumbnaildata_p.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata/stub/src/videothumbnaildata_p.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -117,7 +117,7 @@ // VideoThumbnailData::startBackgroundFetching() // ----------------------------------------------------------------------------- // -void VideoThumbnailDataPrivate::startBackgroundFetching(VideoSortFilterProxyModel *model, int fetchIndex) +void VideoThumbnailDataPrivate::startBackgroundFetching(VideoProxyModelGeneric */*model*/, int /*fetchIndex*/) { mStartBackgroundFetchingCallCount++; } @@ -126,7 +126,7 @@ // VideoThumbnailData::enableThumbnailCreation() // ----------------------------------------------------------------------------- // -void VideoThumbnailDataPrivate::enableThumbnailCreation(bool enable) +void VideoThumbnailDataPrivate::enableThumbnailCreation(bool /*enable*/) { mEnableThumbnailCreationCallCount++; } diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/inc/testvideothumbnaildata_p.h --- a/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/inc/testvideothumbnaildata_p.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/inc/testvideothumbnaildata_p.h Fri Sep 17 08:30:05 2010 +0300 @@ -23,7 +23,7 @@ // FORWARD DECLARATIONS class VideoThumbnailDataTester; -class VideoSortFilterProxyModel; +class VideoProxyModelGeneric; class VideoCollectionWrapper; class QSignalSpy; @@ -63,7 +63,7 @@ private: VideoThumbnailDataTester *mTestObject; - VideoSortFilterProxyModel *mModel; + VideoProxyModelGeneric *mModel; public: VideoCollectionWrapper *mWrapper; diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/inc/videothumbnaildatatester.h --- a/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/inc/videothumbnaildatatester.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/inc/videothumbnaildatatester.h Fri Sep 17 08:30:05 2010 +0300 @@ -22,7 +22,7 @@ #include #include "videothumbnaildata_p.h" -class VideoSortFilterProxyModel; +class VideoProxyModelGeneric; class VideoThumbnailDataTester : public VideoThumbnailDataPrivate { @@ -66,7 +66,7 @@ /** * Calls CVideoThumbnailDataPrivate::initialize */ - void initialize(); + int initialize(); /** * Calls CVideoThumbnailDataPrivate::cleanup diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/src/testvideothumbnaildata_p.cpp --- a/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/src/testvideothumbnaildata_p.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/src/testvideothumbnaildata_p.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -28,7 +28,7 @@ #include "testvideothumbnaildata_p.h" #include "videothumbnailfetcher.h" -#include "videosortfilterproxymodel.h" +#include "videoproxymodelgeneric.h" #include "videocollectionwrapper.h" #include "e32std.h" @@ -115,14 +115,14 @@ VideoThumbnailFetcher::mAddFetchFails = false; VideoThumbnailFetcher::mThumbnailReadyError = 0; - mModel = new VideoSortFilterProxyModel(); + mModel = new VideoProxyModelGeneric(); VideoCollectionWrapper::instance().setModel(mModel); mTestObject = new VideoThumbnailDataTester(); mTestObject->initialize(); mTestObject->mCurrentModel = mModel; - VideoSortFilterProxyModel::mReturnInvalidIndexes = false; - VideoSortFilterProxyModel::mRowCountCallCount = 0; + VideoProxyModelGeneric::mReturnInvalidIndexes = false; + VideoProxyModelGeneric::mRowCountCallCount = 0; qRegisterMetaType >("QList& "); } @@ -186,35 +186,19 @@ // void TestVideoThumbnailData_p::testInitialize() { - VideoCollectionWrapper::instance().setModel(0); - mTestObject = new VideoThumbnailDataTester(); - QVERIFY(mTestObject->mThumbnailFetcher == 0); - QVERIFY(mTestObject->mCurrentModel == 0); - QVERIFY(mTestObject->mBgFetchTimer == 0); - cleanup(); - - mTestObject = new VideoThumbnailDataTester(); - mTestObject->disconnectSignals(); - delete mTestObject->mBgFetchTimer; - mTestObject->mBgFetchTimer = 0; - delete mTestObject->mThumbnailFetcher; - mTestObject->mThumbnailFetcher = 0; - mTestObject->mCurrentModel = 0; - - mTestObject->initialize(); - QVERIFY(mTestObject->mThumbnailFetcher == 0); - QVERIFY(mTestObject->mCurrentModel == 0); - QVERIFY(mTestObject->mBgFetchTimer == 0); - cleanup(); - - init(); - mTestObject->initialize(); - mTestObject->initialize(); + QVERIFY(mTestObject->initialize() == 0); + VideoThumbnailFetcher *fetcher = mTestObject->mThumbnailFetcher; + QTimer *ftimer = mTestObject->mBgFetchTimer; + QTimer *rtimer = mTestObject->mTbnReportTimer; QVERIFY(mTestObject->mThumbnailFetcher != 0); - QVERIFY(mTestObject->mCurrentModel != 0); QVERIFY(mTestObject->mBgFetchTimer != 0); - QCOMPARE( mTestObject->mThumbnailFetcher->mConstructorCallCount, 1); + QVERIFY(mTestObject->mTbnReportTimer != 0); + QVERIFY(mTestObject->initialize() == 0); + // Verify they are still the same. + QVERIFY(mTestObject->mThumbnailFetcher == fetcher); + QVERIFY(mTestObject->mBgFetchTimer == ftimer); + QVERIFY(mTestObject->mTbnReportTimer == rtimer); cleanup(); } @@ -224,7 +208,6 @@ // void TestVideoThumbnailData_p::testGetThumbnail() { - int mediaid(50); QPixmap pixmap(100,100); pixmap.fill(Qt::blue); @@ -248,7 +231,7 @@ // Tests when mModel is null. init(); - VideoSortFilterProxyModel* backupProxyModel = mTestObject->mCurrentModel; + VideoProxyModelGeneric* backupProxyModel = mTestObject->mCurrentModel; mTestObject->mCurrentModel = NULL; spy = new QSignalSpy(mTestObject, SIGNAL(thumbnailsFetched(QList &))); QCOMPARE(mTestObject->startFetchingThumbnail(TMPXItemId(0, 0), TB_PRIORITY), -1); @@ -358,7 +341,7 @@ indexes.append(mTestObject->mCurrentModel->index(0, 0, QModelIndex())); indexes.append(mTestObject->mCurrentModel->index(10, 0, QModelIndex())); indexes.append(mTestObject->mCurrentModel->index(20, 0, QModelIndex())); - VideoSortFilterProxyModel* backupProxyModel = mTestObject->mCurrentModel; + VideoProxyModelGeneric* backupProxyModel = mTestObject->mCurrentModel; mTestObject->mCurrentModel = NULL; spy = new QSignalSpy(mTestObject, SIGNAL(thumbnailsFetched(QList &))); @@ -481,7 +464,7 @@ // Tests when mModel is null. init(); - VideoSortFilterProxyModel* backupProxyModel = mTestObject->mCurrentModel; + VideoProxyModelGeneric* backupProxyModel = mTestObject->mCurrentModel; mTestObject->mCurrentModel = NULL; spy = new QSignalSpy(mTestObject, SIGNAL(thumbnailsFetched(QList &))); mTestObject->emitDoBackgroundFetching(); @@ -490,7 +473,7 @@ QCOMPARE(VideoThumbnailFetcher::mRequests.count(), 0); mTestObject->mCurrentModel = backupProxyModel; QVERIFY(mTestObject->mCurrentFetchIndex == 0); - QCOMPARE(VideoSortFilterProxyModel::mRowCountCallCount, 0); + QCOMPARE(VideoProxyModelGeneric::mRowCountCallCount, 0); cleanup(); // Tests when mThumbnailFetcher is null. @@ -621,7 +604,7 @@ mTestObject->mCurrentModel->appendData(QString("file") + QString::number(i)); } spy = new QSignalSpy(mTestObject, SIGNAL(thumbnailsFetched(QList&))); - VideoSortFilterProxyModel::mReturnInvalidIndexes = true; + VideoProxyModelGeneric::mReturnInvalidIndexes = true; mTestObject->mCurrentFetchIndex = THUMBNAIL_BACKGROUND_FETCH_AMOUNT/2; mTestObject->emitDoBackgroundFetching(); QVERIFY(checkThumbnailReadyCount(spy, 0)); @@ -716,15 +699,6 @@ // Second call when tn has been loaded already. QVERIFY(tn == mTestObject->defaultThumbnail(TMPXItemId(0, KVcxMvcMediaTypeAlbum))); QVERIFY(mTestObject->mDefaultThumbnails.count() == 2); - - // Default tn for unknown category - tn = mTestObject->defaultThumbnail(TMPXItemId(555, KVcxMvcMediaTypeCategory)); - QVERIFY( tn != 0 ); - QVERIFY( tn->isNull() == false ); - // Second call when tn has been loaded already. - QVERIFY(tn == mTestObject->defaultThumbnail(TMPXItemId(0, KVcxMvcMediaTypeCategory))); - // Still two because icon is same as default album - QVERIFY(mTestObject->mDefaultThumbnails.count() == 2); // Default tn for downloads category tn = mTestObject->defaultThumbnail(TMPXItemId(KVcxMvcCategoryIdDownloads, KVcxMvcMediaTypeCategory)); @@ -743,20 +717,13 @@ QVERIFY(mTestObject->mDefaultThumbnails.count() == 4); cleanup(); - init(); - QVERIFY(mTestObject->mDefaultThumbnails.count() == 0); - // Default tn for unknown category, tn not loaded + // Default tn for unknown category. tn = mTestObject->defaultThumbnail(TMPXItemId(555, KVcxMvcMediaTypeCategory)); - QVERIFY( tn != 0 ); - QVERIFY( tn->isNull() == false ); - // Second call when tn has been loaded already. - QVERIFY(tn == mTestObject->defaultThumbnail(TMPXItemId(0, KVcxMvcMediaTypeCategory))); - // Still two because icon is same as default album - QVERIFY(mTestObject->mDefaultThumbnails.count() == 1); + QVERIFY( tn == 0 ); cleanup(); } @@ -810,7 +777,7 @@ // Set new model. mTestObject->mBackgroundFetchingEnabled = true; - VideoSortFilterProxyModel *model = mTestObject->mCurrentModel; + VideoProxyModelGeneric *model = mTestObject->mCurrentModel; mTestObject->mCurrentModel = 0; mTestObject->mCurrentFetchIndex = -5; mTestObject->startBackgroundFetching(model, 10); @@ -955,4 +922,5 @@ cleanup(); } + // End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/src/videothumbnaildatatester.cpp --- a/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/src/videothumbnaildatatester.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/src/videothumbnaildatatester.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -75,9 +75,9 @@ // VideoThumbnailDataTester::initialize() // ----------------------------------------------------------------------------- // -void VideoThumbnailDataTester::initialize() +int VideoThumbnailDataTester::initialize() { - VideoThumbnailDataPrivate::initialize(); + return VideoThumbnailDataPrivate::initialize(); } // ----------------------------------------------------------------------------- diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/stub/inc/videocollectionwrapper.h --- a/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/stub/inc/videocollectionwrapper.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/stub/inc/videocollectionwrapper.h Fri Sep 17 08:30:05 2010 +0300 @@ -25,7 +25,7 @@ #include // FORWARD DECLARATIONS -class VideoSortFilterProxyModel; +class VideoProxyModelGeneric; class VideoCollectionWrapper : public QObject @@ -59,13 +59,13 @@ * * @return address to model or NULL if fails. */ - VideoSortFilterProxyModel* getModel(VideoCollectionCommon::TModelType type); + VideoProxyModelGeneric* getGenericModel(); /* Additional functions needed for testing purposes */ void reset(); - void setModel(VideoSortFilterProxyModel* model); + void setModel(VideoProxyModelGeneric* model); signals: @@ -89,7 +89,7 @@ private: - VideoSortFilterProxyModel* mModel; + VideoProxyModelGeneric* mModel; public: diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/stub/inc/videoproxymodelgeneric.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/stub/inc/videoproxymodelgeneric.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,137 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Videolist sort filter proxy stub implementation +* +*/ + +#ifndef VIDEOPROXYMODELGENERIC_H +#define VIDEOPROXYMODELGENERIC_H + +#include +#include +#include +#include + +class VideoProxyModelGeneric : public QSortFilterProxyModel +{ + Q_OBJECT + +public: + + /** + * Contructor. + * + * @param parent parent of this widget + */ + VideoProxyModelGeneric(QObject *parent=0); + + /** + * Destructor. + * + */ + virtual ~VideoProxyModelGeneric(); + +public: + + /** + * Method checks that model exists and asks for mpx id from + * given object. + * + * @param index index of the item. + * @return int mpx id if succeeds, -1 in case of error + * + */ + TMPXItemId getMediaIdAtIndex(QModelIndex index); + + /** + * Returns filepath. + * + * @param mediaId id for the item, only iId1 is used. + * @returns file path for the item. + */ + QString getMediaFilePathForId(TMPXItemId mediaId); + + /** + * Return to collection level + * + */ + void back(); + + /** + * Return source model. + * + */ + VideoProxyModelGeneric* sourceModel(); + +public: // Simplified data access. + /** + * Return count of filenames. + * + */ + int rowCount(const QModelIndex & parent = QModelIndex()) const; + + /** + * Return specified index. + * + */ + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; + + /** + * Returns copy of the given index. + * + */ + QModelIndex mapToSource(const QModelIndex &proxyIndex) const; + +signals: + + /** + * Signals that the model is ready, ie. that all data has been + * loaded from myvideoscollection. + */ + void modelReady(); + + /** + * notifies that model's physical data structure has changed: + * - item inserted + * - item removed + */ + void modelChanged(); + +public: // Test helper methods. + + static void reset(); + + void appendData(QString fileName); + +protected: // from QSortFilterProxyModel + + /** + * Compares items based in the role setted before sorting. + * + */ + bool lessThan ( const QModelIndex & left, const QModelIndex & right ) const; + +public: + + // Incremented at rowCount calls. + static int mRowCountCallCount; + + // If true index() returns invalid indexes. + static bool mReturnInvalidIndexes; + + // Model items. + QList mFileNames; +}; + +#endif // VIDEOPROXYMODELGENERIC_H diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/stub/inc/videosortfilterproxymodel.h --- a/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/stub/inc/videosortfilterproxymodel.h Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,137 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Videolist sort filter proxy stub implementation -* -*/ - -#ifndef VIDEOSORTFILTERPROXYMODEL_H -#define VIDEOSORTFILTERPROXYMODEL_H - -#include -#include -#include -#include - -class VideoSortFilterProxyModel : public QSortFilterProxyModel -{ - Q_OBJECT - -public: - - /** - * Contructor. - * - * @param parent parent of this widget - */ - VideoSortFilterProxyModel(QObject *parent=0); - - /** - * Destructor. - * - */ - virtual ~VideoSortFilterProxyModel(); - -public: - - /** - * Method checks that model exists and asks for mpx id from - * given object. - * - * @param index index of the item. - * @return int mpx id if succeeds, -1 in case of error - * - */ - TMPXItemId getMediaIdAtIndex(QModelIndex index); - - /** - * Returns filepath. - * - * @param mediaId id for the item, only iId1 is used. - * @returns file path for the item. - */ - QString getMediaFilePathForId(TMPXItemId mediaId); - - /** - * Return to collection level - * - */ - void back(); - - /** - * Return source model. - * - */ - VideoSortFilterProxyModel* sourceModel(); - -public: // Simplified data access. - /** - * Return count of filenames. - * - */ - int rowCount(const QModelIndex & parent = QModelIndex()) const; - - /** - * Return specified index. - * - */ - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; - - /** - * Returns copy of the given index. - * - */ - QModelIndex mapToSource(const QModelIndex &proxyIndex) const; - -signals: - - /** - * Signals that the model is ready, ie. that all data has been - * loaded from myvideoscollection. - */ - void modelReady(); - - /** - * notifies that model's physical data structure has changed: - * - item inserted - * - item removed - */ - void modelChanged(); - -public: // Test helper methods. - - static void reset(); - - void appendData(QString fileName); - -protected: // from QSortFilterProxyModel - - /** - * Compares items based in the role setted before sorting. - * - */ - bool lessThan ( const QModelIndex & left, const QModelIndex & right ) const; - -public: - - // Incremented at rowCount calls. - static int mRowCountCallCount; - - // If true index() returns invalid indexes. - static bool mReturnInvalidIndexes; - - // Model items. - QList mFileNames; -}; - -#endif //VIDEOSORTFILTERPROXYMODEL_H diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/stub/src/videocollectionwrapper.cpp --- a/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/stub/src/videocollectionwrapper.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/stub/src/videocollectionwrapper.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -55,9 +55,8 @@ // VideoCollectionWrapper::open() // ----------------------------------------------------------------------------- // -VideoSortFilterProxyModel* VideoCollectionWrapper::getModel(VideoCollectionCommon::TModelType type) +VideoProxyModelGeneric* VideoCollectionWrapper::getGenericModel() { - Q_UNUSED(type); return mModel; } @@ -74,7 +73,7 @@ // VideoCollectionWrapper::setModel() // ----------------------------------------------------------------------------- // -void VideoCollectionWrapper::setModel(VideoSortFilterProxyModel* model) +void VideoCollectionWrapper::setModel(VideoProxyModelGeneric* model) { Q_UNUSED(model); mModel = model; diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/stub/src/videoproxymodelgeneric.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/stub/src/videoproxymodelgeneric.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,144 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Videolist sort filter proxy stub implementation +* +*/ + +#include +#include + +#include "videocollectioncommon.h" +#include "videoproxymodelgeneric.h" + +int VideoProxyModelGeneric::mRowCountCallCount = 0; +bool VideoProxyModelGeneric::mReturnInvalidIndexes = false; + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::VideoProxyModelGeneric +// ----------------------------------------------------------------------------- +// +VideoProxyModelGeneric::VideoProxyModelGeneric(QObject *parent) : + QSortFilterProxyModel(parent) +{ + reset(); +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::~VideoProxyModelGeneric +// ----------------------------------------------------------------------------- +// +VideoProxyModelGeneric::~VideoProxyModelGeneric() +{ + disconnect(); +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::lessThan +// ----------------------------------------------------------------------------- +// +bool VideoProxyModelGeneric::lessThan(const QModelIndex &left, const QModelIndex &right) const +{ + Q_UNUSED(left); + Q_UNUSED(right); + return false; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::getMediaIdAtIndex +// ----------------------------------------------------------------------------- +// +TMPXItemId VideoProxyModelGeneric::getMediaIdAtIndex(QModelIndex index) +{ + return TMPXItemId(index.row(), 0); +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::getMediaFilePathForId() +// ----------------------------------------------------------------------------- +// +QString VideoProxyModelGeneric::getMediaFilePathForId(TMPXItemId mediaId) +{ + if(mediaId.iId1 >= 0 && mediaId.iId1 < mFileNames.count()) + { + return mFileNames.at(mediaId.iId1); + } + return ""; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::back +// ----------------------------------------------------------------------------- +// +void VideoProxyModelGeneric::back() +{ +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::reset +// ----------------------------------------------------------------------------- +// +void VideoProxyModelGeneric::reset() +{ + +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::appendData +// ----------------------------------------------------------------------------- +// +void VideoProxyModelGeneric::appendData(QString fileName) +{ + mFileNames.append(fileName); +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::rowCount +// ----------------------------------------------------------------------------- +// +int VideoProxyModelGeneric::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + VideoProxyModelGeneric::mRowCountCallCount++; + return mFileNames.count(); +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::index +// ----------------------------------------------------------------------------- +// +QModelIndex VideoProxyModelGeneric::index(int row, int column, const QModelIndex &parent) const +{ + Q_UNUSED(parent); + if(mReturnInvalidIndexes) + return QModelIndex(); + else + return QModelIndex(createIndex(row, column)); +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::mapToSource +// ----------------------------------------------------------------------------- +// +QModelIndex VideoProxyModelGeneric::mapToSource(const QModelIndex &proxyIndex) const +{ + return QModelIndex(proxyIndex); +} + +VideoProxyModelGeneric* VideoProxyModelGeneric::sourceModel() +{ + return this; +} + +// end of file + diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/stub/src/videosortfilterproxymodel.cpp --- a/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/stub/src/videosortfilterproxymodel.cpp Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,140 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Videolist sort filter proxy stub implementation -* -*/ - -#include -#include - -#include "videocollectioncommon.h" -#include "videosortfilterproxymodel.h" - -int VideoSortFilterProxyModel::mRowCountCallCount = 0; -bool VideoSortFilterProxyModel::mReturnInvalidIndexes = false; - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::VideoSortFilterProxyModel -// ----------------------------------------------------------------------------- -// -VideoSortFilterProxyModel::VideoSortFilterProxyModel(QObject *parent) : - QSortFilterProxyModel(parent) -{ - reset(); -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::~VideoSortFilterProxyModel -// ----------------------------------------------------------------------------- -// -VideoSortFilterProxyModel::~VideoSortFilterProxyModel() -{ - disconnect(); -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::lessThan -// ----------------------------------------------------------------------------- -// -bool VideoSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const -{ - return false; -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::getMediaIdAtIndex -// ----------------------------------------------------------------------------- -// -TMPXItemId VideoSortFilterProxyModel::getMediaIdAtIndex(QModelIndex index) -{ - return TMPXItemId(index.row(), 0); -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::getMediaFilePathForId() -// ----------------------------------------------------------------------------- -// -QString VideoSortFilterProxyModel::getMediaFilePathForId(TMPXItemId mediaId) -{ - if(mediaId.iId1 >= 0 && mediaId.iId1 < mFileNames.count()) - { - return mFileNames.at(mediaId.iId1); - } - return ""; -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::back -// ----------------------------------------------------------------------------- -// -void VideoSortFilterProxyModel::back() -{ -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::reset -// ----------------------------------------------------------------------------- -// -void VideoSortFilterProxyModel::reset() -{ - -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::appendData -// ----------------------------------------------------------------------------- -// -void VideoSortFilterProxyModel::appendData(QString fileName) -{ - mFileNames.append(fileName); -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::rowCount -// ----------------------------------------------------------------------------- -// -int VideoSortFilterProxyModel::rowCount(const QModelIndex &parent) const -{ - VideoSortFilterProxyModel::mRowCountCallCount++; - return mFileNames.count(); -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::index -// ----------------------------------------------------------------------------- -// -QModelIndex VideoSortFilterProxyModel::index(int row, int column, const QModelIndex &parent) const -{ - if(mReturnInvalidIndexes) - return QModelIndex(); - else - return QModelIndex(createIndex(row, column)); -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::mapToSource -// ----------------------------------------------------------------------------- -// -QModelIndex VideoSortFilterProxyModel::mapToSource(const QModelIndex &proxyIndex) const -{ - return QModelIndex(proxyIndex); -} - -VideoSortFilterProxyModel* VideoSortFilterProxyModel::sourceModel() -{ - return this; -} - -// end of file - diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/stub/src/videothumbnailfetcher.cpp --- a/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/stub/src/videothumbnailfetcher.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/stub/src/videothumbnailfetcher.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -77,7 +77,7 @@ // VideoThumbnailFetcher::continueFetching() // ----------------------------------------------------------------------------- // -void VideoThumbnailFetcher::continueFetching(bool cancelOngoingFetches) +void VideoThumbnailFetcher::continueFetching(bool /*cancelOngoingFetches*/) { mContinueFetchingCallCount++; } @@ -115,7 +115,7 @@ // VideoThumbnailFetcher::enableThumbnailCreation() // ----------------------------------------------------------------------------- // -void VideoThumbnailFetcher::enableThumbnailCreation(bool enable) +void VideoThumbnailFetcher::enableThumbnailCreation(bool /*enable*/) { mEnableThumbnailCreationCallCount++; } diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/testvideothumbnaildata_p.pro --- a/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/testvideothumbnaildata_p.pro Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/tsrc/testvideothumbnaildata_p/testvideothumbnaildata_p.pro Fri Sep 17 08:30:05 2010 +0300 @@ -55,7 +55,7 @@ inc/videothumbnaildatatester.h \ stub/inc/videothumbnailfetcher.h \ stub/inc/videocollectionwrapper.h \ - stub/inc/videosortfilterproxymodel.h \ + stub/inc/videoproxymodelgeneric.h \ ../../inc/videothumbnaildata_p.h \ ../../../inc/videocollectionexport.h @@ -63,5 +63,5 @@ src/videothumbnaildatatester.cpp \ stub/src/videothumbnailfetcher.cpp \ stub/src/videocollectionwrapper.cpp \ - stub/src/videosortfilterproxymodel.cpp \ + stub/src/videoproxymodelgeneric.cpp \ ../../src/videothumbnaildata_p.cpp diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videocollectionwrapper/videocollectionwrapper.pro --- a/videocollection/videocollectionwrapper/videocollectionwrapper.pro Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videocollectionwrapper/videocollectionwrapper.pro Fri Sep 17 08:30:05 2010 +0300 @@ -57,7 +57,10 @@ inc/videothumbnaildata_p.h \ inc/videothumbnailfetcher.h \ inc/videocollectionutils.h \ - inc/videosortfilterproxymodel.h \ + inc/videoproxymodelgeneric.h \ + inc/videoproxymodelallvideos.h \ + inc/videoproxymodelcollections.h \ + inc/videoproxymodelcontent.h \ inc/videodatacontainer.h \ inc/videodeleteworker.h \ ../inc/videocollectionexport.h @@ -72,7 +75,10 @@ src/videothumbnaildata_p.cpp \ src/videothumbnailfetcher.cpp \ src/videocollectionutils.cpp \ - src/videosortfilterproxymodel.cpp \ + src/videoproxymodelgeneric.cpp \ + src/videoproxymodelallvideos.cpp \ + src/videoproxymodelcollections.cpp \ + src/videoproxymodelcontent.cpp \ src/videodeleteworker.cpp \ src/videodatacontainer.cpp diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videofiledetailsview/inc/videofiledetailsviewplugin.h --- a/videocollection/videofiledetailsview/inc/videofiledetailsviewplugin.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videofiledetailsview/inc/videofiledetailsviewplugin.h Fri Sep 17 08:30:05 2010 +0300 @@ -26,7 +26,7 @@ #include #include -class VideoSortFilterProxyModel; +class VideoProxyModelGeneric; class QModelIndex; class HbAction; class HbMarqueeItem; @@ -236,7 +236,7 @@ /** * Pointer to the model that holds video details. Not owned. */ - VideoSortFilterProxyModel* mModel; + VideoProxyModelGeneric* mModel; /** * pointer to videoservices instance diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videofiledetailsview/src/videofiledetailsviewplugin.cpp --- a/videocollection/videofiledetailsview/src/videofiledetailsviewplugin.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videofiledetailsview/src/videofiledetailsviewplugin.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 76.1.8 % +// Version : %version: 76.1.9 % // INCLUDE FILES #include @@ -44,7 +44,7 @@ #include "videocollectioncommon.h" #include "mpxhbvideocommondefs.h" #include "videocollectionwrapper.h" -#include "videosortfilterproxymodel.h" +#include "videoproxymodelgeneric.h" #include "videoservices.h" #include "videodetailslabel.h" #include "videocollectiontrace.h" @@ -136,7 +136,7 @@ return; } - mModel = mCollectionWrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos); + mModel = mCollectionWrapper.getAllVideosModel(); if (!mModel) { diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videofiledetailsview/tsrc/testplugin/inc/testvideofiledetails.h --- a/videocollection/videofiledetailsview/tsrc/testplugin/inc/testvideofiledetails.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videofiledetailsview/tsrc/testplugin/inc/testvideofiledetails.h Fri Sep 17 08:30:05 2010 +0300 @@ -25,7 +25,7 @@ #include class VideoFileDetailsViewPlugin; -class VideoSortFilterProxyModel; +class VideoProxyModelGeneric; class VideoCollectionWrapper; class TestVideoFileDetails : public QObject @@ -207,7 +207,7 @@ /** * stub model */ - VideoSortFilterProxyModel* mDummyModel; + VideoProxyModelGeneric* mDummyModel; /** * Testable object diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videofiledetailsview/tsrc/testplugin/src/testvideofiledetails.cpp --- a/videocollection/videofiledetailsview/tsrc/testplugin/src/testvideofiledetails.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videofiledetailsview/tsrc/testplugin/src/testvideofiledetails.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -40,7 +40,7 @@ #include "videocollectioncommon.h" #include "mpxhbvideocommondefs.h" #include "videocollectionwrapper.h" -#include "videosortfilterproxymodel.h" +#include "videoproxymodelgeneric.h" #include "testvideofiledetails.h" // trick to get access to protected/private members. @@ -64,7 +64,7 @@ void TestVideoFileDetails::initTestCase() { mDummyModel = 0; - mDummyModel = new VideoSortFilterProxyModel(); + mDummyModel = new VideoProxyModelGeneric(); connect(this, SIGNAL(shortDetailsReady(TMPXItemId)), mDummyModel, SIGNAL(shortDetailsReady(TMPXItemId))); connect(this, SIGNAL(fullDetailsReady(QVariant&)), mDummyModel, SIGNAL(fullVideoDetailsReady(QVariant&))); diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videofiledetailsview/tsrc/testplugin/stub/inc/videocollectionwrapper.h --- a/videocollection/videofiledetailsview/tsrc/testplugin/stub/inc/videocollectionwrapper.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videofiledetailsview/tsrc/testplugin/stub/inc/videocollectionwrapper.h Fri Sep 17 08:30:05 2010 +0300 @@ -26,7 +26,7 @@ // FORWARD DECLARATIONS class QAbstractItemModel; -class VideoSortFilterProxyModel; +class VideoProxyModelGeneric; class VideoCollectionWrapper : public QObject @@ -62,7 +62,7 @@ /** * return mModel */ - VideoSortFilterProxyModel* getModel(int type); + VideoProxyModelGeneric* getAllVideosModel(); /** * NOP at the moment @@ -72,7 +72,7 @@ /** * sete mModel */ - void setModel(VideoSortFilterProxyModel* model); + void setModel(VideoProxyModelGeneric* model); signals: @@ -96,7 +96,7 @@ /** * model to be used when testing videofiledetailsviewplugin */ - VideoSortFilterProxyModel* mModel; + VideoProxyModelGeneric* mModel; public: diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videofiledetailsview/tsrc/testplugin/stub/inc/videoproxymodelgeneric.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videofiledetailsview/tsrc/testplugin/stub/inc/videoproxymodelgeneric.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,202 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Dummy videolistsortfilterproxymodel class definition* +*/ + +#ifndef VIDEOPROXYMODELGENERIC_H +#define VIDEOPROXYMODELGENERIC_H + +// INCLUDES +#include +#include +#include + +// FORWARD DECLARATIONS + + +class VideoProxyModelGeneric : public QAbstractItemModel +{ + /** + * define to be able to use signals and slots + */ + Q_OBJECT + + /** + * disable copy-constructor and assignment operator + */ + Q_DISABLE_COPY(VideoProxyModelGeneric) + +public: + + /** + * Default constructor + */ + VideoProxyModelGeneric(QObject *parent=0); + + /** + * Destructor + */ + ~VideoProxyModelGeneric(); + + /** + * sets index.row() to mStartPlaybackIndex + */ + int openItem(const TMPXItemId &index); + + /** + * sets first index.row() to mDeleteFileIndex + */ + int deleteItems(const QModelIndexList &indexList); + + /** + * returns qmodelindex of item id provided. + * + * @param item id + * @return QModelIndex; + */ + QModelIndex indexOfId(TMPXItemId id); + + + TMPXItemId getMediaIdAtIndex(const QModelIndex &index); + +signals: + + void shortDetailsReady(TMPXItemId index); + + void fullVideoDetailsReady(QVariant& variant); + +public: // from QAbstractItemModel + + VideoProxyModelGeneric* sourceModel(); + + /** + * Returns video item count + */ + int rowCount(const QModelIndex &parent = QModelIndex()) const; + + /** + * Returns video item data from index pointed by. + */ + QMap itemData(const QModelIndex &index) const; + + /** + * data + */ + QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; + + /** + * columnCount + */ + int columnCount(const QModelIndex & parent = QModelIndex()) const; + + /** + * index + */ + QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const; + + /** + * Parent + */ + QModelIndex parent(const QModelIndex & index) const; + +public: // dummy model helper methods + /** + * sets mDatareturnsInvalid + */ + void setDataReturnInvalid(bool setInvalid); + + /** + * returns mLastIndex + */ + QModelIndex lastIndex(); + + TMPXItemId lastId(); + + /** + * returns mDataAccessCount + */ + int dataAccessCount(); + + /** + * clear everything + */ + void reset(); + + /** + * sets role based value to mDatao + */ + void setData(int role, QVariant data); + + /** + * sets mRowCount + */ + void setRowCount(int count); + + /** + * returns mStartPlaybackIndex + */ + TMPXItemId startPlaybackIndex(); + + /** + * returns mDeleteFileIndex + */ + int deleteFileIndex(); + +private: + + /** + * map item to return from data(); + */ + QMap mData; + + /** + * latest used index + */ + mutable QModelIndex mLastIndex; + + /** + * total data -access count throught data() -method + */ + mutable int mDataAccessCount; + + + mutable TMPXItemId mLastId; + + /** + * setted "row count" + */ + int mRowCount; + + /** + * lates passed index of openItem + */ + TMPXItemId mStartPlaybackIndex; + + /** + * latest passed for delete + */ + int mDeleteFileIndex; + + /** + * if true, data() -method returns invalid QVartiant + */ + bool mDatareturnsInvalid; + +}; +#endif // VIDEOPROXYMODELGENERIC_H + +// End of file + + + diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videofiledetailsview/tsrc/testplugin/stub/inc/videosortfilterproxymodel.h --- a/videocollection/videofiledetailsview/tsrc/testplugin/stub/inc/videosortfilterproxymodel.h Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,202 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Dummy videolistsortfilterproxymodel class definition* -*/ - -#ifndef VIDEOSORTFILTERPROXYMODEL_H -#define VIDEOSORTFILTERPROXYMODEL_H - -// INCLUDES -#include -#include -#include - -// FORWARD DECLARATIONS - - -class VideoSortFilterProxyModel : public QAbstractItemModel -{ - /** - * define to be able to use signals and slots - */ - Q_OBJECT - - /** - * disable copy-constructor and assignment operator - */ - Q_DISABLE_COPY(VideoSortFilterProxyModel) - -public: - - /** - * Default constructor - */ - VideoSortFilterProxyModel(); - - /** - * Destructor - */ - ~VideoSortFilterProxyModel(); - - /** - * sets index.row() to mStartPlaybackIndex - */ - int openItem(const TMPXItemId &index); - - /** - * sets first index.row() to mDeleteFileIndex - */ - int deleteItems(const QModelIndexList &indexList); - - /** - * returns qmodelindex of item id provided. - * - * @param item id - * @return QModelIndex; - */ - QModelIndex indexOfId(TMPXItemId id); - - - TMPXItemId getMediaIdAtIndex(const QModelIndex &index); - -signals: - - void shortDetailsReady(TMPXItemId index); - - void fullVideoDetailsReady(QVariant& variant); - -public: // from QAbstractItemModel - - VideoSortFilterProxyModel* sourceModel(); - - /** - * Returns video item count - */ - int rowCount(const QModelIndex &parent = QModelIndex()) const; - - /** - * Returns video item data from index pointed by. - */ - QMap itemData(const QModelIndex &index) const; - - /** - * data - */ - QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; - - /** - * columnCount - */ - int columnCount(const QModelIndex & parent = QModelIndex()) const; - - /** - * index - */ - QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const; - - /** - * Parent - */ - QModelIndex parent(const QModelIndex & index) const; - -public: // dummy model helper methods - /** - * sets mDatareturnsInvalid - */ - void setDataReturnInvalid(bool setInvalid); - - /** - * returns mLastIndex - */ - QModelIndex lastIndex(); - - TMPXItemId lastId(); - - /** - * returns mDataAccessCount - */ - int dataAccessCount(); - - /** - * clear everything - */ - void reset(); - - /** - * sets role based value to mDatao - */ - void setData(int role, QVariant data); - - /** - * sets mRowCount - */ - void setRowCount(int count); - - /** - * returns mStartPlaybackIndex - */ - TMPXItemId startPlaybackIndex(); - - /** - * returns mDeleteFileIndex - */ - int deleteFileIndex(); - -private: - - /** - * map item to return from data(); - */ - QMap mData; - - /** - * latest used index - */ - mutable QModelIndex mLastIndex; - - /** - * total data -access count throught data() -method - */ - mutable int mDataAccessCount; - - - mutable TMPXItemId mLastId; - - /** - * setted "row count" - */ - int mRowCount; - - /** - * lates passed index of openItem - */ - TMPXItemId mStartPlaybackIndex; - - /** - * latest passed for delete - */ - int mDeleteFileIndex; - - /** - * if true, data() -method returns invalid QVartiant - */ - bool mDatareturnsInvalid; - -}; -#endif // VIDEOSORTFILTERPROXYMODEL_H - -// End of file - - - diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videofiledetailsview/tsrc/testplugin/stub/src/hbmessagebox.cpp --- a/videocollection/videofiledetailsview/tsrc/testplugin/stub/src/hbmessagebox.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videofiledetailsview/tsrc/testplugin/stub/src/hbmessagebox.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -54,7 +54,7 @@ } } -void HbMessageBox::setStandardButtons(StandardButtons buttons) +void HbMessageBox::setStandardButtons(StandardButtons /*buttons*/) { //NOP } diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videofiledetailsview/tsrc/testplugin/stub/src/videocollectionwrapper.cpp --- a/videocollection/videofiledetailsview/tsrc/testplugin/stub/src/videocollectionwrapper.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videofiledetailsview/tsrc/testplugin/stub/src/videocollectionwrapper.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -18,7 +18,7 @@ // INCLUDE FILES #include #include -#include "videosortfilterproxymodel.h" +#include "videoproxymodelgeneric.h" #include "videocollectionwrapper.h" int VideoCollectionWrapper::mReferenceCount = 0; @@ -72,7 +72,7 @@ // getModel() // ----------------------------------------------------------------------------- // -VideoSortFilterProxyModel* VideoCollectionWrapper::getModel(int type) +VideoProxyModelGeneric* VideoCollectionWrapper::getAllVideosModel() { return mModel; } @@ -81,7 +81,7 @@ // setModel() // ----------------------------------------------------------------------------- // -void VideoCollectionWrapper::setModel(VideoSortFilterProxyModel* model) +void VideoCollectionWrapper::setModel(VideoProxyModelGeneric* model) { mModel = model; } diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videofiledetailsview/tsrc/testplugin/stub/src/videoproxymodelgeneric.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videocollection/videofiledetailsview/tsrc/testplugin/stub/src/videoproxymodelgeneric.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,290 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Dummy VideoProxyModelGeneric class implementation +* +*/ +// INCLUDE FILES +#include "videoproxymodelgeneric.h" + +// ================= MEMBER FUNCTIONS ======================= +// + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric() +// ----------------------------------------------------------------------------- +// +VideoProxyModelGeneric::VideoProxyModelGeneric(QObject *parent) : +QAbstractItemModel(parent), +mStartPlaybackIndex(TMPXItemId::InvalidId()), +mDeleteFileIndex(-1) +{ + reset(); +} + +// ----------------------------------------------------------------------------- +// ~VideoProxyModelGeneric() +// ----------------------------------------------------------------------------- +// +VideoProxyModelGeneric::~VideoProxyModelGeneric() +{ + reset(); +} + +// ----------------------------------------------------------------------------- +// lastIndex() +// ----------------------------------------------------------------------------- +// +QModelIndex VideoProxyModelGeneric::lastIndex() +{ + return mLastIndex; +} + +// ----------------------------------------------------------------------------- +// lastIndex() +// ----------------------------------------------------------------------------- +// +TMPXItemId VideoProxyModelGeneric::lastId() +{ + return mLastId; +} + +// ----------------------------------------------------------------------------- +// dataAccessCount() +// ----------------------------------------------------------------------------- +// +int VideoProxyModelGeneric::dataAccessCount() +{ + return mDataAccessCount; +} + +// ----------------------------------------------------------------------------- +// reset() +// ----------------------------------------------------------------------------- +// +void VideoProxyModelGeneric::reset() +{ + mLastIndex = QModelIndex(); + mLastId = TMPXItemId::InvalidId(); + mDataAccessCount = 0; + mRowCount = 0; + mData.clear(); + mStartPlaybackIndex = TMPXItemId::InvalidId(); + mDeleteFileIndex = -1; + mDatareturnsInvalid = false; +} + +// ----------------------------------------------------------------------------- +// setDataReturnInvalid() +// ----------------------------------------------------------------------------- +// +void VideoProxyModelGeneric::setDataReturnInvalid(bool setInvalid) +{ + mDatareturnsInvalid = setInvalid; +} + +// ----------------------------------------------------------------------------- +// setData() +// ----------------------------------------------------------------------------- +// +void VideoProxyModelGeneric::setData(int role, QVariant data) +{ + mData.insert(role, data); +} + +// ----------------------------------------------------------------------------- +// setRowCount() +// ----------------------------------------------------------------------------- +// +void VideoProxyModelGeneric::setRowCount(int count) +{ + if ( count == mRowCount ) return; + + if ( count > mRowCount ) { + beginInsertRows(QModelIndex(), mRowCount, count); + mRowCount = count; + endInsertRows(); + } else { + beginRemoveRows(QModelIndex(), count, mRowCount); + mRowCount = count; + endRemoveRows(); + } +} + +// ----------------------------------------------------------------------------- +// rowCount() +// ----------------------------------------------------------------------------- +// +int VideoProxyModelGeneric::rowCount(const QModelIndex &parent ) const +{ + // according to Qt documentation if parent is valid this should return 0 if + // implementing a table based implementation like this. + if (parent.isValid()) + { + return 0; + } + + return mRowCount; +} + +// ----------------------------------------------------------------------------- +// itemData() +// ----------------------------------------------------------------------------- +// +QMap VideoProxyModelGeneric::itemData(const QModelIndex &index) const +{ + QMap itemData; + if (index.isValid()) + { + // returns only basic data of the item + itemData.insert(Qt::DisplayRole, data(index, Qt::DisplayRole)); + itemData.insert(Qt::DecorationRole, data(index, Qt::DecorationRole)); + itemData.insert(Qt::BackgroundRole, data(index, Qt::BackgroundRole)); + } + return itemData; + +} +// ----------------------------------------------------------------------------- +// data() +// ----------------------------------------------------------------------------- +// +QVariant VideoProxyModelGeneric::data(const QModelIndex & index, int role) const +{ + QVariant returnValue = QVariant(); + mLastIndex = index; + mDataAccessCount++; + if (index.isValid() && !mDatareturnsInvalid) + { + returnValue = mData.value(role); + } + + return returnValue; +} + +// ----------------------------------------------------------------------------- +// columnCount() +// ----------------------------------------------------------------------------- +// +int VideoProxyModelGeneric::columnCount(const QModelIndex & parent) const +{ + // according to Qt documentation if parent is valid this should return 0 if + // implementing a table based implementation like this. + if (parent.isValid()) + { + return 0; + } + else + { + return 1; + } +} + +// ----------------------------------------------------------------------------- +// index() +// ----------------------------------------------------------------------------- +// +QModelIndex VideoProxyModelGeneric::index(int row, int column, const QModelIndex & /*parent*/) const +{ + return createIndex(row, column); +} + +// ----------------------------------------------------------------------------- +// parent() +// ----------------------------------------------------------------------------- +// +QModelIndex VideoProxyModelGeneric::parent(const QModelIndex & /*index*/) const +{ + return QModelIndex(); +} + +// ----------------------------------------------------------------------------- +// openItem() +// ----------------------------------------------------------------------------- +// +int VideoProxyModelGeneric::openItem(const TMPXItemId &index) +{ + mStartPlaybackIndex = index; + return 0; +} + +// ----------------------------------------------------------------------------- +// deleteItems() +// ----------------------------------------------------------------------------- +// +int VideoProxyModelGeneric::deleteItems(const QModelIndexList &indexList) +{ + if(indexList.count() > 0) + { + mDeleteFileIndex = indexList.at(0).row(); + return 0; + } + else + { + mDeleteFileIndex = -1; + return -1; + } + +} + +// ----------------------------------------------------------------------------- +// startPlaybackIndex() +// ----------------------------------------------------------------------------- +// +TMPXItemId VideoProxyModelGeneric::startPlaybackIndex() +{ + return mStartPlaybackIndex; +} + +// ----------------------------------------------------------------------------- +// deleteFileIndex() +// ----------------------------------------------------------------------------- +// +int VideoProxyModelGeneric::deleteFileIndex() +{ + return mDeleteFileIndex; +} + +// ----------------------------------------------------------------------------- +// sourceModel() +// ----------------------------------------------------------------------------- +// +VideoProxyModelGeneric* VideoProxyModelGeneric::sourceModel() +{ + return this; +} + +// ----------------------------------------------------------------------------- +// getMediaIdAtIndex() +// ----------------------------------------------------------------------------- +// +TMPXItemId VideoProxyModelGeneric::getMediaIdAtIndex(const QModelIndex &/*index*/) +{ + TMPXItemId id = TMPXItemId::InvalidId(); + id.iId1 = mLastIndex.row(); + id.iId2 = 0; + return id; +} + +// ----------------------------------------------------------------------------- +// VideoProxyModelGeneric::indexOfId() +// ----------------------------------------------------------------------------- +// +QModelIndex VideoProxyModelGeneric::indexOfId(TMPXItemId id) +{ + mLastId = id; + mLastIndex = createIndex(id.iId1, 0); + return mLastIndex; //rikki! createIndex(row, column) +} + + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videofiledetailsview/tsrc/testplugin/stub/src/videoserviceurifetch.cpp --- a/videocollection/videofiledetailsview/tsrc/testplugin/stub/src/videoserviceurifetch.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videofiledetailsview/tsrc/testplugin/stub/src/videoserviceurifetch.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: % +// Version : %version: 3 % #include "videoservices.h" #include "videoserviceurifetch.h" @@ -43,7 +43,7 @@ // fetch() // ---------------------------------------------------------------------------- // -void VideoServiceUriFetch::fetch(const QString& title) +void VideoServiceUriFetch::fetch(const QString& /*title*/) { mServiceApp->setCurrentService(VideoServices::EUriFetcher); } diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videofiledetailsview/tsrc/testplugin/stub/src/videosortfilterproxymodel.cpp --- a/videocollection/videofiledetailsview/tsrc/testplugin/stub/src/videosortfilterproxymodel.cpp Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,289 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Dummy VideoSortFilterProxyModel class implementation -* -*/ -// INCLUDE FILES -#include "videosortfilterproxymodel.h" - -// ================= MEMBER FUNCTIONS ======================= -// - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel() -// ----------------------------------------------------------------------------- -// -VideoSortFilterProxyModel::VideoSortFilterProxyModel() : -mStartPlaybackIndex(TMPXItemId::InvalidId()), -mDeleteFileIndex(-1) -{ - reset(); -} - -// ----------------------------------------------------------------------------- -// ~VideoSortFilterProxyModel() -// ----------------------------------------------------------------------------- -// -VideoSortFilterProxyModel::~VideoSortFilterProxyModel() -{ - reset(); -} - -// ----------------------------------------------------------------------------- -// lastIndex() -// ----------------------------------------------------------------------------- -// -QModelIndex VideoSortFilterProxyModel::lastIndex() -{ - return mLastIndex; -} - -// ----------------------------------------------------------------------------- -// lastIndex() -// ----------------------------------------------------------------------------- -// -TMPXItemId VideoSortFilterProxyModel::lastId() -{ - return mLastId; -} - -// ----------------------------------------------------------------------------- -// dataAccessCount() -// ----------------------------------------------------------------------------- -// -int VideoSortFilterProxyModel::dataAccessCount() -{ - return mDataAccessCount; -} - -// ----------------------------------------------------------------------------- -// reset() -// ----------------------------------------------------------------------------- -// -void VideoSortFilterProxyModel::reset() -{ - mLastIndex = QModelIndex(); - mLastId = TMPXItemId::InvalidId(); - mDataAccessCount = 0; - mRowCount = 0; - mData.clear(); - mStartPlaybackIndex = TMPXItemId::InvalidId(); - mDeleteFileIndex = -1; - mDatareturnsInvalid = false; -} - -// ----------------------------------------------------------------------------- -// setDataReturnInvalid() -// ----------------------------------------------------------------------------- -// -void VideoSortFilterProxyModel::setDataReturnInvalid(bool setInvalid) -{ - mDatareturnsInvalid = setInvalid; -} - -// ----------------------------------------------------------------------------- -// setData() -// ----------------------------------------------------------------------------- -// -void VideoSortFilterProxyModel::setData(int role, QVariant data) -{ - mData.insert(role, data); -} - -// ----------------------------------------------------------------------------- -// setRowCount() -// ----------------------------------------------------------------------------- -// -void VideoSortFilterProxyModel::setRowCount(int count) -{ - if ( count == mRowCount ) return; - - if ( count > mRowCount ) { - beginInsertRows(QModelIndex(), mRowCount, count); - mRowCount = count; - endInsertRows(); - } else { - beginRemoveRows(QModelIndex(), count, mRowCount); - mRowCount = count; - endRemoveRows(); - } -} - -// ----------------------------------------------------------------------------- -// rowCount() -// ----------------------------------------------------------------------------- -// -int VideoSortFilterProxyModel::rowCount(const QModelIndex &parent ) const -{ - // according to Qt documentation if parent is valid this should return 0 if - // implementing a table based implementation like this. - if (parent.isValid()) - { - return 0; - } - - return mRowCount; -} - -// ----------------------------------------------------------------------------- -// itemData() -// ----------------------------------------------------------------------------- -// -QMap VideoSortFilterProxyModel::itemData(const QModelIndex &index) const -{ - QMap itemData; - if (index.isValid()) - { - // returns only basic data of the item - itemData.insert(Qt::DisplayRole, data(index, Qt::DisplayRole)); - itemData.insert(Qt::DecorationRole, data(index, Qt::DecorationRole)); - itemData.insert(Qt::BackgroundRole, data(index, Qt::BackgroundRole)); - } - return itemData; - -} -// ----------------------------------------------------------------------------- -// data() -// ----------------------------------------------------------------------------- -// -QVariant VideoSortFilterProxyModel::data(const QModelIndex & index, int role) const -{ - QVariant returnValue = QVariant(); - mLastIndex = index; - mDataAccessCount++; - if (index.isValid() && !mDatareturnsInvalid) - { - returnValue = mData.value(role); - } - - return returnValue; -} - -// ----------------------------------------------------------------------------- -// columnCount() -// ----------------------------------------------------------------------------- -// -int VideoSortFilterProxyModel::columnCount(const QModelIndex & parent) const -{ - // according to Qt documentation if parent is valid this should return 0 if - // implementing a table based implementation like this. - if (parent.isValid()) - { - return 0; - } - else - { - return 1; - } -} - -// ----------------------------------------------------------------------------- -// index() -// ----------------------------------------------------------------------------- -// -QModelIndex VideoSortFilterProxyModel::index(int row, int column, const QModelIndex & /*parent*/) const -{ - return createIndex(row, column); -} - -// ----------------------------------------------------------------------------- -// parent() -// ----------------------------------------------------------------------------- -// -QModelIndex VideoSortFilterProxyModel::parent(const QModelIndex & /*index*/) const -{ - return QModelIndex(); -} - -// ----------------------------------------------------------------------------- -// openItem() -// ----------------------------------------------------------------------------- -// -int VideoSortFilterProxyModel::openItem(const TMPXItemId &index) -{ - mStartPlaybackIndex = index; - return 0; -} - -// ----------------------------------------------------------------------------- -// deleteItems() -// ----------------------------------------------------------------------------- -// -int VideoSortFilterProxyModel::deleteItems(const QModelIndexList &indexList) -{ - if(indexList.count() > 0) - { - mDeleteFileIndex = indexList.at(0).row(); - return 0; - } - else - { - mDeleteFileIndex = -1; - return -1; - } - -} - -// ----------------------------------------------------------------------------- -// startPlaybackIndex() -// ----------------------------------------------------------------------------- -// -TMPXItemId VideoSortFilterProxyModel::startPlaybackIndex() -{ - return mStartPlaybackIndex; -} - -// ----------------------------------------------------------------------------- -// deleteFileIndex() -// ----------------------------------------------------------------------------- -// -int VideoSortFilterProxyModel::deleteFileIndex() -{ - return mDeleteFileIndex; -} - -// ----------------------------------------------------------------------------- -// sourceModel() -// ----------------------------------------------------------------------------- -// -VideoSortFilterProxyModel* VideoSortFilterProxyModel::sourceModel() -{ - return this; -} - -// ----------------------------------------------------------------------------- -// getMediaIdAtIndex() -// ----------------------------------------------------------------------------- -// -TMPXItemId VideoSortFilterProxyModel::getMediaIdAtIndex(const QModelIndex &index) -{ - TMPXItemId id = TMPXItemId::InvalidId(); - id.iId1 = mLastIndex.row(); - id.iId2 = 0; - return id; -} - -// ----------------------------------------------------------------------------- -// VideoSortFilterProxyModel::indexOfId() -// ----------------------------------------------------------------------------- -// -QModelIndex VideoSortFilterProxyModel::indexOfId(TMPXItemId id) -{ - mLastId = id; - mLastIndex = createIndex(id.iId1, 0); - return mLastIndex; //rikki! createIndex(row, column) -} - - -// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videocollection/videofiledetailsview/tsrc/testplugin/testvideofiledetailsviewplugin.pro --- a/videocollection/videofiledetailsview/tsrc/testplugin/testvideofiledetailsviewplugin.pro Thu Sep 02 20:28:16 2010 +0300 +++ b/videocollection/videofiledetailsview/tsrc/testplugin/testvideofiledetailsviewplugin.pro Fri Sep 17 08:30:05 2010 +0300 @@ -54,7 +54,7 @@ # Input HEADERS += inc/testvideofiledetails.h \ stub/inc/videocollectionwrapper.h \ - stub/inc/videosortfilterproxymodel.h \ + stub/inc/videoproxymodelgeneric.h \ stub/inc/hbmessagebox.h \ stub/inc/shareui.h \ stub/inc/thumbnailmanager_qt.h \ @@ -65,7 +65,7 @@ SOURCES += src/testvideofiledetails.cpp \ stub/src/videocollectionwrapper.cpp \ - stub/src/videosortfilterproxymodel.cpp \ + stub/src/videoproxymodelgeneric.cpp \ stub/src/hbmessagebox.cpp \ stub/src/shareui.cpp \ stub/src/thumbnailmanager_qt.cpp \ diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videohelix/group/mpxvideohelixplayback.mmp --- a/videoplayback/videohelix/group/mpxvideohelixplayback.mmp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videohelix/group/mpxvideohelixplayback.mmp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: ou1cpsw#18 % +// Version : %version: 19 % @@ -43,6 +43,7 @@ SOURCE mpxvideoplayerutility.cpp SOURCE mpxvideodrmhelper.cpp SOURCE mpxvideoposterframesetter.cpp +SOURCE mpxcalldetector.cpp START RESOURCE ../data/10282550.rss TARGET mpxvideohelixplayback.rsc diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videohelix/inc/mpxcalldetector.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoplayback/videohelix/inc/mpxcalldetector.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class for call detaction +* +*/ + +// Version : %version: 1 % + +#ifndef MPXCALLDETECTOR_H +#define MPXCALLDETECTOR_H + +#include +#include + +class MMPXCallDetectorObserver +{ + public: + virtual void CallDetectedL() = 0; +}; + +/** + * Detector for incoming call + */ +NONSHARABLE_CLASS( CMPXCallDetector ) : public CActive +{ + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CMPXCallDetector* NewL( MMPXCallDetectorObserver* aObserver ); + + /** + * Destructor. + */ + ~CMPXCallDetector(); + + public: // New functions + + /** + * Request call notifications + * + */ + void RequestNotification(); + + private: + + /** + * C++ default constructor. + */ + CMPXCallDetector( MMPXCallDetectorObserver* aObserver ); + + /** + * Symbian OS 2nd phase constructor. + */ + void ConstructL(); + + /** + * From CActive + * @see CActive for more information + */ + void RunL(); + + /** + * From CActive + * @see CActive for more information + */ + void DoCancel(); + + private: + + // Call observer + MMPXCallDetectorObserver* iObserver; + RProperty iTsyProperty; +}; + +#endif // CALLDETECTOR_H diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videohelix/inc/mpxvideoplaybackcontroller.h --- a/videoplayback/videohelix/inc/mpxvideoplaybackcontroller.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videohelix/inc/mpxvideoplaybackcontroller.h Fri Sep 17 08:30:05 2010 +0300 @@ -16,7 +16,7 @@ */ -// Version : %version: 29 % +// Version : %version: 30 % #ifndef _CMPXVIDEOPLAYBACKCONTROLLER_H_ @@ -41,6 +41,7 @@ #include "mpxvideoplayerutility.h" #include "mpxvideo_debug.h" +#include "mpxcalldetector.h" // DATA TYPES // FORWARD DECLARATIONS @@ -68,6 +69,7 @@ NONSHARABLE_CLASS( CMPXVideoPlaybackController ) : public CBase , public MMPXCenRepObserver + , public MMPXCallDetectorObserver { public: // @@ -146,6 +148,7 @@ private: + void CallDetectedL(); void SetDisplayWindowL( CMPXCommand& aCmd ); void RestartDSA( CMPXCommand& aCmd ); @@ -261,6 +264,9 @@ // Timer monitoring user activity when TV-out is connected CPeriodic* iUserActivityTimer; + // Call detector + CMPXCallDetector* iCallDetector; + TBool iSeekable; CMpxVideoDrmHelper* iDrmHelper; diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videohelix/inc/mpxvideoplaybackmode.h --- a/videoplayback/videohelix/inc/mpxvideoplaybackmode.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videohelix/inc/mpxvideoplaybackmode.h Fri Sep 17 08:30:05 2010 +0300 @@ -16,7 +16,7 @@ */ -// Version : %version: 20 % +// Version : %version: 21 % #ifndef _CMPXVIDEOPLAYBACKMODE_H_ @@ -68,7 +68,7 @@ virtual void GetPdlStatusL( CMPXCommand& aCmd ); virtual void UpdateSeekPosition( TInt64& aPosition ); inline virtual TBool IsDownloadPaused(); - virtual void HandlePause(); + virtual TInt HandlePause(); virtual void HandleBackground(); virtual TBool IsNetworkMode2GL(); virtual TBool CanPlayNow(); @@ -137,7 +137,7 @@ virtual TBool CanPlayNow(); virtual void HandleOpenComplete(); void OpenFileL( const TDesC& aMediaFile ); - virtual void HandlePause(); + virtual TInt HandlePause(); }; //////////////////////////////////////////////////////////// @@ -153,7 +153,7 @@ // Methods where video plabkack behavior varies for live streaming media inline virtual TInt GetMode(); - virtual void HandlePause(); + virtual TInt HandlePause(); virtual TBool SendErrorToView( TInt aError ); virtual void HandlePauseToPlayTransitionL(); }; diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videohelix/inc/mpxvideoplaybackstate.h --- a/videoplayback/videohelix/inc/mpxvideoplaybackstate.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videohelix/inc/mpxvideoplaybackstate.h Fri Sep 17 08:30:05 2010 +0300 @@ -16,7 +16,7 @@ */ -// Version : %version: 21 % +// Version : %version: 22 % #ifndef _CMPXVIDEOPLAYBACKSTATE_H_ @@ -67,6 +67,7 @@ // Commands received from the Framework virtual void HandlePlay(); virtual void HandlePause(); + virtual void DoHandlePause(); virtual void HandlePlayPause(); virtual void HandleStop(); virtual void HandleStartSeekL( TBool aForward ); diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videohelix/src/mpxcalldetector.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoplayback/videohelix/src/mpxcalldetector.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,124 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +// Version : %version: 1 % + +// INCLUDE FILES +#include + +#include "mpxcalldetector.h" +#include "mpxvideo_debug.h" + + +// --------------------------------------------------------------------------- +// CCallDetector::NewL +// +// --------------------------------------------------------------------------- +// +CMPXCallDetector* CMPXCallDetector::NewL( MMPXCallDetectorObserver* aObserver ) +{ + MPX_ENTER_EXIT(_L("CMPXCallDetector::NewL()")); + + CMPXCallDetector* self = new( ELeave ) CMPXCallDetector( aObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; +} + +// --------------------------------------------------------------------------- +// Destructor +// +// --------------------------------------------------------------------------- +// +CMPXCallDetector::~CMPXCallDetector() +{ + Cancel(); + iTsyProperty.Close(); +} + +// --------------------------------------------------------------------------- +// CCallDetector::RequestNotification +// +// --------------------------------------------------------------------------- +// +void CMPXCallDetector::RequestNotification() +{ + MPX_ENTER_EXIT(_L("CCallDetector::RequestNotification()")); + + iTsyProperty.Subscribe( iStatus ); + SetActive(); +} + +// --------------------------------------------------------------------------- +// Constructor +// +// --------------------------------------------------------------------------- +// +CMPXCallDetector::CMPXCallDetector( MMPXCallDetectorObserver* aObserver ) + : CActive( EPriorityStandard ), iObserver( aObserver ) +{ +} + +// --------------------------------------------------------------------------- +// CCallDetector::ConstructL +// +// --------------------------------------------------------------------------- +// +void CMPXCallDetector::ConstructL() +{ + MPX_ENTER_EXIT(_L("CCallDetector::ConstructL")); + + User::LeaveIfError( iTsyProperty.Attach( KPSUidCtsyCallInformation, KCTsyCallState ) ); + + CActiveScheduler::Add( this ); +} + +// --------------------------------------------------------------------------- +// CCallDetector::RunL +// Called when the voice line status changes. +// --------------------------------------------------------------------------- +// +void CMPXCallDetector::RunL() +{ + TInt status = iStatus.Int(); + + RequestNotification(); + + if ( status == KErrNone ) + { + TInt status; + iTsyProperty.Get( status ); + + if ( status != EPSCTsyCallStateNone ) + { + iObserver->CallDetectedL(); + } + } +} + +// --------------------------------------------------------------------------- +// CCallDetector::DoCancel +// +// --------------------------------------------------------------------------- +// +void CMPXCallDetector::DoCancel() +{ + iTsyProperty.Cancel(); +} + +// End of File diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videohelix/src/mpxvideoplaybackcontroller.cpp --- a/videoplayback/videohelix/src/mpxvideoplaybackcontroller.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videohelix/src/mpxvideoplaybackcontroller.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -16,7 +16,7 @@ */ -// Version : %version: 65 % +// Version : %version: 66 % // @@ -167,6 +167,9 @@ iDrmHelper = CMpxVideoDrmHelper::NewL(); + iCallDetector = CMPXCallDetector::NewL( this ); + iCallDetector->RequestNotification(); + iSavedPosition = 0; iViewActivated = EFalse; } @@ -291,6 +294,14 @@ delete iSeekingState; delete iStoppedState; + if ( iCallDetector ) + { + iCallDetector->Cancel(); + + delete iCallDetector; + iCallDetector = NULL; + } + if ( iPlaybackMode ) { delete iPlaybackMode; @@ -2551,4 +2562,13 @@ iPlaybackMode->HandleFrameReady(aError); } + +void CMPXVideoPlaybackController::CallDetectedL() +{ + MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::CallDetectedL")); + + // Pause playback + DoHandleCommandL( EPbCmdPause ); +} + // End of file diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videohelix/src/mpxvideoplaybackmode.cpp --- a/videoplayback/videohelix/src/mpxvideoplaybackmode.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videohelix/src/mpxvideoplaybackmode.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -16,7 +16,7 @@ */ -// Version : %version: 34 % +// Version : %version: 35 % // @@ -159,7 +159,7 @@ // ------------------------------------------------------------------------------------------------ // CMPXVideoPlaybackMode::HandlePause() // ------------------------------------------------------------------------------------------------ -void CMPXVideoPlaybackMode::HandlePause() +TInt CMPXVideoPlaybackMode::HandlePause() { MPX_ENTER_EXIT(_L("CMPXVideoPlaybackMode::HandlePause()")); @@ -173,10 +173,8 @@ 0, err ); } - else - { - TRAP_IGNORE( iVideoPlaybackCtlr->iState->SendErrorToViewL( err ) ); - } + + return err; } // ------------------------------------------------------------------------------------------------ @@ -479,13 +477,15 @@ // ------------------------------------------------------------------------------------------------ // CMPXStreamingPlaybackMode::HandlePause() // ------------------------------------------------------------------------------------------------ -void CMPXStreamingPlaybackMode::HandlePause() +TInt CMPXStreamingPlaybackMode::HandlePause() { MPX_ENTER_EXIT(_L("CMPXStreamingPlaybackMode::HandlePause()")); + TInt err = KErrNone; + if ( iVideoPlaybackCtlr->iFileDetails->iPausableStream ) { - MPX_TRAPD( err, iVideoPlaybackCtlr->iPlayer->PauseL() ); + MPX_TRAP( err, iVideoPlaybackCtlr->iPlayer->PauseL() ); if ( err == KErrNone ) { @@ -496,13 +496,9 @@ 0, err ); } - else - { - TRAP_IGNORE( iVideoPlaybackCtlr->iState->SendErrorToViewL( err ) ); - } } // Streaming link is non-pausable and no alarm stop playback - else if ( !iVideoPlaybackCtlr->IsAlarm() ) + else if ( ! iVideoPlaybackCtlr->IsAlarm() ) { iVideoPlaybackCtlr->iPlayer->Stop(); @@ -512,6 +508,8 @@ 0, KErrNone ); } + + return err; } @@ -540,7 +538,7 @@ // ------------------------------------------------------------------------------------------------ // CMPXLiveStreamingPlaybackMode::HandlePause() // ------------------------------------------------------------------------------------------------ -void CMPXLiveStreamingPlaybackMode::HandlePause() +TInt CMPXLiveStreamingPlaybackMode::HandlePause() { MPX_ENTER_EXIT(_L("CMPXLiveStreamingPlaybackMode::HandlePause()")); @@ -555,6 +553,8 @@ iVideoPlaybackCtlr->iMPXPluginObs->HandlePluginEvent( MMPXPlaybackPluginObserver::EPPaused, 0, KErrNone ); + + return KErrNone; } // ------------------------------------------------------------------------------------------------ diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videohelix/src/mpxvideoplaybackstate.cpp --- a/videoplayback/videohelix/src/mpxvideoplaybackstate.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videohelix/src/mpxvideoplaybackstate.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -16,7 +16,7 @@ */ -// Version : %version: 48 % +// Version : %version: 49 % // @@ -792,6 +792,21 @@ } } +// ------------------------------------------------------------------------------------------------ +// CMPXVideoPlaybackState::DoHandlePause() +// ------------------------------------------------------------------------------------------------ +void CMPXVideoPlaybackState::DoHandlePause() +{ + MPX_ENTER_EXIT(_L("CMPXVideoPlaybackState::DoHandlePause()")); + + TInt err = iVideoPlaybackCtlr->iPlaybackMode->HandlePause(); + + if ( err != KErrNone ) + { + MPX_TRAPD( err2, SendErrorToViewL( err ) ); + } +} + // ************************************************************************************************* // // STATE SUB-CLASSES @@ -929,7 +944,7 @@ { MPX_DEBUG(_L("CMPXNotInitialisedState::HandlePlay() Plugin error")); - MPX_TRAPD( err, SendErrorToViewL( iVideoPlaybackCtlr->iPBPluginError ) ); + MPX_TRAPD( err, SendErrorToViewL( iVideoPlaybackCtlr->iPBPluginError ) ); } // ------------------------------------------------------------------------------------------------ @@ -1207,7 +1222,7 @@ } else { - iVideoPlaybackCtlr->iPlaybackMode->HandlePause(); + HandlePause(); } iVideoPlaybackCtlr->iAllowAutoPlay = ETrue; @@ -1282,7 +1297,27 @@ { MPX_ENTER_EXIT(_L("CMPXInitialisedState::HandlePause()")); - iVideoPlaybackCtlr->iPlaybackMode->HandlePause(); + TInt err = iVideoPlaybackCtlr->iPlaybackMode->HandlePause(); + + if ( err != KErrNone ) + { + MPX_DEBUG(_L("CMPXInitialisedState::HandlePause() err = %d"), err); + + // + // For Initialized state, Helix will return an error of KErrNotReady since the DRM + // rights consumption has not started. Ignore the KErrNotReady error and transition + // to the stopped state since no rights have been consumed. This will free up + // memory by closing the playback. + // + if ( err == KErrNotReady && iVideoPlaybackCtlr->iFileDetails->iDrmProtected ) + { + HandleStop(); + } + else + { + MPX_TRAPD( err2, SendErrorToViewL( err ) ); + } + } } // ************************************************************************************************* @@ -1368,7 +1403,7 @@ { MPX_ENTER_EXIT(_L("CMPXPlayingState::HandlePause()")); - iVideoPlaybackCtlr->iPlaybackMode->HandlePause(); + DoHandlePause(); } // ------------------------------------------------------------------------------------------------ @@ -1856,7 +1891,7 @@ // // Delayed pause, background event was received while we were in buffering state // - iVideoPlaybackCtlr->iPlaybackMode->HandlePause(); + HandlePause(); } } else @@ -1915,7 +1950,7 @@ // if ( iVideoPlaybackCtlr->iPlaybackMode->IsDownloadPaused() ) { - iVideoPlaybackCtlr->iPlaybackMode->HandlePause(); + DoHandlePause(); } } @@ -1985,7 +2020,7 @@ } else { - iVideoPlaybackCtlr->iPlaybackMode->HandlePause(); + HandlePause(); } } @@ -2008,7 +2043,8 @@ MPX_ENTER_EXIT(_L("CMPXSeekingState::HandlePause()")); MPX_TRAPD( err, HandleStopSeekL() ); - iVideoPlaybackCtlr->iPlaybackMode->HandlePause(); + + DoHandlePause(); } // ------------------------------------------------------------------------------------------------ diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videohelix/tsrc/ut_videohelixtest/conf/videohelixtest.cfg --- a/videoplayback/videohelix/tsrc/ut_videohelixtest/conf/videohelixtest.cfg Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videohelix/tsrc/ut_videohelixtest/conf/videohelixtest.cfg Fri Sep 17 08:30:05 2010 +0300 @@ -589,7 +589,7 @@ waittestclass test test PlayduringVoiceCall pause 100 -test IssueGeneralCommand EPbCmdPlay KErrNone ECallbackBuffering +test IssueGeneralCommand EPbCmdPlay KErrNone ECallbackPlaying pause 1000 test EndPhoneCall delete test diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videohelix/tsrc/ut_videohelixtest/group/videohelixtest.mmp --- a/videoplayback/videohelix/tsrc/ut_videohelixtest/group/videohelixtest.mmp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videohelix/tsrc/ut_videohelixtest/group/videohelixtest.mmp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 11 % +// Version : %version: 12 % @@ -60,6 +60,7 @@ SOURCE mpxvideoplaybackstate.cpp SOURCE mpxvideoseeker.cpp SOURCE mpxvideoposterframesetter.cpp +SOURCE mpxcalldetector.cpp LIBRARY euser.lib diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videohelix/tsrc/ut_videohelixtest/src/videohelixtestbody.cpp --- a/videoplayback/videohelix/tsrc/ut_videohelixtest/src/videohelixtestbody.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videohelix/tsrc/ut_videohelixtest/src/videohelixtestbody.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 26 % +// Version : %version: 27 % // [INCLUDE FILES] - do not remove @@ -1958,6 +1958,13 @@ TInt err = 0; + //callback event + TCallbackEvent* event = new TCallbackEvent; + event->iError = 0; + event->iData = 0; + event->iEvent = EPPaused; + AddExpectedEvent( event ); + //set phone call as Connected err = RProperty::Set(KPSUidCtsyCallInformation, KCTsyCallState, EPSCTsyCallStateConnected); diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/controlinc/videoplaybackcontrolbar.h --- a/videoplayback/videoplaybackview/controlinc/videoplaybackcontrolbar.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/controlinc/videoplaybackcontrolbar.h Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 4 % +// Version : %version: 5 % @@ -45,6 +45,7 @@ void setVisibleToControlBar( bool visible ); void durationChanged( int duration ); void positionChanged( int position ); + void resetControl(); private: VideoPlaybackControlsController *mController; diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/controlinc/videoplaybackfullscreencontrol.h --- a/videoplayback/videoplaybackview/controlinc/videoplaybackfullscreencontrol.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/controlinc/videoplaybackfullscreencontrol.h Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: da1mmcf#9 % +// Version : %version: da1mmcf#10 % @@ -36,9 +36,9 @@ Q_OBJECT public: - VideoPlaybackFullScreenControl( VideoPlaybackControlsController* controller, + VideoPlaybackFullScreenControl( VideoPlaybackControlsController* controller, TVideoPlaybackControls index, - HbWidget* widget, + HbWidget* widget, TUint controlproperties ); virtual ~VideoPlaybackFullScreenControl(); @@ -49,7 +49,7 @@ * Set visibility of each control */ virtual void setVisibility( TMPXPlaybackState aState ); - + /** * return control index */ @@ -79,7 +79,7 @@ * set changed state */ void updateState( TMPXPlaybackState state ); - + /* * UpdateDownloadPosition * updates the download ratio on the progress bar @@ -97,6 +97,8 @@ virtual void updateControlProperties( TUint properties ); + void resetControl(); + protected: VideoPlaybackControlsController* mController; HbWidget *mControl; diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/controlinc/videoplaybackprogressbar.h --- a/videoplayback/videoplaybackview/controlinc/videoplaybackprogressbar.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/controlinc/videoplaybackprogressbar.h Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: da1mmcf#16 % +// Version : %version: da1mmcf#17 % @@ -45,6 +45,7 @@ public: void durationChanged( int duration ); void positionChanged( int position ); + void resetControl(); private slots: void handleSliderPressed(); diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/controlinc/videoplaybacktoolbar.h --- a/videoplayback/videoplaybackview/controlinc/videoplaybacktoolbar.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/controlinc/videoplaybacktoolbar.h Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 4 % +// Version : %version: 5 % @@ -80,6 +80,8 @@ public: VideoPlaybackToolBar( VideoPlaybackControlsController* controller ); virtual ~VideoPlaybackToolBar(); + + public: void updateState( TMPXPlaybackState state ); void aspectRatioChanged( int aspectRatio ); void initialize(); @@ -87,6 +89,7 @@ void positionChanged( int position ); void durationChanged( int duration ); void setVisible( bool visible ); + void resetControl(); private slots: void playPause(); diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/controlsrc/videoplaybackcontrolbar.cpp --- a/videoplayback/videoplaybackview/controlsrc/videoplaybackcontrolbar.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/controlsrc/videoplaybackcontrolbar.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 8 % +// Version : %version: 9 % @@ -148,7 +148,7 @@ if ( visible != isVisible() ) { setVisible( visible ); - mToolBar->setVisible( visible ); + mToolBar->setVisible( visible ); } } @@ -191,4 +191,23 @@ } } +// ------------------------------------------------------------------------------------------------- +// VideoPlaybackControlBar::resetControl() +// ------------------------------------------------------------------------------------------------- +// +void VideoPlaybackControlBar::resetControl() +{ + MPX_DEBUG(_L("VideoPlaybackControlBar::positionChanged()")); + + if ( mProgressBar ) + { + mProgressBar->resetControl(); + } + + if ( mToolBar ) + { + mToolBar->resetControl(); + } +} + //End of file diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/controlsrc/videoplaybackcontrolscontroller.cpp --- a/videoplayback/videoplaybackview/controlsrc/videoplaybackcontrolscontroller.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/controlsrc/videoplaybackcontrolscontroller.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: da1mmcf#50 % +// Version : %version: da1mmcf#51 % @@ -436,6 +436,13 @@ showVolumeControls(); break; } + case EControlCmdHandleBackgroundEvent: + { + MPX_DEBUG(_L(" [EControlCmdHandleBackgroundEvent]")); + + resetControls(); + break; + } } } @@ -1584,4 +1591,18 @@ return showRNLogo; } +// ------------------------------------------------------------------------------------------------- +// VideoPlaybackControlsController::resetControls() +// ------------------------------------------------------------------------------------------------- +// +void VideoPlaybackControlsController::resetControls() +{ + MPX_DEBUG(_L("VideoPlaybackControlsController::resetControls()")); + + for ( int i = 0 ; i < mControls.count() ; i++ ) + { + mControls[i]->resetControl(); + } +} + // End of File diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/controlsrc/videoplaybackfullscreencontrol.cpp --- a/videoplayback/videoplaybackview/controlsrc/videoplaybackfullscreencontrol.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/controlsrc/videoplaybackfullscreencontrol.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: da1mmcf#10 % +// Version : %version: da1mmcf#11 % @@ -33,10 +33,10 @@ // VideoPlaybackFullScreenControl::VideoPlaybackFullScreenControl() // ------------------------------------------------------------------------------------------------- // -VideoPlaybackFullScreenControl::VideoPlaybackFullScreenControl( - VideoPlaybackControlsController* controller, - TVideoPlaybackControls index, - HbWidget* widget, +VideoPlaybackFullScreenControl::VideoPlaybackFullScreenControl( + VideoPlaybackControlsController* controller, + TVideoPlaybackControls index, + HbWidget* widget, TUint controlproperties ) : mController( controller ) , mControl( widget ) @@ -309,4 +309,16 @@ mProperties = properties; } +// ------------------------------------------------------------------------------------------------- +// VideoPlaybackFullScreenControl::resetControl() +// ------------------------------------------------------------------------------------------------- +// +void VideoPlaybackFullScreenControl::resetControl() +{ + if ( mControlIndex == EControlBar ) + { + static_cast(mControl)->resetControl(); + } +} + // End of file diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/controlsrc/videoplaybackprogressbar.cpp --- a/videoplayback/videoplaybackview/controlsrc/videoplaybackprogressbar.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/controlsrc/videoplaybackprogressbar.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: da1mmcf#31 % +// Version : %version: da1mmcf#32 % @@ -310,22 +310,6 @@ mSeekingTimer->start(); } } - else - { - if ( value >= mDuration ) - { - MPX_DEBUG(_L("VideoPlaybackProgressBar::setPosition() reached end of the clip")); - - mController->handleCommand( EMPXPbvCmdEndOfClip ); - } - else - { - value = mProgressSlider->sliderValue(); - - MPX_DEBUG(_L("VideoPlaybackProgressBar::setPosition() position = %d"), value); - mController->handleCommand( EMPXPbvCmdSetPosition, value ); - } - } } // ------------------------------------------------------------------------------------------------- @@ -467,4 +451,18 @@ } } +// ------------------------------------------------------------------------------------------------- +// VideoPlaybackProgressBar::resetControl +// ------------------------------------------------------------------------------------------------- +// +void VideoPlaybackProgressBar::resetControl() +{ + MPX_DEBUG(_L("VideoPlaybackProgressBar::resetControl")); + + if ( mSliderDragging ) + { + handleSliderReleased(); + } +} + //End of file diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/controlsrc/videoplaybacktoolbar.cpp --- a/videoplayback/videoplaybackview/controlsrc/videoplaybacktoolbar.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/controlsrc/videoplaybacktoolbar.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 11 % +// Version : %version: 12 % @@ -769,4 +769,27 @@ } } +// ------------------------------------------------------------------------------------------------- +// VideoPlaybackToolBar::resetControl +// ------------------------------------------------------------------------------------------------- +// +void VideoPlaybackToolBar::resetControl() +{ + MPX_DEBUG(_L("VideoPlaybackToolBar::resetControl")); + + switch( mSeekingState ) + { + case EFastForwarding: + { + ffReleased(); + break; + } + case ERewinding: + { + rwReleased(); + break; + } + } +} + //End of file diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/inc/videoplaybackcontrolscontroller.h --- a/videoplayback/videoplaybackview/inc/videoplaybackcontrolscontroller.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/inc/videoplaybackcontrolscontroller.h Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: da1mmcf#24 % +// Version : %version: da1mmcf#25 % @@ -255,6 +255,8 @@ void generateThumbNail(); + void resetControls(); + signals: /** diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testcontrolbar/inc/testcontrolbar.h --- a/videoplayback/videoplaybackview/tsrc/testcontrolbar/inc/testcontrolbar.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testcontrolbar/inc/testcontrolbar.h Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 2 % +// Version : %version: 3 % #ifndef __TESTCONTROLBAR_H__ #define __TESTCONTROLBAR_H__ @@ -57,6 +57,7 @@ void testSetVisibleToControlBar(); void testDurationChanged(); void testPositionChanged(); + void testResetControl(); signals: void commandSignal(int); diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testcontrolbar/src/testcontrolbar.cpp --- a/videoplayback/videoplaybackview/tsrc/testcontrolbar/src/testcontrolbar.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testcontrolbar/src/testcontrolbar.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -1,5 +1,5 @@ /** -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -12,10 +12,10 @@ * Contributors: * * Description: tester for methods in TestVideoPlaybackControlBar -* +* */ -// Version : %version: 3 % +// Version : %version: 4 % #include @@ -49,9 +49,9 @@ pass[0] = argv[0]; pass[1] = "-o"; pass[2] = "c:\\data\\testcontrolbar.txt"; - + int res = QTest::qExec(&tv, 3, pass); - + return res; } @@ -64,7 +64,7 @@ { MPX_ENTER_EXIT(_L("TestControlBar::init()")); - mController = new VideoPlaybackControlsController(); + mController = new VideoPlaybackControlsController(); mControlBar = new VideoPlaybackControlBar( mController ); mControlBar->initialize(); @@ -212,4 +212,25 @@ cleanup(); } +// --------------------------------------------------------------------------- +// testResetControl +// --------------------------------------------------------------------------- +// +void TestControlBar::testResetControl() +{ + MPX_ENTER_EXIT(_L("TestControlBar::testResetControl()")); + + init(); + + QVERIFY( ! mControlBar->mProgressBar->mReset ); + QVERIFY( ! mControlBar->mToolBar->mReset ); + + mControlBar->resetControl(); + + QVERIFY( mControlBar->mProgressBar->mReset ); + QVERIFY( mControlBar->mToolBar->mReset ); + + cleanup(); +} + // End of file diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testcontrolbar/stub/inc/videoplaybackprogressbar.h --- a/videoplayback/videoplaybackview/tsrc/testcontrolbar/stub/inc/videoplaybackprogressbar.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testcontrolbar/stub/inc/videoplaybackprogressbar.h Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 2 % +// Version : %version: 3 % @@ -38,6 +38,7 @@ void initialize(); void updateWithFileDetails( VideoPlaybackViewFileDetails* details ); void updateState( TMPXPlaybackState state ); + void resetControl(); public: void durationChanged( int duration ); @@ -47,6 +48,7 @@ VideoPlaybackControlsController *mController; VideoPlaybackViewFileDetails *mFileDetails; TMPXPlaybackState mState; + bool mReset; int mDuration; int mPosition; }; diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testcontrolbar/stub/inc/videoplaybacktoolbar.h --- a/videoplayback/videoplaybackview/tsrc/testcontrolbar/stub/inc/videoplaybacktoolbar.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testcontrolbar/stub/inc/videoplaybacktoolbar.h Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 2 % +// Version : %version: 3 % @@ -45,6 +45,7 @@ void durationChanged( int duration ); void positionChanged( int position ); void setVisible( bool visible ); + void resetControl(); public: VideoPlaybackControlsController *mController; @@ -53,6 +54,7 @@ int mPosition; int mDuration; bool mVisible; + bool mReset; TMPXPlaybackState mState; }; diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testcontrolbar/stub/src/videoplaybackprogressbar.cpp --- a/videoplayback/videoplaybackview/tsrc/testcontrolbar/stub/src/videoplaybackprogressbar.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testcontrolbar/stub/src/videoplaybackprogressbar.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 2 % +// Version : %version: 3 % @@ -28,9 +28,10 @@ // VideoPlaybackProgressBar::VideoPlaybackProgressBar // ------------------------------------------------------------------------------------------------- // -VideoPlaybackProgressBar::VideoPlaybackProgressBar( +VideoPlaybackProgressBar::VideoPlaybackProgressBar( VideoPlaybackControlsController* controller ) : mController( controller ) + , mReset( false ) , mDuration( -1 ) { MPX_ENTER_EXIT(_L("VideoPlaybackProgressBar::VideoPlaybackProgressBar()")); @@ -99,4 +100,15 @@ mState = state; } +// ------------------------------------------------------------------------------------------------- +// VideoPlaybackProgressBar::resetControl() +// ------------------------------------------------------------------------------------------------- +// +void VideoPlaybackProgressBar::resetControl() +{ + MPX_DEBUG(_L("VideoPlaybackProgressBar::resetControl()")); + + mReset = true; +} + //End of file diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testcontrolbar/stub/src/videoplaybacktoolbar.cpp --- a/videoplayback/videoplaybackview/tsrc/testcontrolbar/stub/src/videoplaybacktoolbar.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testcontrolbar/stub/src/videoplaybacktoolbar.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 2 % +// Version : %version: 3 % @@ -31,9 +31,10 @@ // VideoPlaybackToolBar::VideoPlaybackToolBar() // ------------------------------------------------------------------------------------------------- // -VideoPlaybackToolBar::VideoPlaybackToolBar( +VideoPlaybackToolBar::VideoPlaybackToolBar( VideoPlaybackControlsController* controller ) : mController( controller ) + , mReset( false ) { MPX_ENTER_EXIT(_L("VideoPlaybackToolBar::VideoPlaybackToolBar")); } @@ -123,4 +124,15 @@ mVisible = visible; } +// ------------------------------------------------------------------------------------------------- +// VideoPlaybackToolBar::resetControl() +// ------------------------------------------------------------------------------------------------- +// +void VideoPlaybackToolBar::resetControl() +{ + MPX_DEBUG(_L("VideoPlaybackToolBar::resetControl()")); + + mReset = true; +} + //End of file diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testcontrolscontroller/inc/testcontrolscontroller.h --- a/videoplayback/videoplaybackview/tsrc/testcontrolscontroller/inc/testcontrolscontroller.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testcontrolscontroller/inc/testcontrolscontroller.h Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 9 % +// Version : %version: 10 % #ifndef __TESTCONTROLSCONTROLLER_H__ #define __TESTCONTROLSCONTROLLER_H__ @@ -71,6 +71,7 @@ void testHandleEventTvOutDisconnected(); void testHandleEventHandleErrors(); void testHandleEventShowVolumeControls(); + void testHandleEventBackground(); void testIsFileDetailsAdded(); // diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testcontrolscontroller/src/testcontrolscontroller.cpp --- a/videoplayback/videoplaybackview/tsrc/testcontrolscontroller/src/testcontrolscontroller.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testcontrolscontroller/src/testcontrolscontroller.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 14 % +// Version : %version: 15 % #include #include @@ -663,6 +663,23 @@ } // ------------------------------------------------------------------------------------------------- +// TestControlsController::testHandleEventBackground +// ------------------------------------------------------------------------------------------------- +// +void TestControlsController::testHandleEventBackground() +{ + MPX_DEBUG(_L("TestControlsController::testHandleEventBackground()") ); + + init(); + + mController->handleEvent( EControlCmdHandleBackgroundEvent, 0 ); + + QVERIFY( mController->mControls[0]->mControlReset ); + + cleanup(); +} + +// ------------------------------------------------------------------------------------------------- // TestControlsController::testHandleCommand // ------------------------------------------------------------------------------------------------- // diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testcontrolscontroller/stub/inc/videoplaybackfullscreencontrol.h --- a/videoplayback/videoplaybackview/tsrc/testcontrolscontroller/stub/inc/videoplaybackfullscreencontrol.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testcontrolscontroller/stub/inc/videoplaybackfullscreencontrol.h Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 3 % +// Version : %version: 4 % @@ -36,9 +36,9 @@ Q_OBJECT public: - VideoPlaybackFullScreenControl( VideoPlaybackControlsController* controller, + VideoPlaybackFullScreenControl( VideoPlaybackControlsController* controller, TVideoPlaybackControls index, - HbWidget* widget, + HbWidget* widget, TUint controlproperties ); virtual ~VideoPlaybackFullScreenControl(); @@ -49,7 +49,7 @@ * Set visibility of each control */ virtual void setVisibility( TMPXPlaybackState aState ); - + /** * return control index */ @@ -84,7 +84,7 @@ * set changed state */ void updateState( TMPXPlaybackState state ); - + /* * UpdateDownloadPosition * updates the download ratio on the progress bar @@ -102,6 +102,8 @@ virtual void updateControlProperties( TUint properties ); + void resetControl(); + public: int mPosition; int mDuration; @@ -109,15 +111,16 @@ int mDownloadSize; int mDownloadPosition; int mVolume; - + bool mVisible; TMPXPlaybackState mState; TMPXPlaybackState mVisibilityState; - + VideoPlaybackControlsController* mController; HbWidget *mControl; TVideoPlaybackControls mControlIndex; TUint mProperties; + bool mControlReset; }; #endif /*VIDEOPLAYBACKFULLSCREENCONTROL_H_*/ diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testcontrolscontroller/stub/src/videoplaybackfullscreencontrol.cpp --- a/videoplayback/videoplaybackview/tsrc/testcontrolscontroller/stub/src/videoplaybackfullscreencontrol.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testcontrolscontroller/stub/src/videoplaybackfullscreencontrol.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 4 % +// Version : %version: 5 % @@ -32,15 +32,16 @@ // VideoPlaybackFullScreenControl::VideoPlaybackFullScreenControl() // ------------------------------------------------------------------------------------------------- // -VideoPlaybackFullScreenControl::VideoPlaybackFullScreenControl( - VideoPlaybackControlsController* controller, - TVideoPlaybackControls index, - HbWidget* widget, +VideoPlaybackFullScreenControl::VideoPlaybackFullScreenControl( + VideoPlaybackControlsController* controller, + TVideoPlaybackControls index, + HbWidget* widget, TUint controlproperties ) : mController( controller ) , mControl( widget ) , mControlIndex( index ) , mProperties( controlproperties ) + , mControlReset( false ) { MPX_ENTER_EXIT(_L("VideoPlaybackFullScreenControl::VideoPlaybackFullScreenControl()")); @@ -81,7 +82,7 @@ void VideoPlaybackFullScreenControl::setVisibility( TMPXPlaybackState state ) { MPX_DEBUG(_L("VideoPlaybackFullScreenControl::setVisibility(%d)"), state); - + mVisibilityState = state; } @@ -111,7 +112,7 @@ bool VideoPlaybackFullScreenControl::durationChanged( int duration ) { MPX_DEBUG(_L("VideoPlaybackFullScreenControl::durationChanged() [%d]"), duration ); - mDuration = duration; + mDuration = duration; return true; } @@ -120,9 +121,9 @@ // ------------------------------------------------------------------------------------------------- // bool VideoPlaybackFullScreenControl::positionChanged( int position ) -{ +{ MPX_DEBUG(_L("VideoPlaybackFullScreenControl::positionChanged() [%d]"), position ); - mPosition = position; + mPosition = position; return true; } @@ -134,7 +135,7 @@ { MPX_DEBUG(_L("VideoPlaybackFullScreenControl::aspectRatioChanged() [%d]"), aspectRatio ); mAspectRatio = aspectRatio; - return true; + return true; } // ------------------------------------------------------------------------------------------------- @@ -166,7 +167,7 @@ void VideoPlaybackFullScreenControl::updateState( TMPXPlaybackState state ) { MPX_DEBUG(_L("VideoPlaybackFullScreenControl::updateState() [%d]"), state ); - mState = state; + mState = state; } // ------------------------------------------------------------------------------------------------- @@ -190,4 +191,13 @@ mProperties = properties; } +// ------------------------------------------------------------------------------------------------- +// VideoPlaybackFullScreenControl::resetControl() +// ------------------------------------------------------------------------------------------------- +// +void VideoPlaybackFullScreenControl::resetControl() +{ + mControlReset = true; +} + // End of file diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testfullscreencontrol/inc/testfullscreencontrol.h --- a/videoplayback/videoplaybackview/tsrc/testfullscreencontrol/inc/testfullscreencontrol.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testfullscreencontrol/inc/testfullscreencontrol.h Fri Sep 17 08:30:05 2010 +0300 @@ -1,5 +1,5 @@ /** -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -12,7 +12,7 @@ * Contributors: * * Description: test module for VideoPlaybackFullScreenControl -* +* */ #ifndef __TESTFULLSCREENCONTROL_H__ @@ -40,23 +40,23 @@ * will be called before each testfunction is executed. * */ - void init(); - + void init(); + /** * will be called after every testfunction. * */ void cleanup(); - + // test functions for the test framework void setup( TVideoPlaybackControls control ); - + void createControl( TVideoPlaybackControls control ); - + private slots: - + void testControlIndex(); - + void testDurationChanged(); void testPositionChanged(); @@ -64,14 +64,16 @@ void testAspectRatioChanged(); void testUpdateState(); - + void testUpdateControlsWithFileDetails(); - void testUpdateControlProperties(); - + void testUpdateControlProperties(); + + void testResetControl(); + signals: void commandSignal(int); - + private: VideoPlaybackControlsController* mControlsController; VideoPlaybackFullScreenControl* mFullScreenControl; diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testfullscreencontrol/src/testfullscreencontrol.cpp --- a/videoplayback/videoplaybackview/tsrc/testfullscreencontrol/src/testfullscreencontrol.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testfullscreencontrol/src/testfullscreencontrol.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -1,5 +1,5 @@ /** -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -12,10 +12,10 @@ * Contributors: * * Description: tester for methods in VideoPlaybackFullScreenControl -* +* */ -// Version : %version: 4 % +// Version : %version: 5 % #include @@ -38,9 +38,9 @@ #undef private -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // main -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // int main(int argc, char *argv[]) { @@ -48,31 +48,31 @@ HbApplication app(argc, argv); HbMainWindow window; - + TestFullScreenControl tv; char *pass[3]; pass[0] = argv[0]; pass[1] = "-o"; pass[2] = "c:\\data\\testfullscreencontrol.txt"; - + int res = QTest::qExec(&tv, 3, pass); - + return res; } -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // init -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // void TestFullScreenControl::init() { MPX_ENTER_EXIT(_L("TestFullScreenControl::init()")); } -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // setup -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // void TestFullScreenControl::setup( TVideoPlaybackControls control ) { @@ -80,13 +80,13 @@ mControlsController = new VideoPlaybackControlsController(); - - createControl( control ); + + createControl( control ); } -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // createControl -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // void TestFullScreenControl::createControl( TVideoPlaybackControls control ) { @@ -96,68 +96,70 @@ { case EStatusPane: { - mFullScreenControl = new VideoPlaybackFullScreenControl( mControlsController, + mFullScreenControl = new VideoPlaybackFullScreenControl( mControlsController, control, - NULL, - 0 ); - break; + NULL, + 0 ); + break; } case EControlBar: { - VideoPlaybackControlBar *controlBar = - new VideoPlaybackControlBar( mControlsController ); - + VideoPlaybackControlBar *controlBar = + new VideoPlaybackControlBar( mControlsController ); + mFullScreenControl = new VideoPlaybackFullScreenControl( mControlsController, control, controlBar, - 0 ); - + 0 ); + break; } case EDetailsViewPlaybackWindow: { - break; + break; } - } + } } -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // cleanup -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // void TestFullScreenControl::cleanup() { MPX_ENTER_EXIT(_L("TestFullScreenControl::cleanup()")); + if ( mFullScreenControl ) + { + delete mFullScreenControl; + mFullScreenControl = NULL; + } + if ( mControlsController ) { delete mControlsController; - mControlsController = NULL; - } - - if ( mFullScreenControl ) - { - delete mFullScreenControl; - mFullScreenControl = NULL; + mControlsController = NULL; } } -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // testControlIndex -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // void TestFullScreenControl::testControlIndex() { MPX_ENTER_EXIT(_L("TestFullScreenControl::testControlIndex()")); setup( EStatusPane ); - + QVERIFY( mFullScreenControl->controlIndex() == EStatusPane ); + + cleanup(); } -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // testDurationChanged -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // void TestFullScreenControl::testDurationChanged() { @@ -165,118 +167,150 @@ // test for progress bar delete mFullScreenControl; - mFullScreenControl = NULL; + mFullScreenControl = NULL; setup( EControlBar ); - QVERIFY( mFullScreenControl->durationChanged( 100 ) ); - QVERIFY( static_cast(mFullScreenControl->mControl)->mDuration == 100 ); - + QVERIFY( mFullScreenControl->durationChanged( 100 ) ); + QVERIFY( static_cast(mFullScreenControl->mControl)->mDuration == 100 ); + // test for something other than progress bar delete mFullScreenControl; mFullScreenControl = NULL; - setup( EStatusPane ); - QVERIFY( ! mFullScreenControl->durationChanged( 100 ) ); - + setup( EStatusPane ); + QVERIFY( ! mFullScreenControl->durationChanged( 100 ) ); + + cleanup(); } -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // testPositionChanged -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // void TestFullScreenControl::testPositionChanged() -{ +{ MPX_ENTER_EXIT(_L("TestFullScreenControl::testPositionChanged()")); // test for progress bar delete mFullScreenControl; - mFullScreenControl = NULL; + mFullScreenControl = NULL; setup( EControlBar ); - QVERIFY( mFullScreenControl->positionChanged( 100 ) ); - QVERIFY( static_cast(mFullScreenControl->mControl)->mPosition == 100 ); - + QVERIFY( mFullScreenControl->positionChanged( 100 ) ); + QVERIFY( static_cast(mFullScreenControl->mControl)->mPosition == 100 ); + // test for something other than progress bar delete mFullScreenControl; mFullScreenControl = NULL; - setup( EStatusPane ); + setup( EStatusPane ); QVERIFY( ! mFullScreenControl->positionChanged( 100 ) ); + + cleanup(); } -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // testAspectRatioChanged -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // void TestFullScreenControl::testAspectRatioChanged() { MPX_ENTER_EXIT(_L("TestFullScreenControl::testAspectRatioChanged()")); - // test for button bar - delete mFullScreenControl; - mFullScreenControl = NULL; - setup( EControlBar ); + setup( EControlBar ); QVERIFY( mFullScreenControl->aspectRatioChanged( 3 ) ); // EMMFNatural - QVERIFY( static_cast(mFullScreenControl->mControl)->mAspectRatio == 3 ); - + QVERIFY( static_cast(mFullScreenControl->mControl)->mAspectRatio == 3 ); + // test for something other than button bar - delete mFullScreenControl; - mFullScreenControl = NULL; - setup( EStatusPane ); + if ( mFullScreenControl ) + { + delete mFullScreenControl; + mFullScreenControl = NULL; + } + + setup( EStatusPane ); QVERIFY( ! mFullScreenControl->aspectRatioChanged( 3 ) ); // EMMFNatural + + cleanup(); } -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // testUpdateState -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // void TestFullScreenControl::testUpdateState() { MPX_ENTER_EXIT(_L("TestFullScreenControl::testUpdateState()")); - delete mFullScreenControl; - mFullScreenControl = NULL; - setup( EControlBar ); - mFullScreenControl->updateState( EPbStatePaused ); - QVERIFY( static_cast(mFullScreenControl->mControl)->mState == EPbStatePaused ); + setup( EControlBar ); + + mFullScreenControl->updateState( EPbStatePaused ); + QVERIFY( static_cast(mFullScreenControl->mControl)->mState == EPbStatePaused ); + + cleanup(); } -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // testUpdateControlsWithFileDetails -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // void TestFullScreenControl::testUpdateControlsWithFileDetails() { MPX_ENTER_EXIT(_L("TestFullScreenControl::testUpdateControlsWithFileDetails()")); - VideoPlaybackViewFileDetails *fileDetails = new VideoPlaybackViewFileDetails(); - + VideoPlaybackViewFileDetails *fileDetails = new VideoPlaybackViewFileDetails(); + setup( EControlBar ); - + fileDetails->mPausableStream = true; - + mFullScreenControl->updateControlsWithFileDetails( fileDetails ); - - QVERIFY( static_cast(mFullScreenControl->mControl)->mFileDetails->mPausableStream ); + + QVERIFY( static_cast(mFullScreenControl->mControl)->mFileDetails->mPausableStream ); if ( fileDetails ) { delete fileDetails; - fileDetails = NULL; + fileDetails = NULL; } + + cleanup(); } -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // testUpdateControlProperties -// --------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // void TestFullScreenControl::testUpdateControlProperties() -{ +{ MPX_ENTER_EXIT(_L("TestFullScreenControl::testUpdateControlProperties()")); setup( EStatusPane ); - + mFullScreenControl->updateControlProperties( 1 ); - + QVERIFY( mFullScreenControl != NULL ); - + QVERIFY( mFullScreenControl->mProperties == 1 ); + + cleanup(); } - + +// ------------------------------------------------------------------------------------------------- +// testResetControl +// ------------------------------------------------------------------------------------------------- +// +void TestFullScreenControl::testResetControl() +{ + MPX_ENTER_EXIT(_L("TestFullScreenControl::testResetControl()")); + + setup( EControlBar ); + + QVERIFY( static_cast(mFullScreenControl->mControl)->mReset == false ); + + mFullScreenControl->resetControl(); + + QVERIFY( mFullScreenControl != NULL ); + + QVERIFY( static_cast(mFullScreenControl->mControl)->mReset ); + + cleanup(); +} + // End of file diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testfullscreencontrol/stub/inc/videoplaybackcontrolbar.h --- a/videoplayback/videoplaybackview/tsrc/testfullscreencontrol/stub/inc/videoplaybackcontrolbar.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testfullscreencontrol/stub/inc/videoplaybackcontrolbar.h Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 3 % +// Version : %version: 4 % @@ -43,6 +43,7 @@ void setVisibleToControlBar( bool visible ); void durationChanged( int duration ); void positionChanged( int position ); + void resetControl(); public: VideoPlaybackControlsController *mController; @@ -50,6 +51,7 @@ int mDuration; int mAspectRatio; bool mVisibility; + bool mReset; TMPXPlaybackState mState; VideoPlaybackViewFileDetails *mFileDetails; }; diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testfullscreencontrol/stub/src/videoplaybackcontrolbar.cpp --- a/videoplayback/videoplaybackview/tsrc/testfullscreencontrol/stub/src/videoplaybackcontrolbar.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testfullscreencontrol/stub/src/videoplaybackcontrolbar.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 3 % +// Version : %version: 4 % @@ -32,9 +32,10 @@ // VideoPlaybackControlBar::VideoPlaybackControlBar() // ------------------------------------------------------------------------------------------------- // -VideoPlaybackControlBar::VideoPlaybackControlBar( +VideoPlaybackControlBar::VideoPlaybackControlBar( VideoPlaybackControlsController* controller ) : mController( controller ) + , mReset( false ) { MPX_ENTER_EXIT(_L("VideoPlaybackControlBar::VideoPlaybackControlBar")); } @@ -116,4 +117,15 @@ mPosition = position; } +// ------------------------------------------------------------------------------------------------- +// VideoPlaybackControlBar::resetControl() +// ------------------------------------------------------------------------------------------------- +// +void VideoPlaybackControlBar::resetControl() +{ + MPX_DEBUG(_L("VideoPlaybackControlBar::resetControl()")); + + mReset = true; +} + //End of file diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testmpxvideoviewwrapper/src/testmpxvideoviewwrapper.cpp --- a/videoplayback/videoplaybackview/tsrc/testmpxvideoviewwrapper/src/testmpxvideoviewwrapper.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testmpxvideoviewwrapper/src/testmpxvideoviewwrapper.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 16 % +// Version : %version: 17 % #include #include @@ -650,6 +650,7 @@ // TRAPD( errIssueVidAppFGCmd, mVideoViewWrapper->IssueVideoAppForegroundCmdL( ETrue, ETrue ) ); QVERIFY( mVideoViewWrapper->iPlaybackUtility->iCommand == EPbCmdHandleForeground ); + QVERIFY( mVideoViewWrapper->iControlsController->mReceivedEvent == EControlCmdHandleForegroundEvent ); QVERIFY( errIssueVidAppFGCmd == KErrNone ); // @@ -657,6 +658,7 @@ // TRAP( errIssueVidAppFGCmd, mVideoViewWrapper->IssueVideoAppForegroundCmdL( EFalse, EFalse ) ); QVERIFY( mVideoViewWrapper->iPlaybackUtility->iCommand == EPbCmdHandleBackground ); + QVERIFY( mVideoViewWrapper->iControlsController->mReceivedEvent == EControlCmdHandleBackgroundEvent ); QVERIFY( errIssueVidAppFGCmd == KErrNone ); cleanup(); diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testmpxvideoviewwrapper/stub/inc/videoplaybackuserinputhandler.h --- a/videoplayback/videoplaybackview/tsrc/testmpxvideoviewwrapper/stub/inc/videoplaybackuserinputhandler.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testmpxvideoviewwrapper/stub/inc/videoplaybackuserinputhandler.h Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 5 % +// Version : %version: 6 % @@ -38,7 +38,7 @@ * Two-phased constructor. */ IMPORT_C static CVideoPlaybackUserInputHandler* NewL( - CMPXVideoViewWrapper* aWrapper, TBool aTvOutConnected ); + CMPXVideoViewWrapper* aWrapper ); /** * Destructor. @@ -55,22 +55,21 @@ /** * Symbian 2nd phase constructor. */ - void ConstructL( TBool aTvOutConnected ); + void ConstructL(); public: void ProcessKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); void SetForeground( TBool aForeground ); - + void HandleTVOutEventL(TBool aTVOutConnected); - + private: TBool iTVOutConnected; // Flag to indicate if TV is connected TBool iForeground; CMPXVideoViewWrapper* iViewWrapper; }; - #endif /*VIDEOPLAYBACKUSERINPUTHANDLER_H_*/ // End of File diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testmpxvideoviewwrapper/stub/src/videoplaybackuserinputhandler.cpp --- a/videoplayback/videoplaybackview/tsrc/testmpxvideoviewwrapper/stub/src/videoplaybackuserinputhandler.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testmpxvideoviewwrapper/stub/src/videoplaybackuserinputhandler.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 7 % +// Version : %version: 8 % // INCLUDE FILES @@ -35,9 +35,6 @@ #include "../inc/videoplaybackuserinputhandler.h" -// CONSTANTS -const TInt KMPXMicroSecondsInASecond = 1000000; - // ======== MEMBER FUNCTIONS ======================================================================= @@ -55,14 +52,14 @@ // ------------------------------------------------------------------------------------------------- // CVideoPlaybackUserInputHandler* CVideoPlaybackUserInputHandler::NewL( - CMPXVideoViewWrapper* aWrapper, TBool aTvOutConnected ) + CMPXVideoViewWrapper* aWrapper) { MPX_DEBUG(_L("CVideoPlaybackUserInputHandler::NewL()")); CVideoPlaybackUserInputHandler* self = new (ELeave) CVideoPlaybackUserInputHandler( aWrapper ); CleanupStack::PushL( self ); - self->ConstructL( aTvOutConnected ); + self->ConstructL(); CleanupStack::Pop(); return self; } @@ -72,9 +69,8 @@ // Symbian 2nd phase constructor can leave. // ------------------------------------------------------------------------------------------------- // -void CVideoPlaybackUserInputHandler::ConstructL( TBool aTvOutConnected ) +void CVideoPlaybackUserInputHandler::ConstructL() { - Q_UNUSED( aTvOutConnected ); } // ------------------------------------------------------------------------------------------------- diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testprogressbar/inc/testprogressbar.h --- a/videoplayback/videoplaybackview/tsrc/testprogressbar/inc/testprogressbar.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testprogressbar/inc/testprogressbar.h Fri Sep 17 08:30:05 2010 +0300 @@ -1,5 +1,5 @@ /** -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -12,10 +12,10 @@ * Contributors: * * Description: tester for methods in TestProgressBar -* +* */ -// Version : %version: 3 % +// Version : %version: 4 % #ifndef __TESTPROGRESSBAR_H__ #define __TESTPROGRESSBAR_H__ @@ -37,17 +37,17 @@ * will be called before each testfunction is executed. * */ - void init(); - + void init(); + /** * will be called after every testfunction. * */ void cleanup(); - + void setup(); - // test functions for the test framework + // test functions for the test framework private slots: void testHandleSliderPressed(); void testHandleSliderMoved(); @@ -55,8 +55,9 @@ void testUpdateWithFileDetails(); void testUpdateState(); void testDurationChanged(); - void testPositionChanged(); + void testPositionChanged(); void testHandleSeekingTimeout(); + void testResetControl(); signals: void commandSignal(); diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testprogressbar/src/testprogressbar.cpp --- a/videoplayback/videoplaybackview/tsrc/testprogressbar/src/testprogressbar.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testprogressbar/src/testprogressbar.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 10 % +// Version : %version: 11 % #include @@ -214,31 +214,6 @@ QVERIFY( mProgBar->mProgressSlider->progressValue() == movedPositoin ); QVERIFY( mProgBar->mProgressSlider->sliderValue() == movedPositoin ); - // - // If user isnot dragging the slider and movedPosition > mDuration - // - movedPositoin = 30; - mProgBar->mSliderDragging = false; - - emit mProgBar->mProgressSlider->move( movedPositoin ); - - QVERIFY( mProgBar->mProgressSlider->progressValue() == mProgBar->mDuration ); - QVERIFY( mProgBar->mProgressSlider->sliderValue() == mProgBar->mDuration ); - QVERIFY( mController->mCommand == EMPXPbvCmdEndOfClip ); - - // - // If user isnot dragging the slider and movedPosition < mDuration - // - movedPositoin = 10; - - emit mProgBar->mProgressSlider->move( movedPositoin ); - - QVERIFY( mProgBar->mProgressSlider->progressValue() == movedPositoin ); - QVERIFY( mProgBar->mProgressSlider->sliderValue() == movedPositoin ); - - QVERIFY( mController->mCommand == EMPXPbvCmdSetPosition ); - QVERIFY( mController->mValue == movedPositoin ); - cleanup(); } @@ -450,4 +425,31 @@ cleanup(); } +// ------------------------------------------------------------------------------------------------- +// testResetControl +// ------------------------------------------------------------------------------------------------- +// +void TestProgressBar::testResetControl() +{ + MPX_ENTER_EXIT(_L("TestProgressBar::testResetControl()")); + + setup(); + + mController->mTimerAction = ETimerCancel; + mProgBar->mSliderDragging = true; + mProgBar->resetControl(); + + QVERIFY( ! mProgBar->mSliderDragging ); + QVERIFY( mController->mTimerAction == ETimerReset ); + + mController->mTimerAction = ETimerCancel; + mProgBar->mSliderDragging = false; + mProgBar->resetControl(); + + QVERIFY( ! mProgBar->mSliderDragging ); + QVERIFY( mController->mTimerAction == ETimerCancel ); + + cleanup(); +} + // End of file diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testtoolbar/inc/testtoolbar.h --- a/videoplayback/videoplaybackview/tsrc/testtoolbar/inc/testtoolbar.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testtoolbar/inc/testtoolbar.h Fri Sep 17 08:30:05 2010 +0300 @@ -1,5 +1,5 @@ /** -* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -12,10 +12,10 @@ * Contributors: * * Description: tester for methods in TestToolBar -* +* */ -// Version : %version: 2 % +// Version : %version: 3 % #ifndef __TESTTOOLBAR_H__ #define __TESTTOOLBAR_H__ @@ -37,15 +37,15 @@ * will be called before each testfunction is executed. * */ - void init( bool attachOperation = false ); - + void init( bool attachOperation = false ); + /** * will be called after every testfunction. * */ void cleanup(); - // test functions for the test framework + // test functions for the test framework private slots: // the order in which these testXX methods are declared is important @@ -64,6 +64,7 @@ void testOpenDetailsView(); void testAttach(); void testSend(); + void testResetControl(); signals: void commandSignal(); diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testtoolbar/src/testtoolbar.cpp --- a/videoplayback/videoplaybackview/tsrc/testtoolbar/src/testtoolbar.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testtoolbar/src/testtoolbar.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 7 % +// Version : %version: 8 % #include @@ -675,4 +675,59 @@ cleanup(); } +// ------------------------------------------------------------------------------------------------- +// testResetControl +// ------------------------------------------------------------------------------------------------- +// +void TestToolBar::testResetControl() +{ + MPX_ENTER_EXIT(_L("TestToolBar::testResetControl()")); + + init( true ); + + // + // FF + // + mVideoToolBar->mSeekingState = EFastForwarding; + mController->mTimerAction = ETimerCancel; + mController->mCommand = EMPXPbvCmdSeekForward; + + mVideoToolBar->resetControl(); + + QVERIFY( mVideoToolBar->mSeekingState == ENotSeeking ); + QVERIFY( mController->mTimerAction == ETimerReset ); + QVERIFY( mController->mCommand == EMPXPbvCmdEndSeek ); + + // + // RW + // + mController->mTimerAction = ETimerCancel; + mController->mCommand = EMPXPbvCmdSeekForward; + mVideoToolBar->mSeekingState = ERewinding; + + mVideoToolBar->resetControl(); + + QVERIFY( mVideoToolBar->mSeekingState == ENotSeeking ); + QVERIFY( mController->mTimerAction == ETimerReset ); + QVERIFY( mController->mCommand == EMPXPbvCmdEndSeek ); + + // + // Not seeking + // + mController->mTimerAction = ETimerCancel; + mController->mCommand = EMPXPbvCmdPlay; + mVideoToolBar->mSeekingState = ENotSeeking; + + mVideoToolBar->resetControl(); + + QVERIFY( mVideoToolBar->mSeekingState == ENotSeeking ); + QVERIFY( mController->mTimerAction == ETimerCancel ); + QVERIFY( mController->mCommand == EMPXPbvCmdPlay ); + + // + // clean up + // + cleanup(); +} + // End of file diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testuserinputhandler/inc/testuserinputhandler.h --- a/videoplayback/videoplaybackview/tsrc/testuserinputhandler/inc/testuserinputhandler.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testuserinputhandler/inc/testuserinputhandler.h Fri Sep 17 08:30:05 2010 +0300 @@ -1,5 +1,5 @@ /** -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -12,7 +12,7 @@ * Contributors: * * Description: tester for methods in User Input Handler -* +* */ #ifndef __TESTUSERINPUTHANDLER_H__ @@ -23,55 +23,38 @@ #include - // forward declaration class CMPXVideoViewWrapper; +class VideoBasePlaybackView; class CVideoPlaybackUserInputHandler; -class VideoBasePlaybackView; class TestUserInputHandler : public QObject { Q_OBJECT -public: - - void init(); - - void cleanup(); - - void setup(); - - - // test functions for the test framework -private slots: - - void testProcessMediaKeyPlay(); - - void testProcessMediaKeyPause(); - - void testProcessMediaKeyPlayPause(); + public: + void init(); + void cleanup(); + void setup(); - void testProcessMediaKeyStop(); + // test functions for the test framework + private slots: + void testProcessMediaKeyPlay(); + void testProcessMediaKeyPause(); + void testProcessMediaKeyPlayPause(); + void testProcessMediaKeyStop(); + void testProcessMediaKeyForward(); + void testProcessMediaKeyRewind(); + void testProcessMediaKeyVolumeUp(); + void testProcessMediaKeyVolumeDown(); + void testProcessMediaKeyWhenLocked(); + void testProcessMediaKeyWhenInBackground(); - void testProcessMediaKeyForward(); - - void testProcessMediaKeyRewind(); - - void testProcessMediaKeyVolumeUp(); - - void testProcessMediaKeyVolumeDown(); - - void testHandleTVOutEventL(); - - -signals: - -private: - CVideoPlaybackUserInputHandler* mUserInputHdlr; - VideoBasePlaybackView* mBaseVideoView; - CMPXVideoViewWrapper* mVideoViewWrapper; - + private: + CVideoPlaybackUserInputHandler* mUserInputHdlr; + VideoBasePlaybackView* mBaseVideoView; + CMPXVideoViewWrapper* mVideoViewWrapper; }; diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testuserinputhandler/src/testuserinputhandler.cpp --- a/videoplayback/videoplaybackview/tsrc/testuserinputhandler/src/testuserinputhandler.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testuserinputhandler/src/testuserinputhandler.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -1,5 +1,5 @@ /** -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -12,13 +12,18 @@ * Contributors: * * Description: tester for methods in User Input Handler -* +* */ #include #include #include +#include +#include +#include +#include + #include #include #include @@ -40,30 +45,29 @@ { HbApplication app(argc, argv); HbMainWindow window; - + TestUserInputHandler tv; char *pass[3]; pass[0] = argv[0]; pass[1] = "-o"; pass[2] = "c:\\data\\testuserinputhandler.txt"; - + int res = QTest::qExec(&tv, 3, pass); - + return res; } - // --------------------------------------------------------------------------- // init // --------------------------------------------------------------------------- // void TestUserInputHandler::init() -{ +{ mBaseVideoView = new VideoBasePlaybackView(); - mVideoViewWrapper = CMPXVideoViewWrapper::NewL( mBaseVideoView ); - - mUserInputHdlr = CVideoPlaybackUserInputHandler::NewL(mVideoViewWrapper, false); + mVideoViewWrapper = CMPXVideoViewWrapper::NewL( mBaseVideoView ); + + mUserInputHdlr = CVideoPlaybackUserInputHandler::NewL( mVideoViewWrapper ); } // --------------------------------------------------------------------------- @@ -71,15 +75,15 @@ // --------------------------------------------------------------------------- // void TestUserInputHandler::cleanup() -{ +{ delete mUserInputHdlr; - mUserInputHdlr = NULL; - + mUserInputHdlr = NULL; + delete mVideoViewWrapper; mVideoViewWrapper = NULL; - + delete mBaseVideoView; - mBaseVideoView = NULL; + mBaseVideoView = NULL; } // --------------------------------------------------------------------------- @@ -87,39 +91,39 @@ // --------------------------------------------------------------------------- // void TestUserInputHandler::setup() -{ +{ } void TestUserInputHandler::testProcessMediaKeyPlay() -{ +{ init(); - - mUserInputHdlr->iProcessingInputType = EVideoNone; - + + mUserInputHdlr->iProcessingInputType = EVideoNone; + mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonPress); QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoMediaKeys ); - + // this event should be ignored as the 1st event is still being processed mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPause, ERemConCoreApiButtonPress); - + // verify that "Play" is still being processed and not "Pause" QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ERemConCoreApiPlay ); - + // send the release event for "Play" mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonRelease); - + // verify that no input is now being processed QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone ); - + cleanup(); } void TestUserInputHandler::testProcessMediaKeyPause() -{ +{ init(); - - mUserInputHdlr->iProcessingInputType = EVideoNone; - + + mUserInputHdlr->iProcessingInputType = EVideoNone; + // Issue Play mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonPress); mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonRelease); @@ -127,43 +131,43 @@ // Initiate Pause mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPause, ERemConCoreApiButtonPress); - QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoMediaKeys ); - QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ERemConCoreApiPause ); - - mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPause, ERemConCoreApiButtonRelease); + QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoMediaKeys ); + QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ERemConCoreApiPause ); + + mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPause, ERemConCoreApiButtonRelease); QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone ); - - cleanup(); - + + cleanup(); + } void TestUserInputHandler::testProcessMediaKeyPlayPause() -{ +{ init(); - - mUserInputHdlr->iProcessingInputType = EVideoNone; - + + mUserInputHdlr->iProcessingInputType = EVideoNone; + mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPausePlayFunction, ERemConCoreApiButtonClick); - QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone ); - + QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone ); + // set to background mUserInputHdlr->iForeground = false; - + mUserInputHdlr->iLastMediaKeyPressed = ENop; // this event should be ignored as iForeground is false mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPausePlayFunction, ERemConCoreApiButtonPress); QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ENop ); - QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone ); - - cleanup(); + QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone ); + + cleanup(); } void TestUserInputHandler::testProcessMediaKeyStop() -{ +{ init(); - - mUserInputHdlr->iProcessingInputType = EVideoNone; - + + mUserInputHdlr->iProcessingInputType = EVideoNone; + // Issue Play mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonPress); mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonRelease); @@ -171,21 +175,21 @@ // Stop mUserInputHdlr->ProcessMediaKey(ERemConCoreApiStop, ERemConCoreApiButtonPress); - QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoMediaKeys ); - QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ERemConCoreApiStop ); - - mUserInputHdlr->ProcessMediaKey(ERemConCoreApiStop, ERemConCoreApiButtonRelease); + QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoMediaKeys ); + QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ERemConCoreApiStop ); + + mUserInputHdlr->ProcessMediaKey(ERemConCoreApiStop, ERemConCoreApiButtonRelease); QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone ); - - cleanup(); + + cleanup(); } void TestUserInputHandler::testProcessMediaKeyForward() -{ +{ init(); - - mUserInputHdlr->iProcessingInputType = EVideoNone; - + + mUserInputHdlr->iProcessingInputType = EVideoNone; + // Issue Play mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonPress); mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonRelease); @@ -193,21 +197,21 @@ // Forward mUserInputHdlr->ProcessMediaKey(ERemConCoreApiFastForward, ERemConCoreApiButtonPress); - QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoMediaKeys ); - QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ERemConCoreApiFastForward ); - - mUserInputHdlr->ProcessMediaKey(ERemConCoreApiFastForward, ERemConCoreApiButtonRelease); + QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoMediaKeys ); + QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ERemConCoreApiFastForward ); + + mUserInputHdlr->ProcessMediaKey(ERemConCoreApiFastForward, ERemConCoreApiButtonRelease); QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone ); - - cleanup(); + + cleanup(); } void TestUserInputHandler::testProcessMediaKeyRewind() -{ +{ init(); - - mUserInputHdlr->iProcessingInputType = EVideoNone; - + + mUserInputHdlr->iProcessingInputType = EVideoNone; + // Issue Play mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonPress); mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonRelease); @@ -215,109 +219,102 @@ // Forward mUserInputHdlr->ProcessMediaKey(ERemConCoreApiFastForward, ERemConCoreApiButtonPress); - QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoMediaKeys ); - QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ERemConCoreApiFastForward ); - - mUserInputHdlr->ProcessMediaKey(ERemConCoreApiFastForward, ERemConCoreApiButtonRelease); + QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoMediaKeys ); + QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ERemConCoreApiFastForward ); + + mUserInputHdlr->ProcessMediaKey(ERemConCoreApiFastForward, ERemConCoreApiButtonRelease); QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone ); - + // Rewind mUserInputHdlr->ProcessMediaKey(ERemConCoreApiRewind, ERemConCoreApiButtonPress); - QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoMediaKeys ); - QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ERemConCoreApiRewind ); - - mUserInputHdlr->ProcessMediaKey(ERemConCoreApiRewind, ERemConCoreApiButtonRelease); + QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoMediaKeys ); + QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ERemConCoreApiRewind ); + + mUserInputHdlr->ProcessMediaKey(ERemConCoreApiRewind, ERemConCoreApiButtonRelease); QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone ); - - cleanup(); + + cleanup(); } void TestUserInputHandler::testProcessMediaKeyVolumeUp() -{ +{ init(); - - mUserInputHdlr->iProcessingInputType = EVideoNone; - - // Issue Play - mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonPress); - mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonRelease); - QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone ); - - // Volume Up - mUserInputHdlr->ProcessMediaKey(ERemConCoreApiVolumeUp, ERemConCoreApiButtonPress); - QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoMediaKeys ); - QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ERemConCoreApiVolumeUp ); - QVERIFY( mUserInputHdlr->iVolumeRepeatTimer->IsActive() ); - QVERIFY( mUserInputHdlr->iVolumeRepeatUp ); - - mUserInputHdlr->ProcessMediaKey(ERemConCoreApiVolumeUp, ERemConCoreApiButtonRelease); - QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone ); - QVERIFY( ! mUserInputHdlr->iVolumeRepeatTimer->IsActive() ); - - cleanup(); -} -void TestUserInputHandler::testProcessMediaKeyVolumeDown() -{ - init(); - - mUserInputHdlr->iProcessingInputType = EVideoNone; - + mUserInputHdlr->iProcessingInputType = EVideoNone; + // Issue Play mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonPress); mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonRelease); QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone ); - - // Volume Down - mUserInputHdlr->ProcessMediaKey(ERemConCoreApiVolumeDown, ERemConCoreApiButtonPress); - QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoMediaKeys ); - QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ERemConCoreApiVolumeDown ); + + // Volume Up + mUserInputHdlr->ProcessMediaKey(ERemConCoreApiVolumeUp, ERemConCoreApiButtonPress); + QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoMediaKeys ); + QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ERemConCoreApiVolumeUp ); QVERIFY( mUserInputHdlr->iVolumeRepeatTimer->IsActive() ); - QVERIFY( ! mUserInputHdlr->iVolumeRepeatUp ); - - mUserInputHdlr->ProcessMediaKey(ERemConCoreApiVolumeDown, ERemConCoreApiButtonRelease); - QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone ); - QVERIFY( ! mUserInputHdlr->iVolumeRepeatTimer->IsActive() ); - - cleanup(); + QVERIFY( mUserInputHdlr->iVolumeRepeatUp ); + + mUserInputHdlr->ProcessMediaKey(ERemConCoreApiVolumeUp, ERemConCoreApiButtonRelease); + QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone ); + QVERIFY( ! mUserInputHdlr->iVolumeRepeatTimer->IsActive() ); + + cleanup(); } -void TestUserInputHandler::testHandleTVOutEventL() -{ - - /////////////////////////////// - // 1. HandleTVOutEventL(true) - /////////////////////////////// +void TestUserInputHandler::testProcessMediaKeyVolumeDown() +{ init(); - - mUserInputHdlr->iDisplayTimeOut = 0; - - mUserInputHdlr->HandleTVOutEventL(true); - - QVERIFY( mUserInputHdlr->iDisplayTimeOut != 0 ); - QVERIFY( mUserInputHdlr->iDisplayTimer->IsActive() ); - + + mUserInputHdlr->iProcessingInputType = EVideoNone; + + // Issue Play + mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonPress); + mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonRelease); + QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone ); + + // Volume Down + mUserInputHdlr->ProcessMediaKey(ERemConCoreApiVolumeDown, ERemConCoreApiButtonPress); + QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoMediaKeys ); + QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ERemConCoreApiVolumeDown ); + QVERIFY( mUserInputHdlr->iVolumeRepeatTimer->IsActive() ); + QVERIFY( ! mUserInputHdlr->iVolumeRepeatUp ); + + mUserInputHdlr->ProcessMediaKey(ERemConCoreApiVolumeDown, ERemConCoreApiButtonRelease); + QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone ); + QVERIFY( ! mUserInputHdlr->iVolumeRepeatTimer->IsActive() ); + cleanup(); - - - /////////////////////////////// - // 2. HandleTVOutEventL(false) - /////////////////////////////// - init(); - - mUserInputHdlr->iDisplayTimeOut = 0; - - mUserInputHdlr->HandleTVOutEventL(false); - QVERIFY( ! mUserInputHdlr->iDisplayTimer->IsActive() ); - - cleanup(); - } +void TestUserInputHandler::testProcessMediaKeyWhenLocked() +{ + + init(); + mUserInputHdlr->iProcessingInputType = EVideoNone; + RProperty::Set( KPSUidAvkonDomain, KAknKeyguardStatus, true ); + // media keys should be ignored when key lock is ON + mUserInputHdlr->ProcessMediaKey(ERemConCoreApiVolumeDown, ERemConCoreApiButtonPress); + QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone ); + + RProperty::Set( KPSUidAvkonDomain, KAknKeyguardStatus, false ); + + cleanup(); +} + +void TestUserInputHandler::testProcessMediaKeyWhenInBackground() +{ + init(); + + mUserInputHdlr->iProcessingInputType = EVideoNone; + mUserInputHdlr->iForeground = false; + + // media keys should be ignored when not in foreground + mUserInputHdlr->ProcessMediaKey(ERemConCoreApiVolumeDown, ERemConCoreApiButtonPress); + QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone ); + + cleanup(); +} // End of file - - - diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testuserinputhandler/stub/inc/centralrepository.h --- a/videoplayback/videoplaybackview/tsrc/testuserinputhandler/stub/inc/centralrepository.h Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: Stub declaration for central repository -// - -#ifndef __CENTRALREPOSITORY_H__ -#define __CENTRALREPOSITORY_H__ - -#include - - -class CRepository : public CBase - { -public: - - static CRepository* NewLC(TUid aRepositoryUid); - - virtual ~CRepository(); - - TInt Get(TUint32 aKey, TInt& aValue); - - }; - -#endif // __CENTRALREPOSITORY_H__ diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testuserinputhandler/stub/inc/hal.h --- a/videoplayback/videoplaybackview/tsrc/testuserinputhandler/stub/inc/hal.h Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -/* -* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Stub declaration for HAL -* -*/ - -// Version : %version: 1 % - - - -#ifndef __HAL_H__ -#define __HAL_H__ - -#include -#include - -class HAL : public CBase - { - -public: - - static TInt Get(TAttribute aAttribute, TInt& aValue); - - - static TInt Set(TAttribute aAttribute, TInt aValue); - - - }; - - -#endif - diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testuserinputhandler/stub/src/centralrepository.cpp --- a/videoplayback/videoplaybackview/tsrc/testuserinputhandler/stub/src/centralrepository.cpp Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Stub implementation for central repository -* -*/ - -// Version : %version: 2 % - - - -// -// INCLUDE FILES -// -#include "centralrepository.h" - - -CRepository* CRepository::NewLC( TUid /* aRepositoryUid */ ) -{ - CRepository* self = new (ELeave) CRepository(); - - CleanupStack::PushL( self ); - - return self; -} - - -TInt CRepository::Get( TUint32 /* aKey */, TInt& aValue ) -{ - aValue = 10; - return KErrNone; -} - -CRepository::~CRepository() -{ -} - - -// EOF diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testuserinputhandler/stub/src/hal.cpp --- a/videoplayback/videoplaybackview/tsrc/testuserinputhandler/stub/src/hal.cpp Thu Sep 02 20:28:16 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Stub implementation for HAL -* -*/ - -// Version : %version: 1 % - - - -// -// INCLUDE FILES -// -#include "hal.h" - - -TInt HAL::Get(TAttribute /*aAttribute*/, TInt& aValue) -{ - aValue = 5; - return KErrNone; -} - -TInt HAL::Set(TAttribute /*aAttribute*/, TInt /*aValue*/) -{ - return KErrNone; -} - - -// EOF diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/tsrc/testuserinputhandler/testuserinputhandler.pro --- a/videoplayback/videoplaybackview/tsrc/testuserinputhandler/testuserinputhandler.pro Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/tsrc/testuserinputhandler/testuserinputhandler.pro Fri Sep 17 08:30:05 2010 +0300 @@ -14,7 +14,7 @@ # Description: Project file for building testuserinputhandler # # -# Version : %version: 4 % +# Version : %version: 6 % TEMPLATE = app TARGET = testuserinputhandler @@ -31,22 +31,19 @@ LIBS += -lremconcoreapi.dll \ - -lremconInterfacebase.dll + -lremconInterfacebase.dll \ + -lcentralrepository.dll # Input HEADERS += stub/inc/mpxvideoviewwrapper.h \ stub/inc/videobaseplaybackview.h \ stub/inc/videoplaybackviewfiledetails.h \ - stub/inc/hal.h \ - stub/inc/centralrepository.h \ inc/testuserinputhandler.h \ ../../viewinc/videoplaybackuserinputhandler.h SOURCES += stub/src/mpxvideoviewwrapper.cpp \ stub/src/videobaseplaybackview.cpp \ stub/src/videoplaybackviewfiledetails.cpp \ - stub/src/hal.cpp \ - stub/src/centralrepository.cpp \ src/testuserinputhandler.cpp \ ../../viewsrc/videoplaybackuserinputhandler.cpp diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/videoplaybackview.pro --- a/videoplayback/videoplaybackview/videoplaybackview.pro Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/videoplaybackview.pro Fri Sep 17 08:30:05 2010 +0300 @@ -14,7 +14,7 @@ # Description: Project file for building Videoplayer components # # -# Version : %version: 32 % +# Version : %version: da1mmcf#33 % TEMPLATE = lib @@ -58,7 +58,6 @@ -lcone.dll \ -lefsrv.dll \ -lws32.dll \ - -lhal.dll \ -lgdi.dll \ -lshareui.dll diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/viewinc/videoplaybackuserinputhandler.h --- a/videoplayback/videoplaybackview/viewinc/videoplaybackuserinputhandler.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/viewinc/videoplaybackuserinputhandler.h Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 7 % +// Version : %version: 9 % @@ -41,8 +41,7 @@ /** * Two-phased constructor. */ - static CVideoPlaybackUserInputHandler* NewL( - CMPXVideoViewWrapper* aWrapper, TBool aTvOutConnected ); + static CVideoPlaybackUserInputHandler* NewL( CMPXVideoViewWrapper* aWrapper ); /** * Destructor. @@ -59,10 +58,12 @@ /** * Symbian 2nd phase constructor. */ - void ConstructL( TBool aTvOutConnected ); + void ConstructL(); public: - void ProcessKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); + /*void ProcessPointerEventL( CCoeControl* aControl, + const TPointerEvent& aPointerEvent, + TVideoControlType aMPXControl );*/ void ProcessMediaKey( TRemConCoreApiOperationId aOperationId, TRemConCoreApiButtonAction aButtonAct ); @@ -90,9 +91,8 @@ * @return void */ void SetForeground( TBool aForeground ); - - void HandleTVOutEventL( TBool aTVOutConnected ); - + + private: /** * Handles volume repeat timer timout @@ -105,6 +105,12 @@ * @return void */ void HandleVolumeRepeatL(); + + /** + * Checks if the key lock is ON + * @return ETrue if keylock is ON, EFalse otherwise + */ + TBool IsKeyLocked(); void HandleFastForward( TRemConCoreApiButtonAction aButtonAct ); @@ -114,17 +120,9 @@ void HandleVolumeDown( TRemConCoreApiButtonAction aButtonAct ); - // Handles the Display light timer timeout - static TInt HandleDisplayTimeout( TAny* aPtr ); - - // Disable the display backlight - void DisableBacklight(); - - // Enable the display backlight - void EnableBacklight(); - - // Restarts the timer for display light time-out - void RestartDisplayTimer(); + /*void ReRoutePointerEventL( CCoeControl* aControl, + const TPointerEvent& aPointerEvent, + TVideoControlType aControl );*/ private: @@ -138,15 +136,10 @@ CPeriodic* iVolumeRepeatTimer; // owned TBool iVolumeRepeatUp; - TBool iTVOutConnected; // Flag to indicate if TV is connected - CPeriodic* iDisplayTimer; // Timer to timeout the lights time-out - TInt iDisplayTimeOut; // Value of the lights time-out - TBool iForeground; CMPXVideoViewWrapper* iViewWrapper; }; - #endif /*VIDEOPLAYBACKUSERINPUTHANDLER_H_*/ // End of File diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/viewsrc/mpxvideoviewwrapper.cpp --- a/videoplayback/videoplaybackview/viewsrc/mpxvideoviewwrapper.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/viewsrc/mpxvideoviewwrapper.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: da1mmcf#45 % +// Version : %version: da1mmcf#47 % @@ -125,7 +125,7 @@ // // Create user input handler // - iUserInputHandler = CVideoPlaybackUserInputHandler::NewL( this, iFileDetails->mTvOutConnected ); + iUserInputHandler = CVideoPlaybackUserInputHandler::NewL( this ); } // ------------------------------------------------------------------------------------------------- @@ -581,11 +581,6 @@ cmdId = EControlCmdTvOutConnected; } - if ( iUserInputHandler ) - { - TRAP_IGNORE(iUserInputHandler->HandleTVOutEventL( tvOutConnected )); - } - if ( iControlsController ) { iControlsController->handleEvent( cmdId ); @@ -1271,13 +1266,19 @@ MPX_ENTER_EXIT(_L("CMPXVideoViewWrapper::IssueVideoAppForegroundCmdL()"), _L("aViewForeground = %d, aAppForegournd = %d"), aViewForeground, aAppForegournd ); + iUserInputHandler->SetForeground( aAppForegournd ); + TMPXVideoPlaybackCommand videoCmd = EPbCmdHandleBackground; + TVideoPlaybackControlCommandIds controlsCmd = EControlCmdHandleBackgroundEvent; if ( aViewForeground ) { videoCmd = EPbCmdHandleForeground; + controlsCmd = EControlCmdHandleForegroundEvent; } + iControlsController->handleEvent( controlsCmd ); + // // create command to pass to playback plugin // diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackview/viewsrc/videoplaybackuserinputhandler.cpp --- a/videoplayback/videoplaybackview/viewsrc/videoplaybackuserinputhandler.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackview/viewsrc/videoplaybackuserinputhandler.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 9 % +// Version : %version: 11 % // INCLUDE FILES @@ -32,9 +32,7 @@ #include // display timeout setting keys #include #include - -#include -#include +#include #include "mpxvideo_debug.h" #include "mpxvideoviewwrapper.h" @@ -42,9 +40,6 @@ #include "videoplaybackuserinputhandler.h" -// CONSTANTS -const TInt KMPXMicroSecondsInASecond = 1000000; - // ======== MEMBER FUNCTIONS ======================================================================= @@ -53,7 +48,9 @@ // ------------------------------------------------------------------------------------------------- // CVideoPlaybackUserInputHandler::CVideoPlaybackUserInputHandler( CMPXVideoViewWrapper* aWrapper ) - : iViewWrapper( aWrapper ) + : iProcessingInputType( EVideoNone ) + , iForeground( ETrue ) + , iViewWrapper( aWrapper ) { } @@ -61,15 +58,14 @@ // CVideoPlaybackUserInputHandler::NewL() // ------------------------------------------------------------------------------------------------- // -CVideoPlaybackUserInputHandler* CVideoPlaybackUserInputHandler::NewL( - CMPXVideoViewWrapper* aWrapper, TBool aTvOutConnected ) +CVideoPlaybackUserInputHandler* CVideoPlaybackUserInputHandler::NewL( CMPXVideoViewWrapper* aWrapper ) { - MPX_DEBUG(_L("CVideoPlaybackUserInputHandler::NewL()")); + MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::NewL()")); CVideoPlaybackUserInputHandler* self = new (ELeave) CVideoPlaybackUserInputHandler( aWrapper ); CleanupStack::PushL( self ); - self->ConstructL( aTvOutConnected ); + self->ConstructL(); CleanupStack::Pop(); return self; } @@ -79,40 +75,17 @@ // Symbian 2nd phase constructor can leave. // ------------------------------------------------------------------------------------------------- // -void CVideoPlaybackUserInputHandler::ConstructL( TBool aTvOutConnected ) +void CVideoPlaybackUserInputHandler::ConstructL() { MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::ConstructL()")); iVolumeRepeatTimer = CPeriodic::NewL( CActive::EPriorityStandard ); - iDisplayTimer = CPeriodic::NewL( CPeriodic::EPriorityStandard ); + iInterfaceSelector = CRemConInterfaceSelector::NewL(); iCoreTarget = CRemConCoreApiTarget::NewL( *iInterfaceSelector, *this ); - iTVOutConnected = aTvOutConnected; - - // Start the timer if TV out is connected - if ( iTVOutConnected ) - { - // Get the display light time-out value from CenRep - CRepository* repository = CRepository::NewLC( KCRUidLightSettings ); - - // What's the timeout value (in seconds ) for the display light? - repository->Get( KDisplayLightsTimeout, iDisplayTimeOut ); - MPX_DEBUG(_L("CVideoPlaybackUserInputHandler::ConstructL Display Timeout( %d )"), iDisplayTimeOut); - - CleanupStack::PopAndDestroy( repository ); - - // Convert the timeout value to microseconds - iDisplayTimeOut *= KMPXMicroSecondsInASecond; - - RestartDisplayTimer(); - } - // not detrimental if Media Keys dont work - so ignore any errors here TRAP_IGNORE( iInterfaceSelector->OpenTargetL() ); - - iProcessingInputType = EVideoNone; - iForeground = ETrue; } // ------------------------------------------------------------------------------------------------- @@ -121,28 +94,20 @@ // CVideoPlaybackUserInputHandler::~CVideoPlaybackUserInputHandler() { + MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::~CVideoPlaybackUserInputHandler()")); + if ( iVolumeRepeatTimer ) { iVolumeRepeatTimer->Cancel(); delete iVolumeRepeatTimer; } - if ( iDisplayTimer ) - { - iDisplayTimer->Cancel(); - delete iDisplayTimer; - } - if ( iInterfaceSelector ) { delete iInterfaceSelector; iCoreTarget = NULL; iInterfaceSelector = NULL; } - - // make sure that backlight enabled when - // the view updates or deactivates - EnableBacklight(); } // ------------------------------------------------------------------------------------------------- @@ -181,7 +146,8 @@ void CVideoPlaybackUserInputHandler::DoHandleMediaKey( TRemConCoreApiOperationId aOperationId, TRemConCoreApiButtonAction aButtonAct ) { - MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::DoHandleMediaKey()")); + MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::DoHandleMediaKey()"), + _L("aOperationId = %d"), aOperationId ); switch ( aOperationId ) { @@ -189,41 +155,41 @@ { if ( aButtonAct == ERemConCoreApiButtonClick ) { - TRAP_IGNORE(iViewWrapper->HandleCommandL( EMPXPbvCmdStop )); + TRAP_IGNORE( iViewWrapper->HandleCommandL( EMPXPbvCmdStop ) ); } break; } case ERemConCoreApiRewind: { - HandleRewind(aButtonAct); + HandleRewind( aButtonAct ); break; } case ERemConCoreApiFastForward: { - HandleFastForward(aButtonAct); + HandleFastForward( aButtonAct ); break; } case ERemConCoreApiVolumeUp: { - HandleVolumeUp(aButtonAct); + HandleVolumeUp( aButtonAct ); break; } case ERemConCoreApiVolumeDown: { - HandleVolumeDown(aButtonAct); + HandleVolumeDown( aButtonAct ); break; } case ERemConCoreApiPausePlayFunction: { if ( aButtonAct == ERemConCoreApiButtonClick ) { - TRAP_IGNORE(iViewWrapper->HandleCommandL(EMPXPbvCmdPlayPause)); + TRAP_IGNORE( iViewWrapper->HandleCommandL( EMPXPbvCmdPlayPause ) ); } break; } case ERemConCoreApiPause: { - TRAP_IGNORE(iViewWrapper->HandleCommandL(EMPXPbvCmdPause)); + TRAP_IGNORE( iViewWrapper->HandleCommandL( EMPXPbvCmdPause ) ); break; } case ERemConCoreApiPlay: @@ -235,7 +201,9 @@ break; } default: + { break; + } } } @@ -245,13 +213,15 @@ // void CVideoPlaybackUserInputHandler::HandleFastForward( TRemConCoreApiButtonAction aButtonAct ) { - if (aButtonAct == ERemConCoreApiButtonPress) + MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::HandleFastForward()")); + + if ( aButtonAct == ERemConCoreApiButtonPress ) { - TRAP_IGNORE(iViewWrapper->HandleCommandL(EMPXPbvCmdSeekForward)); + TRAP_IGNORE( iViewWrapper->HandleCommandL( EMPXPbvCmdSeekForward ) ); } - else if (aButtonAct == ERemConCoreApiButtonRelease) + else if ( aButtonAct == ERemConCoreApiButtonRelease ) { - TRAP_IGNORE(iViewWrapper->HandleCommandL(EMPXPbvCmdEndSeek)); + TRAP_IGNORE( iViewWrapper->HandleCommandL( EMPXPbvCmdEndSeek ) ); } } @@ -262,13 +232,15 @@ // void CVideoPlaybackUserInputHandler::HandleRewind( TRemConCoreApiButtonAction aButtonAct ) { - if (aButtonAct == ERemConCoreApiButtonPress) + MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::HandleFastForward()")); + + if ( aButtonAct == ERemConCoreApiButtonPress ) { - TRAP_IGNORE(iViewWrapper->HandleCommandL(EMPXPbvCmdSeekBackward)); + TRAP_IGNORE( iViewWrapper->HandleCommandL( EMPXPbvCmdSeekBackward ) ); } - else if (aButtonAct == ERemConCoreApiButtonRelease) + else if ( aButtonAct == ERemConCoreApiButtonRelease ) { - TRAP_IGNORE(iViewWrapper->HandleCommandL(EMPXPbvCmdEndSeek)); + TRAP_IGNORE( iViewWrapper->HandleCommandL( EMPXPbvCmdEndSeek ) ); } } @@ -278,6 +250,9 @@ // void CVideoPlaybackUserInputHandler::HandleVolumeUp( TRemConCoreApiButtonAction aButtonAct ) { + MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::HandleVolumeUp()"), + _L("aButtonAct = %d"), aButtonAct ); + switch ( aButtonAct ) { case ERemConCoreApiButtonPress: @@ -289,6 +264,7 @@ } iVolumeRepeatUp = ETrue; + iVolumeRepeatTimer->Start( KAknStandardKeyboardRepeatRate, KAknStandardKeyboardRepeatRate, @@ -313,13 +289,14 @@ } } - // ------------------------------------------------------------------------------------------------- // CVideoPlaybackUserInputHandler::HandleVolumeDown() // ------------------------------------------------------------------------------------------------- // void CVideoPlaybackUserInputHandler::HandleVolumeDown( TRemConCoreApiButtonAction aButtonAct ) { + MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::HandleVolumeDown()")); + switch ( aButtonAct ) { case ERemConCoreApiButtonPress: @@ -331,6 +308,7 @@ } iVolumeRepeatUp = EFalse; + iVolumeRepeatTimer->Start( KAknStandardKeyboardRepeatRate, KAknStandardKeyboardRepeatRate, @@ -355,102 +333,148 @@ } } +/* // ------------------------------------------------------------------------------------------------- -// CVideoPlaybackUserInputHandler::ProcessKeyEvent() +// CMPXVideoPlaybackUserInputHandler::ProcessPointerEvent() // ------------------------------------------------------------------------------------------------- // -void CVideoPlaybackUserInputHandler::ProcessKeyEventL( const TKeyEvent& /*aKeyEvent*/, - TEventCode /*aType*/ ) +void +CMPXVideoPlaybackUserInputHandler::ProcessPointerEventL( CCoeControl* aControl, + const TPointerEvent& aPointerEvent, + TMPXVideoControlType aControl ) { - MPX_DEBUG(_L("VideoPlaybackUserInputHandler::ProcessKeyEvent")); + MPX_ENTER_EXIT(_L("CMPXVideoPlaybackUserInputHandler::ProcessPointerEvent()"), + _L("iProcessingInputType = %d, aPointerEvent.iType = %d"), + iProcessingInputType, aPointerEvent.iType ); - /* - switch (iProcessingInputType) + switch ( iProcessingInputType ) { - case EVideoNone: + case EMpxVideoNone: { - if (aType == EEventKeyDown && iForeground) + if ( aPointerEvent.iType == TPointerEvent::EButton1Down && IsUserInputAllowed() ) { - iProcessingInputType = EVideoKeyboard; - iLastPressedKeyCode = aKeyEvent.iCode; - iLastPressedKeyScanCode = aKeyEvent.iScanCode; - if ( iTVOutConnected ) - { - RestartDisplayTimer(); - } - iViewWrapper->DoHandleKeyEventL( aKeyEvent, aType ); + iProcessingInputType = EMpxVideoTouch; + + // + // Save the active controls pointer to reroute invalid pointer events + // + iActiveControlPtr = aControl; + iActiveControlType = aMPXControl; + + ReRoutePointerEventL( aControl, aPointerEvent, aMPXControl ); } + break; } - case EVideoKeyboard: + case EMpxVideoTouch: { - if (aType == EEventKeyUp) + if ( aControl == iActiveControlPtr ) { - // only handle up event for the key being handled - // ignore spurious key presses - if (aKeyEvent.iCode == iLastPressedKeyCode && - aKeyEvent.iScanCode == iLastPressedKeyScanCode) + // + // Event is from the active control, process pointer event normally + // + if ( aPointerEvent.iType != TPointerEvent::EButton1Down ) { - iViewWrapper->DoHandleKeyEventL( aKeyEvent, aType ); + ReRoutePointerEventL( aControl, aPointerEvent, aMPXControl ); - // reset the value only on key up event - iProcessingInputType = EVideoNone; + // + // reset the value only on pointer up event - but not on drag + // + if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) + { + iProcessingInputType = EMpxVideoNone; + iActiveControlPtr = NULL; + } } } + else + { + // + // Event is from non active control + // This should not happen, but if event is a button up event, + // end the current active control pointer processing + // + if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) + { + // + // Reroute button up event to active control and end current + // control processing + // + ReRoutePointerEventL( iActiveControlPtr, aPointerEvent, iActiveControlType ); + iProcessingInputType = EMpxVideoNone; + iActiveControlPtr = NULL; + } + } + break; } - default: - { - // user input is disallowed - break; - } - } // switch*/ + } // switch } // ------------------------------------------------------------------------------------------------- +// CMPXVideoPlaybackUserInputHandler::ReRoutePointerEventL() +// ------------------------------------------------------------------------------------------------- +// +void CMPXVideoPlaybackUserInputHandler::ReRoutePointerEventL( CCoeControl* aControl, + const TPointerEvent& aPointerEvent, + TVideoControlType aMPXControl ) +{ + MPX_ENTER_EXIT(_L("CMPXVideoPlaybackUserInputHandler::ReRoutePointerEventL()"), + _L("aMPXControl = %d"), aMPXControl ); + + if ( aMPXControl == EMpxVideoPlaybackContainer ) + { + iContainer->DoHandlePointerEventL( aPointerEvent ); + } + else if ( aMPXControl == EMpxVideoPlaybackControl ) + { + static_cast(aControl)->DoHandlePointerEventL( aPointerEvent ); + } +}*/ + +// ------------------------------------------------------------------------------------------------- // CVideoPlaybackUserInputHandler::ProcessMediaKey() // ------------------------------------------------------------------------------------------------- // void CVideoPlaybackUserInputHandler::ProcessMediaKey( TRemConCoreApiOperationId aOperationId, TRemConCoreApiButtonAction aButtonAct ) { - MPX_DEBUG(_L("CVideoPlaybackUserInputHandler::ProcessMediaKey")); + MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::ProcessMediaKey()"), + _L("iProcessingInputType = %d, aButtonAct = %d"), + iProcessingInputType, aButtonAct ); - switch (iProcessingInputType) + switch ( iProcessingInputType ) { case EVideoNone: { - if (aButtonAct == ERemConCoreApiButtonPress && iForeground) + if ( iForeground && !IsKeyLocked() ) { - iProcessingInputType = EVideoMediaKeys; - iLastMediaKeyPressed = aOperationId; - DoHandleMediaKey(aOperationId, aButtonAct); - if ( iTVOutConnected ) - { - RestartDisplayTimer(); + if ( aButtonAct == ERemConCoreApiButtonPress ) + { + iProcessingInputType = EVideoMediaKeys; + iLastMediaKeyPressed = aOperationId; + DoHandleMediaKey( aOperationId, aButtonAct ); + } + else if ( aButtonAct == ERemConCoreApiButtonClick ) + { + DoHandleMediaKey( aOperationId, aButtonAct ); + + // reset on click AND/OR release + iProcessingInputType = EVideoNone; } } - else if (aButtonAct == ERemConCoreApiButtonClick && iForeground) - { - DoHandleMediaKey(aOperationId, aButtonAct); - if ( iTVOutConnected ) - { - RestartDisplayTimer(); - } - // reset on click AND/OR release - iProcessingInputType = EVideoNone; - } + break; } case EVideoMediaKeys: { - if (aButtonAct == ERemConCoreApiButtonRelease) + if ( aButtonAct == ERemConCoreApiButtonRelease ) { // handle only if this release is for media-key being currently handled // ignore spurious media key presses - if (iLastMediaKeyPressed == aOperationId) + if ( iLastMediaKeyPressed == aOperationId ) { - DoHandleMediaKey(aOperationId, aButtonAct); + DoHandleMediaKey( aOperationId, aButtonAct ); // reset on click AND/OR release iProcessingInputType = EVideoNone; } @@ -465,7 +489,6 @@ } // switch } - // ------------------------------------------------------------------------------------------------- // CVideoPlaybackUserInputHandler::HandleVolumeRepeatTimeoutL() // ------------------------------------------------------------------------------------------------- @@ -497,122 +520,44 @@ iViewWrapper->HandleCommandL( command ); } - // ------------------------------------------------------------------------------------------------- // CVideoPlaybackUserInputHandler::SetForeground() // ------------------------------------------------------------------------------------------------- // void CVideoPlaybackUserInputHandler::SetForeground( TBool aForeground ) { + MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::SetForeground()"), + _L("aForeground = %d"), aForeground ); + iForeground = aForeground; - if ( !iForeground ) + if ( ! iForeground ) { - // we are in background so reset iProcessingInputType value + // + // Keyboard focus has been lost + // Reset input type and clear volume timer if necessary + // iProcessingInputType = EVideoNone; + + if ( iVolumeRepeatTimer->IsActive() ) + { + iVolumeRepeatTimer->Cancel(); + } } } // ------------------------------------------------------------------------------------------------- -// CVideoPlaybackUserInputHandler::DisableBacklight() -// ------------------------------------------------------------------------------------------------- -// -void CVideoPlaybackUserInputHandler::DisableBacklight() -{ - MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::DisableBacklight")); - - // cancel the timer - iDisplayTimer->Cancel(); - - // disable the backlight - HAL::Set( HALData::EBacklightState, 0 ); -} - -// ------------------------------------------------------------------------------------------------- -// CVideoPlaybackUserInputHandler::EnableBacklight() -// ------------------------------------------------------------------------------------------------- -// -void CVideoPlaybackUserInputHandler::EnableBacklight() -{ - MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::EnableBacklight")); - - // enable the backlight - HAL::Set( HALData::EBacklightState, 1 ); -} - - -// ------------------------------------------------------------------------------------------------- -// CVideoPlaybackUserInputHandler::HandleTVOutEvent() +// CVideoPlaybackUserInputHandler::IsKeyLocked // ------------------------------------------------------------------------------------------------- // -void CVideoPlaybackUserInputHandler::HandleTVOutEventL(TBool aTVOutConnected) +TBool CVideoPlaybackUserInputHandler::IsKeyLocked() { - MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::HandleTVOutEvent")); - - iTVOutConnected = aTVOutConnected; - - if ( iTVOutConnected ) - { - // Get the display light time-out value from CenRep - CRepository* repository = CRepository::NewLC( KCRUidLightSettings ); - - // What's the timeout value (in seconds ) for the display light? - repository->Get( KDisplayLightsTimeout, iDisplayTimeOut ); - MPX_DEBUG(_L("CVideoPlaybackUserInputHandler::ConstructL Display Timeout( %d )"), iDisplayTimeOut); - - CleanupStack::PopAndDestroy( repository ); - - // Convert the timeout value to microseconds - iDisplayTimeOut *= KMPXMicroSecondsInASecond; - - RestartDisplayTimer(); - } - else - { - iDisplayTimer->Cancel(); - EnableBacklight(); - } -} + TBool keylock( EFalse ); + RProperty::Get( KPSUidAvkonDomain, KAknKeyguardStatus, keylock ); -// ------------------------------------------------------------------------------------------------- -// CVideoPlaybackUserInputHandler::HandleDisplayTimeout -// ------------------------------------------------------------------------------------------------- -// -TInt CVideoPlaybackUserInputHandler::HandleDisplayTimeout( TAny* aPtr ) -{ - MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::HandleDisplayTimeout")); - - static_cast(aPtr)->DisableBacklight(); - - return KErrNone; -} + MPX_DEBUG(_L("CVideoPlaybackUserInputHandler::IsKeyLocked(%d)"), keylock); -// ----------------------------------------------------------------------------- -// CVideoPlaybackUserInputHandler::RestartDisplayTimer -// ----------------------------------------------------------------------------- -// -void CVideoPlaybackUserInputHandler::RestartDisplayTimer() -{ - MPX_ENTER_EXIT(_L("CVideoPlaybackUserInputHandler::RestartDisplayTimer")); - - // check if the display timer is running if so cancelit - if ( iDisplayTimer->IsActive() ) - { - iDisplayTimer->Cancel(); - } - else - { - // timeout has happened and the backlight is disabled - // enable the backlight - HAL::Set( HALData::EBacklightState, 1 ); - } - - TBool backlightState; - TInt ret = HAL::Get( HALData::EBacklightState, backlightState ); - - // Re start the display backlight timer - iDisplayTimer->Start( iDisplayTimeOut, iDisplayTimeOut, - TCallBack( CVideoPlaybackUserInputHandler::HandleDisplayTimeout, this ) ); + return keylock; } // EOF diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackviewplugin/tsrc/testvideoplaybackviewplugin/inc/testvideoplaybackviewplugin.h --- a/videoplayback/videoplaybackviewplugin/tsrc/testvideoplaybackviewplugin/inc/testvideoplaybackviewplugin.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackviewplugin/tsrc/testvideoplaybackviewplugin/inc/testvideoplaybackviewplugin.h Fri Sep 17 08:30:05 2010 +0300 @@ -22,8 +22,8 @@ // INCLUDES #include + class VideoPlaybackViewPlugin; -class MpxViewPlugin; class TestVideoPlaybackViewPlugin : public QObject @@ -59,7 +59,7 @@ void commandSignal(int); private: - MpxViewPlugin* mVidPBPlugin; + VideoPlaybackViewPlugin* mVidPBPlugin; }; diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackviewplugin/tsrc/testvideoplaybackviewplugin/src/testvideoplaybackviewplugin.cpp --- a/videoplayback/videoplaybackviewplugin/tsrc/testvideoplaybackviewplugin/src/testvideoplaybackviewplugin.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackviewplugin/tsrc/testvideoplaybackviewplugin/src/testvideoplaybackviewplugin.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -17,9 +17,7 @@ #include #include -#include -#include -#include + #include "testvideoplaybackviewplugin.h" @@ -56,13 +54,8 @@ // void TestVideoPlaybackViewPlugin::init() { - QList impls; - XQPluginLoader::listImplementations("org.nokia.mmdt.MpxViewPlugin/1.0", impls); - - XQPluginLoader pluginLoader( MpxHbVideoCommon::KMpxVideoPluginDllPlaybackUid ); - QObject* instance = pluginLoader.instance(); - - mVidPBPlugin = qobject_cast( instance )->viewPlugin(); ; + + mVidPBPlugin = new VideoPlaybackViewPlugin(); } // --------------------------------------------------------------------------- @@ -87,11 +80,11 @@ QVERIFY(mVidPBPlugin != NULL ); - QVERIFY(reinterpret_cast( mVidPBPlugin )->mView == NULL ); + QVERIFY(mVidPBPlugin->mView == NULL ); mVidPBPlugin->createView(); - QVERIFY(reinterpret_cast( mVidPBPlugin )->mView != NULL ); + QVERIFY(mVidPBPlugin->mView != NULL ); } // --------------------------------------------------------------------------- @@ -100,10 +93,10 @@ // void TestVideoPlaybackViewPlugin::testActivateView() { - QVERIFY(reinterpret_cast( mVidPBPlugin )->mView != NU + QVERIFY(mVidPBPlugin->mView != NULL ); mVidPBPlugin->activateView(); - QVERIFY(reinterpret_cast( mVidPBPlugin )->mViewActivated == true ); + QVERIFY(mVidPBPlugin->mViewActivated == true ); } // --------------------------------------------------------------------------- @@ -112,12 +105,12 @@ // void TestVideoPlaybackViewPlugin::testDeactivateView() { - QVERIFY(reinterpret_cast( mVidPBPlugin )->mView != NULL ); - QVERIFY(reinterpret_cast( mVidPBPlugin )->mViewActivated == true ); + QVERIFY(mVidPBPlugin->mView != NULL ); + QVERIFY(mVidPBPlugin->mViewActivated == true ); mVidPBPlugin->deactivateView(); - QVERIFY(reinterpret_cast( mVidPBPlugin )->mViewActivated == false ); + QVERIFY(mVidPBPlugin->mViewActivated == false ); } // --------------------------------------------------------------------------- @@ -126,11 +119,11 @@ // void TestVideoPlaybackViewPlugin::testDestroyView() { - QVERIFY(reinterpret_cast( mVidPBPlugin )->mView != NULL ); + QVERIFY(mVidPBPlugin->mView != NULL ); mVidPBPlugin->destroyView(); - QVERIFY(reinterpret_cast( mVidPBPlugin )->mView == NULL ); + QVERIFY(mVidPBPlugin->mView == NULL ); } // --------------------------------------------------------------------------- @@ -140,8 +133,7 @@ void TestVideoPlaybackViewPlugin::testGetView() { QVERIFY( mVidPBPlugin->getView() != NULL ); - QVERIFY(reinterpret_cast( mVidPBPlugin )->mView == - reinterpret_cast( mVidPBPlugin )->getView() ); + QVERIFY(mVidPBPlugin->mView == mVidPBPlugin->getView() ); } // End of file diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackviewplugin/tsrc/testvideoplaybackviewplugin/stub/src/videoplaybackview.cpp --- a/videoplayback/videoplaybackviewplugin/tsrc/testvideoplaybackviewplugin/stub/src/videoplaybackview.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackviewplugin/tsrc/testvideoplaybackviewplugin/stub/src/videoplaybackview.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,13 +15,13 @@ * */ -// Version : %version: 3 % +// Version : %version: 4 % // Include Files #include -#include "videoplaybackview.h" +#include "../inc/videoplaybackview.h" // Member Functions @@ -55,7 +55,7 @@ // VideoPlaybackView::handleDeactivateView() // ------------------------------------------------------------------------------------------------- // -EXPORT_C void VideoPlaybackView::handleDeactivateView() +void VideoPlaybackView::handleDeactivateView() { } diff -r a76e86df7ccd -r 0e1e938beb1a videoplayback/videoplaybackviewplugin/tsrc/testvideoplaybackviewplugin/testvideoplaybackviewplugin.pro --- a/videoplayback/videoplaybackviewplugin/tsrc/testvideoplaybackviewplugin/testvideoplaybackviewplugin.pro Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayback/videoplaybackviewplugin/tsrc/testvideoplaybackviewplugin/testvideoplaybackviewplugin.pro Fri Sep 17 08:30:05 2010 +0300 @@ -14,29 +14,28 @@ # Description: Project file for building Videoplayer components # # -# Version : %version: 5 % +# Version : %version: 6 % TEMPLATE = app TARGET = -CONFIG += qtestlib hb +CONFIG += qtestlib qt hb -DEPENDPATH += . \ - inc \ - src +INCLUDEPATH += hbstub +INCLUDEPATH += inc stub/inc -INCLUDEPATH += +DEPENDPATH += inc src stub/inc stub/src LIBS += -lestor.dll \ -lmpxviewframeworkqt.dll \ -lxqplugins.dll # Input -HEADERS += inc/testvideoplaybackviewplugin.h \ - stub/inc/videoplaybackview.h \ +HEADERS += testvideoplaybackviewplugin.h \ + videoplaybackview.h \ ../../inc/videoplaybackviewplugin.h \ ../../../../inc/mpxhbvideocommondefs.h -SOURCES += stub/src/videoplaybackview.cpp \ - src/testvideoplaybackviewplugin.cpp \ +SOURCES += testvideoplaybackviewplugin.cpp \ + videoplaybackview.cpp \ ../../src/videoplaybackviewplugin.cpp diff -r a76e86df7ccd -r 0e1e938beb1a videoplayerapp/bwins/videoplayerengineu.def --- a/videoplayerapp/bwins/videoplayerengineu.def Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayerapp/bwins/videoplayerengineu.def Fri Sep 17 08:30:05 2010 +0300 @@ -1,68 +1,67 @@ EXPORTS - ?qt_metacall@VideoPlayerEngine@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 1 NONAME ; int VideoPlayerEngine::qt_metacall(enum QMetaObject::Call, int, void * *) - ?metaObject@VideoPlayerEngine@@UBEPBUQMetaObject@@XZ @ 2 NONAME ; struct QMetaObject const * VideoPlayerEngine::metaObject(void) const - ?instance@VideoActivityState@@SAAAV1@XZ @ 3 NONAME ; class VideoActivityState & VideoActivityState::instance(void) - ?tr@VideoPlayerEngine@@SA?AVQString@@PBD0H@Z @ 4 NONAME ; class QString VideoPlayerEngine::tr(char const *, char const *, int) - ?qt_metacast@VideoServices@@UAEPAXPBD@Z @ 5 NONAME ; void * VideoServices::qt_metacast(char const *) - ?getBrowseCategory@VideoServices@@QBEHXZ @ 6 NONAME ; int VideoServices::getBrowseCategory(void) const - ?setCurrentView@VideoPlayerEngine@@AAEXXZ @ 7 NONAME ; void VideoPlayerEngine::setCurrentView(void) + ?playMedia@VideoPlayerEngine@@QAEXVRFile@@@Z @ 1 NONAME ; void VideoPlayerEngine::playMedia(class RFile) + ?instance@VideoActivityState@@SAAAV1@XZ @ 2 NONAME ; class VideoActivityState & VideoActivityState::instance(void) + ??0VideoPlayerEngine@@QAE@_N@Z @ 3 NONAME ; VideoPlayerEngine::VideoPlayerEngine(bool) + ?qt_metacast@VideoServices@@UAEPAXPBD@Z @ 4 NONAME ; void * VideoServices::qt_metacast(char const *) + ?getBrowseCategory@VideoServices@@QBEHXZ @ 5 NONAME ; int VideoServices::getBrowseCategory(void) const + ?engine@VideoServices@@AAEPAVVideoPlayerEngine@@XZ @ 6 NONAME ; class VideoPlayerEngine * VideoServices::engine(void) + ?loadPluginAndCreateView@VideoPlayerEngine@@AAEXW4MpxHbVideoViewType@MpxHbVideoCommon@@@Z @ 7 NONAME ; void VideoPlayerEngine::loadPluginAndCreateView(enum MpxHbVideoCommon::MpxHbVideoViewType) ?trUtf8@VideoServices@@SA?AVQString@@PBD0@Z @ 8 NONAME ; class QString VideoServices::trUtf8(char const *, char const *) - ?isPlayServiceInvoked@VideoPlayerEngine@@AAE_NXZ @ 9 NONAME ; bool VideoPlayerEngine::isPlayServiceInvoked(void) + ?setEmbedded@VideoPlayerEngine@@QAEXXZ @ 9 NONAME ; void VideoPlayerEngine::setEmbedded(void) ?itemSelected@VideoServices@@QAEXABVQString@@@Z @ 10 NONAME ; void VideoServices::itemSelected(class QString const &) - ?doDelayedLoad@VideoPlayerEngine@@AAEXXZ @ 11 NONAME ; void VideoPlayerEngine::doDelayedLoad(void) - ?handleCommand@VideoPlayerEngine@@QAEXH@Z @ 12 NONAME ; void VideoPlayerEngine::handleCommand(int) - ??1VideoServices@@EAE@XZ @ 13 NONAME ; VideoServices::~VideoServices(void) + ?createMissingViews@VideoPlayerEngine@@AAEXXZ @ 11 NONAME ; void VideoPlayerEngine::createMissingViews(void) + ??1VideoServices@@EAE@XZ @ 12 NONAME ; VideoServices::~VideoServices(void) + ??0VideoServices@@AAE@PAVVideoPlayerEngine@@@Z @ 13 NONAME ; VideoServices::VideoServices(class VideoPlayerEngine *) ?titleReady@VideoServices@@IAEXABVQString@@@Z @ 14 NONAME ; void VideoServices::titleReady(class QString const &) - ?staticMetaObject@VideoPlayerEngine@@2UQMetaObject@@B @ 15 NONAME ; struct QMetaObject const VideoPlayerEngine::staticMetaObject - ?setActivityData@VideoActivityState@@QAEXABVQVariant@@ABVQString@@@Z @ 16 NONAME ; void VideoActivityState::setActivityData(class QVariant const &, class QString const &) - ??0VideoActivityState@@AAE@XZ @ 17 NONAME ; VideoActivityState::VideoActivityState(void) - ?activated@VideoServices@@IAEXH@Z @ 18 NONAME ; void VideoServices::activated(int) + ?setActivityData@VideoActivityState@@QAEXABVQVariant@@ABVQString@@@Z @ 15 NONAME ; void VideoActivityState::setActivityData(class QVariant const &, class QString const &) + ??0VideoActivityState@@AAE@XZ @ 16 NONAME ; VideoActivityState::VideoActivityState(void) + ?activated@VideoServices@@IAEXH@Z @ 17 NONAME ; void VideoServices::activated(int) + ?playMedia@VideoPlayerEngine@@QAEXVQString@@@Z @ 18 NONAME ; void VideoPlayerEngine::playMedia(class QString) ?metaObject@VideoServices@@UBEPBUQMetaObject@@XZ @ 19 NONAME ; struct QMetaObject const * VideoServices::metaObject(void) const - ?disconnectView@VideoPlayerEngine@@AAEXXZ @ 20 NONAME ; void VideoPlayerEngine::disconnectView(void) + ?getStaticMetaObject@VideoPlayerEngine@@SAABUQMetaObject@@XZ @ 20 NONAME ; struct QMetaObject const & VideoPlayerEngine::getStaticMetaObject(void) ??_EVideoActivityState@@UAE@I@Z @ 21 NONAME ; VideoActivityState::~VideoActivityState(unsigned int) - ??_EVideoServices@@UAE@I@Z @ 22 NONAME ; VideoServices::~VideoServices(unsigned int) - ?setEngine@VideoServices@@AAEXPAVVideoPlayerEngine@@@Z @ 23 NONAME ; void VideoServices::setEngine(class VideoPlayerEngine *) - ?browsingEnded@VideoServices@@QAEXXZ @ 24 NONAME ; void VideoServices::browsingEnded(void) - ?playMedia@VideoPlayerEngine@@QAEXVRFile@@@Z @ 25 NONAME ; void VideoPlayerEngine::playMedia(class RFile) - ?getStaticMetaObject@VideoServices@@SAABUQMetaObject@@XZ @ 26 NONAME ; struct QMetaObject const & VideoServices::getStaticMetaObject(void) - ?decreaseReferenceCount@VideoServices@@QAEXXZ @ 27 NONAME ; void VideoServices::decreaseReferenceCount(void) - ?setEmbedded@VideoPlayerEngine@@QAEXXZ @ 28 NONAME ; void VideoPlayerEngine::setEmbedded(void) - ?setCurrentService@VideoServices@@AAEXW4TVideoService@1@@Z @ 29 NONAME ; void VideoServices::setCurrentService(enum VideoServices::TVideoService) - ?trUtf8@VideoPlayerEngine@@SA?AVQString@@PBD0H@Z @ 30 NONAME ; class QString VideoPlayerEngine::trUtf8(char const *, char const *, int) - ??0VideoServices@@AAE@PAVVideoPlayerEngine@@@Z @ 31 NONAME ; VideoServices::VideoServices(class VideoPlayerEngine *) - ?tr@VideoPlayerEngine@@SA?AVQString@@PBD0@Z @ 32 NONAME ; class QString VideoPlayerEngine::tr(char const *, char const *) - ?getStaticMetaObject@VideoPlayerEngine@@SAABUQMetaObject@@XZ @ 33 NONAME ; struct QMetaObject const & VideoPlayerEngine::getStaticMetaObject(void) + ?createPlaybackView@VideoPlayerEngine@@AAEXXZ @ 22 NONAME ; void VideoPlayerEngine::createPlaybackView(void) + ?handleCommand@VideoPlayerEngine@@QAEXH@Z @ 23 NONAME ; void VideoPlayerEngine::handleCommand(int) + ??_EVideoServices@@UAE@I@Z @ 24 NONAME ; VideoServices::~VideoServices(unsigned int) + ?browsingEnded@VideoServices@@QAEXXZ @ 25 NONAME ; void VideoServices::browsingEnded(void) + ?handlePlaybackFailure@VideoPlayerEngine@@AAEXH@Z @ 26 NONAME ; void VideoPlayerEngine::handlePlaybackFailure(int) + ?connectView@VideoPlayerEngine@@AAEXXZ @ 27 NONAME ; void VideoPlayerEngine::connectView(void) + ?getStaticMetaObject@VideoServices@@SAABUQMetaObject@@XZ @ 28 NONAME ; struct QMetaObject const & VideoServices::getStaticMetaObject(void) + ?decreaseReferenceCount@VideoServices@@QAEXXZ @ 29 NONAME ; void VideoServices::decreaseReferenceCount(void) + ?setCurrentService@VideoServices@@AAEXW4TVideoService@1@@Z @ 30 NONAME ; void VideoServices::setCurrentService(enum VideoServices::TVideoService) + ?trUtf8@VideoPlayerEngine@@SA?AVQString@@PBD0@Z @ 31 NONAME ; class QString VideoPlayerEngine::trUtf8(char const *, char const *) + ?setCurrentView@VideoPlayerEngine@@AAEXXZ @ 32 NONAME ; void VideoPlayerEngine::setCurrentView(void) + ?instance@VideoServices@@SAPAV1@PAVVideoPlayerEngine@@@Z @ 33 NONAME ; class VideoServices * VideoServices::instance(class VideoPlayerEngine *) ?trUtf8@VideoServices@@SA?AVQString@@PBD0H@Z @ 34 NONAME ; class QString VideoServices::trUtf8(char const *, char const *, int) - ??1VideoActivityState@@EAE@XZ @ 35 NONAME ; VideoActivityState::~VideoActivityState(void) - ?createMissingViews@VideoPlayerEngine@@AAEXXZ @ 36 NONAME ; void VideoPlayerEngine::createMissingViews(void) - ?handleQuit@VideoPlayerEngine@@AAEXXZ @ 37 NONAME ; void VideoPlayerEngine::handleQuit(void) - ?createPlaybackView@VideoPlayerEngine@@AAEXXZ @ 38 NONAME ; void VideoPlayerEngine::createPlaybackView(void) - ?sortRole@VideoServices@@QBEHXZ @ 39 NONAME ; int VideoServices::sortRole(void) const - ?staticMetaObject@VideoServices@@2UQMetaObject@@B @ 40 NONAME ; struct QMetaObject const VideoServices::staticMetaObject - ??1VideoPlayerEngine@@UAE@XZ @ 41 NONAME ; VideoPlayerEngine::~VideoPlayerEngine(void) - ?loadPluginAndCreateView@VideoPlayerEngine@@AAEXW4MpxHbVideoViewType@MpxHbVideoCommon@@@Z @ 42 NONAME ; void VideoPlayerEngine::loadPluginAndCreateView(enum MpxHbVideoCommon::MpxHbVideoViewType) - ?tr@VideoServices@@SA?AVQString@@PBD0H@Z @ 43 NONAME ; class QString VideoServices::tr(char const *, char const *, int) - ?qt_metacast@VideoPlayerEngine@@UAEPAXPBD@Z @ 44 NONAME ; void * VideoPlayerEngine::qt_metacast(char const *) - ?playMedia@VideoPlayerEngine@@QAEXVQString@@@Z @ 45 NONAME ; void VideoPlayerEngine::playMedia(class QString) - ?activateView@VideoPlayerEngine@@AAEXW4MpxHbVideoViewType@MpxHbVideoCommon@@@Z @ 46 NONAME ; void VideoPlayerEngine::activateView(enum MpxHbVideoCommon::MpxHbVideoViewType) - ??0VideoPlayerEngine@@QAE@_N@Z @ 47 NONAME ; VideoPlayerEngine::VideoPlayerEngine(bool) - ?getActivityData@VideoActivityState@@QAE?BVQVariant@@ABVQString@@@Z @ 48 NONAME ; class QVariant const VideoActivityState::getActivityData(class QString const &) - ?contextTitle@VideoServices@@QBE?AVQString@@XZ @ 49 NONAME ; class QString VideoServices::contextTitle(void) const - ?shouldActivateCollectionView@VideoPlayerEngine@@AAE_NXZ @ 50 NONAME ; bool VideoPlayerEngine::shouldActivateCollectionView(void) - ?initialize@VideoPlayerEngine@@QAEXXZ @ 51 NONAME ; void VideoPlayerEngine::initialize(void) - ?trUtf8@VideoPlayerEngine@@SA?AVQString@@PBD0@Z @ 52 NONAME ; class QString VideoPlayerEngine::trUtf8(char const *, char const *) - ?qt_metacall@VideoServices@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 53 NONAME ; int VideoServices::qt_metacall(enum QMetaObject::Call, int, void * *) - ?currentService@VideoServices@@QAE?AW4TVideoService@1@XZ @ 54 NONAME ; enum VideoServices::TVideoService VideoServices::currentService(void) - ?mInstance@VideoServices@@0PAV1@A @ 55 NONAME ; class VideoServices * VideoServices::mInstance - ?tr@VideoServices@@SA?AVQString@@PBD0@Z @ 56 NONAME ; class QString VideoServices::tr(char const *, char const *) - ?engine@VideoServices@@AAEPAVVideoPlayerEngine@@XZ @ 57 NONAME ; class VideoPlayerEngine * VideoServices::engine(void) - ?connectView@VideoPlayerEngine@@AAEXXZ @ 58 NONAME ; void VideoPlayerEngine::connectView(void) - ?shouldExit@VideoPlayerEngine@@AAE_NXZ @ 59 NONAME ; bool VideoPlayerEngine::shouldExit(void) - ?instance@VideoServices@@SAPAV1@PAVVideoPlayerEngine@@@Z @ 60 NONAME ; class VideoServices * VideoServices::instance(class VideoPlayerEngine *) - ??_EVideoPlayerEngine@@UAE@I@Z @ 61 NONAME ; VideoPlayerEngine::~VideoPlayerEngine(unsigned int) - ?applicationReady@VideoPlayerEngine@@IAEXXZ @ 62 NONAME ; void VideoPlayerEngine::applicationReady(void) - ?viewReadySlot@VideoPlayerEngine@@QAEXXZ @ 63 NONAME ; void VideoPlayerEngine::viewReadySlot(void) - ?handlePlaybackFailure@VideoPlayerEngine@@AAEXH@Z @ 64 NONAME ; void VideoPlayerEngine::handlePlaybackFailure(int) - ?playURI@VideoPlayerEngine@@QAEXVQString@@@Z @ 65 NONAME ; void VideoPlayerEngine::playURI(class QString) - ?serviceQuit@VideoPlayerEngine@@AAEXXZ @ 66 NONAME ; void VideoPlayerEngine::serviceQuit(void) + ?tr@VideoPlayerEngine@@SA?AVQString@@PBD0H@Z @ 35 NONAME ; class QString VideoPlayerEngine::tr(char const *, char const *, int) + ??1VideoActivityState@@EAE@XZ @ 36 NONAME ; VideoActivityState::~VideoActivityState(void) + ?staticMetaObject@VideoPlayerEngine@@2UQMetaObject@@B @ 37 NONAME ; struct QMetaObject const VideoPlayerEngine::staticMetaObject + ?doDelayedLoad@VideoPlayerEngine@@AAEXXZ @ 38 NONAME ; void VideoPlayerEngine::doDelayedLoad(void) + ?initialize@VideoPlayerEngine@@QAEXXZ @ 39 NONAME ; void VideoPlayerEngine::initialize(void) + ?qt_metacall@VideoPlayerEngine@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 40 NONAME ; int VideoPlayerEngine::qt_metacall(enum QMetaObject::Call, int, void * *) + ?sortRole@VideoServices@@QBEHXZ @ 41 NONAME ; int VideoServices::sortRole(void) const + ?qt_metacast@VideoPlayerEngine@@UAEPAXPBD@Z @ 42 NONAME ; void * VideoPlayerEngine::qt_metacast(char const *) + ?shouldExit@VideoPlayerEngine@@AAE_NXZ @ 43 NONAME ; bool VideoPlayerEngine::shouldExit(void) + ?staticMetaObject@VideoServices@@2UQMetaObject@@B @ 44 NONAME ; struct QMetaObject const VideoServices::staticMetaObject + ?isPlayServiceInvoked@VideoPlayerEngine@@AAE_NXZ @ 45 NONAME ; bool VideoPlayerEngine::isPlayServiceInvoked(void) + ?applicationReady@VideoPlayerEngine@@IAEXXZ @ 46 NONAME ; void VideoPlayerEngine::applicationReady(void) + ?metaObject@VideoPlayerEngine@@UBEPBUQMetaObject@@XZ @ 47 NONAME ; struct QMetaObject const * VideoPlayerEngine::metaObject(void) const + ?tr@VideoServices@@SA?AVQString@@PBD0H@Z @ 48 NONAME ; class QString VideoServices::tr(char const *, char const *, int) + ??_EVideoPlayerEngine@@UAE@I@Z @ 49 NONAME ; VideoPlayerEngine::~VideoPlayerEngine(unsigned int) + ?activateView@VideoPlayerEngine@@AAEXW4MpxHbVideoViewType@MpxHbVideoCommon@@@Z @ 50 NONAME ; void VideoPlayerEngine::activateView(enum MpxHbVideoCommon::MpxHbVideoViewType) + ?contextTitle@VideoServices@@QBE?AVQString@@XZ @ 51 NONAME ; class QString VideoServices::contextTitle(void) const + ?getActivityData@VideoActivityState@@QAE?BVQVariant@@ABVQString@@@Z @ 52 NONAME ; class QVariant const VideoActivityState::getActivityData(class QString const &) + ?tr@VideoPlayerEngine@@SA?AVQString@@PBD0@Z @ 53 NONAME ; class QString VideoPlayerEngine::tr(char const *, char const *) + ?disconnectView@VideoPlayerEngine@@AAEXXZ @ 54 NONAME ; void VideoPlayerEngine::disconnectView(void) + ?qt_metacall@VideoServices@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 55 NONAME ; int VideoServices::qt_metacall(enum QMetaObject::Call, int, void * *) + ?currentService@VideoServices@@QAE?AW4TVideoService@1@XZ @ 56 NONAME ; enum VideoServices::TVideoService VideoServices::currentService(void) + ?trUtf8@VideoPlayerEngine@@SA?AVQString@@PBD0H@Z @ 57 NONAME ; class QString VideoPlayerEngine::trUtf8(char const *, char const *, int) + ?playURI@VideoPlayerEngine@@QAEXVQString@@@Z @ 58 NONAME ; void VideoPlayerEngine::playURI(class QString) + ?handleQuit@VideoPlayerEngine@@AAEXXZ @ 59 NONAME ; void VideoPlayerEngine::handleQuit(void) + ?mInstance@VideoServices@@0PAV1@A @ 60 NONAME ; class VideoServices * VideoServices::mInstance + ?tr@VideoServices@@SA?AVQString@@PBD0@Z @ 61 NONAME ; class QString VideoServices::tr(char const *, char const *) + ?setEngine@VideoServices@@AAEXPAVVideoPlayerEngine@@@Z @ 62 NONAME ; void VideoServices::setEngine(class VideoPlayerEngine *) + ??1VideoPlayerEngine@@UAE@XZ @ 63 NONAME ; VideoPlayerEngine::~VideoPlayerEngine(void) + ?shouldActivateCollectionView@VideoPlayerEngine@@AAE_NXZ @ 64 NONAME ; bool VideoPlayerEngine::shouldActivateCollectionView(void) + ?serviceQuit@VideoPlayerEngine@@AAEXXZ @ 65 NONAME ; void VideoPlayerEngine::serviceQuit(void) diff -r a76e86df7ccd -r 0e1e938beb1a videoplayerapp/eabi/videoplayerengineu.def --- a/videoplayerapp/eabi/videoplayerengineu.def Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayerapp/eabi/videoplayerengineu.def Fri Sep 17 08:30:05 2010 +0300 @@ -31,42 +31,41 @@ _ZN17VideoPlayerEngine13handleCommandEi @ 30 NONAME _ZN17VideoPlayerEngine14disconnectViewEv @ 31 NONAME _ZN17VideoPlayerEngine14setCurrentViewEv @ 32 NONAME - _ZN17VideoPlayerEngine16staticMetaObjectE @ 33 NONAME DATA 16 - _ZN17VideoPlayerEngine18createMissingViewsEv @ 34 NONAME - _ZN17VideoPlayerEngine18createPlaybackViewEv @ 35 NONAME - _ZN17VideoPlayerEngine19getStaticMetaObjectEv @ 36 NONAME - _ZN17VideoPlayerEngine20isPlayServiceInvokedEv @ 37 NONAME - _ZN17VideoPlayerEngine23loadPluginAndCreateViewEN16MpxHbVideoCommon18MpxHbVideoViewTypeE @ 38 NONAME - _ZN17VideoPlayerEngine28shouldActivateCollectionViewEv @ 39 NONAME - _ZN17VideoPlayerEngine9playMediaE5RFile @ 40 NONAME - _ZN17VideoPlayerEngine9playMediaE7QString @ 41 NONAME - _ZN17VideoPlayerEngineC1Eb @ 42 NONAME - _ZN17VideoPlayerEngineC2Eb @ 43 NONAME - _ZN17VideoPlayerEngineD0Ev @ 44 NONAME - _ZN17VideoPlayerEngineD1Ev @ 45 NONAME - _ZN17VideoPlayerEngineD2Ev @ 46 NONAME - _ZN18VideoActivityState15getActivityDataERK7QString @ 47 NONAME - _ZN18VideoActivityState15setActivityDataERK8QVariantRK7QString @ 48 NONAME - _ZN18VideoActivityState8instanceEv @ 49 NONAME - _ZN18VideoActivityStateC1Ev @ 50 NONAME - _ZN18VideoActivityStateC2Ev @ 51 NONAME - _ZN18VideoActivityStateD0Ev @ 52 NONAME - _ZN18VideoActivityStateD1Ev @ 53 NONAME - _ZN18VideoActivityStateD2Ev @ 54 NONAME - _ZNK13VideoServices10metaObjectEv @ 55 NONAME - _ZNK13VideoServices12contextTitleEv @ 56 NONAME - _ZNK13VideoServices17getBrowseCategoryEv @ 57 NONAME - _ZNK13VideoServices8sortRoleEv @ 58 NONAME - _ZNK17VideoPlayerEngine10metaObjectEv @ 59 NONAME - _ZTI13VideoServices @ 60 NONAME - _ZTI17VideoPlayerEngine @ 61 NONAME - _ZTI18VideoActivityState @ 62 NONAME - _ZTV13VideoServices @ 63 NONAME - _ZTV17VideoPlayerEngine @ 64 NONAME - _ZTV18VideoActivityState @ 65 NONAME - _ZN17VideoPlayerEngine13viewReadySlotEv @ 66 NONAME - _ZN17VideoPlayerEngine16applicationReadyEv @ 67 NONAME - _ZN17VideoPlayerEngine21handlePlaybackFailureEi @ 68 NONAME - _ZN17VideoPlayerEngine7playURIE7QString @ 69 NONAME - _ZN17VideoPlayerEngine11serviceQuitEv @ 70 NONAME + _ZN17VideoPlayerEngine16applicationReadyEv @ 33 NONAME + _ZN17VideoPlayerEngine16staticMetaObjectE @ 34 NONAME DATA 16 + _ZN17VideoPlayerEngine18createMissingViewsEv @ 35 NONAME + _ZN17VideoPlayerEngine18createPlaybackViewEv @ 36 NONAME + _ZN17VideoPlayerEngine19getStaticMetaObjectEv @ 37 NONAME + _ZN17VideoPlayerEngine20isPlayServiceInvokedEv @ 38 NONAME + _ZN17VideoPlayerEngine21handlePlaybackFailureEi @ 39 NONAME + _ZN17VideoPlayerEngine23loadPluginAndCreateViewEN16MpxHbVideoCommon18MpxHbVideoViewTypeE @ 40 NONAME + _ZN17VideoPlayerEngine28shouldActivateCollectionViewEv @ 41 NONAME + _ZN17VideoPlayerEngine7playURIE7QString @ 42 NONAME + _ZN17VideoPlayerEngine9playMediaE5RFile @ 43 NONAME + _ZN17VideoPlayerEngine9playMediaE7QString @ 44 NONAME + _ZN17VideoPlayerEngineC1Eb @ 45 NONAME + _ZN17VideoPlayerEngineC2Eb @ 46 NONAME + _ZN17VideoPlayerEngineD0Ev @ 47 NONAME + _ZN17VideoPlayerEngineD1Ev @ 48 NONAME + _ZN17VideoPlayerEngineD2Ev @ 49 NONAME + _ZN18VideoActivityState15getActivityDataERK7QString @ 50 NONAME + _ZN18VideoActivityState15setActivityDataERK8QVariantRK7QString @ 51 NONAME + _ZN18VideoActivityState8instanceEv @ 52 NONAME + _ZN18VideoActivityStateC1Ev @ 53 NONAME + _ZN18VideoActivityStateC2Ev @ 54 NONAME + _ZN18VideoActivityStateD0Ev @ 55 NONAME + _ZN18VideoActivityStateD1Ev @ 56 NONAME + _ZN18VideoActivityStateD2Ev @ 57 NONAME + _ZNK13VideoServices10metaObjectEv @ 58 NONAME + _ZNK13VideoServices12contextTitleEv @ 59 NONAME + _ZNK13VideoServices17getBrowseCategoryEv @ 60 NONAME + _ZNK13VideoServices8sortRoleEv @ 61 NONAME + _ZNK17VideoPlayerEngine10metaObjectEv @ 62 NONAME + _ZTI13VideoServices @ 63 NONAME + _ZTI17VideoPlayerEngine @ 64 NONAME + _ZTI18VideoActivityState @ 65 NONAME + _ZTV13VideoServices @ 66 NONAME + _ZTV17VideoPlayerEngine @ 67 NONAME + _ZTV18VideoActivityState @ 68 NONAME + _ZN17VideoPlayerEngine11serviceQuitEv @ 69 NONAME diff -r a76e86df7ccd -r 0e1e938beb1a videoplayerapp/inc/videoplayerengine.h --- a/videoplayerapp/inc/videoplayerengine.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayerapp/inc/videoplayerengine.h Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: 20 % +// Version : %version: ou1cpsw#22 % #ifndef VIDEOPLAYERENGINE_H #define VIDEOPLAYERENGINE_H @@ -33,6 +33,7 @@ class MpxViewPlugin; class VideoServices; class VideoPlaybackWrapper; +class AfActivityStorage; /** * VideoPlayerEngine @@ -64,7 +65,6 @@ public slots: void handleCommand( int commandCode ); - void viewReadySlot(); private slots: void handleQuit(); @@ -111,6 +111,8 @@ VideoPlaybackWrapper *mPlaybackWrapper; VideoServices* mVideoServices; + + AfActivityStorage* mActivityStorage; }; diff -r a76e86df7ccd -r 0e1e938beb1a videoplayerapp/videoplayer/inc/videoplayerapp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoplayerapp/videoplayer/inc/videoplayerapp.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of VideoPlayerApp +* +*/ + +// Version : %version: 1 % + +#ifndef VIDEOPLAYERAPP_H +#define VIDEOPLAYERAPP_H + +#include + +/** + * VideoPlayerApp + * + */ +class VideoPlayerApp : public HbApplication +{ + Q_OBJECT + + public: + /** + * Constructor + */ + VideoPlayerApp(int &argc, + char *argv[], + Hb::ApplicationFlags flags = Hb::DefaultApplicationFlags); + + /** + * Destructor. + */ + ~VideoPlayerApp(); + + signals: + + /** + * Emitted when application view has been drawn. + */ + void applicationReady(); + + public slots: + + /** + * Should be connected to HbMainWindow's viewReady signal, so that + * applicationReady signal is emitted at correct time. + */ + void viewReadySlot(); +}; + +#endif // VIDEOPLAYERAPP_H + +// EOF diff -r a76e86df7ccd -r 0e1e938beb1a videoplayerapp/videoplayer/sis/create_videoplayer_urel_sisx.bat --- a/videoplayerapp/videoplayer/sis/create_videoplayer_urel_sisx.bat Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayerapp/videoplayer/sis/create_videoplayer_urel_sisx.bat Fri Sep 17 08:30:05 2010 +0300 @@ -17,5 +17,5 @@ REM Make qt videoplayer urel sisx file (contains hb -libraries) call makesis videoplayer_urel.pkg videoplayer_urel.sis -call signsis videoplayer_urel.sis videoplayer_urel.sisx Nokia_RnDCert_02.der Nokia_RnDCert_02.key +call signsis videoplayer_urel.sis videoplayer_urel.sisx \Nokia_RnDCert_02.der \Nokia_RnDCert_02.key call del videoplayer_urel.sis diff -r a76e86df7ccd -r 0e1e938beb1a videoplayerapp/videoplayer/sis/videoplayer_stub.pkg --- a/videoplayerapp/videoplayer/sis/videoplayer_stub.pkg Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayerapp/videoplayer/sis/videoplayer_stub.pkg Fri Sep 17 08:30:05 2010 +0300 @@ -18,7 +18,7 @@ &EN ; SIS header: name, uid, version -# {"videoplayer"}, (0x200211FE), 1, 0, 0, TYPE=SA +# {"videoplayer"}, (0x200211FE), 10,10,1, TYPE=SA ; Localised Vendor name %{"Nokia, Qt Software"} diff -r a76e86df7ccd -r 0e1e938beb1a videoplayerapp/videoplayer/src/main.cpp --- a/videoplayerapp/videoplayer/src/main.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayerapp/videoplayer/src/main.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,22 +15,26 @@ * */ -// Version : %version: 10 % +// Version : %version: 11.1.3 % #include #include #include #include -#include #include #include "videoplayerengine.h" -#include "videoactivitystate.h" +#include "videoplayerapp.h" int main(int argc, char *argv[]) { - HbApplication app( argc, argv, Hb::SplashFixedVertical ); + // + // has the application been launched via XQ Service Framework + // + bool isAservice(XQServiceUtil::isService(argc, argv)); + + VideoPlayerApp app( argc, argv, isAservice ? Hb::NoSplash : Hb::SplashFixedVertical ); // // automatically loads & installs corresponding translation file @@ -38,26 +42,15 @@ HbTranslator translator("videos"); translator.loadCommon(); - // - // has the application been launched via XQ Service Framework - // - bool isService = XQServiceUtil::isService(); - - if ( ! isService ) + if ( !isAservice ) { app.setApplicationName( hbTrId("txt_videos_title_videos") ); - - HbActivityManager *actManager = app.activityManager(); - // save activity data locally - VideoActivityState::instance().setActivityData( actManager->activityData( ACTIVITY_VIDEOPLAYER_MAINVIEW ) ); - // remove from activitymanager - actManager->removeActivity( ACTIVITY_VIDEOPLAYER_MAINVIEW ); } HbMainWindow mainWindow( 0, Hb::WindowFlagTransparent ); + QObject::connect(&mainWindow, SIGNAL(viewReady()), &app, SLOT(viewReadySlot())); - VideoPlayerEngine *engine = new VideoPlayerEngine( isService ); - QObject::connect(&mainWindow, SIGNAL(viewReady()), engine, SLOT(viewReadySlot())); + VideoPlayerEngine *engine = new VideoPlayerEngine( isAservice ); engine->initialize(); mainWindow.show(); return app.exec(); diff -r a76e86df7ccd -r 0e1e938beb1a videoplayerapp/videoplayer/src/videoplayerapp.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoplayerapp/videoplayer/src/videoplayerapp.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of VideoPlayerEngine +* +*/ + +// Version : %version: 1 % + + +#include +#include "videoplayerapp.h" +#include "mpxvideo_debug.h" + +// ------------------------------------------------------------------------------------------------- +// VideoPlayerApp() +// ------------------------------------------------------------------------------------------------- +// +VideoPlayerApp::VideoPlayerApp(int &argc, char *argv[], Hb::ApplicationFlags flags) + : HbApplication(argc, argv, flags) +{ + MPX_DEBUG(_L("VideoPlayerApp::VideoPlayerApp()")); +} + +// ------------------------------------------------------------------------------------------------- +// ~VideoPlayerApp() +// ------------------------------------------------------------------------------------------------- +// +VideoPlayerApp::~VideoPlayerApp() +{ + MPX_DEBUG(_L("VideoPlayerApp::~VideoPlayerApp()")); +} + +// ------------------------------------------------------------------------------------------------- +// viewReadySlot() +// ------------------------------------------------------------------------------------------------- +// +void VideoPlayerApp::viewReadySlot() +{ + MPX_ENTER_EXIT(_L("VideoPlayerApp::viewReadySlot()")); + + // applicationReady signal should be emitted only once, so disconnect the viewReady signal. + disconnect(hbInstance->allMainWindows().value(0), SIGNAL(viewReady()), + this, SLOT(viewReadySlot())); + + emit applicationReady(); +} + +// End of file diff -r a76e86df7ccd -r 0e1e938beb1a videoplayerapp/videoplayer/videoplayer.pro --- a/videoplayerapp/videoplayer/videoplayer.pro Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayerapp/videoplayer/videoplayer.pro Fri Sep 17 08:30:05 2010 +0300 @@ -14,7 +14,7 @@ # Description: Project file for building Videoplayer components # # -# Version : %version: 3 % +# Version : %version: 5 % TEMPLATE = app @@ -27,7 +27,7 @@ TARGET.CAPABILITY = ALL -DRM -TCB TARGET.EPOCHEAPSIZE = 0x20000 0x1600000 TARGET.UID3 = 0x200211FE - SKINICON = qtg_large_video_tv + SKINICON = qtg_large_video BLD_INF_RULES.prj_exports += "rom/videoplayer.iby CORE_APP_LAYER_IBY_EXPORT_PATH(videoplayer.iby)" \ "rom/videoplayerresources.iby LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(videoplayerresources.iby)" \ @@ -55,7 +55,10 @@ VPATH += src -SOURCES += main.cpp +HEADERS += inc/videoplayerapp.h + +SOURCES += src/main.cpp \ + src/videoplayerapp.cpp RSS_RULES += \ " datatype_list = " \ diff -r a76e86df7ccd -r 0e1e938beb1a videoplayerapp/videoplayerengine/src/videoplayerengine.cpp --- a/videoplayerapp/videoplayerengine/src/videoplayerengine.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayerapp/videoplayerengine/src/videoplayerengine.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: da1mmcf#43 % +// Version : %version: 47 % #include @@ -26,8 +26,8 @@ #include #include #include -#include #include +#include #include "videoplayerengine.h" #include "videoactivitystate.h" @@ -50,6 +50,7 @@ , mFileDetailsViewPlugin( 0 ) , mPlaybackWrapper( 0 ) , mVideoServices( 0 ) + , mActivityStorage( 0 ) { MPX_DEBUG(_L("VideoPlayerEngine::VideoPlayerEngine()")); } @@ -91,6 +92,8 @@ delete mPlaybackWrapper; + delete mActivityStorage; + // disconnect all signals disconnect(); } @@ -151,6 +154,16 @@ } else { + if(!mActivityStorage) + { + mActivityStorage = new AfActivityStorage(); + } + + VideoActivityState::instance().setActivityData(mActivityStorage->activityData(ACTIVITY_VIDEOPLAYER_MAINVIEW)); + + // after reading, remove activity to prevent multiple instances in taskswitcher + mActivityStorage->removeActivity(ACTIVITY_VIDEOPLAYER_MAINVIEW); + // // check latest plugin type from activity manager data and create + activate it // CollectionView (default) and playbackview are the ones that are accepted @@ -233,20 +246,6 @@ } // ------------------------------------------------------------------------------------------------- -// viewReadySlot() -// ------------------------------------------------------------------------------------------------- -// -void VideoPlayerEngine::viewReadySlot() -{ - MPX_ENTER_EXIT(_L("VideoPlayerEngine::viewReady()")); - emit applicationReady(); - // since we need to emit applicationReady only once at startup, - // disconnect the viewReady -signal from this object - disconnect(hbInstance->allMainWindows().value(0), SIGNAL(viewReady()), - this, SLOT(viewReadySlot())); -} - -// ------------------------------------------------------------------------------------------------- // doDelayedLoad() // ------------------------------------------------------------------------------------------------- // @@ -488,18 +487,26 @@ { MPX_ENTER_EXIT(_L("VideoPlayerEngine::handleQuit()")); - if ( ! mIsService ) + if ( ! mIsService && mActivityStorage) { VideoActivityState &localActivity(VideoActivityState::instance()); + + // screenshot required for activity to save correctly + // need to take it before deactivation to actually show something + QVariantHash metadata; + HbMainWindow *window = hbInstance->allMainWindows().first(); + metadata.insert("screenshot", QPixmap::grabWidget(window, window->rect())); - QVariant data = QVariant(); - HbActivityManager *actManager = qobject_cast(qApp)->activityManager(); + QVariant data = QVariant(); // // deactivate is the final point for current plugin to save it's activity data into // VideoActivityState before they are saved to to activity manager // - mCurrentViewPlugin->deactivateView(); + if ( mCurrentViewPlugin ) + { + mCurrentViewPlugin->deactivateView(); + } // // get and save recent view type: either playback or collection view plugins are currently used. @@ -523,11 +530,12 @@ data = viewType; localActivity.setActivityData( data, KEY_VIEWPLUGIN_TYPE ); - - // save data to activity manager - actManager->addActivity( ACTIVITY_VIDEOPLAYER_MAINVIEW, - localActivity.getActivityData(), - QVariantHash() ); + + // save data to activity manager, if it fails there's nothing to do + mActivityStorage->saveActivity( ACTIVITY_VIDEOPLAYER_MAINVIEW, + localActivity.getActivityData(), + metadata ); + } delete this; @@ -633,7 +641,11 @@ bool result = false; - if ( mIsService ) + if ( mIsPlayService ) + { + result = true; + } + else if ( mIsService ) { QString intface = XQServiceUtil::interfaceName(); MPX_DEBUG(_L("VideoPlayerEngine::isPlayServiceInvoked() : interfaceName(%s)"), intface.data() ); diff -r a76e86df7ccd -r 0e1e938beb1a videoplayerapp/videoplayerengine/tsrc/testvideoappuiengine/testvideoappuiengine.pro --- a/videoplayerapp/videoplayerengine/tsrc/testvideoappuiengine/testvideoappuiengine.pro Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayerapp/videoplayerengine/tsrc/testvideoappuiengine/testvideoappuiengine.pro Fri Sep 17 08:30:05 2010 +0300 @@ -14,13 +14,18 @@ # Description: Project file for building Videoplayer components # # -# Version : %version: 3 % +# Version : %version: 4 % TEMPLATE = app TARGET = testvideoappuiengine DEFINES += BUILD_VIDEOPLAYERAPP_DLL +symbian: +{ + MMP_RULES += "USERINCLUDE stub/inc" +} + INCLUDEPATH += stub/inc \ ../../../../inc \ $$MW_LAYER_SYSTEMINCLUDE diff -r a76e86df7ccd -r 0e1e938beb1a videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/inc/testvideoplayerengine.h --- a/videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/inc/testvideoplayerengine.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/inc/testvideoplayerengine.h Fri Sep 17 08:30:05 2010 +0300 @@ -23,7 +23,7 @@ // - how to setup construction to fail for testing purposes -// Version : %version: da1mmcf#9 % +// Version : %version: da1mmcf#10 % #ifndef __TESTVIDEOPLAYERENGINE_H__ #define __TESTVIDEOPLAYERENGINE_H__ @@ -83,7 +83,7 @@ void testSetEmbedded(); void testInitWithActivityData(); - void testHandleQuitWihtActivityData(); + void testHandleQuitWithActivityData(); // called after last test case executed void cleanupTestCase(); diff -r a76e86df7ccd -r 0e1e938beb1a videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/src/testvideoplayerengine.cpp --- a/videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/src/testvideoplayerengine.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/src/testvideoplayerengine.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: da1mmcf#15 % +// Version : %version: 18 % // INCLUDES #include @@ -31,6 +31,7 @@ #include #include +#include "afactivitystorage.h" #include "mpxhbvideocommondefs.h" #include "testvideoplayerengine.h" #include "stub/inc/mpxviewpluginqt.h" @@ -225,6 +226,9 @@ QVERIFY( mTestObject->mIsService == true ); QVERIFY( VideoServices::mReferenceCount == 0 ); + AfActivityStorage::mLastHandledActivity = ""; + AfActivityStorage::mActivityCount = 0; + mTestObject->initialize(); QVERIFY( mTestObject->mCurrentViewPlugin == 0 ); @@ -235,8 +239,10 @@ QVERIFY( mTestObject->mVideoServices != 0 ); QVERIFY( mTestObject->mIsService == true ); QVERIFY( VideoServices::mReferenceCount == 1 ); - QVERIFY( mTestObject->mCollectionViewPlugin != mTestObject->mPlaybackViewPlugin ); + // during service initialization, we do not remove possible exiting activation state + QVERIFY( AfActivityStorage::mActivityCount == 0 ); + QVERIFY( AfActivityStorage::mLastHandledActivity.isEmpty() ); cleanup(); @@ -267,7 +273,7 @@ QVERIFY( mTestObject->mVideoServices == 0 ); QVERIFY( mTestObject->mIsService == false ); QVERIFY( VideoServices::mReferenceCount == 0 ); - +/* mCurrentViewPlugin = mTestObject->mCurrentViewPlugin; mPlaybackViewPlugin = mTestObject->mPlaybackViewPlugin; mCollectionViewPlugin = mTestObject->mCollectionViewPlugin; @@ -280,7 +286,7 @@ QVERIFY( mCollectionViewPlugin == mTestObject->mCollectionViewPlugin ); QVERIFY( mFileDetailsViewPlugin == mTestObject->mFileDetailsViewPlugin ); QVERIFY( VideoServices::mReferenceCount == 0 ); - +*/ cleanup(); QVERIFY( VideoServices::mReferenceCount == 0 ); @@ -882,6 +888,8 @@ init(); QVERIFY( !mTestObject.isNull() ); + AfActivityStorage::mLastHandledActivity = ""; + AfActivityStorage::mActivityCount = 0; mTestObject->initialize(); @@ -894,14 +902,20 @@ QVERIFY( mTestObject->mPlaybackWrapper ); QVERIFY( mTestObject->mCurrentViewPlugin->activated() ); QVERIFY( mTestObject->mCollectionViewPlugin->activated() ); + QVERIFY( AfActivityStorage::mActivityCount == -1 ); + QVERIFY( AfActivityStorage::mLastHandledActivity == ACTIVITY_VIDEOPLAYER_MAINVIEW ); cleanup(); init(); QVERIFY( !mTestObject.isNull() ); + QHash activityHash; + // playback plugin + AfActivityStorage::mLastHandledActivity = ""; + AfActivityStorage::mActivityCount = 0; QVariant data = int( MpxHbVideoCommon::PlaybackView ); - // playback plugin - VideoActivityState::instance().setActivityData( data, KEY_VIEWPLUGIN_TYPE ); + activityHash[KEY_VIEWPLUGIN_TYPE] = data; + AfActivityStorage::mDataToReturn = activityHash; mTestObject->initialize(); QVERIFY( mTestObject ); QVERIFY( mTestObject->mCurrentViewPlugin ); @@ -911,6 +925,8 @@ QVERIFY( mTestObject->mPlaybackWrapper ); QVERIFY( mTestObject->mCurrentViewPlugin->activated() ); QVERIFY( mTestObject->mPlaybackViewPlugin->activated() ); + QVERIFY( AfActivityStorage::mActivityCount == -1 ); + QVERIFY( AfActivityStorage::mLastHandledActivity == ACTIVITY_VIDEOPLAYER_MAINVIEW ); cleanup(); init(); @@ -918,8 +934,11 @@ // only collection view and playback view are accepted, so all other cases // ends up into default: collectionview + AfActivityStorage::mLastHandledActivity = ""; + AfActivityStorage::mActivityCount = 0; data = int( MpxHbVideoCommon::VideoDetailsView ); - VideoActivityState::instance().setActivityData( data, KEY_VIEWPLUGIN_TYPE ); + activityHash[KEY_VIEWPLUGIN_TYPE] = data; + AfActivityStorage::mDataToReturn = activityHash; mTestObject->initialize(); QVERIFY( mTestObject ); QVERIFY( mTestObject->mCurrentViewPlugin ); @@ -929,43 +948,66 @@ QVERIFY( mTestObject->mPlaybackWrapper ); QVERIFY( mTestObject->mCurrentViewPlugin->activated() ); QVERIFY( mTestObject->mCollectionViewPlugin->activated() ); + QVERIFY( AfActivityStorage::mActivityCount == -1 ); + QVERIFY( AfActivityStorage::mLastHandledActivity == ACTIVITY_VIDEOPLAYER_MAINVIEW ); cleanup(); } -void TestVideoPlayerEngine::testHandleQuitWihtActivityData() +void TestVideoPlayerEngine::testHandleQuitWithActivityData() { MPX_ENTER_EXIT(_L("TestVideoPlayerEngine::testHandleQuitWihtActivityData()")); // we make sure that engine saves correct plugin type before exit // using VideoActivityState since value is saved there before actually // being save to activitymanager + QHash activityHash; + QVariant data = int( MpxHbVideoCommon::CollectionView ); + activityHash[KEY_VIEWPLUGIN_TYPE] = data; + AfActivityStorage::mDataToReturn = activityHash; + init(); - init(); + AfActivityStorage::mLastHandledActivity = ""; + AfActivityStorage::mActivityCount = 0; QVERIFY( !mTestObject.isNull() ); connect( this, SIGNAL(aboutToQuit()), mTestObject, SLOT(handleQuit()) ); mTestObject->initialize(); VideoActivityState::mAllDataGetCount = 0; - + QVERIFY( AfActivityStorage::mActivityCount == -1 ); + QVERIFY( AfActivityStorage::mLastHandledActivity == ACTIVITY_VIDEOPLAYER_MAINVIEW ); + AfActivityStorage::mLastHandledActivity = ""; emit aboutToQuit(); - - QVariant data = QVariant(); + + data = QVariant(); data = VideoActivityState::instance().getActivityData( KEY_VIEWPLUGIN_TYPE ); QVERIFY( data.isValid() ); QVERIFY( data.toInt() == MpxHbVideoCommon::CollectionView ); QVERIFY( VideoActivityState::mAllDataGetCount == 1 ); + QVERIFY( AfActivityStorage::mActivityCount == 0 ); + QVERIFY( AfActivityStorage::mLastHandledActivity == ACTIVITY_VIDEOPLAYER_MAINVIEW ); cleanup(); init(); QVERIFY( ! mTestObject.isNull() ); connect( this, SIGNAL(aboutToQuit()), mTestObject, SLOT(handleQuit()) ); + data = int(MpxHbVideoCommon::PlaybackView); - VideoActivityState::instance().setActivityData( data, KEY_VIEWPLUGIN_TYPE ); + activityHash[KEY_VIEWPLUGIN_TYPE] = data; + data.clear(); + data = bool( true ); + activityHash[KEY_LAST_LOCAL_PLAYBACK] = data; + AfActivityStorage::mDataToReturn = activityHash; + AfActivityStorage::mLastHandledActivity = ""; + AfActivityStorage::mActivityCount = 0; + mTestObject->initialize(); VideoActivityState::mAllDataGetCount = 0; + QVERIFY( AfActivityStorage::mActivityCount == -1 ); + QVERIFY( AfActivityStorage::mLastHandledActivity == ACTIVITY_VIDEOPLAYER_MAINVIEW ); + AfActivityStorage::mLastHandledActivity = ""; emit aboutToQuit(); @@ -974,16 +1016,26 @@ QVERIFY( data.isValid() ); QVERIFY( data.toInt() == MpxHbVideoCommon::PlaybackView ); QVERIFY( VideoActivityState::mAllDataGetCount == 1 ); + QVERIFY( AfActivityStorage::mActivityCount == 0 ); + QVERIFY( AfActivityStorage::mLastHandledActivity == ACTIVITY_VIDEOPLAYER_MAINVIEW ); cleanup(); init(); QVERIFY( ! mTestObject.isNull() ); connect( this, SIGNAL(aboutToQuit()), mTestObject, SLOT(handleQuit()) ); - + activityHash.clear(); + data.clear(); data = int( MpxHbVideoCommon::VideoDetailsView ); - VideoActivityState::instance().setActivityData( data, KEY_VIEWPLUGIN_TYPE ); + activityHash[KEY_VIEWPLUGIN_TYPE] = data; + AfActivityStorage::mDataToReturn = activityHash; + AfActivityStorage::mLastHandledActivity = ""; + AfActivityStorage::mActivityCount = 0; + mTestObject->initialize(); VideoActivityState::mAllDataGetCount = 0; + QVERIFY( AfActivityStorage::mActivityCount == -1 ); + QVERIFY( AfActivityStorage::mLastHandledActivity == ACTIVITY_VIDEOPLAYER_MAINVIEW ); + AfActivityStorage::mLastHandledActivity = ""; emit aboutToQuit(); @@ -992,6 +1044,8 @@ QVERIFY( data.isValid() ); QVERIFY( data.toInt() == MpxHbVideoCommon::CollectionView ); QVERIFY( VideoActivityState::mAllDataGetCount == 1 ); + QVERIFY( AfActivityStorage::mActivityCount == 0 ); + QVERIFY( AfActivityStorage::mLastHandledActivity == ACTIVITY_VIDEOPLAYER_MAINVIEW ); cleanup(); } diff -r a76e86df7ccd -r 0e1e938beb1a videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/stub/inc/afactivitystorage.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/stub/inc/afactivitystorage.h Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: stub AfActivityStorage +* +*/ + +// Version : %version: 2 % + +#ifndef AFACTIVITYSTORAGE_H +#define AFACTIVITYSTORAGE_H + + +#include +#include +#include + +class AfActivityStorage +{ + +public: + AfActivityStorage(); + virtual ~AfActivityStorage(); + + bool saveActivity(const QString &activityId, const QVariant &activityData, const QVariantHash &metadata); + + QVariant activityData(const QString &activityId) const; + + bool removeActivity (const QString &activityId); + + static QVariant mDataToReturn; + + static int mActivityCount; + + static QString mLastHandledActivity; + +}; + +#endif // AFACTIVITYSTORAGE_H + diff -r a76e86df7ccd -r 0e1e938beb1a videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/stub/inc/hbinstance.h --- a/videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/stub/inc/hbinstance.h Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/stub/inc/hbinstance.h Fri Sep 17 08:30:05 2010 +0300 @@ -15,12 +15,13 @@ * */ -// Version : %version: % +// Version : %version: da1mmcf#8 % #ifndef _HBINSTANCE_H #define _HBINSTANCE_H #include +#include // Get stubs included before they are searched from /epoc32/include/mw #include "stub/inc/mpxviewpluginqt.h" @@ -37,9 +38,7 @@ public: static HbInstance *instance(); - HbInstance* primaryWindow() const; - - QList allMainWindows() const; + QList allMainWindows() const; void removeView( QGraphicsWidget* y ); @@ -50,6 +49,9 @@ private: HbInstance(); ~HbInstance(); + +public: + QList mWindows; }; #endif // STUBHBINSTANCE_H diff -r a76e86df7ccd -r 0e1e938beb1a videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/stub/src/afactivitystorage.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/stub/src/afactivitystorage.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: stub AfActivityStorage +* +*/ + +// Version : %version: 2 % + +#include "afactivitystorage.h" + +QVariant AfActivityStorage::mDataToReturn = QVariant(); + +int AfActivityStorage::mActivityCount = 0; + +QString AfActivityStorage::mLastHandledActivity = QString(); + +AfActivityStorage::AfActivityStorage() +{ +} + +AfActivityStorage::~AfActivityStorage() +{ +} + +bool AfActivityStorage::saveActivity(const QString &activityId, const QVariant &activityData, const QVariantHash &metadata) +{ + Q_UNUSED(activityData); + Q_UNUSED(metadata); + mLastHandledActivity = activityId; + mActivityCount++; +} + +QVariant AfActivityStorage::activityData(const QString &activityId) const +{ + Q_UNUSED(activityId); + return mDataToReturn; +} + +bool AfActivityStorage::removeActivity(const QString &activityId) +{ + mLastHandledActivity = activityId; + mActivityCount--; + return true; +} + + diff -r a76e86df7ccd -r 0e1e938beb1a videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/stub/src/hbinstance.cpp --- a/videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/stub/src/hbinstance.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/stub/src/hbinstance.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,16 +15,15 @@ * */ -// Version : %version: da1mmcf#7 % +// Version : %version: da1mmcf#8 % -#include #include "stub/inc/hbinstance.h" #include "mpxvideo_debug.h" bool initialised = false; HbInstance* mInstance = 0; -QList mInstances; +QList mWindows; // ------------------------------------------------------------------------------------------------- // HbInstance::HbInstance() @@ -33,6 +32,9 @@ HbInstance::HbInstance() { MPX_DEBUG(_L("HbInstance::HbInstance()")); + + HbMainWindow* window = new HbMainWindow(); + mWindows.append(window); } // ------------------------------------------------------------------------------------------------- @@ -54,32 +56,21 @@ if ( ! initialised ) { - mInstance = new HbInstance(); - initialised = true; - mInstances.append(mInstance); + mInstance = new HbInstance(); } return mInstance; } // ------------------------------------------------------------------------------------------------- -// HbInstance::primaryWindow() -// ------------------------------------------------------------------------------------------------- -// -HbInstance* HbInstance::primaryWindow() const -{ - MPX_DEBUG(_L("HbInstance::primaryWindow()")); - return mInstance; -} - -// ------------------------------------------------------------------------------------------------- // HbInstance::allMainWindows() // ------------------------------------------------------------------------------------------------- // -QList HbInstance::allMainWindows() const +QList HbInstance::allMainWindows() const { MPX_DEBUG(_L("HbInstance::allMainWindows()")); - return mInstances; + + return mWindows; } // ------------------------------------------------------------------------------------------------- diff -r a76e86df7ccd -r 0e1e938beb1a videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/stub/src/videoplaybackwrapper.cpp --- a/videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/stub/src/videoplaybackwrapper.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/stub/src/videoplaybackwrapper.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: da1mmcf#10 % +// Version : %version: da1mmcf#11 % #include "videoplaybackwrapper.h" @@ -75,7 +75,10 @@ { MPX_ENTER_EXIT(_L("VideoPlaybackWrapper::replayMedia")); - Q_UNUSED( aFileName ); + Q_UNUSED( aFileName ); + + emit handlePlaybackView( MpxHbVideoCommon::ActivatePlaybackView ); + return 0; } diff -r a76e86df7ccd -r 0e1e938beb1a videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/stub/src/xqpluginloader.cpp --- a/videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/stub/src/xqpluginloader.cpp Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/stub/src/xqpluginloader.cpp Fri Sep 17 08:30:05 2010 +0300 @@ -15,7 +15,7 @@ * */ -// Version : %version: % +// Version : %version: da1mmcf#6 % #include "stub/inc/xqpluginloader.h" #include "stub/inc/xqplugininfo.h" @@ -75,10 +75,7 @@ return 0; } - if ( ! mPluginList.contains( mUid ) ) - { - mPluginList[mUid] = new TestViewPlugin(); - } + mPluginList[mUid] = new TestViewPlugin(); return mPluginList[mUid]; } diff -r a76e86df7ccd -r 0e1e938beb1a videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/testvideoplayerengine.pro --- a/videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/testvideoplayerengine.pro Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayerapp/videoplayerengine/tsrc/testvideoplayerengine/testvideoplayerengine.pro Fri Sep 17 08:30:05 2010 +0300 @@ -14,13 +14,19 @@ # Description: Project file for building Videoplayer components # # -# Version : %version: da1mmcf#14 % +# Version : %version: 16 % TEMPLATE = app TARGET = testvideoplayerengine DEFINES += BUILD_VIDEOPLAYERAPP_DLL +symbian: +{ + MMP_RULES += "USERINCLUDE stub/inc" +} + + DEPENDPATH += inc src stub/src stub/inc INCLUDEPATH +=stub/inc \ @@ -46,6 +52,7 @@ videoserviceview.h \ hbview.h \ videoactivitystate.h \ + afactivitystorage.h \ ../../../../inc/videoplayerengine.h SOURCES += videoplaybackwrapper.cpp \ @@ -59,4 +66,5 @@ videoserviceplay.cpp \ videoserviceview.cpp \ videoactivitystate.cpp \ + afactivitystorage.cpp \ ../../src/videoplayerengine.cpp diff -r a76e86df7ccd -r 0e1e938beb1a videoplayerapp/videoplayerengine/videoplayerengine.pro --- a/videoplayerapp/videoplayerengine/videoplayerengine.pro Thu Sep 02 20:28:16 2010 +0300 +++ b/videoplayerapp/videoplayerengine/videoplayerengine.pro Fri Sep 17 08:30:05 2010 +0300 @@ -14,7 +14,7 @@ # Description: Project file for building Videoplayer components # # -# Version : %version: da1mmcf#31 % +# Version : %version: 32 % TEMPLATE = lib @@ -56,7 +56,8 @@ -lxqserviceutil.dll \ -lflogger.dll \ -lefsrv \ - -lcommonengine.dll + -lcommonengine.dll \ + -lafservice.dll DEPENDPATH += ../../inc ../inc inc VPATH += src