--- a/videocollection/videocollectionview/src/videolistview.cpp Tue Jul 06 14:17:50 2010 +0300
+++ b/videocollection/videocollectionview/src/videolistview.cpp Wed Aug 18 09:50:14 2010 +0300
@@ -15,7 +15,7 @@
*
*/
-// Version : %version: 113 %
+// Version : %version: 113.1.5 %
// INCLUDE FILES
#include <xqserviceutil.h>
@@ -32,6 +32,8 @@
#include <hbgroupbox.h>
#include <hbpushbutton.h>
#include <hbinputdialog.h>
+#include <hbparameterlengthlimiter.h>
+#include <hbtoolbarextension.h>
#include <vcxmyvideosdefs.h>
#include "videoservices.h"
@@ -45,10 +47,13 @@
#include "videosortfilterproxymodel.h"
#include "videocollectionuiloader.h"
#include "mpxhbvideocommondefs.h"
+#include "videooperatorservice.h"
+#include "videocollectioncenrepdefs.h"
#include "videocollectiontrace.h"
// Object names.
const char* const LIST_VIEW_OBJECT_NAME_OPTIONS_MENU = "vc::ListViewOptionsMenu";
+const char* const LIST_VIEW_OBJECT_NAME_TOOLBAR_EXTENSION = "vc::ListViewToolbarExtension";
// ---------------------------------------------------------------------------
// Constructor
@@ -66,6 +71,7 @@
, mCurrentList( 0 )
, mToolbarViewsActionGroup( 0 )
, mToolbarCollectionActionGroup( 0 )
+ , mToolbarServiceExtension( 0 )
{
FUNC_LOG;
}
@@ -83,11 +89,22 @@
mToolbarActions.clear();
mSortingRoles.clear();
+ delete mToolbarServiceExtension;
+ mToolbarServiceExtension = 0;
+
if(mVideoServices)
{
mVideoServices->decreaseReferenceCount();
mVideoServices = 0;
}
+
+ QList<VideoOperatorService *>::const_iterator iter = mVideoOperatorServices.constBegin();
+ while(iter != mVideoOperatorServices.constEnd())
+ {
+ delete *iter;
+ iter++;
+ }
+ mVideoOperatorServices.clear();
}
// ---------------------------------------------------------------------------
@@ -147,6 +164,7 @@
params.append(VideoCollectionUiLoaderParam(
DOCML_NAME_VC_VIDEOLISTWIDGET,
DOCML_VIDEOCOLLECTIONVIEW_FILE,
+ DOCML_VIDEOCOLLECTIONVIEW_SECTION_LIST,
true,
videoListPhase));
@@ -257,8 +275,6 @@
DOCML_NAME_VC_COLLECTIONWIDGET );
}
-
-
return 0;
}
@@ -334,7 +350,10 @@
this, SLOT(layoutChangedSlot())) ||
!connect(
mCurrentList->getModel()->sourceModel(), SIGNAL(modelReady()),
- this, SLOT(modelReadySlot())))
+ this, SLOT(modelReadySlot())) ||
+ !connect(
+ mCurrentList->getModel()->sourceModel(), SIGNAL(albumListReady()),
+ this, SLOT(albumListReadySlot())))
{
ERROR(-1, "VideoListView::activateView() failed to connect signals.");
// deactivate view so we get rid of dangling connections.
@@ -372,20 +391,28 @@
{
FUNC_LOG;
- // if mModelReady is false, then it means that this is the first time modelReady
- // signal fires. Signaling that view is ready.
- if(!mViewReady)
+ // check that current list is all videos or collection content.
+ VideoCollectionCommon::TCollectionLevels level = mCurrentList->getLevel();
+ if(level != VideoCollectionCommon::ELevelCategory)
{
- mViewReady = true;
- emit viewReady();
+ modelReady();
}
-
- mModelReady = true;
+}
+
+// ---------------------------------------------------------------------------
+// albumListReadySlot
+// ---------------------------------------------------------------------------
+//
+void VideoListView::albumListReadySlot()
+{
+ FUNC_LOG;
- // since the reset signal arrives after
- // layout changed, need to make sure that
- // view is updated in case needed
- layoutChangedSlot();
+ // check that current list is category list.
+ VideoCollectionCommon::TCollectionLevels level = mCurrentList->getLevel();
+ if(level == VideoCollectionCommon::ELevelCategory)
+ {
+ modelReady();
+ }
}
// ---------------------------------------------------------------------------
@@ -457,6 +484,30 @@
}
// ---------------------------------------------------------------------------
+// modelReady()
+// ---------------------------------------------------------------------------
+//
+void VideoListView::modelReady()
+{
+ FUNC_LOG;
+
+ // if mViewReady is false, then it means that this is the first time
+ // modelReady or albumListReady signal fires. Signaling that view is ready.
+ if(!mViewReady)
+ {
+ mViewReady = true;
+ emit viewReady();
+ }
+
+ mModelReady = true;
+
+ // since the reset signal arrives after
+ // layout changed, need to make sure that
+ // view is updated in case needed
+ layoutChangedSlot();
+}
+
+// ---------------------------------------------------------------------------
// cleanup()
// ---------------------------------------------------------------------------
//
@@ -500,9 +551,10 @@
if (!mVideoServices)
{
- // Services tab
- mToolbarActions[ETBActionServices] = createAction("qtg_mono_ovistore",
- mToolbarViewsActionGroup, SLOT(openServicesViewSlot()));
+ // Create services button or toolbar extension depending how many operator
+ // services are configured.
+ createOperatorServicesToolbar();
+
// Add Videos tab
mToolbarActions[ETBActionAddVideos] =
createAction("qtg_mono_add_to_video_collection",
@@ -519,14 +571,12 @@
if( !bar
|| !mToolbarActions[ETBActionAllVideos]
|| !mToolbarActions[ETBActionCollections]
- || ( !mVideoServices && (!mToolbarActions[ETBActionServices]
- || !mToolbarActions[ETBActionAddVideos]
- || !mToolbarActions[ETBActionRemoveVideos])))
+ || ( !mVideoServices && (!mToolbarActions[ETBActionAddVideos]
+ || !mToolbarActions[ETBActionRemoveVideos])))
{
ERROR(-1, "VideoListView::createToolbar() failed to create all actions or the toolbar.");
delete mToolbarActions[ETBActionAllVideos];
delete mToolbarActions[ETBActionCollections];
- delete mToolbarActions[ETBActionServices];
delete mToolbarActions[ETBActionAddVideos];
delete mToolbarActions[ETBActionRemoveVideos];
return -1;
@@ -536,7 +586,7 @@
mToolbarActions[ETBActionAllVideos]->setCheckable(true);
mToolbarActions[ETBActionCollections]->setCheckable(true);
- if (!mVideoServices)
+ if(!mVideoServices && mToolbarActions[ETBActionServices])
{
mToolbarActions[ETBActionServices]->setCheckable(false);
}
@@ -559,13 +609,98 @@
{
bar->addActions(mToolbarCollectionActionGroup->actions());
}
-
+
+ if(mToolbarServiceExtension && (level == VideoCollectionCommon::ELevelCategory
+ || level == VideoCollectionCommon::ELevelVideos))
+ {
+ HbAction *action = bar->addExtension(mToolbarServiceExtension);
+ HbIcon icon("qtg_mono_video_services");
+ action->setIcon(icon);
+ }
}
return 0;
}
// ---------------------------------------------------------------------------
+// createOperatorServicesToolbar()
+// ---------------------------------------------------------------------------
+//
+void VideoListView::createOperatorServicesToolbar()
+{
+ FUNC_LOG;
+ if(mVideoOperatorServices.count() > 0)
+ {
+ return;
+ }
+
+ // Load services.
+
+ loadOperatorService(KVideoCollectionViewCenrepServiceItem1Title, KVideoCollectionViewCenrepServiceItem1ToolbarIconPath,
+ KVideoCollectionViewCenrepServiceItem1Url, KVideoCollectionViewCenrepServiceItem1Uid);
+
+ loadOperatorService(KVideoCollectionViewCenrepServiceItem2Title, KVideoCollectionViewCenrepServiceItem2ToolbarIconPath,
+ KVideoCollectionViewCenrepServiceItem2Url, KVideoCollectionViewCenrepServiceItem2Uid);
+
+ loadOperatorService(KVideoCollectionViewCenrepServiceItem3Title, KVideoCollectionViewCenrepServiceItem3ToolbarIconPath,
+ KVideoCollectionViewCenrepServiceItem3Url, KVideoCollectionViewCenrepServiceItem3Uid);
+
+ loadOperatorService(KVideoCollectionViewCenrepServiceItem4Title, KVideoCollectionViewCenrepServiceItem4ToolbarIconPath,
+ KVideoCollectionViewCenrepServiceItem4Url, KVideoCollectionViewCenrepServiceItem4Uid);
+
+ loadOperatorService(KVideoCollectionViewCenrepServiceItem5Title, KVideoCollectionViewCenrepServiceItem5ToolbarIconPath,
+ KVideoCollectionViewCenrepServiceItem5Url, KVideoCollectionViewCenrepServiceItem5Uid);
+
+ loadOperatorService(KVideoCollectionViewCenrepServiceItem6Title, KVideoCollectionViewCenrepServiceItem6ToolbarIconPath,
+ KVideoCollectionViewCenrepServiceItem6Url, KVideoCollectionViewCenrepServiceItem6Uid);
+
+ // Create toolbar extension when there's multiple services.
+ if(mVideoOperatorServices.count() > 1 && !mToolbarServiceExtension)
+ {
+ mToolbarServiceExtension = new HbToolBarExtension();
+ mToolbarServiceExtension->setObjectName(LIST_VIEW_OBJECT_NAME_TOOLBAR_EXTENSION);
+
+ QList<VideoOperatorService *>::const_iterator iter = mVideoOperatorServices.constBegin();
+ while(iter != mVideoOperatorServices.constEnd())
+ {
+ HbIcon icon((*iter)->iconResource());
+ HbAction *action = mToolbarServiceExtension->addAction(icon, (*iter)->title(),
+ (*iter), SLOT(launchService()));
+ action->setObjectName((*iter)->title());
+ iter++;
+ }
+ }
+
+ // Add toolbar button when there's only one service.
+ if(mVideoOperatorServices.count() == 1)
+ {
+ VideoOperatorService *service = mVideoOperatorServices[0];
+ mToolbarActions[ETBActionServices] = createAction(service->iconResource(),
+ mToolbarViewsActionGroup, 0 /*do not connect to any slot*/);
+ connect(mToolbarActions[ETBActionServices], SIGNAL(triggered()), service, SLOT(launchService()));
+ }
+}
+
+// ---------------------------------------------------------------------------
+// loadOperatorService()
+// ---------------------------------------------------------------------------
+//
+void VideoListView::loadOperatorService(int titleKey, int iconKey, int uriKey, int uidKey)
+{
+ FUNC_LOG;
+ VideoOperatorService *service = new VideoOperatorService();
+ if(service->load(titleKey, iconKey, uriKey, uidKey))
+ {
+ mVideoOperatorServices.append(service);
+ }
+ else
+ {
+ // Load failed, delete service data.
+ delete service;
+ }
+}
+
+// ---------------------------------------------------------------------------
// createAction()
// ---------------------------------------------------------------------------
//
@@ -578,13 +713,16 @@
HbIcon hbIcon(icon);
action->setIcon(hbIcon);
- if(!connect(action, SIGNAL(triggered()), this, slot)) {
- // actiongroup deletion deletes this also.
- // return 0 tells that there was a problem in creation to caller.
- delete action;
- return 0;
+ if(slot)
+ {
+ if(!connect(action, SIGNAL(triggered()), this, slot)) {
+ // actiongroup deletion deletes this also.
+ // return 0 tells that there was a problem in creation to caller.
+ delete action;
+ return 0;
+ }
}
-
+
return action;
}
@@ -712,7 +850,8 @@
}
else
{
- subLabel->setHeading(hbTrId("txt_videos_subtitle_1_l2").arg(mCollectionName).arg(itemCount));
+ QString text = HbParameterLengthLimiter(hbTrId("txt_videos_subtitle_1_l2")).arg(mCollectionName).arg(itemCount);
+ subLabel->setHeading(text);
}
}
}
@@ -904,13 +1043,17 @@
}
// ---------------------------------------------------------------------------
-// openservicesViewSlot()
+// openOperatorServiceSlot()
// ---------------------------------------------------------------------------
//
-void VideoListView::openServicesViewSlot()
+void VideoListView::openOperatorServiceSlot()
{
FUNC_LOG;
- debugNotImplementedYet();
+
+ if(mVideoOperatorServices.count() > 0)
+ {
+ mVideoOperatorServices[0]->launchService();
+ }
}
// ---------------------------------------------------------------------------
@@ -1302,32 +1445,20 @@
const TMPXItemId &collectionId)
{
FUNC_LOG;
-
- // clear toolbar actions.
- toolBar()->clearActions();
+
+ // update / clear collection name
+ mCollectionName = collection;
- VideoListWidget *collectionContentWidget =
- mUiLoader->findWidget<VideoListWidget>(
- DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
-
- if(!collectionContentWidget)
- {
- return;
- }
- // update collection specific information
- mCollectionName = collection;
-
- // disable collection content animations during widget change
- HbAbstractItemView::ItemAnimations animationState = collectionContentWidget->enabledAnimations();
- collectionContentWidget->setEnabledAnimations(HbAbstractItemView::None);
-
if(openingCollection)
{
- // open album view
- if (collectionId == TMPXItemId::InvalidId() || mCurrentList == collectionContentWidget)
+ VideoListWidget *collectionContentWidget =
+ mUiLoader->findWidget<VideoListWidget>(
+ DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
+ // open album view, mCurrentList might be NULL at this point
+ if (!collectionContentWidget || mCurrentList == collectionContentWidget)
{
- // no currentlist or currentlist is already collection content -list
- collectionContentWidget->setEnabledAnimations(animationState);
+ // collection widget cannot be loaded or
+ // currentlist is already collection content -list
return;
}
@@ -1344,18 +1475,21 @@
}
else
{
- collectionContentWidget->setEnabledAnimations(animationState);
return;
}
-
- // Start fetching content before changing.
+
VideoSortFilterProxyModel *model = collectionContentWidget->getModel();
if(!model)
{
// no model for content widget, cannot activate
- collectionContentWidget->setEnabledAnimations(animationState);
return;
}
+
+ // disable collection content animations during widget change
+ HbAbstractItemView::ItemAnimations animationState = collectionContentWidget->enabledAnimations();
+ collectionContentWidget->setEnabledAnimations(HbAbstractItemView::None);
+
+ // Start fetching content before changing list widget
model->openItem(collectionId);
// deactivat current widget.
@@ -1369,35 +1503,49 @@
mCurrentList->activate(level);
updateSubLabel();
-
- model->invalidate();
// update hint widget for correct content
mModelReady = model->rowCount() > 0;
setHintLevel(VideoHintWidget::Collection);
- // update toolbar for albums, default categories don't have one.
- if(level == VideoCollectionCommon::ELevelAlbum &&
+ // update toolbar for albums, default categories don't have one. Neither does services.
+ toolBar()->clearActions();
+ if(!mVideoServices && level == VideoCollectionCommon::ELevelAlbum &&
mToolbarCollectionActionGroup && 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);
}
else
{
+ // clear actions to make sure there is no wrong toolbar in case main
+ // toolbar actiongroup actiongroup is missing
+ toolBar()->clearActions();
// open collection view
- openCollectionViewSlot();
-
+ openCollectionViewSlot();
// update toolbar
if(mToolbarViewsActionGroup && mToolbarActions.contains(ETBActionCollections))
- {
+ {
toolBar()->addActions(mToolbarViewsActionGroup->actions());
mToolbarActions[ETBActionCollections]->setChecked(true);
+ setItemVisible(Hb::ToolBarItem, true);
+
+ if(mToolbarServiceExtension)
+ {
+ HbAction *action = toolBar()->addExtension(mToolbarServiceExtension);
+ HbIcon icon("qtg_mono_video_services");
+ action->setIcon(icon);
+ }
}
- }
- // restore animations for collection content widget
- collectionContentWidget->setEnabledAnimations(animationState);
+ }
if(!mVideoServices)
{
// save / clear collection related activity data
@@ -1454,7 +1602,7 @@
}
else if (name.compare(DOCML_NAME_HINT_BUTTON) == 0)
{
- connect(object, SIGNAL(clicked(bool)), this, SLOT(openServicesViewSlot()));
+ connect(object, SIGNAL(clicked(bool)), this, SLOT(openOperatorServiceSlot()));
}
else if (name.compare(DOCML_NAME_SORT_BY_DATE) == 0)
{