--- a/videocollection/videocollectionview/src/videolistselectiondialog.cpp Tue Oct 05 09:26:49 2010 +0300
+++ b/videocollection/videocollectionview/src/videolistselectiondialog.cpp Fri Oct 15 16:29:10 2010 +0300
@@ -15,35 +15,38 @@
*
*/
-// Version : %version: 30.1.5 %
+// Version : %version: 30.1.7 %
// INCLUDE FILES
#include <qgraphicsitem.h>
-#include <hblabel.h>
-#include <hbcheckbox.h>
+#include <qtimer.h>
+
+#include <vcxmyvideosdefs.h>
+
#include <hbaction.h>
-#include <hbstackedwidget.h>
#include <hbabstractitemview.h>
#include <hbinputdialog.h>
-#include <vcxmyvideosdefs.h>
-#include <hbstyleloader.h>
+#include <hbwidget.h>
+#include <hblistview.h>
+#include <hblistviewitem.h>
-#include "videocollectionuiloader.h"
-#include "videolistwidget.h"
#include "videoproxymodelgeneric.h"
#include "videolistselectiondialog.h"
#include "videocollectionwrapper.h"
#include "videocollectionviewutils.h"
#include "videocollectionclient.h"
#include "videocollectiontrace.h"
+#include "videothumbnaildata.h"
// Object names.
-const char* const SELECTION_DIALOG_OBJECT_NAME_LIST_WIDGET = "vc:SelectionDialogListWidget";
const char* const SELECTION_DIALOG_OBJECT_NAME_NEW_COLLECTION = "vc:SelectionDialogNewCollection";
const char* const LIST_VIEW_OBJECT_NAME_CREATE_COLLECTION = "vc::ListViewInputDialogCreateCollection";
const char* const SELECTION_DIALOG_OBJECT_NAME_BUTTON_OK = "vc:SelectionDialogButtonOk";
const char* const SELECTION_DIALOG_OBJECT_NAME_BUTTON_CANCEL = "vc:SelectionDialogButtonCancel";
+// Interval in ms to report the scroll position.
+const int SCROLL_POSITION_TIMER_TIMEOUT = 100;
+
/**
* global qHash function required fo creating hash values for TMPXItemId -keys
*/
@@ -73,49 +76,22 @@
// VideoListSelectionDialog
// ---------------------------------------------------------------------------
//
-VideoListSelectionDialog::VideoListSelectionDialog( VideoCollectionUiLoader *uiLoader,
- QGraphicsItem *parent)
- : HbDialog( parent )
- , mUiLoader( uiLoader )
- , mTypeOfSelection( -1 )
- , mHeading( 0 )
- , mCheckboxContainer( 0 )
- , mItemCount( 0 )
- , mCheckBoxText( 0 )
- , mCheckBox( 0 )
- , mListContainer( 0 )
- , mForcedCheck( false )
+VideoListSelectionDialog::VideoListSelectionDialog( QGraphicsItem *parent)
+ : HbSelectionDialog( parent )
+ , mTypeOfSelection( ENoFunction )
, mModel( 0 )
, mModelReady( false )
, mAlbumListReady( false )
- , mListWidget( 0 )
+ , mListInitialised( false )
, mPrimaryAction( 0 )
, mSecondaryAction( 0 )
+ , mScrollPositionTimer( 0 )
{
FUNC_LOG;
-
- HbStyleLoader::registerFilePath( ":/style/hbdialog.css" );
- setDismissPolicy(HbDialog::NoDismiss);
- setTimeout(HbDialog::NoTimeout);
-
- // create model for list widget
- mModel =
- VideoCollectionWrapper::instance().getGenericModel();
- if (mModel)
- {
- // create list widget
- mListWidget = new VideoListWidget(mUiLoader);
- if(mListWidget->initialize(*mModel) < 0)
- {
- ERROR(-1, "VideoListSelectionDialog::VideoListSelectionDialog() failed to init list widget");
- delete mListWidget;
- mListWidget = 0;
- }
- // disable list related animations to make dialog faster
- mListWidget->setEnabledAnimations(HbAbstractItemView::None);
- mListWidget->setObjectName(SELECTION_DIALOG_OBJECT_NAME_LIST_WIDGET);
- }
+ // create model and init list, this will create listview in HbSelectionDialog
+ mModel = VideoCollectionWrapper::instance().getGenericModel();
+ initList(0);
}
// ---------------------------------------------------------------------------
@@ -125,20 +101,21 @@
VideoListSelectionDialog::~VideoListSelectionDialog()
{
FUNC_LOG;
- HbStyleLoader::unregisterFilePath( ":/style/hbdialog.css" );
- delete mListWidget;
- mListWidget = 0;
+
+ delete mScrollPositionTimer;
+ delete mPrimaryAction;
+ delete mSecondaryAction;
}
// ---------------------------------------------------------------------------
// setupContent
// ---------------------------------------------------------------------------
//
-void VideoListSelectionDialog::setupContent(int type, TMPXItemId activeItem)
+void VideoListSelectionDialog::setupContent(VideoListSelectionDialog::TSelectionFunction type, TMPXItemId activeItem)
{
FUNC_LOG;
INFO_1("VideoListSelectionDialog::setupContent() type: %d", type);
- if(type < EDeleteVideos || type > ESelectCollection)
+ if(type == ENoFunction)
{
return;
}
@@ -149,7 +126,6 @@
ERROR(-1, "VideoListSelectionDialog::setupContent() dialog init failed.");
return;
}
- mSelection.clear();
mSelectedVideos.clear();
mSelectedAlbumId = TMPXItemId::InvalidId();
mNewAlbumText = QString();
@@ -194,84 +170,174 @@
return false;
}
}
- if (!mListContainer)
+
+ if(!mScrollPositionTimer)
{
- mListContainer =
- mUiLoader->findWidget<HbStackedWidget>(DOCML_NAME_LIST_CONTAINER);
-
- if(!mListWidget)
+ mScrollPositionTimer = new QTimer();
+ mScrollPositionTimer->setSingleShot(true);
+ }
+ return true;
+}
+
+// ---------------------------------------------------------------------------
+// initList
+// ---------------------------------------------------------------------------
+//
+bool VideoListSelectionDialog::initList(VideoProxyModelGeneric *model)
+{
+ FUNC_LOG;
+
+ setModel(model);
+
+ if(!mListInitialised)
+ {
+ HbWidget* content = static_cast<HbWidget*>(this->primitive("content"));
+ if(content)
{
- mListWidget = new VideoListWidget(mUiLoader);
- mListWidget->setObjectName(SELECTION_DIALOG_OBJECT_NAME_LIST_WIDGET);
- if(mListWidget->initialize(*mModel) < 0)
+ HbListView* view = static_cast<HbListView*>(content->primitive("list"));
+ if (view)
{
- ERROR(-1, "VideoListSelectionDialog::initDialog() failed to setup VideoListWidget.");
- delete mListWidget;
- mListWidget = 0;
- mListContainer = 0;
- return false;
+ HbListViewItem *prototype = view->listItemPrototype();
+ if(prototype)
+ {
+ prototype->setGraphicsSize(HbListViewItem::WideThumbnail);
+ }
+ view->setItemRecycling(true);
+ view->setClampingStyle(HbScrollArea::BounceBackClamping);
+ view->setScrollingStyle(HbScrollArea::PanWithFollowOn);
+ view->setFrictionEnabled(true);
+ view->setUniformItemSizes(true);
+ view->setSelectionMode(HbAbstractItemView::NoSelection);
+ view->setItemPixmapCacheEnabled(true);
+ view->setEnabledAnimations(HbAbstractItemView::None);
+
+ mListInitialised = true;
}
}
- if(mListContainer)
- {
- mListContainer->addWidget(mListWidget);
- }
}
-
- if(!mHeading)
- {
- mHeading = mUiLoader->findWidget<HbLabel>(DOCML_NAME_DLG_HEADINGLBL);
- }
- if(!mCheckboxContainer)
- {
- mCheckboxContainer = mUiLoader->findWidget<HbWidget>(DOCML_NAME_CHECK_CONTAINER);
- }
- if(!mItemCount)
- {
- mItemCount = mUiLoader->findWidget<HbLabel>(DOCML_NAME_LBL_SELECTION);
- mItemCount->setAlignment(Qt::AlignRight);
- }
- if(!mCheckBox)
- {
- mCheckBox = mUiLoader->findWidget<HbCheckBox >(DOCML_NAME_MARKALL);
- }
-
- if(!mCheckBoxText)
- {
- mCheckBoxText = mUiLoader->findWidget<HbLabel >(DOCML_NAME_LBL_MARKALL);
- }
-
- // HbDialog connects actions to finished signal by default.
- if(!mPrimaryAction)
- {
- mPrimaryAction = new HbAction(hbTrId("txt_common_button_ok"));
- mPrimaryAction->setObjectName(SELECTION_DIALOG_OBJECT_NAME_BUTTON_OK);
- addAction(mPrimaryAction);
- }
- if(!mSecondaryAction)
- {
- mSecondaryAction = new HbAction(hbTrId("txt_common_button_cancel"));
- mSecondaryAction->setObjectName(SELECTION_DIALOG_OBJECT_NAME_BUTTON_CANCEL);
- addAction(mSecondaryAction);
- }
-
- if(!mListContainer || !mHeading || !mCheckBox || !mCheckBoxText)
- {
- ERROR(-1, "VideoListSelectionDialog::initDialog() !mListContainer || !mHeading || !mCheckBox || !mCheckBoxText");
- return false;
- }
- return true;
+ return mListInitialised;
}
// ---------------------------------------------------------------------------
// activateSelection
// ---------------------------------------------------------------------------
//
-void VideoListSelectionDialog::activateSelection()
+void VideoListSelectionDialog::activateSelection(bool changeMode)
{
FUNC_LOG;
+ QString headingTxt("");
+ QString primaryTxt("");
+ // create texts
+ switch(mTypeOfSelection)
+ {
+ case EDeleteVideos:
+ primaryTxt = hbTrId("txt_common_button_delete");
+ headingTxt = hbTrId("txt_videos_title_delete_videos");
+ break;
+ case EAddToCollection:
+ primaryTxt = hbTrId("txt_common_button_add");
+ headingTxt = hbTrId("txt_videos_title_add_videos");
+ break;
+ case ECreateCollection:
+ primaryTxt = hbTrId("txt_common_button_ok");
+ headingTxt = hbTrId("txt_videos_title_add_videos");
+ break;
+ case ERemoveFromCollection:
+ primaryTxt = hbTrId("txt_common_button_remove");
+ headingTxt = hbTrId("txt_videos_title_remove_videos");
+ break;
+ case ESelectCollection:
+ primaryTxt = hbTrId("txt_videos_button_new");
+ headingTxt = hbTrId("txt_videos_title_select_collection");
+ break;
+ default:
+ break;
+ }
+
+ mModelReady = false;
+ mAlbumListReady = false;
+ setModel(0);
+
+ if(mTypeOfSelection == ESelectCollection)
+ {
+ mModel->open(VideoCollectionCommon::ELevelCategory);
+ VideoCollectionViewUtils::sortModel(mModel, false, VideoCollectionCommon::ELevelCategory);
+
+ setModel(mModel);
+ setSelectionMode(HbAbstractItemView::NoSelection);
+
+ if(changeMode)
+ {
+ removeAction(mSecondaryAction);
+ if(!mPrimaryAction)
+ {
+ mPrimaryAction = new HbAction();
+ mPrimaryAction->setObjectName(SELECTION_DIALOG_OBJECT_NAME_BUTTON_OK);
+ addAction(mPrimaryAction);
+ }
+ // New collection button is always enabled for collection selection.
+ mPrimaryAction->setDisabled(false);
+ }
+ else
+ {
+ clearActions();
+
+ if(!mPrimaryAction)
+ {
+ mPrimaryAction = new HbAction(primaryTxt);
+ mPrimaryAction->setObjectName(SELECTION_DIALOG_OBJECT_NAME_BUTTON_OK);
+ }
+ else
+ {
+ mPrimaryAction->setText(primaryTxt);
+ }
+ addAction(mPrimaryAction);
+
+ if(!mSecondaryAction)
+ {
+ mSecondaryAction = new HbAction(hbTrId("txt_common_button_cancel"));
+ mSecondaryAction->setObjectName(SELECTION_DIALOG_OBJECT_NAME_BUTTON_CANCEL);
+ }
+ addAction(mSecondaryAction);
+
+ // New collection button is always enabled for collection selection.
+ mPrimaryAction->setDisabled(false);
+ }
+ }
+ else
+ {
+ mModel->open(VideoCollectionCommon::ELevelVideos);
+ VideoCollectionViewUtils::sortModel(mModel, false, VideoCollectionCommon::ELevelVideos);
+
+ setModel(mModel);
+ setSelectionMode(HbAbstractItemView::MultiSelection);
+ clearActions();
+
+ if(!mPrimaryAction)
+ {
+ mPrimaryAction = new HbAction(primaryTxt);
+ mPrimaryAction->setObjectName(SELECTION_DIALOG_OBJECT_NAME_BUTTON_OK);
+ }
+ else
+ {
+ mPrimaryAction->setText(primaryTxt);
+ }
+ addAction(mPrimaryAction);
+
+ // Add button will be enabled when videos are selected from the list.
+ mPrimaryAction->setDisabled(mTypeOfSelection != ECreateCollection);
+
+ if(!mSecondaryAction)
+ {
+ mSecondaryAction = new HbAction(hbTrId("txt_common_button_cancel"));
+ mSecondaryAction->setObjectName(SELECTION_DIALOG_OBJECT_NAME_BUTTON_CANCEL);
+ }
+ addAction(mSecondaryAction);
+ }
+ setHeadingText(headingTxt);
+
// "add to collection", "remove from collection" and "create collection" -selections
- // needs additional functionality for primary key
+ // needs additional functionality for primary key
if(mTypeOfSelection == EAddToCollection ||
mTypeOfSelection == ERemoveFromCollection ||
mTypeOfSelection == ECreateCollection)
@@ -279,60 +345,6 @@
mPrimaryAction->disconnect(SIGNAL(triggered()));
connect(mPrimaryAction, SIGNAL(triggered()), this, SLOT(primaryActionTriggeredSlot()));
}
- QString headingTxt("");
- QString primaryTxt("");
- // create texts
- switch(mTypeOfSelection)
- {
- case EDeleteVideos:
- primaryTxt = hbTrId("txt_common_button_delete");
- break;
- case EAddToCollection:
- primaryTxt = hbTrId("txt_common_button_add");
- break;
- case ECreateCollection:
- primaryTxt = hbTrId("txt_common_button_ok");
- break;
- case ERemoveFromCollection:
- primaryTxt = hbTrId("txt_common_button_remove");
- break;
- case ESelectCollection:
- primaryTxt = hbTrId("txt_videos_button_new");
- break;
- default:
- break;
- }
-
- mPrimaryAction->setText(primaryTxt);
-
- mModelReady = false;
- mAlbumListReady = false;
-
- if(mTypeOfSelection == ESelectCollection)
- {
- headingTxt = hbTrId("txt_videos_title_select_collection");
- mCheckboxContainer->setVisible(false);
- mListWidget->setSelectionMode(-1);
- mListWidget->activate(VideoCollectionCommon::ELevelCategory);
- // New collection button is always enabled for collection selection.
- mPrimaryAction->setDisabled(false);
- }
- else
- {
- headingTxt = hbTrId("txt_videos_title_select_videos");
- mListWidget->setSelectionMode(HbAbstractItemView::MultiSelection);
- mListWidget->activate(VideoCollectionCommon::ELevelVideos);
- mCheckboxContainer->setVisible(true);
- mItemCount->setPlainText(tr("0/%1").arg(mModel->rowCount()));
- mCheckBox->setChecked(false);
-
- // Add button will be enabled when videos are selected from the list.
- mPrimaryAction->setDisabled(mTypeOfSelection != ECreateCollection);
- }
- mHeading->setPlainText(headingTxt);
- // sort to make sure dialog has correctly filtered content
- // at the same order as in view
- VideoCollectionViewUtils::sortModel(mModel, false, mListWidget->getLevel());
}
// ---------------------------------------------------------------------------
@@ -342,15 +354,8 @@
void VideoListSelectionDialog::exec()
{
FUNC_LOG;
- // clear checkbox
- mCheckBox->setChecked(false);
-
- mListWidget->clearSelection();
-
- // scroll list back to top
- mListWidget->scrollTo(mModel->index(0, 0));
-
- connectSignals();
+
+ connectSignals();
if(mTypeOfSelection == ECreateCollection)
{
@@ -361,7 +366,9 @@
else if(mModel->rowCount())
{
// show dialog
- HbDialog::open();
+ VideoThumbnailData::instance().enableBackgroundFetching(true);
+ fetchThumbnailsForVisibleItems();
+ HbSelectionDialog::open();
}
else if((mModelReady && mTypeOfSelection != ESelectCollection) ||
(mAlbumListReady && mTypeOfSelection == ESelectCollection))
@@ -380,10 +387,37 @@
{
FUNC_LOG;
disconnectSignals();
- if(action == mSecondaryAction)
+ if(mScrollPositionTimer)
+ {
+ if(mScrollPositionTimer->isActive())
+ {
+ mScrollPositionTimer->stop();
+ }
+ delete mScrollPositionTimer;
+ mScrollPositionTimer = 0;
+ }
+ if(action != mPrimaryAction)
{
- INFO("VideoListSelectionDialog::exec(): secondary action triggered.")
- return;
+ if(mTypeOfSelection == ESelectCollection)
+ {
+ QModelIndexList selection = selectedModelIndexes();
+ int count(selection.count());
+
+ if((count == 1) && (selection.at(0).isValid()))
+ {
+ mSelectedAlbumId = mModel->getMediaIdAtIndex(selection.at(0));
+ }
+ else
+ {
+ INFO("VideoListSelectionDialog::exec(): secondary action triggered.")
+ return;
+ }
+ }
+ else
+ {
+ INFO("VideoListSelectionDialog::exec(): secondary action triggered.")
+ return;
+ }
}
if(mTypeOfSelection == ESelectCollection)
@@ -430,7 +464,9 @@
{
mNewAlbumText = text;
// show video selection dialog
- HbDialog::open();
+ VideoThumbnailData::instance().enableBackgroundFetching(true);
+ fetchThumbnailsForVisibleItems();
+ HbSelectionDialog::open();
}
else
{
@@ -457,6 +493,8 @@
//
void VideoListSelectionDialog::finalize(QString albumName)
{
+ close();
+
// Must be checked again if type was ESelectCollection
if(mTypeOfSelection == EAddToCollection ||
mTypeOfSelection == ECreateCollection)
@@ -501,64 +539,37 @@
// user is deleting videos
else if(mTypeOfSelection == EDeleteVideos)
{
- QVariant data = mSelection.indexes().count();
+ QModelIndexList selection = selectedModelIndexes();
+ QVariant data = selection.count();
+
VideoCollectionViewUtils::instance().showStatusMsgSlot(
VideoCollectionCommon::statusDeleteInProgress,
data);
- // delete items
- mModel->deleteItems(mSelection.indexes());
- }
-}
-
-// ---------------------------------------------------------------------------
-// markAllStateChanged
-// ---------------------------------------------------------------------------
-//
-void VideoListSelectionDialog::markAllStateChangedSlot(int state)
-{
- FUNC_LOG;
- if(mForcedCheck)
- {
- return;
+ // delete items
+ mModel->deleteItems(selection);
}
- if(state == Qt::Checked)
- {
- mListWidget->selectAll();
- }
- else
- {
- mListWidget->clearSelection();
- }
}
// ---------------------------------------------------------------------------
// selectionChangedSlot
// ---------------------------------------------------------------------------
//
-void VideoListSelectionDialog::selectionChangedSlot(const QItemSelection &selected, const QItemSelection &deselected)
-{
- FUNC_LOG;
+void VideoListSelectionDialog::selectionChangedSlot()
+{
+ FUNC_LOG;
if(!mPrimaryAction || mTypeOfSelection == ESelectCollection)
{
INFO("VideoListSelectionDialog::selectionChangedSlot(): no primary action or we are selecting collection.")
return;
}
-
- if(selected.indexes().count() > 0)
- {
- mSelection.merge(selected, QItemSelectionModel::Select);
- }
-
- if(deselected.indexes().count() > 0)
- {
- mSelection.merge(deselected, QItemSelectionModel::Deselect);
- }
-
- if(mSelection.indexes().count() > 0)
+
+ QModelIndexList selected(selectedModelIndexes());
+
+ if(selected.count() > 0)
{
mPrimaryAction->setDisabled(false);
-
if(mTypeOfSelection == ECreateCollection)
+
{
mPrimaryAction->setText(hbTrId("txt_common_button_add"));
}
@@ -571,25 +582,6 @@
{
mPrimaryAction->setText(hbTrId("txt_common_button_ok"));
}
- }
-
- updateCounterSlot();
-}
-
-// ---------------------------------------------------------------------------
-// singleItemSelectedSlot
-// ---------------------------------------------------------------------------
-//
-void VideoListSelectionDialog::singleItemSelectedSlot(const QModelIndex &index)
-{
- FUNC_LOG;
- if(mTypeOfSelection == ESelectCollection)
- {
- if(index.isValid())
- {
- mSelectedAlbumId = mModel->getMediaIdAtIndex(index);
- mPrimaryAction->trigger();
- }
}
}
@@ -618,21 +610,15 @@
{
finishedSlot(mPrimaryAction);
}
-
return;
}
// if dialog is not yet visible, bring it visible.
if(!isVisible() && mTypeOfSelection != ECreateCollection)
{
- // scroll list back to top
- mListWidget->scrollTo(mModel->index(0, 0));
-
- HbDialog::open();
+ HbSelectionDialog::open();
}
-
- updateCounterSlot();
- }
+ }
}
// ---------------------------------------------------------------------------
@@ -650,48 +636,19 @@
finishedSlot(mPrimaryAction);
return;
}
-
+ else
+ {
+ mPrimaryAction->setText(hbTrId("txt_videos_button_new"));
+ }
// if dialog is not yet visible, bring it visible.
if(!isVisible())
{
- // scroll list back to top
- mListWidget->scrollTo(mModel->index(0, 0));
-
- HbDialog::open();
+ HbSelectionDialog::open();
}
-
- updateCounterSlot();
}
}
// ---------------------------------------------------------------------------
-// updateCounterSlot
-// ---------------------------------------------------------------------------
-//
-void VideoListSelectionDialog::updateCounterSlot()
-{
- FUNC_LOG;
- if(!mItemCount)
- {
- return;
- }
-
- int rowCount = mModel->rowCount();
- int selectionCount = mSelection.indexes().count();
- mItemCount->setPlainText(tr("%1/%2").arg(selectionCount).arg(rowCount));
- mForcedCheck = true;
- if(selectionCount == rowCount && rowCount > 0)
- {
- mCheckBox->setChecked(true);
- }
- else
- {
- mCheckBox->setChecked(false);
- }
- mForcedCheck = false;
-}
-
-// ---------------------------------------------------------------------------
// primaryActionTriggeredSlot
// ---------------------------------------------------------------------------
//
@@ -703,7 +660,7 @@
connect(mPrimaryAction, SIGNAL(triggered()), this, SLOT(close()));
// update video items selection here before content changes.
- QModelIndexList indexes = mSelection.indexes();
+ QModelIndexList indexes = selectedModelIndexes();
int count = indexes.count();
TMPXItemId id = TMPXItemId::InvalidId();
for(int i = 0; i < count; ++i)
@@ -728,8 +685,8 @@
// videos for collection selected, but collection
// not yet selected, activate selection for it
mTypeOfSelection = ESelectCollection;
- activateSelection();
- }
+ activateSelection(true);
+ }
}
// ---------------------------------------------------------------------------
@@ -741,23 +698,31 @@
FUNC_LOG;
// dialog finished
connect(this, SIGNAL(finished(HbAction*)), this, SLOT(finishedSlot(HbAction*)));
-
- // selection changes
- connect(mListWidget, SIGNAL(activated(const QModelIndex&)),
- this, SLOT(singleItemSelectedSlot(const QModelIndex&)));
-
- connect(mListWidget->selectionModel(), SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)),
- this, SLOT(selectionChangedSlot(const QItemSelection&, const QItemSelection &)));
+
+ //selection changes
+ connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedSlot()));
// model changes signals
connect(mModel->sourceModel(), SIGNAL(modelReady()), this, SLOT(modelReadySlot()));
connect(mModel->sourceModel(), SIGNAL(albumListReady()), this, SLOT(albumListReadySlot()));
- connect(mModel->sourceModel(), SIGNAL(modelChanged()), this, SLOT(updateCounterSlot()));
-
- // mark all state changes
- connect(mCheckBox, SIGNAL(stateChanged(int)), this, SLOT(markAllStateChangedSlot(int)));
+
+ connect(mScrollPositionTimer, SIGNAL(timeout()), this, SLOT(scrollPositionTimerSlot()));
+
+ HbWidget* content = static_cast<HbWidget*>(this->primitive("content"));
+ HbListView* view(0);
+ if(content)
+ {
+ view = static_cast<HbListView*>(content->primitive("list"));
+ if (view)
+ {
+ connect(view, SIGNAL(scrollingEnded()), this, SLOT(scrollingEndedSlot()));
+ connect(view, SIGNAL(scrollingStarted()), this, SLOT(scrollingStartedSlot()));
+ connect(view, SIGNAL(scrollPositionChanged(const QPointF &)),
+ this, SLOT(scrollPositionChangedSlot(const QPointF &)));
+ }
+ }
}
-
+
// ---------------------------------------------------------------------------
// disconnectSignals
// ---------------------------------------------------------------------------
@@ -766,20 +731,35 @@
{
FUNC_LOG;
disconnect(this, SIGNAL(finished(HbAction*)), this, SLOT(finishedSlot(HbAction*)));
-
- disconnect(mListWidget, SIGNAL(activated(const QModelIndex&)),
- this, SLOT(singleItemSelectedSlot(const QModelIndex&)));
-
- disconnect(mListWidget->selectionModel(), SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)),
- this, SLOT(selectionChangedSlot(const QItemSelection&, const QItemSelection &)));
+
+ //selection changes
+ disconnect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedSlot()));
// model changes signals
- disconnect(mModel->sourceModel(), SIGNAL(modelReady()), this, SLOT(modelReadySlot()));
+ disconnect(mModel->sourceModel(), SIGNAL(modelReady()), this, SLOT(modelReadySlot()));
disconnect(mModel->sourceModel(), SIGNAL(albumListReady()), this, SLOT(albumListReadySlot()));
- disconnect(mModel->sourceModel(), SIGNAL(modelChanged()), this, SLOT(updateCounterSlot()));
-
- // mark all state changes
- disconnect(mCheckBox, SIGNAL(stateChanged(int)), this, SLOT(markAllStateChangedSlot(int)));
+
+ // check that scroll position timer is created
+ if (mScrollPositionTimer)
+ {
+ disconnect(
+ mScrollPositionTimer, SIGNAL(timeout()),
+ this, SLOT(scrollPositionTimerSlot()));
+ }
+
+ HbWidget* content = static_cast<HbWidget*>(this->primitive("content"));
+ HbListView* view(0);
+ if(content)
+ {
+ view = static_cast<HbListView*>(content->primitive("list"));
+ if (view)
+ {
+ disconnect(view, SIGNAL(scrollingEnded()), this, SLOT(scrollingEndedSlot()));
+ disconnect(view, SIGNAL(scrollingStarted()), this, SLOT(scrollingStartedSlot()));
+ disconnect(view, SIGNAL(scrollPositionChanged(const QPointF &)),
+ this, SLOT(scrollPositionChangedSlot(const QPointF &)));
+ }
+ }
}
// ---------------------------------------------------------------------------
@@ -792,8 +772,8 @@
QString name;
if(mSelectedAlbumId.iId2 > KVcxMvcMediaTypeVideo)
{
- VideoProxyModelGeneric *model =
- VideoCollectionWrapper::instance().getGenericModel();
+ VideoProxyModelGeneric *model = VideoCollectionWrapper::instance().getGenericModel();
+
if(!model)
{
return name;
@@ -807,4 +787,93 @@
return name;
}
+// ---------------------------------------------------------------------------
+// scrollingStartedSlot
+// ---------------------------------------------------------------------------
+//
+void VideoListSelectionDialog::scrollingStartedSlot()
+{
+ FUNC_LOG_ADDR(this);
+ VideoThumbnailData::instance().enableThumbnailCreation(false);
+}
+
+// ---------------------------------------------------------------------------
+// scrollingEndedSlot
+// ---------------------------------------------------------------------------
+//
+void VideoListSelectionDialog::scrollingEndedSlot()
+{
+ FUNC_LOG_ADDR(this);
+
+ if(mScrollPositionTimer)
+ {
+ mScrollPositionTimer->stop();
+ }
+
+ VideoThumbnailData::instance().enableBackgroundFetching(true);
+ VideoThumbnailData::instance().enableThumbnailCreation(true);
+ fetchThumbnailsForVisibleItems();
+}
+
+// ---------------------------------------------------------------------------
+// scrollPositionChangedSlot
+// ---------------------------------------------------------------------------
+//
+void VideoListSelectionDialog::scrollPositionChangedSlot(const QPointF &newPosition)
+{
+ Q_UNUSED(newPosition);
+
+ if(mScrollPositionTimer && !mScrollPositionTimer->isActive())
+ mScrollPositionTimer->start(SCROLL_POSITION_TIMER_TIMEOUT);
+}
+
+// ---------------------------------------------------------------------------
+// scrollPositionTimerSlot
+// ---------------------------------------------------------------------------
+//
+void VideoListSelectionDialog::scrollPositionTimerSlot()
+{
+ FUNC_LOG_ADDR(this);
+
+ fetchThumbnailsForVisibleItems();
+}
+
+// ---------------------------------------------------------------------------
+// fetchThumbnailsForVisibleItems
+// ---------------------------------------------------------------------------
+//
+void VideoListSelectionDialog::fetchThumbnailsForVisibleItems()
+{
+ FUNC_LOG_ADDR(this);
+
+ // No need to do anything if thumbnail fetching is not enabled.
+ if(!VideoThumbnailData::instance().backgroundFetchingEnabled())
+ {
+ return;
+ }
+ HbWidget* content = static_cast<HbWidget*>(this->primitive("content"));
+ HbListView* view(0);
+ if(content)
+ {
+ view = static_cast<HbListView*>(content->primitive("list"));
+ if (!view)
+ {
+ return;
+ }
+ }
+
+ const QList<HbAbstractViewItem *> itemsVisible = view->visibleItems();
+
+ if(itemsVisible.count() > 0)
+ {
+ int row = itemsVisible.value(0)->modelIndex().row();
+ VideoThumbnailData::instance().startBackgroundFetching(mModel, row);
+ }
+ else
+ {
+ // Nothing visible yet, start from first index.
+ VideoThumbnailData::instance().startBackgroundFetching(mModel, 0);
+ }
+}
+
// End of file