94 disconnect(); |
93 disconnect(); |
95 delete mContextMenu; |
94 delete mContextMenu; |
96 mContextMenu = 0; |
95 mContextMenu = 0; |
97 delete mNavKeyAction; |
96 delete mNavKeyAction; |
98 mNavKeyAction = 0; |
97 mNavKeyAction = 0; |
|
98 |
|
99 if(mVideoServices) |
|
100 { |
|
101 mVideoServices->decreaseReferenceCount(); |
|
102 mVideoServices = 0; |
|
103 } |
99 } |
104 } |
100 |
105 |
101 // --------------------------------------------------------------------------- |
106 // --------------------------------------------------------------------------- |
102 // initialize |
107 // initialize |
103 // --------------------------------------------------------------------------- |
108 // --------------------------------------------------------------------------- |
104 // |
109 // |
105 int VideoListWidget::initialize(VideoSortFilterProxyModel &model, |
110 int VideoListWidget::initialize(VideoSortFilterProxyModel &model, |
106 VideoServices* videoServices, |
111 bool isService, |
107 VideoCollectionCommon::TCollectionLevels level) |
112 VideoCollectionCommon::TCollectionLevels level) |
108 { |
113 { |
109 FUNC_LOG_ADDR(this); |
114 FUNC_LOG_ADDR(this); |
110 mModel = &model; |
115 mModel = &model; |
111 mVideoServices = videoServices; |
|
112 mCurrentLevel = level; |
116 mCurrentLevel = level; |
113 |
117 |
114 if(mVideoServices) |
118 if(isService) |
115 { |
119 { |
116 mIsService = true; |
120 if(!mVideoServices) |
117 |
121 { |
|
122 mVideoServices = VideoServices::instance(); |
|
123 } |
118 if(XQServiceUtil::interfaceName().contains("IVideoFetch")) |
124 if(XQServiceUtil::interfaceName().contains("IVideoFetch")) |
119 { |
125 { |
120 mService = VideoServices::EUriFetcher; |
126 mService = VideoServices::EUriFetcher; |
121 } |
127 } |
122 else if (XQServiceUtil::interfaceName().contains("IVideoBrowse")) |
128 else if (XQServiceUtil::interfaceName().contains("IVideoBrowse")) |
123 { |
129 { |
124 mService = VideoServices::EBrowse; |
130 mService = VideoServices::EBrowse; |
125 } |
131 } |
126 } |
132 } |
|
133 else |
|
134 { |
|
135 if(mVideoServices) |
|
136 { |
|
137 mVideoServices->decreaseReferenceCount(); |
|
138 mVideoServices = 0; |
|
139 } |
|
140 } |
127 |
141 |
128 // init list view |
142 // init list view |
129 VideoCollectionViewUtils::initListView(this); |
143 VideoCollectionViewUtils::initListView(this); |
130 |
144 |
131 mScrollPositionTimer = new QTimer(); |
145 mScrollPositionTimer = new QTimer(); |
132 mScrollPositionTimer->setSingleShot(true); |
146 mScrollPositionTimer->setSingleShot(true); |
133 |
147 |
134 if (mIsService) |
148 if (mVideoServices) |
135 { |
149 { |
136 connect(this, SIGNAL(fileUri(const QString&)), mVideoServices, SLOT(itemSelected(const QString&))); |
150 connect(this, SIGNAL(fileUri(const QString&)), mVideoServices, SLOT(itemSelected(const QString&))); |
137 } |
151 } |
138 |
152 |
139 setModel(mModel); |
153 setModel(mModel); |
228 // |
242 // |
229 int VideoListWidget::connectSignals() |
243 int VideoListWidget::connectSignals() |
230 { |
244 { |
231 FUNC_LOG_ADDR(this); |
245 FUNC_LOG_ADDR(this); |
232 |
246 |
233 int retval(0); |
247 if (mSignalsConnected) |
234 |
248 { |
235 if (!mSignalsConnected) |
249 return 0; |
236 { |
250 } |
237 if(!connect(this, SIGNAL(scrollingStarted()), this, SLOT(scrollingStartedSlot())) || |
251 |
238 !connect(this, SIGNAL(scrollingEnded()), this, SLOT(scrollingEndedSlot())) || |
252 if(!connect(this, SIGNAL(scrollingStarted()), this, SLOT(scrollingStartedSlot())) || |
239 !connect(this, SIGNAL(scrollPositionChanged(const QPointF &)), |
253 !connect(this, SIGNAL(scrollingEnded()), this, SLOT(scrollingEndedSlot())) || |
240 this, SLOT(scrollPositionChangedSlot(const QPointF &))) || |
254 !connect(this, SIGNAL(scrollPositionChanged(const QPointF &)), |
241 !connect(mScrollPositionTimer, SIGNAL(timeout()), this, SLOT(scrollPositionTimerSlot())) || |
255 this, SLOT(scrollPositionChangedSlot(const QPointF &))) || |
242 !connect(this, SIGNAL(longPressed(HbAbstractViewItem *, const QPointF &)), |
256 !connect(mScrollPositionTimer, SIGNAL(timeout()), this, SLOT(scrollPositionTimerSlot())) || |
243 this, SLOT(longPressedSlot(HbAbstractViewItem *, const QPointF &)))) |
257 !connect(this, SIGNAL(longPressed(HbAbstractViewItem *, const QPointF &)), |
244 { |
258 this, SLOT(longPressedSlot(HbAbstractViewItem *, const QPointF &)))) |
245 return -1; |
259 { |
246 } |
260 return -1; |
247 |
261 } |
248 if (!isBrowsingService()) |
262 |
249 { |
263 // handle navi key trigger -signal connection |
250 if(VideoCollectionCommon::EModelTypeCollectionContent == mModel->getType()) |
264 const char *slot = SLOT(quit()); |
251 { |
265 QObject *receiver = qApp; |
252 if (!connect(mNavKeyAction, SIGNAL(triggered()), this, SLOT(back()))) |
266 |
253 { |
267 if(mVideoServices && mService == VideoServices::EBrowse) |
254 retval = -1; |
268 { |
255 } |
269 receiver = mVideoServices; |
256 } |
270 slot = SLOT(browsingEnded()); |
257 else |
271 } |
258 { |
272 else |
259 if (!connect(mNavKeyAction, SIGNAL(triggered()), qApp, SLOT(quit()))) |
273 { |
260 { |
274 if(mCurrentLevel == VideoCollectionCommon::ELevelAlbum || |
261 retval = -1; |
275 mCurrentLevel == VideoCollectionCommon::ELevelDefaultColl) |
262 } |
276 { |
263 } |
277 receiver = this; |
264 } |
278 slot = SLOT(back()); |
265 |
279 } |
266 mSignalsConnected = true; |
280 else if(mVideoServices && mService == VideoServices::EUriFetcher) |
267 } |
281 { |
268 return retval; |
282 receiver = this; |
|
283 slot = SLOT(endVideoFecthingSlot()); |
|
284 } |
|
285 } |
|
286 if(!connect(mNavKeyAction, SIGNAL(triggered()), receiver, slot)) |
|
287 { |
|
288 return -1; |
|
289 } |
|
290 mSignalsConnected = true; |
|
291 |
|
292 return 0; |
269 } |
293 } |
270 |
294 |
271 // --------------------------------------------------------------------------- |
295 // --------------------------------------------------------------------------- |
272 // disConnectSignals |
296 // disConnectSignals |
273 // --------------------------------------------------------------------------- |
297 // --------------------------------------------------------------------------- |
294 { |
318 { |
295 disconnect( |
319 disconnect( |
296 mScrollPositionTimer, SIGNAL(timeout()), |
320 mScrollPositionTimer, SIGNAL(timeout()), |
297 this, SLOT(scrollPositionTimerSlot())); |
321 this, SLOT(scrollPositionTimerSlot())); |
298 } |
322 } |
299 |
323 if(mNavKeyAction) |
300 // check that model and navigation action exists |
324 { |
301 if (!isBrowsingService()) |
325 mNavKeyAction->disconnect(SIGNAL(triggered())); |
302 { |
|
303 if (mModel && |
|
304 mModel->getType() == VideoCollectionCommon::EModelTypeCollectionContent) |
|
305 { |
|
306 if (mNavKeyAction) |
|
307 { |
|
308 disconnect( |
|
309 mNavKeyAction, SIGNAL(triggered()), |
|
310 this, SLOT(back())); |
|
311 } |
|
312 } |
|
313 else |
|
314 { |
|
315 if (mNavKeyAction) |
|
316 { |
|
317 disconnect( |
|
318 mNavKeyAction, SIGNAL(triggered()), |
|
319 qApp, SLOT(quit())); |
|
320 } |
|
321 } |
|
322 } |
326 } |
323 |
327 |
324 mSignalsConnected = false; |
328 mSignalsConnected = false; |
325 } |
|
326 |
|
327 // --------------------------------------------------------------------------- |
|
328 // isBrowsingService |
|
329 // --------------------------------------------------------------------------- |
|
330 // |
|
331 bool VideoListWidget::isBrowsingService() const |
|
332 { |
|
333 FUNC_LOG_ADDR(this); |
|
334 |
|
335 bool isBrowsingService = false; |
|
336 |
|
337 if (mIsService && |
|
338 mVideoServices && |
|
339 mService == VideoServices::EBrowse) |
|
340 { |
|
341 isBrowsingService = true; |
|
342 } |
|
343 |
|
344 return isBrowsingService; |
|
345 } |
329 } |
346 |
330 |
347 // --------------------------------------------------------------------------- |
331 // --------------------------------------------------------------------------- |
348 // setNavigationAction |
332 // setNavigationAction |
349 // --------------------------------------------------------------------------- |
333 // --------------------------------------------------------------------------- |
353 FUNC_LOG_ADDR(this); |
337 FUNC_LOG_ADDR(this); |
354 |
338 |
355 // Create navigation action if not already created |
339 // Create navigation action if not already created |
356 if (!mNavKeyAction) |
340 if (!mNavKeyAction) |
357 { |
341 { |
358 if (isBrowsingService()) |
342 Hb::NavigationAction navAction = Hb::QuitNaviAction; |
359 { |
343 QString objectName = LIST_WIDGET_OBJECT_NAME_NAV_KEY_QUIT; |
360 mNavKeyAction = new HbAction(Hb::QuitNaviAction); |
344 if(mCurrentLevel == VideoCollectionCommon::ELevelAlbum || |
361 mNavKeyAction->setObjectName(LIST_WIDGET_OBJECT_NAME_NAV_KEY_QUIT); |
345 mCurrentLevel == VideoCollectionCommon::ELevelDefaultColl) |
362 connect(mNavKeyAction, SIGNAL(triggered()), |
346 { |
363 mVideoServices, SLOT(browsingEnded())); |
347 navAction = Hb::BackNaviAction; |
364 } |
348 objectName = LIST_WIDGET_OBJECT_NAME_NAV_KEY_BACK; |
365 else if (mModel) |
349 } |
366 { |
350 mNavKeyAction = new HbAction(navAction); |
367 if (VideoCollectionCommon::EModelTypeCollectionContent == mModel->getType()) |
351 mNavKeyAction->setObjectName(LIST_WIDGET_OBJECT_NAME_NAV_KEY_BACK); |
368 { |
|
369 mNavKeyAction = new HbAction(Hb::BackNaviAction); |
|
370 mNavKeyAction->setObjectName(LIST_WIDGET_OBJECT_NAME_NAV_KEY_BACK); |
|
371 } |
|
372 else |
|
373 { |
|
374 mNavKeyAction = new HbAction(Hb::QuitNaviAction); |
|
375 mNavKeyAction->setObjectName(LIST_WIDGET_OBJECT_NAME_NAV_KEY_QUIT); |
|
376 } |
|
377 } |
|
378 } |
352 } |
379 |
353 |
380 // Set navigation action only when widget is not in selection mode |
354 // Set navigation action only when widget is not in selection mode |
381 if (mSelectionMode == HbAbstractItemView::NoSelection) |
355 if (mSelectionMode == HbAbstractItemView::NoSelection) |
382 { |
356 { |
454 if (mService == VideoServices::EUriFetcher) |
428 if (mService == VideoServices::EUriFetcher) |
455 { |
429 { |
456 mContextMenuActions[EActionAttach] = |
430 mContextMenuActions[EActionAttach] = |
457 mContextMenu->addAction(hbTrId("txt_videos_menu_attach"), this, SLOT(openItemSlot())); |
431 mContextMenu->addAction(hbTrId("txt_videos_menu_attach"), this, SLOT(openItemSlot())); |
458 mContextMenuActions[EActionAttach]->setObjectName(LIST_WIDGET_OBJECT_NAME_ACTION_ATTACH); |
432 mContextMenuActions[EActionAttach]->setObjectName(LIST_WIDGET_OBJECT_NAME_ACTION_ATTACH); |
|
433 |
|
434 mContextMenuActions[EActionOpen] = |
|
435 mContextMenu->addAction(hbTrId("txt_common_menu_open"), this, SLOT(openItemSlot())); |
|
436 mContextMenuActions[EActionOpen]->setObjectName(LIST_WIDGET_OBJECT_NAME_ACTION_OPEN); |
459 |
437 |
460 mContextMenuActions[EActionPlay] = |
438 mContextMenuActions[EActionPlay] = |
461 mContextMenu->addAction(hbTrId("txt_videos_menu_play"), this, SLOT(playItemSlot())); |
439 mContextMenu->addAction(hbTrId("txt_videos_menu_play"), this, SLOT(playItemSlot())); |
462 mContextMenuActions[EActionPlay]->setObjectName(LIST_WIDGET_OBJECT_NAME_ACTION_PLAY); |
440 mContextMenuActions[EActionPlay]->setObjectName(LIST_WIDGET_OBJECT_NAME_ACTION_PLAY); |
463 |
441 |
550 mContextMenu = 0; |
528 mContextMenu = 0; |
551 mContextMenuActions.clear(); |
529 mContextMenuActions.clear(); |
552 return; |
530 return; |
553 } |
531 } |
554 |
532 |
555 if (isBrowsingService()) |
533 if (mVideoServices) |
556 { |
534 { |
557 setBrowsingServiceContextMenu(); |
535 setServiceContextMenu(); |
558 return; |
536 return; |
559 } |
537 } |
560 |
|
561 |
538 |
562 if(mCurrentLevel == VideoCollectionCommon::ELevelVideos || |
539 if(mCurrentLevel == VideoCollectionCommon::ELevelVideos || |
563 mCurrentLevel == VideoCollectionCommon::ELevelDefaultColl) |
540 mCurrentLevel == VideoCollectionCommon::ELevelDefaultColl) |
564 { |
541 { |
565 if (!mIsService) |
542 mContextMenuActions[EActionAddToCollection]->setVisible(true); |
566 { |
543 mContextMenuActions[EActionDelete]->setVisible(true); |
567 mContextMenuActions[EActionAddToCollection]->setVisible(true); |
|
568 mContextMenuActions[EActionDelete]->setVisible(true); |
|
569 } |
|
570 else |
|
571 { |
|
572 mContextMenuActions[EActionAttach]->setVisible(true); |
|
573 } |
|
574 mContextMenuActions[EActionPlay]->setVisible(true); |
544 mContextMenuActions[EActionPlay]->setVisible(true); |
575 mContextMenuActions[EActionDetails]->setVisible(true); |
545 mContextMenuActions[EActionDetails]->setVisible(true); |
576 } |
546 } |
577 else if(mCurrentLevel == VideoCollectionCommon::ELevelCategory) |
547 else if(mCurrentLevel == VideoCollectionCommon::ELevelCategory) |
578 { |
548 { |
579 mContextMenuActions[EActionOpen]->setVisible(true); |
549 mContextMenuActions[EActionOpen]->setVisible(true); |
580 TMPXItemId mpxId = mModel->getMediaIdAtIndex(currentIndex()); |
550 TMPXItemId mpxId = mModel->getMediaIdAtIndex(currentIndex()); |
581 if(!mIsService && mpxId.iId2 == KVcxMvcMediaTypeAlbum) |
551 if(mpxId.iId2 == KVcxMvcMediaTypeAlbum) |
582 { |
552 { |
583 mContextMenuActions[EActionRename]->setVisible(true); |
553 mContextMenuActions[EActionRename]->setVisible(true); |
584 mContextMenuActions[EActionRemoveCollection]->setVisible(true); |
554 mContextMenuActions[EActionRemoveCollection]->setVisible(true); |
585 } |
555 } |
586 } |
556 } |
587 else if(mCurrentLevel == VideoCollectionCommon::ELevelAlbum) |
557 else if(mCurrentLevel == VideoCollectionCommon::ELevelAlbum) |
588 { |
558 { |
589 if (!mIsService) |
559 mContextMenuActions[EActionRemove]->setVisible(true); |
590 { |
560 mContextMenuActions[EActionDelete]->setVisible(true); |
591 mContextMenuActions[EActionRemove]->setVisible(true); |
|
592 mContextMenuActions[EActionDelete]->setVisible(true); |
|
593 } else { |
|
594 mContextMenuActions[EActionAttach]->setVisible(true); |
|
595 } |
|
596 mContextMenuActions[EActionPlay]->setVisible(true); |
561 mContextMenuActions[EActionPlay]->setVisible(true); |
597 mContextMenuActions[EActionDetails]->setVisible(true); |
562 mContextMenuActions[EActionDetails]->setVisible(true); |
598 } |
563 } |
599 } |
564 } |
600 |
565 |
601 // --------------------------------------------------------------------------- |
566 // --------------------------------------------------------------------------- |
602 // setBrowsingServiceContextMenu |
567 // setServiceContextMenu |
603 // --------------------------------------------------------------------------- |
568 // --------------------------------------------------------------------------- |
604 // |
569 // |
605 void VideoListWidget::setBrowsingServiceContextMenu() |
570 void VideoListWidget::setServiceContextMenu() |
606 { |
571 { |
607 FUNC_LOG_ADDR(this); |
572 FUNC_LOG_ADDR(this); |
608 mContextMenuActions[EActionPlay]->setVisible(true); |
573 |
609 mContextMenuActions[EActionDelete]->setVisible(true); |
574 if(mCurrentLevel == VideoCollectionCommon::ELevelCategory) |
610 mContextMenuActions[EActionDetails]->setVisible(true); |
575 { |
|
576 mContextMenuActions[EActionOpen]->setVisible(true); |
|
577 } |
|
578 else if(mCurrentLevel > VideoCollectionCommon::ELevelCategory) |
|
579 { |
|
580 mContextMenuActions[EActionDetails]->setVisible(true); |
|
581 mContextMenuActions[EActionPlay]->setVisible(true); |
|
582 if(mService == VideoServices::EBrowse) |
|
583 { |
|
584 mContextMenuActions[EActionDelete]->setVisible(true); |
|
585 } |
|
586 else if(mService == VideoServices::EUriFetcher) |
|
587 { |
|
588 mContextMenuActions[EActionAttach]->setVisible(true); |
|
589 } |
|
590 } |
611 } |
591 } |
612 |
592 |
613 // --------------------------------------------------------------------------- |
593 // --------------------------------------------------------------------------- |
614 // getModel |
594 // getModel |
615 // --------------------------------------------------------------------------- |
595 // --------------------------------------------------------------------------- |
651 // doEmitActivated |
631 // doEmitActivated |
652 // --------------------------------------------------------------------------- |
632 // --------------------------------------------------------------------------- |
653 // |
633 // |
654 void VideoListWidget::doEmitActivated (const QModelIndex &index) |
634 void VideoListWidget::doEmitActivated (const QModelIndex &index) |
655 { |
635 { |
656 if(mIsService && |
636 if(mVideoServices && |
657 mVideoServices && |
|
658 mService == VideoServices::EUriFetcher && |
637 mService == VideoServices::EUriFetcher && |
659 mCurrentLevel != VideoCollectionCommon::ELevelCategory) |
638 mCurrentLevel != VideoCollectionCommon::ELevelCategory) |
660 { |
639 { |
661 QVariant variant = mModel->data(index, VideoCollectionCommon::KeyFilePath); |
640 QVariant variant = mModel->data(index, VideoCollectionCommon::KeyFilePath); |
662 if ( variant.isValid() ) |
641 if ( variant.isValid() ) |
956 |
935 |
957 if(mModel) |
936 if(mModel) |
958 { |
937 { |
959 // Empty the proxy model causing the items to be removed from list widget. |
938 // Empty the proxy model causing the items to be removed from list widget. |
960 mModel->setAlbumInUse(TMPXItemId::InvalidId()); |
939 mModel->setAlbumInUse(TMPXItemId::InvalidId()); |
961 emit collectionOpened(false, QString(), QModelIndex()); |
940 emit collectionOpened(false, QString(), TMPXItemId::InvalidId()); |
|
941 } |
|
942 } |
|
943 |
|
944 // --------------------------------------------------------------------------- |
|
945 // endVideoFecthingSlot |
|
946 // --------------------------------------------------------------------------- |
|
947 // |
|
948 void VideoListWidget::endVideoFecthingSlot() |
|
949 { |
|
950 if(mVideoServices && mService == VideoServices::EUriFetcher) |
|
951 { |
|
952 QString empty = ""; |
|
953 emit fileUri(empty); |
962 } |
954 } |
963 } |
955 } |
964 |
956 |
965 // --------------------------------------------------------------------------- |
957 // --------------------------------------------------------------------------- |
966 // scrollingStartedSlot |
958 // scrollingStartedSlot |