videocollection/videocollectionview/src/videolistwidget.cpp
changeset 15 cf5481c2bc0b
child 17 69946d1824c4
equal deleted inserted replaced
2:dec420019252 15:cf5481c2bc0b
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Videolist content widget implementation
       
    15 *
       
    16 */
       
    17 
       
    18 #include "videolistwidget.h"
       
    19 
       
    20 #include <qcoreapplication.h>
       
    21 #include <qtimer.h>
       
    22 #include <hbscrollbar.h>
       
    23 #include <xqserviceutil.h>
       
    24 #include <hbmenu.h>
       
    25 #include <hbaction.h>
       
    26 #include <hbinstance.h>
       
    27 #include <hbmainwindow.h>
       
    28 #include <hblistviewitem.h>
       
    29 #include <hbmessagebox.h>
       
    30 #include <vcxmyvideosdefs.h>
       
    31 
       
    32 #include "videocollectionviewutils.h"
       
    33 #include "videocollectionuiloader.h"
       
    34 #include "videolistselectiondialog.h"
       
    35 #include "videoservices.h"
       
    36 #include "videothumbnaildata.h"
       
    37 #include "videosortfilterproxymodel.h"
       
    38 #include "videocollectioncommon.h"
       
    39 #include "mpxhbvideocommondefs.h"
       
    40 
       
    41 // Interval in ms to report the scroll position.
       
    42 const int SCROLL_POSITION_TIMER_TIMEOUT = 100;
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // Constructor
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 VideoListWidget::VideoListWidget(VideoCollectionUiLoader *uiLoader, HbView *parent) :
       
    49 HbListView(parent),
       
    50 mModel(0),
       
    51 mVideoServices(0),
       
    52 mCurrentLevel(VideoCollectionCommon::ELevelInvalid),
       
    53 mSignalsConnected(false),
       
    54 mIsService(false),
       
    55 mNavKeyBackAction(0),
       
    56 mNavKeyQuitAction(0),
       
    57 mContextMenu(0),
       
    58 mSelectionMode(HbAbstractItemView::NoSelection),
       
    59 mScrollPositionTimer(0),
       
    60 mUiLoader(uiLoader)
       
    61 {
       
    62     // NOP
       
    63 }
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // Destructor
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 VideoListWidget::~VideoListWidget()
       
    70 {
       
    71     delete mScrollPositionTimer;
       
    72     mScrollPositionTimer = 0;
       
    73 	mContextMenuActions.clear();
       
    74 	disconnect();
       
    75     delete mContextMenu;
       
    76     mContextMenu = 0;
       
    77     delete mNavKeyBackAction;
       
    78     mNavKeyBackAction = 0;
       
    79     delete mNavKeyQuitAction;
       
    80     mNavKeyQuitAction = 0;
       
    81 }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // initialize
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 int VideoListWidget::initialize(VideoSortFilterProxyModel &model, VideoServices* videoServices)
       
    88 {
       
    89     mModel = &model;
       
    90 
       
    91 	mVideoServices = videoServices;
       
    92 
       
    93 	if(mVideoServices)
       
    94 	{
       
    95 		mIsService = true;
       
    96 	}
       
    97 
       
    98     // init list view
       
    99     VideoCollectionViewUtils::initListView(this);
       
   100 
       
   101     // Navigation keys.
       
   102     mNavKeyBackAction = new HbAction(Hb::BackNaviAction);
       
   103 	
       
   104     mNavKeyQuitAction = new HbAction(Hb::QuitNaviAction);
       
   105 
       
   106 	mScrollPositionTimer = new QTimer();
       
   107 	mScrollPositionTimer->setSingleShot(true);
       
   108 
       
   109 	if (mIsService)
       
   110 	{
       
   111 		connect(this, SIGNAL(fileUri(const QString&)), mVideoServices, SLOT(itemSelected(const QString&)));
       
   112 	}
       
   113 
       
   114 	setModel(mModel);
       
   115 	
       
   116     return 0;
       
   117 }
       
   118 
       
   119 // ---------------------------------------------------------------------------
       
   120 // activate
       
   121 // ---------------------------------------------------------------------------
       
   122 //
       
   123 int VideoListWidget::activate()
       
   124 {
       
   125     return activate(mCurrentLevel);
       
   126 }
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 // activate
       
   130 // ---------------------------------------------------------------------------
       
   131 //
       
   132 int VideoListWidget::activate(VideoCollectionCommon::TCollectionLevels level)
       
   133 {
       
   134     if(!mModel)
       
   135     {
       
   136         return -1;
       
   137     }
       
   138     
       
   139 	mCurrentLevel = level;
       
   140     setVisible(true);
       
   141 
       
   142     if ( connectSignals() < 0)
       
   143     {
       
   144         return -1;
       
   145     }
       
   146 
       
   147     HbView *currentView = hbInstance->allMainWindows().value(0)->currentView();
       
   148 
       
   149     // Set navigation key only when widget is not in selection mode.
       
   150     if(currentView && mSelectionMode == HbAbstractItemView::NoSelection)
       
   151     {
       
   152         if(level != VideoCollectionCommon::ELevelDefaultColl && 
       
   153            level != VideoCollectionCommon::ELevelAlbum)
       
   154         {
       
   155             if(mNavKeyQuitAction)
       
   156             {
       
   157                 currentView->setNavigationAction(mNavKeyQuitAction);
       
   158             }
       
   159         }
       
   160         else if(mNavKeyBackAction)
       
   161         {
       
   162             currentView->setNavigationAction(mNavKeyBackAction);
       
   163         }
       
   164     }
       
   165     // open model to the current level in case not in album or category
       
   166     if(level != VideoCollectionCommon::ELevelAlbum &&
       
   167         level != VideoCollectionCommon::ELevelDefaultColl)
       
   168     {
       
   169          mModel->open(level);
       
   170     }
       
   171     
       
   172     // Enable thumbnail background fetching.
       
   173     VideoThumbnailData &thumbnailData = VideoThumbnailData::instance();
       
   174     thumbnailData.enableBackgroundFetching(true);
       
   175     thumbnailData.startBackgroundFetching(mModel, 0);
       
   176 
       
   177     return 0;
       
   178 }
       
   179 
       
   180 // ---------------------------------------------------------------------------
       
   181 // deactivate
       
   182 // ---------------------------------------------------------------------------
       
   183 //
       
   184 void VideoListWidget::deactivate()
       
   185 {
       
   186     if(mContextMenu) 
       
   187     {
       
   188         mContextMenu->hide();
       
   189     }
       
   190 
       
   191     setVisible(false);
       
   192     disConnectSignals();
       
   193     
       
   194     // Free allocated memory for list thumbnails and disable background fetching.
       
   195     VideoThumbnailData &thumbnailData = VideoThumbnailData::instance();
       
   196     thumbnailData.enableBackgroundFetching(false);
       
   197     thumbnailData.freeThumbnailData();
       
   198 }
       
   199 
       
   200 // ---------------------------------------------------------------------------
       
   201 // getLevel
       
   202 // ---------------------------------------------------------------------------
       
   203 //
       
   204 VideoCollectionCommon::TCollectionLevels VideoListWidget::getLevel()
       
   205 {
       
   206     return mCurrentLevel;
       
   207 }
       
   208 
       
   209 // ---------------------------------------------------------------------------
       
   210 // connectSignals
       
   211 // ---------------------------------------------------------------------------
       
   212 //
       
   213 int VideoListWidget::connectSignals()
       
   214 {
       
   215     if (!mSignalsConnected)
       
   216     {
       
   217         if(!connect(this, SIGNAL(scrollingStarted()), this, SLOT(scrollingStartedSlot())) ||
       
   218            !connect(this, SIGNAL(scrollingEnded()), this, SLOT(scrollingEndedSlot())) ||
       
   219            !connect(this, SIGNAL(scrollPositionChanged(const QPointF &)), 
       
   220                    this, SLOT(scrollPositionChangedSlot(const QPointF &))) ||
       
   221            !connect(mScrollPositionTimer, SIGNAL(timeout()), this, SLOT(scrollPositionTimerSlot())) || 
       
   222            !connect(mNavKeyBackAction, SIGNAL(triggered()), this, SLOT(back())) ||
       
   223            !connect(mNavKeyQuitAction, SIGNAL(triggered()), qApp, SLOT(quit()))) 
       
   224         {
       
   225             return -1;
       
   226         }
       
   227         mSignalsConnected = true;
       
   228     }
       
   229 	return 0;
       
   230 }
       
   231 
       
   232 // ---------------------------------------------------------------------------
       
   233 // disConnectSignals
       
   234 // ---------------------------------------------------------------------------
       
   235 //
       
   236 void VideoListWidget::disConnectSignals()
       
   237 {
       
   238     disconnect(this, SIGNAL(scrollingStarted()), this, SLOT(scrollingStartedSlot()));
       
   239     disconnect(this, SIGNAL(scrollingEnded()), this, SLOT(scrollingEndedSlot()));
       
   240     disconnect(this, SIGNAL(scrollPositionChanged(const QPointF&)), 
       
   241                this, SLOT(scrollPositionChangedSlot(const QPointF&)));
       
   242     disconnect(mScrollPositionTimer, SIGNAL(timeout()), this, SLOT(scrollPositionTimerSlot()));
       
   243     disconnect(mNavKeyBackAction, SIGNAL(triggered()), this, SLOT(back()));
       
   244     disconnect(mNavKeyQuitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
       
   245 
       
   246 	mSignalsConnected = false;
       
   247 }
       
   248 
       
   249 // ---------------------------------------------------------------------------
       
   250 // deleteItemSlot
       
   251 // ---------------------------------------------------------------------------
       
   252 //
       
   253 void VideoListWidget::deleteItemSlot()
       
   254 {
       
   255     if(!mModel)
       
   256     {
       
   257         return;
       
   258     }
       
   259     
       
   260     QVariant variant;
       
   261     QModelIndex index = currentIndex();
       
   262     variant = mModel->data(index, Qt::DisplayRole);
       
   263 
       
   264     if (variant.isValid())
       
   265     {
       
   266         QString text = hbTrId("txt_videos_info_do_you_want_to_delete_1").arg(
       
   267                 variant.toStringList().first());
       
   268         if(HbMessageBox::question(text))
       
   269         {
       
   270             QModelIndexList list;
       
   271             list.append(index);
       
   272             mModel->deleteItems(list);
       
   273         }
       
   274     }
       
   275 }
       
   276 
       
   277 // ---------------------------------------------------------------------------
       
   278 // createContextMenu
       
   279 // ---------------------------------------------------------------------------
       
   280 //
       
   281 void VideoListWidget::createContextMenu()
       
   282 {
       
   283     if(mContextMenu)
       
   284     {
       
   285         return;
       
   286     }
       
   287     
       
   288     mContextMenu = new HbMenu();
       
   289     if (mContextMenu)
       
   290     {
       
   291         mContextMenu->setDismissPolicy(HbPopup::TapAnywhere);
       
   292         if (mIsService)
       
   293         {
       
   294             mContextMenuActions[EActionPlay]    = 
       
   295                     mContextMenu->addAction(hbTrId("txt_videos_menu_play"), this, SLOT(playItemSlot())); 
       
   296             mContextMenuActions[EActionDetails] = 
       
   297                     mContextMenu->addAction(hbTrId("txt_common_menu_details"), this, SLOT(openDetailsSlot()));
       
   298         }
       
   299         else
       
   300         {
       
   301             mContextMenuActions[EActionAddToCollection] = 
       
   302                     mContextMenu->addAction(hbTrId("txt_videos_menu_add_to_collection"), this, SLOT(addToCollectionSlot()));
       
   303             mContextMenuActions[EActionRemove]           = 
       
   304                     mContextMenu->addAction(hbTrId("txt_videos_menu_remove_from_collection"), this, SLOT(removeFromCollectionSlot()));
       
   305             mContextMenuActions[EActionRename]           = 
       
   306                     mContextMenu->addAction(hbTrId("txt_common_menu_rename_item"), this, SLOT(renameSlot()));
       
   307             mContextMenuActions[EActionRemoveCollection] = 
       
   308                     mContextMenu->addAction(hbTrId("txt_videos_menu_remove_collection"), this, SLOT(removeCollectionSlot()));   
       
   309             mContextMenuActions[EActionDelete]           = 
       
   310                     mContextMenu->addAction(hbTrId("txt_common_menu_delete"), this, SLOT(deleteItemSlot()));
       
   311             mContextMenuActions[EActionDetails]          = 
       
   312                     mContextMenu->addAction(hbTrId("txt_common_menu_details"), this, SLOT(openDetailsSlot()));
       
   313         }
       
   314     }
       
   315 }
       
   316 
       
   317 // -------------------------------------------------------------------------------------------------
       
   318 // setContextMenu
       
   319 // -------------------------------------------------------------------------------------------------
       
   320 //
       
   321 void VideoListWidget::setContextMenu()
       
   322 {
       
   323     if(!mContextMenu)
       
   324     {
       
   325         createContextMenu();
       
   326     }
       
   327     
       
   328     if (!mContextMenu)
       
   329     {
       
   330         // failed to create context menu, return
       
   331         return;
       
   332     }
       
   333     
       
   334 	int menuActionCount = 0;
       
   335     HbAction *action = 0;
       
   336     foreach(action, mContextMenuActions.values())
       
   337     {
       
   338         if(action)
       
   339         {
       
   340 			++menuActionCount;
       
   341 			action->setVisible(false);
       
   342         }
       
   343     }
       
   344     if(menuActionCount != mContextMenuActions.values().count() || mContextMenuActions.values().count() == 0)
       
   345     {
       
   346     	// fatal error, some action(s) was not created before.
       
   347         delete mContextMenu;
       
   348         mContextMenu = 0;
       
   349         mContextMenuActions.clear();
       
   350     	return;
       
   351     }
       
   352 
       
   353     HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
       
   354 
       
   355     if(mCurrentLevel == VideoCollectionCommon::ELevelVideos ||
       
   356        mCurrentLevel == VideoCollectionCommon::ELevelDefaultColl)
       
   357     {
       
   358     	if (!mIsService)
       
   359     	{
       
   360 			mContextMenuActions[EActionAddToCollection]->setVisible(true);
       
   361     		mContextMenuActions[EActionDelete]->setVisible(true);
       
   362     	}
       
   363     	else
       
   364     	{
       
   365     		mContextMenuActions[EActionPlay]->setVisible(true);
       
   366     	}
       
   367 		mContextMenuActions[EActionDetails]->setVisible(true);
       
   368     }
       
   369     else if(mCurrentLevel == VideoCollectionCommon::ELevelCategory) 
       
   370     {
       
   371 		if(!mIsService)
       
   372 		{
       
   373             mContextMenuActions[EActionRename]->setVisible(true);
       
   374             mContextMenuActions[EActionRemoveCollection]->setVisible(true);
       
   375 		}
       
   376     }
       
   377     else if(mCurrentLevel == VideoCollectionCommon::ELevelAlbum)
       
   378     {
       
   379     	if (!mIsService)
       
   380     	{
       
   381 			mContextMenuActions[EActionRemove]->setVisible(true);
       
   382             mContextMenuActions[EActionDelete]->setVisible(true);
       
   383     	}
       
   384     	else
       
   385     	{
       
   386     		mContextMenuActions[EActionPlay]->setVisible(true);
       
   387     	}
       
   388 		mContextMenuActions[EActionDetails]->setVisible(true);
       
   389     }
       
   390 }
       
   391 
       
   392 
       
   393 // ---------------------------------------------------------------------------
       
   394 // getModel
       
   395 // ---------------------------------------------------------------------------
       
   396 //
       
   397 VideoSortFilterProxyModel& VideoListWidget::getModel()
       
   398 { 
       
   399     return *mModel; 
       
   400 }
       
   401 
       
   402 // ---------------------------------------------------------------------------
       
   403 // emitActivated
       
   404 // This slot is called by the fw when viewitem is activated
       
   405 // ---------------------------------------------------------------------------
       
   406 //
       
   407 void VideoListWidget::emitActivated (const QModelIndex &modelIndex)
       
   408 {
       
   409     // surprisingly interenting feature: after long press also single press
       
   410     // is executed. as a workaround the following hack check is needed.
       
   411     // otherwise after the context menu is shown also single press action
       
   412     // is executed.
       
   413     if (mContextMenu &&
       
   414         mContextMenu->isVisible())
       
   415     {
       
   416         // do not activate context menu if it is already visible
       
   417         return;
       
   418     }
       
   419     
       
   420     if(mSelectionMode != HbAbstractItemView::NoSelection)
       
   421     {
       
   422         // no custom functionality defined
       
   423         emit activated(modelIndex);
       
   424         return;
       
   425     }
       
   426 
       
   427     if (!mModel || !modelIndex.isValid())
       
   428     {
       
   429         return;
       
   430     }
       
   431     
       
   432     if (mCurrentLevel == VideoCollectionCommon::ELevelCategory)
       
   433     {
       
   434         QVariant variant = mModel->data(modelIndex, Qt::DisplayRole);
       
   435         if (variant.isValid())
       
   436         {
       
   437             // signal view that item has been activated
       
   438             emit(collectionOpened(true,
       
   439                 variant.toStringList().first(),
       
   440                 modelIndex));                       
       
   441         }
       
   442         return;
       
   443     }
       
   444     if(mIsService && (mCurrentLevel != VideoCollectionCommon::ELevelCategory))
       
   445     {
       
   446     	QVariant variant = mModel->data(modelIndex, VideoCollectionCommon::KeyFilePath);
       
   447 		if ( variant.isValid()  )
       
   448 		{
       
   449 			QString itemPath = variant.value<QString>();
       
   450 			emit(fileUri(itemPath));
       
   451 		}
       
   452     }
       
   453     else
       
   454     {
       
   455     	mModel->openItem(mModel->getMediaIdAtIndex(modelIndex));
       
   456     }
       
   457 }
       
   458 
       
   459 // ---------------------------------------------------------------------------
       
   460 // setSelectionMode
       
   461 // called by the fw when user long presses some item
       
   462 // ---------------------------------------------------------------------------
       
   463 //
       
   464 //
       
   465 void VideoListWidget::setSelectionMode(int mode)
       
   466 {
       
   467     HbAbstractItemView::SelectionMode selMode = HbAbstractItemView::NoSelection;
       
   468     if(mode >= HbAbstractItemView::NoSelection && mode <= HbAbstractItemView::ContiguousSelection)
       
   469     {
       
   470         selMode = HbAbstractItemView::SelectionMode(mode);
       
   471     }
       
   472 
       
   473     HbListView::setSelectionMode(selMode);
       
   474     mSelectionMode = mode;
       
   475 }
       
   476 
       
   477 // ---------------------------------------------------------------------------
       
   478 // longPressGesture
       
   479 // called by the fw when user long presses some item
       
   480 // ---------------------------------------------------------------------------
       
   481 //
       
   482 //
       
   483 void VideoListWidget::longPressGesture (const QPointF &point)
       
   484 {
       
   485     if(mSelectionMode != HbAbstractItemView::NoSelection)
       
   486     {
       
   487         // do not activate context menu during selection mode
       
   488         return;
       
   489     }
       
   490 
       
   491     HbAbstractViewItem *viewItem = itemAtPosition(point);
       
   492     if (viewItem)
       
   493     {
       
   494         QModelIndex index = viewItem->modelIndex();
       
   495         if(mModel && index.isValid())
       
   496         {   
       
   497             TMPXItemId mpxId = mModel->getMediaIdAtIndex(index);
       
   498             // Only videos and user created albums have context menu.
       
   499             if((mpxId.iId2 == KVcxMvcMediaTypeVideo) ||
       
   500                (!mIsService && mpxId.iId2 == KVcxMvcMediaTypeAlbum ))
       
   501             {
       
   502                 setContextMenu();
       
   503                 // if menu not yet exists, it has been created
       
   504                 // setup might fail causing menu to be removed
       
   505                 if(mContextMenu)
       
   506                 {
       
   507                     mContextMenu->setPreferredPos(point);
       
   508                     mContextMenu->show();
       
   509                 }
       
   510             }
       
   511         }
       
   512     }
       
   513 	HbListView::longPressGesture(point);
       
   514 }
       
   515 
       
   516 // ---------------------------------------------------------------------------
       
   517 // doDelayedsSlot
       
   518 // ---------------------------------------------------------------------------
       
   519 //
       
   520 void VideoListWidget::doDelayedsSlot()
       
   521 {
       
   522 	if (!mContextMenu)
       
   523 	{
       
   524 		createContextMenu();
       
   525 	}
       
   526 }
       
   527 
       
   528 // ---------------------------------------------------------------------------
       
   529 // playItemSlot
       
   530 // ---------------------------------------------------------------------------
       
   531 //
       
   532 void VideoListWidget::playItemSlot()
       
   533 {
       
   534     mModel->openItem(mModel->getMediaIdAtIndex(currentIndex()));
       
   535 }
       
   536 
       
   537 // ---------------------------------------------------------------------------
       
   538 // openDetailsSlot
       
   539 // ---------------------------------------------------------------------------
       
   540 //
       
   541 void VideoListWidget::openDetailsSlot()
       
   542 {   
       
   543     if(mModel && mModel->fetchItemDetails(currentIndex()) == 0 ) 
       
   544     {
       
   545         emit command(MpxHbVideoCommon::ActivateVideoDetailsView);
       
   546     }
       
   547 }
       
   548 
       
   549 // ---------------------------------------------------------------------------
       
   550 // renameSlot
       
   551 // ---------------------------------------------------------------------------
       
   552 //
       
   553 void VideoListWidget::renameSlot()
       
   554 {
       
   555 	debugNotImplementedYet();
       
   556 }
       
   557 
       
   558 // ---------------------------------------------------------------------------
       
   559 // addToCollectionSlot
       
   560 // ---------------------------------------------------------------------------
       
   561 //
       
   562 void VideoListWidget::addToCollectionSlot()
       
   563 {
       
   564     VideoListSelectionDialog *dialog =
       
   565        mUiLoader->findWidget<VideoListSelectionDialog>(
       
   566            DOCML_NAME_DIALOG);
       
   567     if (!dialog || !mModel)
       
   568     {
       
   569         return;
       
   570     }
       
   571     TMPXItemId itemId = mModel->getMediaIdAtIndex(currentIndex());
       
   572     if(itemId != TMPXItemId::InvalidId())
       
   573     {
       
   574         dialog->setupContent(VideoListSelectionDialog::ESelectCollection, itemId);
       
   575         dialog->exec();
       
   576     }
       
   577 }
       
   578 
       
   579 // ---------------------------------------------------------------------------
       
   580 // removeFromCollectionSlot
       
   581 // ---------------------------------------------------------------------------
       
   582 //
       
   583 void VideoListWidget::removeFromCollectionSlot()
       
   584 {
       
   585     if(!mModel)
       
   586     {
       
   587         return;
       
   588     }
       
   589     TMPXItemId collectionId = mModel->getOpenItem();
       
   590     TMPXItemId itemId = mModel->getMediaIdAtIndex(currentIndex());
       
   591     if(collectionId != TMPXItemId::InvalidId() && 
       
   592        itemId != TMPXItemId::InvalidId())
       
   593     {
       
   594         QList<TMPXItemId> ids;
       
   595         ids.append(itemId);
       
   596         mModel->removeItemsFromAlbum(collectionId, ids);
       
   597     }
       
   598 }
       
   599 
       
   600 // ---------------------------------------------------------------------------
       
   601 // removeCollectionSlot
       
   602 // ---------------------------------------------------------------------------
       
   603 //
       
   604 void VideoListWidget::removeCollectionSlot()
       
   605 {
       
   606     if(!mModel)
       
   607     {
       
   608         return;
       
   609     }
       
   610     
       
   611     QVariant variant;
       
   612     QModelIndex index = currentIndex();
       
   613     variant = mModel->data(index, Qt::DisplayRole);
       
   614 
       
   615     if (variant.isValid())
       
   616     {
       
   617         QString text = tr("Do you want to remove collection \"%1\"?").arg( //TODO: localisation
       
   618                 variant.toStringList().first());
       
   619         if(HbMessageBox::question(text))
       
   620         {
       
   621             QModelIndexList list;
       
   622             list.append(index);
       
   623         	mModel->removeAlbums(list);
       
   624         }
       
   625     }
       
   626 }
       
   627 
       
   628 // ---------------------------------------------------------------------------
       
   629 // playAllSlot
       
   630 // ---------------------------------------------------------------------------
       
   631 //
       
   632 void VideoListWidget::playAllSlot()
       
   633 {
       
   634 	debugNotImplementedYet();
       
   635 }
       
   636 
       
   637 // ---------------------------------------------------------------------------
       
   638 // back
       
   639 // ---------------------------------------------------------------------------
       
   640 //
       
   641 void VideoListWidget::back()
       
   642 {
       
   643 	// Empty the proxy model causing the items to be removed from list widget.
       
   644     mModel->setAlbumInUse(TMPXItemId::InvalidId());
       
   645     if(mModel)
       
   646     {
       
   647         emit collectionOpened(false, QString(), QModelIndex());
       
   648     }
       
   649 }
       
   650 
       
   651 // ---------------------------------------------------------------------------
       
   652 // scrollingStartedSlot
       
   653 // ---------------------------------------------------------------------------
       
   654 //
       
   655 void VideoListWidget::scrollingStartedSlot()
       
   656 {
       
   657     VideoThumbnailData::instance().enableThumbnailCreation(false);
       
   658 }
       
   659 
       
   660 // ---------------------------------------------------------------------------
       
   661 // scrollingEndedSlot
       
   662 // ---------------------------------------------------------------------------
       
   663 //
       
   664 void VideoListWidget::scrollingEndedSlot()
       
   665 {
       
   666     if(mScrollPositionTimer)
       
   667         mScrollPositionTimer->stop();	
       
   668     VideoThumbnailData::instance().enableThumbnailCreation(true);
       
   669     fetchThumbnailsForVisibleItems();
       
   670 }
       
   671 
       
   672 // ---------------------------------------------------------------------------
       
   673 // scrollPositionChangedSlot
       
   674 // ---------------------------------------------------------------------------
       
   675 //
       
   676 void VideoListWidget::scrollPositionChangedSlot(const QPointF &newPosition)
       
   677 {
       
   678     Q_UNUSED(newPosition);
       
   679 	if(mScrollPositionTimer && !mScrollPositionTimer->isActive())
       
   680 	    mScrollPositionTimer->start(SCROLL_POSITION_TIMER_TIMEOUT);
       
   681 }
       
   682 
       
   683 // ---------------------------------------------------------------------------
       
   684 // scrollPositionTimerSlot
       
   685 // ---------------------------------------------------------------------------
       
   686 //
       
   687 void VideoListWidget::scrollPositionTimerSlot()
       
   688 {
       
   689     fetchThumbnailsForVisibleItems();
       
   690 }
       
   691 
       
   692 // ---------------------------------------------------------------------------
       
   693 // fetchThumbnailsForVisibleItems
       
   694 // ---------------------------------------------------------------------------
       
   695 //
       
   696 void VideoListWidget::fetchThumbnailsForVisibleItems()
       
   697 {
       
   698     const QList<HbAbstractViewItem *> itemsVisible = visibleItems();
       
   699 
       
   700     if(itemsVisible.count() > 0)
       
   701     {
       
   702         int row = itemsVisible.value(0)->modelIndex().row();
       
   703         VideoThumbnailData::instance().startBackgroundFetching(mModel, row);
       
   704     }
       
   705 }
       
   706 
       
   707 // ---------------------------------------------------------------------------
       
   708 // debugNotImplementedYet
       
   709 // ---------------------------------------------------------------------------
       
   710 //
       
   711 void VideoListWidget::debugNotImplementedYet()
       
   712 {
       
   713     HbMessageBox::information(tr("Not implemented yet"));
       
   714 }
       
   715 
       
   716 // end of file