993 if(!mCurrentList) |
1015 if(!mCurrentList) |
994 { |
1016 { |
995 return; |
1017 return; |
996 } |
1018 } |
997 |
1019 |
998 VideoSortFilterProxyModel &model = mCurrentList->getModel(); |
|
999 |
|
1000 bool ok = false; |
|
1001 // query a name for the collection |
1020 // query a name for the collection |
1002 QString label(hbTrId("txt_videos_title_enter_name")); |
1021 QString label(hbTrId("txt_videos_title_enter_name")); |
1003 QString text(hbTrId("txt_videos_dialog_entry_new_collection")); |
1022 QString text(hbTrId("txt_videos_dialog_entry_new_collection")); |
1004 text = HbInputDialog::getText(label, text, &ok); |
1023 |
1005 if (ok && text.length()) |
1024 HbInputDialog *dialog = new HbInputDialog(); |
1006 { |
1025 dialog->setAttribute(Qt::WA_DeleteOnClose); |
|
1026 dialog->getText(label, this, SLOT(createCollectionDialogFinished(HbAction *)), text); |
|
1027 } |
|
1028 |
|
1029 // ------------------------------------------------------------------------------------------------- |
|
1030 // createCollectionDialogFinished |
|
1031 // ------------------------------------------------------------------------------------------------- |
|
1032 // |
|
1033 void VideoListView::createCollectionDialogFinished(HbAction *action) |
|
1034 { |
|
1035 FUNC_LOG; |
|
1036 Q_UNUSED(action); |
|
1037 |
|
1038 HbInputDialog *dialog = static_cast<HbInputDialog*>(sender()); |
|
1039 |
|
1040 QVariant variant = dialog->value(); |
|
1041 |
|
1042 if(dialog->actions().first() == action && variant.isValid()) |
|
1043 { |
|
1044 VideoSortFilterProxyModel &model = mCurrentList->getModel(); |
|
1045 |
1007 // resolve collection true name and add new album |
1046 // resolve collection true name and add new album |
1008 text = model.resolveAlbumName(text); |
1047 QString text = model.resolveAlbumName(variant.toString()); |
1009 |
1048 |
1010 // when collection reports about new collection, we open it right away, |
1049 if(text.length()) |
1011 // for that, connect to rowsInserted so that the new album can be opened |
1050 { |
1012 if(!connect(&model, SIGNAL(rowsInserted(const QModelIndex&, int, int)), |
1051 // when collection reports about new collection, we open it right away, |
1013 this, SLOT(openNewAlbumSlot(const QModelIndex&, int, int)))) |
1052 // for that, connect to rowsInserted so that the new album can be opened |
1014 { |
1053 if(!connect(&model, SIGNAL(rowsInserted(const QModelIndex&, int, int)), |
1015 return; |
1054 this, SLOT(openNewAlbumSlot(const QModelIndex&, int, int)))) |
1016 } |
1055 { |
1017 |
1056 return; |
1018 model.addNewAlbum(text); |
1057 } |
|
1058 |
|
1059 model.addNewAlbum(text); |
|
1060 } |
1019 } |
1061 } |
1020 } |
1062 } |
1021 |
1063 |
1022 // ------------------------------------------------------------------------------------------------- |
1064 // ------------------------------------------------------------------------------------------------- |
1023 // addVideosToCollectionSlot |
1065 // addVideosToCollectionSlot |
1268 void VideoListView::collectionOpenedSlot(bool collectionOpened, |
1310 void VideoListView::collectionOpenedSlot(bool collectionOpened, |
1269 const QString& collection, |
1311 const QString& collection, |
1270 const QModelIndex &index) |
1312 const QModelIndex &index) |
1271 { |
1313 { |
1272 FUNC_LOG; |
1314 FUNC_LOG; |
1273 if(mTransitionOngoing) |
1315 |
1274 { |
1316 // clear toolbar actions. |
1275 return; |
1317 toolBar()->clearActions(); |
1276 } |
1318 |
1277 else |
1319 VideoListWidget *collectionContentWidget = |
1278 { |
1320 mUiLoader->findWidget<VideoListWidget>( |
1279 // clear toolbar actions. |
1321 DOCML_NAME_VC_COLLECTIONCONTENTWIDGET); |
1280 toolBar()->clearActions(); |
1322 |
1281 } |
1323 if(!collectionContentWidget) |
1282 |
1324 { |
|
1325 return; |
|
1326 } |
|
1327 // update collection specific information |
|
1328 mCollectionName = collection; |
|
1329 |
|
1330 // disable collection content animations during widget change |
|
1331 HbAbstractItemView::ItemAnimations animationState = collectionContentWidget->enabledAnimations(); |
|
1332 collectionContentWidget->setEnabledAnimations(HbAbstractItemView::None); |
|
1333 |
1283 if(collectionOpened) |
1334 if(collectionOpened) |
1284 { |
1335 { |
1285 if(!index.isValid()) |
1336 // open album view |
1286 { |
1337 if (!index.isValid() || !mCurrentList || mCurrentList == collectionContentWidget) |
|
1338 { |
|
1339 // no currentlist or currentlist is already collection content -list |
|
1340 collectionContentWidget->setEnabledAnimations(animationState); |
1287 return; |
1341 return; |
1288 } |
1342 } |
1289 |
1343 |
1290 // open album view |
1344 // get item id before deactivating |
1291 VideoListWidget *collectionContentWidget = |
1345 TMPXItemId itemId = mCurrentList->getModel().getMediaIdAtIndex(index); |
1292 mUiLoader->findWidget<VideoListWidget>( |
|
1293 DOCML_NAME_VC_COLLECTIONCONTENTWIDGET); |
|
1294 |
1346 |
1295 if (!mCurrentList || mCurrentList == collectionContentWidget) |
1347 // get level from the item to be opened only default |
1296 { |
1348 // or user defined collections can be activated here |
1297 // no currentlist or currentlist is already list |
1349 VideoCollectionCommon::TCollectionLevels level = VideoCollectionCommon::ELevelInvalid; |
1298 // we're about to transit |
1350 if(itemId.iId2 == KVcxMvcMediaTypeCategory) |
|
1351 { |
|
1352 level = VideoCollectionCommon::ELevelDefaultColl; |
|
1353 } |
|
1354 else if(itemId.iId2 == KVcxMvcMediaTypeAlbum) |
|
1355 { |
|
1356 level = VideoCollectionCommon::ELevelAlbum; |
|
1357 } |
|
1358 else |
|
1359 { |
|
1360 collectionContentWidget->setEnabledAnimations(animationState); |
1299 return; |
1361 return; |
1300 } |
1362 } |
1301 |
|
1302 // get item id before deactivating |
|
1303 TMPXItemId itemId = TMPXItemId::InvalidId(); |
|
1304 itemId = mCurrentList->getModel().getMediaIdAtIndex(index); |
|
1305 |
1363 |
1306 // only category or album can be activated here |
1364 // Start fetching content before changing. |
1307 if(itemId == TMPXItemId::InvalidId() || |
|
1308 (itemId.iId2 != KVcxMvcMediaTypeCategory && |
|
1309 itemId.iId2 != KVcxMvcMediaTypeAlbum)) |
|
1310 { |
|
1311 return; |
|
1312 } |
|
1313 |
|
1314 // Send level that is opened with the effect. |
|
1315 QVariant nextLevel; |
|
1316 if(itemId.iId2 == KVcxMvcMediaTypeCategory) |
|
1317 { |
|
1318 nextLevel = QVariant(VideoCollectionCommon::ELevelDefaultColl); |
|
1319 } |
|
1320 else if(itemId.iId2 == KVcxMvcMediaTypeAlbum) |
|
1321 { |
|
1322 nextLevel = QVariant(VideoCollectionCommon::ELevelAlbum); |
|
1323 } |
|
1324 |
|
1325 // Start fetching content. |
|
1326 collectionContentWidget->getModel().openItem(itemId); |
1365 collectionContentWidget->getModel().openItem(itemId); |
1327 |
1366 |
1328 HbEffect::start(collectionContentWidget, |
1367 // deactivat current widget. |
1329 EFFECT_SLIDE_IN_TO_LEFT, |
1368 mCurrentList->deactivate(); |
1330 this, |
|
1331 "finishCollectionOpenedSlot", |
|
1332 nextLevel); |
|
1333 |
1369 |
1334 mTransitionOngoing = true; |
1370 // activate video collection content widget and set it as current list. |
|
1371 mCurrentList = collectionContentWidget; |
|
1372 mCurrentList->activate(level); |
|
1373 |
|
1374 updateSubLabel(); |
|
1375 |
|
1376 // setup correct sorting, collection content contains always a list of videos so we use |
|
1377 // ELevelVideos as target for sorting |
|
1378 VideoCollectionViewUtils::sortModel(&mCurrentList->getModel(), false, VideoCollectionCommon::ELevelVideos); |
|
1379 mCurrentList->getModel().invalidate(); |
|
1380 |
|
1381 // update hint widget for correct content |
|
1382 setHintLevel(VideoHintWidget::Collection); |
|
1383 showHint(); |
|
1384 |
|
1385 // update toolbar for albums, default categories don't have one. |
|
1386 if(level == VideoCollectionCommon::ELevelAlbum && |
|
1387 mToolbarCollectionActionGroup && mToolbarActions.contains(ETBActionCollections)) |
|
1388 { |
|
1389 mToolbarActions[ETBActionCollections]->setChecked(false); |
|
1390 toolBar()->addActions(mToolbarCollectionActionGroup->actions()); |
|
1391 } |
1335 } |
1392 } |
1336 else |
1393 else |
1337 { |
1394 { |
1338 // open categories view. |
1395 // open collection view |
1339 VideoListWidget *collectionContentWidget = |
1396 openCollectionViewSlot(); |
1340 mUiLoader->findWidget<VideoListWidget>( |
|
1341 DOCML_NAME_VC_COLLECTIONCONTENTWIDGET); |
|
1342 |
1397 |
1343 HbEffect::start(collectionContentWidget, |
1398 // update toolbar |
1344 EFFECT_SLIDE_OUT_TO_LEFT, |
1399 if(mToolbarViewsActionGroup && mToolbarActions.contains(ETBActionCollections)) |
1345 this, |
1400 { |
1346 "finishCollectionClosedSlot"); |
1401 toolBar()->addActions(mToolbarViewsActionGroup->actions()); |
1347 |
1402 mToolbarActions[ETBActionCollections]->setChecked(true); |
1348 mTransitionOngoing = true; |
1403 } |
1349 } |
1404 } |
1350 // update collection specific information |
1405 // restore animations for collection content widget |
1351 mCollectionName = collection; |
1406 collectionContentWidget->setEnabledAnimations(animationState); |
1352 } |
1407 |
1353 |
|
1354 // ------------------------------------------------------------------------------------------------- |
|
1355 // finishCollectionOpenedSlot |
|
1356 // ------------------------------------------------------------------------------------------------- |
|
1357 // |
|
1358 void VideoListView::finishCollectionOpenedSlot(const HbEffect::EffectStatus &status) |
|
1359 { |
|
1360 FUNC_LOG; |
|
1361 Q_UNUSED(status); |
|
1362 |
|
1363 mTransitionOngoing = false; |
|
1364 |
|
1365 // deactivat current widget. |
|
1366 mCurrentList->deactivate(); |
|
1367 |
|
1368 // activate video collection content widget. |
|
1369 mCurrentList = mUiLoader->findWidget<VideoListWidget>( |
|
1370 DOCML_NAME_VC_COLLECTIONCONTENTWIDGET); |
|
1371 |
|
1372 if(!mCurrentList || !status.userData.isValid()) |
|
1373 { |
|
1374 return; |
|
1375 } |
|
1376 |
|
1377 updateSubLabel(); |
|
1378 |
|
1379 VideoCollectionCommon::TCollectionLevels level = |
|
1380 static_cast<VideoCollectionCommon::TCollectionLevels>(status.userData.toInt()); |
|
1381 mCurrentList->activate(level); |
|
1382 |
|
1383 VideoCollectionViewUtils::sortModel(&mCurrentList->getModel(), false, VideoCollectionCommon::ELevelVideos); |
|
1384 mCurrentList->getModel().invalidate(); |
|
1385 |
|
1386 // update hint widget |
|
1387 setHintLevel(VideoHintWidget::Collection); |
|
1388 showHint(); |
|
1389 |
|
1390 // update toolbar for albums, default categories don't have one. |
|
1391 if(level == VideoCollectionCommon::ELevelAlbum && |
|
1392 mToolbarCollectionActionGroup && mToolbarActions.contains(ETBActionCollections)) |
|
1393 { |
|
1394 mToolbarActions[ETBActionCollections]->setChecked(false); |
|
1395 toolBar()->addActions(mToolbarCollectionActionGroup->actions()); |
|
1396 } |
|
1397 } |
|
1398 |
|
1399 // ------------------------------------------------------------------------------------------------- |
|
1400 // finishCollectionClosedSlot |
|
1401 // ------------------------------------------------------------------------------------------------- |
|
1402 // |
|
1403 void VideoListView::finishCollectionClosedSlot(const HbEffect::EffectStatus &status) |
|
1404 { |
|
1405 FUNC_LOG; |
|
1406 Q_UNUSED(status); |
|
1407 |
|
1408 mTransitionOngoing = false; |
|
1409 |
|
1410 // open collection view |
|
1411 openCollectionViewSlot(); |
|
1412 |
|
1413 // update toolbar |
|
1414 if(mToolbarViewsActionGroup && mToolbarActions.contains(ETBActionCollections)) |
|
1415 { |
|
1416 toolBar()->addActions(mToolbarViewsActionGroup->actions()); |
|
1417 mToolbarActions[ETBActionCollections]->setChecked(true); |
|
1418 } |
|
1419 } |
1408 } |
1420 |
1409 |
1421 // ------------------------------------------------------------------------------------------------- |
1410 // ------------------------------------------------------------------------------------------------- |
1422 // objectReadySlot |
1411 // objectReadySlot |
1423 // ------------------------------------------------------------------------------------------------- |
1412 // ------------------------------------------------------------------------------------------------- |