videocollection/videocollectionview/src/videolistview.cpp
author hgs
Thu, 01 Apr 2010 23:32:44 +0300
changeset 35 3738fe97f027
parent 34 bbb98528c666
child 36 8aed59de29f9
permissions -rw-r--r--
201011
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:   Videolist view class source code
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
#include <xqserviceutil.h>
hgs
parents:
diff changeset
    19
#include <QActionGroup>
hgs
parents:
diff changeset
    20
#include <hbinstance.h>
hgs
parents:
diff changeset
    21
#include <hbmainwindow.h>
hgs
parents:
diff changeset
    22
#include <hbmessagebox.h>
hgs
parents:
diff changeset
    23
#include <hbstackedwidget.h>
hgs
parents:
diff changeset
    24
#include <hbstackedlayout.h>
hgs
parents:
diff changeset
    25
#include <hblistwidget.h>
hgs
parents:
diff changeset
    26
#include <hbtoolbar.h>
hgs
parents:
diff changeset
    27
#include <hbaction.h>
hgs
parents:
diff changeset
    28
#include <hbmenu.h>
hgs
parents:
diff changeset
    29
#include <hbgroupbox.h>
hgs
parents:
diff changeset
    30
#include <hbpushbutton.h>
34
hgs
parents: 30
diff changeset
    31
#include <hbinputdialog.h>
hgs
parents: 30
diff changeset
    32
#include <vcxmyvideosdefs.h>
30
hgs
parents:
diff changeset
    33
hgs
parents:
diff changeset
    34
#include "videoservices.h"
hgs
parents:
diff changeset
    35
#include "videolistselectiondialog.h"
hgs
parents:
diff changeset
    36
#include "videocollectionviewutils.h"
hgs
parents:
diff changeset
    37
#include "videolistwidget.h"
hgs
parents:
diff changeset
    38
#include "videohintwidget.h"
hgs
parents:
diff changeset
    39
#include "videolistview.h"
hgs
parents:
diff changeset
    40
#include "videocollectioncommon.h"
hgs
parents:
diff changeset
    41
#include "videocollectionwrapper.h"
hgs
parents:
diff changeset
    42
#include "videosortfilterproxymodel.h"
hgs
parents:
diff changeset
    43
#include "videocollectionuiloader.h"
35
hgs
parents: 34
diff changeset
    44
#include "mpxhbvideocommondefs.h"
30
hgs
parents:
diff changeset
    45
hgs
parents:
diff changeset
    46
// remove these
hgs
parents:
diff changeset
    47
#include <QDebug>
hgs
parents:
diff changeset
    48
hgs
parents:
diff changeset
    49
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    50
// Constructor
hgs
parents:
diff changeset
    51
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    52
//
hgs
parents:
diff changeset
    53
VideoListView::VideoListView(VideoCollectionUiLoader *uiLoader, QGraphicsItem *parent) :
hgs
parents:
diff changeset
    54
HbView(parent),
hgs
parents:
diff changeset
    55
mUiUtils(VideoCollectionViewUtils::instance()),
hgs
parents:
diff changeset
    56
mWrapper(VideoCollectionWrapper::instance()),
hgs
parents:
diff changeset
    57
mUiLoader(uiLoader),
hgs
parents:
diff changeset
    58
mIsService(false),
35
hgs
parents: 34
diff changeset
    59
mHintLoaded(false),
hgs
parents: 34
diff changeset
    60
mListsLoaded(false),
hgs
parents: 34
diff changeset
    61
mMultiselectionLoaded(false),
30
hgs
parents:
diff changeset
    62
mModelReady(false),
35
hgs
parents: 34
diff changeset
    63
mTransitionOngoing(false),
hgs
parents: 34
diff changeset
    64
mHintLevel(VideoHintWidget::AllVideos),
30
hgs
parents:
diff changeset
    65
mVideoServices(0),
34
hgs
parents: 30
diff changeset
    66
mCurrentList(0),
30
hgs
parents:
diff changeset
    67
mToolbarViewsActionGroup(0),
34
hgs
parents: 30
diff changeset
    68
mToolbarCollectionActionGroup(0)
30
hgs
parents:
diff changeset
    69
{
hgs
parents:
diff changeset
    70
    // NOP
hgs
parents:
diff changeset
    71
}
hgs
parents:
diff changeset
    72
hgs
parents:
diff changeset
    73
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    74
// Destructor
hgs
parents:
diff changeset
    75
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    76
//
hgs
parents:
diff changeset
    77
VideoListView::~VideoListView()
hgs
parents:
diff changeset
    78
{
hgs
parents:
diff changeset
    79
    qDebug() << "VideoListView::~VideoListView()";
34
hgs
parents: 30
diff changeset
    80
    
35
hgs
parents: 34
diff changeset
    81
    toolBar()->clearActions();
hgs
parents: 34
diff changeset
    82
    
30
hgs
parents:
diff changeset
    83
    mToolbarActions.clear();
hgs
parents:
diff changeset
    84
    mSortingRoles.clear();
hgs
parents:
diff changeset
    85
hgs
parents:
diff changeset
    86
    if(mVideoServices)
hgs
parents:
diff changeset
    87
    {
hgs
parents:
diff changeset
    88
    	mVideoServices->decreaseReferenceCount();
hgs
parents:
diff changeset
    89
    	mVideoServices = 0;
hgs
parents:
diff changeset
    90
    }
hgs
parents:
diff changeset
    91
}
hgs
parents:
diff changeset
    92
hgs
parents:
diff changeset
    93
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    94
// initializeView()
hgs
parents:
diff changeset
    95
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    96
//
hgs
parents:
diff changeset
    97
int VideoListView::initializeView()
hgs
parents:
diff changeset
    98
{
hgs
parents:
diff changeset
    99
	if(!mUiLoader)
hgs
parents:
diff changeset
   100
	{
34
hgs
parents: 30
diff changeset
   101
        cleanup();
30
hgs
parents:
diff changeset
   102
		return -1;
hgs
parents:
diff changeset
   103
	}
hgs
parents:
diff changeset
   104
hgs
parents:
diff changeset
   105
    if (XQServiceUtil::isService() && !mVideoServices)
hgs
parents:
diff changeset
   106
    {
hgs
parents:
diff changeset
   107
    	mIsService = true;
hgs
parents:
diff changeset
   108
hgs
parents:
diff changeset
   109
    	mVideoServices = VideoServices::instance();
hgs
parents:
diff changeset
   110
hgs
parents:
diff changeset
   111
    	if (!mVideoServices)
hgs
parents:
diff changeset
   112
        {
34
hgs
parents: 30
diff changeset
   113
            cleanup();
30
hgs
parents:
diff changeset
   114
        	return -1;
hgs
parents:
diff changeset
   115
		}
hgs
parents:
diff changeset
   116
        else
hgs
parents:
diff changeset
   117
        {
hgs
parents:
diff changeset
   118
        	connect(mVideoServices, SIGNAL(titleReady(const QString&)), this, SLOT(titleReadySlot(const QString&)));
hgs
parents:
diff changeset
   119
        }
hgs
parents:
diff changeset
   120
	}
hgs
parents:
diff changeset
   121
    
34
hgs
parents: 30
diff changeset
   122
    // start open all videos model
hgs
parents: 30
diff changeset
   123
    VideoSortFilterProxyModel *model =
hgs
parents: 30
diff changeset
   124
        mWrapper.getModel(VideoCollectionWrapper::EAllVideos);
hgs
parents: 30
diff changeset
   125
    if (model)
30
hgs
parents:
diff changeset
   126
    {
34
hgs
parents: 30
diff changeset
   127
        model->open(VideoCollectionCommon::ELevelVideos);
hgs
parents: 30
diff changeset
   128
    }
hgs
parents: 30
diff changeset
   129
    else
30
hgs
parents:
diff changeset
   130
    {
hgs
parents:
diff changeset
   131
        cleanup();
hgs
parents:
diff changeset
   132
        return -1;
hgs
parents:
diff changeset
   133
    }
34
hgs
parents: 30
diff changeset
   134
    
hgs
parents: 30
diff changeset
   135
    // start loading widgets
hgs
parents: 30
diff changeset
   136
    QSet<QString> uiItems;
hgs
parents: 30
diff changeset
   137
    uiItems.insert(DOCML_NAME_VC_VIDEOLISTWIDGET);
35
hgs
parents: 34
diff changeset
   138
    uiItems.insert(DOCML_NAME_VC_HEADINGBANNER);
34
hgs
parents: 30
diff changeset
   139
    uiItems.insert(DOCML_NAME_OPTIONS_MENU);
35
hgs
parents: 34
diff changeset
   140
    if(!mIsService)
hgs
parents: 34
diff changeset
   141
    {
hgs
parents: 34
diff changeset
   142
		uiItems.insert(DOCML_NAME_ADD_TO_COLLECTION);
hgs
parents: 34
diff changeset
   143
		uiItems.insert(DOCML_NAME_CREATE_COLLECTION);
hgs
parents: 34
diff changeset
   144
		uiItems.insert(DOCML_NAME_DELETE_MULTIPLE);
hgs
parents: 34
diff changeset
   145
    }
34
hgs
parents: 30
diff changeset
   146
    uiItems.insert(DOCML_NAME_SORT_MENU);
hgs
parents: 30
diff changeset
   147
    uiItems.insert(DOCML_NAME_SORT_BY_DATE);
hgs
parents: 30
diff changeset
   148
    uiItems.insert(DOCML_NAME_SORT_BY_NAME);
hgs
parents: 30
diff changeset
   149
    uiItems.insert(DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS);
hgs
parents: 30
diff changeset
   150
    uiItems.insert(DOCML_NAME_SORT_BY_RATING);
hgs
parents: 30
diff changeset
   151
    uiItems.insert(DOCML_NAME_SORT_BY_SIZE);
hgs
parents: 30
diff changeset
   152
    mUiLoader->startLoading(uiItems,
hgs
parents: 30
diff changeset
   153
        this,
hgs
parents: 30
diff changeset
   154
        SLOT(widgetReadySlot(QGraphicsWidget*, const QString&)),
hgs
parents: 30
diff changeset
   155
        SLOT(objectReadySlot(QObject*, const QString&)));
hgs
parents: 30
diff changeset
   156
    uiItems.clear();
hgs
parents: 30
diff changeset
   157
    
hgs
parents: 30
diff changeset
   158
    // TODO: create toolbar temporarily here until it has been moved to docml
hgs
parents: 30
diff changeset
   159
    if (createToolbar() != 0)
hgs
parents: 30
diff changeset
   160
    {
hgs
parents: 30
diff changeset
   161
        cleanup();
hgs
parents: 30
diff changeset
   162
        return -1;
hgs
parents: 30
diff changeset
   163
    }
30
hgs
parents:
diff changeset
   164
hgs
parents:
diff changeset
   165
    return 0;
hgs
parents:
diff changeset
   166
}
hgs
parents:
diff changeset
   167
hgs
parents:
diff changeset
   168
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   169
// titleReadySlot()
hgs
parents:
diff changeset
   170
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   171
//
hgs
parents:
diff changeset
   172
void VideoListView::titleReadySlot(const QString& title)
hgs
parents:
diff changeset
   173
{
hgs
parents:
diff changeset
   174
	setTitle(title);
hgs
parents:
diff changeset
   175
}
hgs
parents:
diff changeset
   176
hgs
parents:
diff changeset
   177
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   178
// activateView()
hgs
parents:
diff changeset
   179
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   180
//
hgs
parents:
diff changeset
   181
int VideoListView::activateView()
hgs
parents:
diff changeset
   182
{
34
hgs
parents: 30
diff changeset
   183
    VideoListWidget *videoList =
hgs
parents: 30
diff changeset
   184
        mUiLoader->findWidget<VideoListWidget>(
hgs
parents: 30
diff changeset
   185
            DOCML_NAME_VC_VIDEOLISTWIDGET);
hgs
parents: 30
diff changeset
   186
    if (videoList)
30
hgs
parents:
diff changeset
   187
    {
34
hgs
parents: 30
diff changeset
   188
    	VideoCollectionCommon::TCollectionLevels level = VideoCollectionCommon::ELevelVideos;
hgs
parents: 30
diff changeset
   189
        if (mCurrentList)
hgs
parents: 30
diff changeset
   190
        {
hgs
parents: 30
diff changeset
   191
        	level = mCurrentList->getLevel();
hgs
parents: 30
diff changeset
   192
        }
hgs
parents: 30
diff changeset
   193
        else
hgs
parents: 30
diff changeset
   194
        {
hgs
parents: 30
diff changeset
   195
        	mCurrentList = videoList;
hgs
parents: 30
diff changeset
   196
        }
hgs
parents: 30
diff changeset
   197
        
hgs
parents: 30
diff changeset
   198
    	int result = mCurrentList->activate(level);
35
hgs
parents: 34
diff changeset
   199
        if(result < 0)
34
hgs
parents: 30
diff changeset
   200
        {
hgs
parents: 30
diff changeset
   201
            // activate failed, deactivate view so we get rid of dangling connections.
hgs
parents: 30
diff changeset
   202
            deactivateView();
hgs
parents: 30
diff changeset
   203
            return -1;
hgs
parents: 30
diff changeset
   204
        }
hgs
parents: 30
diff changeset
   205
        
hgs
parents: 30
diff changeset
   206
        HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
hgs
parents: 30
diff changeset
   207
        if (mainWnd)
hgs
parents: 30
diff changeset
   208
        {
hgs
parents: 30
diff changeset
   209
        mainWnd->setOrientation(Qt::Vertical, false);
hgs
parents: 30
diff changeset
   210
            if(!connect(
hgs
parents: 30
diff changeset
   211
                    mainWnd, SIGNAL(aboutToChangeOrientation()),
hgs
parents: 30
diff changeset
   212
                    this, SLOT( aboutToChangeOrientationSlot())) ||
hgs
parents: 30
diff changeset
   213
               !connect(
hgs
parents: 30
diff changeset
   214
                   mainWnd, SIGNAL(orientationChanged(Qt::Orientation)),
hgs
parents: 30
diff changeset
   215
                   this, SLOT(orientationChangedSlot(Qt::Orientation))) ||
hgs
parents: 30
diff changeset
   216
               !connect(
hgs
parents: 30
diff changeset
   217
                   &mWrapper, SIGNAL(asyncStatus(int, QVariant&)),
hgs
parents: 30
diff changeset
   218
                   this, SLOT(handleAsyncStatusSlot(int, QVariant&))) ||
hgs
parents: 30
diff changeset
   219
               !connect(
hgs
parents: 30
diff changeset
   220
                   mCurrentList->getModel().sourceModel(), SIGNAL(modelChanged()),
hgs
parents: 30
diff changeset
   221
                   this, SLOT(layoutChangedSlot())) ||
hgs
parents: 30
diff changeset
   222
               !connect(
hgs
parents: 30
diff changeset
   223
                   mCurrentList->getModel().sourceModel(), SIGNAL(modelReady()),
hgs
parents: 30
diff changeset
   224
                   this, SLOT(modelReadySlot())))
hgs
parents: 30
diff changeset
   225
            {
hgs
parents: 30
diff changeset
   226
                // deactivate view so we get rid of dangling connections.
hgs
parents: 30
diff changeset
   227
                deactivateView();
hgs
parents: 30
diff changeset
   228
                return -1;
hgs
parents: 30
diff changeset
   229
            }
hgs
parents: 30
diff changeset
   230
        }
hgs
parents: 30
diff changeset
   231
        else
hgs
parents: 30
diff changeset
   232
        {
hgs
parents: 30
diff changeset
   233
            return -1;
hgs
parents: 30
diff changeset
   234
        }
hgs
parents: 30
diff changeset
   235
    }
hgs
parents: 30
diff changeset
   236
    else
hgs
parents: 30
diff changeset
   237
    {
30
hgs
parents:
diff changeset
   238
        return -1;
hgs
parents:
diff changeset
   239
    }
34
hgs
parents: 30
diff changeset
   240
    
hgs
parents: 30
diff changeset
   241
    return 0;
30
hgs
parents:
diff changeset
   242
}
hgs
parents:
diff changeset
   243
35
hgs
parents: 34
diff changeset
   244
hgs
parents: 34
diff changeset
   245
// ---------------------------------------------------------------------------
hgs
parents: 34
diff changeset
   246
// loadMultiSelection
hgs
parents: 34
diff changeset
   247
// ---------------------------------------------------------------------------
hgs
parents: 34
diff changeset
   248
//
hgs
parents: 34
diff changeset
   249
void VideoListView::loadMultiSelection()
hgs
parents: 34
diff changeset
   250
{
hgs
parents: 34
diff changeset
   251
	if(!mIsService)
hgs
parents: 34
diff changeset
   252
    {
hgs
parents: 34
diff changeset
   253
		if(!mMultiselectionLoaded)
hgs
parents: 34
diff changeset
   254
		{
hgs
parents: 34
diff changeset
   255
			QSet<QString> uiItems;
hgs
parents: 34
diff changeset
   256
			uiItems.insert(DOCML_NAME_DIALOG);
hgs
parents: 34
diff changeset
   257
			mUiLoader->startLoading(uiItems,
hgs
parents: 34
diff changeset
   258
				this,
hgs
parents: 34
diff changeset
   259
				SLOT(widgetReadySlot(QGraphicsWidget*, const QString&)),
hgs
parents: 34
diff changeset
   260
				SLOT(objectReadySlot(QObject*, const QString&)));
hgs
parents: 34
diff changeset
   261
			uiItems.clear();
hgs
parents: 34
diff changeset
   262
			mMultiselectionLoaded = true;
hgs
parents: 34
diff changeset
   263
		}
hgs
parents: 34
diff changeset
   264
    }
hgs
parents: 34
diff changeset
   265
}
hgs
parents: 34
diff changeset
   266
hgs
parents: 34
diff changeset
   267
// ---------------------------------------------------------------------------
hgs
parents: 34
diff changeset
   268
// loadLists
hgs
parents: 34
diff changeset
   269
// ---------------------------------------------------------------------------
hgs
parents: 34
diff changeset
   270
//
hgs
parents: 34
diff changeset
   271
void VideoListView::loadLists(bool doAsync)
hgs
parents: 34
diff changeset
   272
{
hgs
parents: 34
diff changeset
   273
	if(!mListsLoaded)
hgs
parents: 34
diff changeset
   274
	{
hgs
parents: 34
diff changeset
   275
		QSet<QString> uiItems;
hgs
parents: 34
diff changeset
   276
		uiItems.insert(DOCML_NAME_VC_COLLECTIONWIDGET);
hgs
parents: 34
diff changeset
   277
		uiItems.insert(DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
hgs
parents: 34
diff changeset
   278
		mUiLoader->startLoading(uiItems,
hgs
parents: 34
diff changeset
   279
			this,
hgs
parents: 34
diff changeset
   280
			SLOT(widgetReadySlot(QGraphicsWidget*, const QString&)),
hgs
parents: 34
diff changeset
   281
			SLOT(objectReadySlot(QObject*, const QString&)));
hgs
parents: 34
diff changeset
   282
		uiItems.clear();
hgs
parents: 34
diff changeset
   283
hgs
parents: 34
diff changeset
   284
		if(!doAsync)
hgs
parents: 34
diff changeset
   285
		{
hgs
parents: 34
diff changeset
   286
			VideoListWidget* widget(0);
hgs
parents: 34
diff changeset
   287
			widget = mUiLoader->findWidget<VideoListWidget>(DOCML_NAME_VC_COLLECTIONWIDGET);
hgs
parents: 34
diff changeset
   288
			widget->setVisible(false);
hgs
parents: 34
diff changeset
   289
			widget = mUiLoader->findWidget<VideoListWidget>(DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
hgs
parents: 34
diff changeset
   290
			widget->setVisible(false);
hgs
parents: 34
diff changeset
   291
		}
hgs
parents: 34
diff changeset
   292
	    mListsLoaded = true;
hgs
parents: 34
diff changeset
   293
	}
hgs
parents: 34
diff changeset
   294
}
hgs
parents: 34
diff changeset
   295
hgs
parents: 34
diff changeset
   296
// ---------------------------------------------------------------------------
hgs
parents: 34
diff changeset
   297
// doDelayedsSlot
hgs
parents: 34
diff changeset
   298
// ---------------------------------------------------------------------------
hgs
parents: 34
diff changeset
   299
//
hgs
parents: 34
diff changeset
   300
void VideoListView::doDelayedsSlot()
hgs
parents: 34
diff changeset
   301
{
hgs
parents: 34
diff changeset
   302
	loadLists(true);
hgs
parents: 34
diff changeset
   303
	loadMultiSelection();
hgs
parents: 34
diff changeset
   304
	loadHint(true);
hgs
parents: 34
diff changeset
   305
	emit doDelayeds();
hgs
parents: 34
diff changeset
   306
}
hgs
parents: 34
diff changeset
   307
30
hgs
parents:
diff changeset
   308
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   309
// modelReadySlot
hgs
parents:
diff changeset
   310
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   311
//
hgs
parents:
diff changeset
   312
void VideoListView::modelReadySlot()
hgs
parents:
diff changeset
   313
{
hgs
parents:
diff changeset
   314
    mModelReady = true;
34
hgs
parents: 30
diff changeset
   315
    
30
hgs
parents:
diff changeset
   316
    // since the reset signal arrives after
hgs
parents:
diff changeset
   317
    // layout changed, need to make sure that
hgs
parents:
diff changeset
   318
    // view is updated in case needed
hgs
parents:
diff changeset
   319
    layoutChangedSlot();
hgs
parents:
diff changeset
   320
}
hgs
parents:
diff changeset
   321
hgs
parents:
diff changeset
   322
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   323
// layoutChangedSlot
hgs
parents:
diff changeset
   324
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   325
//
hgs
parents:
diff changeset
   326
void VideoListView::layoutChangedSlot()
hgs
parents:
diff changeset
   327
{
hgs
parents:
diff changeset
   328
    updateSubLabel();
hgs
parents:
diff changeset
   329
    
hgs
parents:
diff changeset
   330
    if(mModelReady)
hgs
parents:
diff changeset
   331
    {
hgs
parents:
diff changeset
   332
        showHint();
hgs
parents:
diff changeset
   333
    }
hgs
parents:
diff changeset
   334
}
hgs
parents:
diff changeset
   335
hgs
parents:
diff changeset
   336
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   337
// deactivateView()
hgs
parents:
diff changeset
   338
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   339
//
hgs
parents:
diff changeset
   340
void VideoListView::deactivateView()
hgs
parents:
diff changeset
   341
{
hgs
parents:
diff changeset
   342
    HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
34
hgs
parents: 30
diff changeset
   343
    
hgs
parents: 30
diff changeset
   344
    mainWnd->unsetOrientation();
hgs
parents: 30
diff changeset
   345
    
30
hgs
parents:
diff changeset
   346
    disconnect(mainWnd, SIGNAL(aboutToChangeOrientation()),
hgs
parents:
diff changeset
   347
               this, SLOT(aboutToChangeOrientationSlot()));
hgs
parents:
diff changeset
   348
hgs
parents:
diff changeset
   349
    disconnect(mainWnd, SIGNAL(orientationChanged(Qt::Orientation)),
hgs
parents:
diff changeset
   350
               this, SLOT(orientationChangedSlot(Qt::Orientation)));
hgs
parents:
diff changeset
   351
34
hgs
parents: 30
diff changeset
   352
    disconnect(&mWrapper, SIGNAL(asyncStatus(int, QVariant&)),
30
hgs
parents:
diff changeset
   353
               this, SLOT(handleAsyncStatusSlot(int, QVariant&)));
34
hgs
parents: 30
diff changeset
   354
    
hgs
parents: 30
diff changeset
   355
    HbMenu *menu = mUiLoader->findWidget<HbMenu>(DOCML_NAME_OPTIONS_MENU);
hgs
parents: 30
diff changeset
   356
    if (menu)
hgs
parents: 30
diff changeset
   357
    {
hgs
parents: 30
diff changeset
   358
        menu->hide();
hgs
parents: 30
diff changeset
   359
    }
hgs
parents: 30
diff changeset
   360
    
hgs
parents: 30
diff changeset
   361
    if(mCurrentList && &(mCurrentList->getModel()) && mCurrentList->getModel().sourceModel())
hgs
parents: 30
diff changeset
   362
    {
hgs
parents: 30
diff changeset
   363
        disconnect(mCurrentList->getModel().sourceModel(),
hgs
parents: 30
diff changeset
   364
                SIGNAL(modelChanged()),
hgs
parents: 30
diff changeset
   365
                this, SLOT(layoutChangedSlot()));
hgs
parents: 30
diff changeset
   366
        disconnect(mCurrentList->getModel().sourceModel(),
hgs
parents: 30
diff changeset
   367
                SIGNAL(modelReady()),
hgs
parents: 30
diff changeset
   368
                this, SLOT(modelReadySlot()));
30
hgs
parents:
diff changeset
   369
34
hgs
parents: 30
diff changeset
   370
        showHint(false);
hgs
parents: 30
diff changeset
   371
    }
30
hgs
parents:
diff changeset
   372
    
34
hgs
parents: 30
diff changeset
   373
    if(mCurrentList)
30
hgs
parents:
diff changeset
   374
    {
34
hgs
parents: 30
diff changeset
   375
        mCurrentList->deactivate();
30
hgs
parents:
diff changeset
   376
    }
hgs
parents:
diff changeset
   377
}
hgs
parents:
diff changeset
   378
hgs
parents:
diff changeset
   379
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   380
// back()
hgs
parents:
diff changeset
   381
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   382
//
hgs
parents:
diff changeset
   383
void VideoListView::back()
hgs
parents:
diff changeset
   384
{
hgs
parents:
diff changeset
   385
    // NOP
hgs
parents:
diff changeset
   386
}
hgs
parents:
diff changeset
   387
hgs
parents:
diff changeset
   388
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   389
// cleanup()
hgs
parents:
diff changeset
   390
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   391
//
hgs
parents:
diff changeset
   392
void VideoListView::cleanup()
hgs
parents:
diff changeset
   393
{
hgs
parents:
diff changeset
   394
    delete mToolbarViewsActionGroup;
hgs
parents:
diff changeset
   395
    mToolbarViewsActionGroup = 0;
hgs
parents:
diff changeset
   396
hgs
parents:
diff changeset
   397
    delete mToolbarCollectionActionGroup;
hgs
parents:
diff changeset
   398
    mToolbarCollectionActionGroup = 0;
hgs
parents:
diff changeset
   399
    
34
hgs
parents: 30
diff changeset
   400
    mCurrentList = 0;    
30
hgs
parents:
diff changeset
   401
}
hgs
parents:
diff changeset
   402
hgs
parents:
diff changeset
   403
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   404
// createToolbar()
hgs
parents:
diff changeset
   405
// Creates toolbar, toolbar actions and toolbar icons
hgs
parents:
diff changeset
   406
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   407
//
hgs
parents:
diff changeset
   408
int VideoListView::createToolbar()
hgs
parents:
diff changeset
   409
{
hgs
parents:
diff changeset
   410
    // Create actiongroup and add all actions to it. This ensures that only one is
hgs
parents:
diff changeset
   411
    // active at certain moment.
hgs
parents:
diff changeset
   412
hgs
parents:
diff changeset
   413
    if(!mToolbarViewsActionGroup && !mToolbarCollectionActionGroup)
hgs
parents:
diff changeset
   414
    {
hgs
parents:
diff changeset
   415
    	mToolbarViewsActionGroup = new QActionGroup(this);
hgs
parents:
diff changeset
   416
        mToolbarCollectionActionGroup = new QActionGroup(this);
hgs
parents:
diff changeset
   417
hgs
parents:
diff changeset
   418
        if(!mToolbarViewsActionGroup || !mToolbarCollectionActionGroup)
hgs
parents:
diff changeset
   419
        {
hgs
parents:
diff changeset
   420
            delete mToolbarViewsActionGroup;
hgs
parents:
diff changeset
   421
            mToolbarViewsActionGroup = 0;
hgs
parents:
diff changeset
   422
hgs
parents:
diff changeset
   423
            delete mToolbarCollectionActionGroup;
hgs
parents:
diff changeset
   424
            mToolbarCollectionActionGroup = 0;
hgs
parents:
diff changeset
   425
hgs
parents:
diff changeset
   426
            return -1;
hgs
parents:
diff changeset
   427
        }
hgs
parents:
diff changeset
   428
hgs
parents:
diff changeset
   429
        // create toolbar item actions
hgs
parents:
diff changeset
   430
hgs
parents:
diff changeset
   431
        // All Videos tab
34
hgs
parents: 30
diff changeset
   432
        mToolbarActions[ETBActionAllVideos] = createAction(":/images/qtg_mono_video_all.svg",
30
hgs
parents:
diff changeset
   433
                mToolbarViewsActionGroup, SLOT(openAllVideosViewSlot()));
hgs
parents:
diff changeset
   434
hgs
parents:
diff changeset
   435
        // Collections tab
35
hgs
parents: 34
diff changeset
   436
        mToolbarActions[ETBActionCollections] = createAction("qtg_mono_video_collection",
30
hgs
parents:
diff changeset
   437
                mToolbarViewsActionGroup, SLOT(openCollectionViewSlot()));
hgs
parents:
diff changeset
   438
hgs
parents:
diff changeset
   439
        if (!mIsService)
hgs
parents:
diff changeset
   440
        {
hgs
parents:
diff changeset
   441
			// Services tab
35
hgs
parents: 34
diff changeset
   442
			mToolbarActions[ETBActionServices] = createAction("qtg_mono_ovistore",
30
hgs
parents:
diff changeset
   443
					mToolbarViewsActionGroup, SLOT(openServicesViewSlot()));
hgs
parents:
diff changeset
   444
			// Add Videos tab
35
hgs
parents: 34
diff changeset
   445
			mToolbarActions[ETBActionAddVideos] = 
hgs
parents: 34
diff changeset
   446
			        createAction("qtg_mono_add_to_video_collection",
30
hgs
parents:
diff changeset
   447
					mToolbarCollectionActionGroup, SLOT(addVideosToCollectionSlot()));
hgs
parents:
diff changeset
   448
hgs
parents:
diff changeset
   449
			// Remove Videos tab
35
hgs
parents: 34
diff changeset
   450
			mToolbarActions[ETBActionRemoveVideos] = 
hgs
parents: 34
diff changeset
   451
			        createAction(":/images/qtg_mono_remove_from_video_collection.svg",
hgs
parents: 34
diff changeset
   452
					mToolbarCollectionActionGroup, SLOT(removeVideosFromCollectionSlot()));
30
hgs
parents:
diff changeset
   453
        }
hgs
parents:
diff changeset
   454
hgs
parents:
diff changeset
   455
        HbToolBar *bar = toolBar(); // First call to toolBar() creates the object, so on failure it could return 0.
hgs
parents:
diff changeset
   456
hgs
parents:
diff changeset
   457
        if(   !bar
hgs
parents:
diff changeset
   458
		   || !mToolbarActions[ETBActionAllVideos]
hgs
parents:
diff changeset
   459
           || !mToolbarActions[ETBActionCollections]
hgs
parents:
diff changeset
   460
           || (!mToolbarActions[ETBActionServices]     && !mIsService)
hgs
parents:
diff changeset
   461
           || (!mToolbarActions[ETBActionAddVideos]    && !mIsService)
hgs
parents:
diff changeset
   462
           || (!mToolbarActions[ETBActionRemoveVideos] && !mIsService))
hgs
parents:
diff changeset
   463
        {
hgs
parents:
diff changeset
   464
        	delete mToolbarActions[ETBActionAllVideos];
hgs
parents:
diff changeset
   465
            delete mToolbarActions[ETBActionCollections];
hgs
parents:
diff changeset
   466
            delete mToolbarActions[ETBActionServices];
hgs
parents:
diff changeset
   467
            delete mToolbarActions[ETBActionAddVideos];
hgs
parents:
diff changeset
   468
            delete mToolbarActions[ETBActionRemoveVideos];
hgs
parents:
diff changeset
   469
        	return -1;
hgs
parents:
diff changeset
   470
        }
hgs
parents:
diff changeset
   471
hgs
parents:
diff changeset
   472
        // Collection view actions are not checkable
hgs
parents:
diff changeset
   473
        mToolbarActions[ETBActionAllVideos]->setCheckable(true);
hgs
parents:
diff changeset
   474
        mToolbarActions[ETBActionCollections]->setCheckable(true);
hgs
parents:
diff changeset
   475
hgs
parents:
diff changeset
   476
        if (!mIsService)
hgs
parents:
diff changeset
   477
        {
35
hgs
parents: 34
diff changeset
   478
        	mToolbarActions[ETBActionServices]->setCheckable(false);
30
hgs
parents:
diff changeset
   479
        }
hgs
parents:
diff changeset
   480
hgs
parents:
diff changeset
   481
        // Allvideos is checked at creation phase
hgs
parents:
diff changeset
   482
        mToolbarActions[ETBActionAllVideos]->setChecked(true);
hgs
parents:
diff changeset
   483
hgs
parents:
diff changeset
   484
        bar->addActions(mToolbarViewsActionGroup->actions());
34
hgs
parents: 30
diff changeset
   485
        bar->setVisible(true);
30
hgs
parents:
diff changeset
   486
    }
hgs
parents:
diff changeset
   487
hgs
parents:
diff changeset
   488
    return 0;
hgs
parents:
diff changeset
   489
}
hgs
parents:
diff changeset
   490
hgs
parents:
diff changeset
   491
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   492
// createAction()
hgs
parents:
diff changeset
   493
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   494
//
34
hgs
parents: 30
diff changeset
   495
HbAction* VideoListView::createAction(QString icon,
30
hgs
parents:
diff changeset
   496
        QActionGroup* actionGroup, const char *slot)
hgs
parents:
diff changeset
   497
{
hgs
parents:
diff changeset
   498
    HbAction* action = new HbAction(actionGroup);
hgs
parents:
diff changeset
   499
    if(!action) {
hgs
parents:
diff changeset
   500
        return 0;
hgs
parents:
diff changeset
   501
    }
hgs
parents:
diff changeset
   502
hgs
parents:
diff changeset
   503
    HbIcon hbIcon(icon);
hgs
parents:
diff changeset
   504
    action->setIcon(hbIcon);
hgs
parents:
diff changeset
   505
hgs
parents:
diff changeset
   506
    if(!connect(action, SIGNAL(triggered()), this, slot)) {
hgs
parents:
diff changeset
   507
        // actiongroup deletion deletes this also.
hgs
parents:
diff changeset
   508
        // return 0 tells that there was a problem in creation to caller.
hgs
parents:
diff changeset
   509
        delete action;
hgs
parents:
diff changeset
   510
        return 0;
hgs
parents:
diff changeset
   511
    }
hgs
parents:
diff changeset
   512
hgs
parents:
diff changeset
   513
    return action;
hgs
parents:
diff changeset
   514
}
hgs
parents:
diff changeset
   515
hgs
parents:
diff changeset
   516
// ---------------------------------------------------------------------------
35
hgs
parents: 34
diff changeset
   517
// loadHint
hgs
parents: 34
diff changeset
   518
// ---------------------------------------------------------------------------
hgs
parents: 34
diff changeset
   519
//
hgs
parents: 34
diff changeset
   520
void VideoListView::loadHint(bool doAsync)
hgs
parents: 34
diff changeset
   521
{
hgs
parents: 34
diff changeset
   522
	if(!mHintLoaded)
hgs
parents: 34
diff changeset
   523
	{
hgs
parents: 34
diff changeset
   524
		QSet<QString> uiItems;
hgs
parents: 34
diff changeset
   525
	    uiItems.insert(DOCML_NAME_VC_VIDEOHINTWIDGET);
hgs
parents: 34
diff changeset
   526
	    uiItems.insert(DOCML_NAME_HINT_BUTTON);
hgs
parents: 34
diff changeset
   527
	    uiItems.insert(DOCML_NAME_NO_VIDEOS_LABEL);
hgs
parents: 34
diff changeset
   528
		mUiLoader->startLoading(uiItems,
hgs
parents: 34
diff changeset
   529
			this,
hgs
parents: 34
diff changeset
   530
			SLOT(widgetReadySlot(QGraphicsWidget*, const QString&)),
hgs
parents: 34
diff changeset
   531
			SLOT(objectReadySlot(QObject*, const QString&)));
hgs
parents: 34
diff changeset
   532
		uiItems.clear();
hgs
parents: 34
diff changeset
   533
hgs
parents: 34
diff changeset
   534
		if(!doAsync)
hgs
parents: 34
diff changeset
   535
		{
hgs
parents: 34
diff changeset
   536
			HbPushButton* button = mUiLoader->findWidget<HbPushButton>(DOCML_NAME_HINT_BUTTON);
hgs
parents: 34
diff changeset
   537
		}
hgs
parents: 34
diff changeset
   538
		mHintLoaded = true;
hgs
parents: 34
diff changeset
   539
	}
hgs
parents: 34
diff changeset
   540
}
hgs
parents: 34
diff changeset
   541
hgs
parents: 34
diff changeset
   542
// ---------------------------------------------------------------------------
30
hgs
parents:
diff changeset
   543
// showHint
hgs
parents:
diff changeset
   544
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   545
//
hgs
parents:
diff changeset
   546
void VideoListView::showHint(bool show)
hgs
parents:
diff changeset
   547
{
34
hgs
parents: 30
diff changeset
   548
    if(!mCurrentList)
30
hgs
parents:
diff changeset
   549
    {
34
hgs
parents: 30
diff changeset
   550
        return;
30
hgs
parents:
diff changeset
   551
    }
34
hgs
parents: 30
diff changeset
   552
hgs
parents: 30
diff changeset
   553
    VideoSortFilterProxyModel &model = mCurrentList->getModel();
35
hgs
parents: 34
diff changeset
   554
hgs
parents: 34
diff changeset
   555
    HbGroupBox *subLabel =
hgs
parents: 34
diff changeset
   556
        mUiLoader->findWidget<HbGroupBox>(DOCML_NAME_VC_HEADINGBANNER);
hgs
parents: 34
diff changeset
   557
hgs
parents: 34
diff changeset
   558
    if((!mHintLoaded && !show) || (!mHintLoaded && model.rowCount() != 0))
hgs
parents: 34
diff changeset
   559
    {
hgs
parents: 34
diff changeset
   560
    	if(subLabel)
hgs
parents: 34
diff changeset
   561
    	{
hgs
parents: 34
diff changeset
   562
    		subLabel->show();
hgs
parents: 34
diff changeset
   563
    	}
hgs
parents: 34
diff changeset
   564
    	return;
hgs
parents: 34
diff changeset
   565
    }
hgs
parents: 34
diff changeset
   566
    else if(!mHintLoaded)
hgs
parents: 34
diff changeset
   567
    {
hgs
parents: 34
diff changeset
   568
    	loadHint(false);
hgs
parents: 34
diff changeset
   569
    }
hgs
parents: 34
diff changeset
   570
34
hgs
parents: 30
diff changeset
   571
    VideoHintWidget *hintWidget =
hgs
parents: 30
diff changeset
   572
        mUiLoader->findWidget<VideoHintWidget>(
hgs
parents: 30
diff changeset
   573
            DOCML_NAME_VC_VIDEOHINTWIDGET);
35
hgs
parents: 34
diff changeset
   574
hgs
parents: 34
diff changeset
   575
    if (hintWidget)
hgs
parents: 34
diff changeset
   576
    {
hgs
parents: 34
diff changeset
   577
        hintWidget->setLevel(mHintLevel);
hgs
parents: 34
diff changeset
   578
    }
hgs
parents: 34
diff changeset
   579
34
hgs
parents: 30
diff changeset
   580
    if (mModelReady &&
hgs
parents: 30
diff changeset
   581
        model.rowCount() == 0 &&
hgs
parents: 30
diff changeset
   582
        hintWidget)
hgs
parents: 30
diff changeset
   583
    {
hgs
parents: 30
diff changeset
   584
        show ? hintWidget->activate() : hintWidget->deactivate();
hgs
parents: 30
diff changeset
   585
    }
hgs
parents: 30
diff changeset
   586
    else if (hintWidget)
30
hgs
parents:
diff changeset
   587
    {
hgs
parents:
diff changeset
   588
        show = false;
34
hgs
parents: 30
diff changeset
   589
        hintWidget->deactivate();
30
hgs
parents:
diff changeset
   590
    }
hgs
parents:
diff changeset
   591
hgs
parents:
diff changeset
   592
    if(show && mToolbarViewsActionGroup && mToolbarCollectionActionGroup) 
hgs
parents:
diff changeset
   593
    {
hgs
parents:
diff changeset
   594
    	if(!mIsService)
hgs
parents:
diff changeset
   595
    	{
34
hgs
parents: 30
diff changeset
   596
    		mToolbarActions[ETBActionRemoveVideos]->setVisible(false);
30
hgs
parents:
diff changeset
   597
    	}
34
hgs
parents: 30
diff changeset
   598
        if(mCurrentList->getLevel() == VideoCollectionCommon::ELevelDefaultColl) 
hgs
parents: 30
diff changeset
   599
        {
hgs
parents: 30
diff changeset
   600
        	if(!mIsService)
hgs
parents: 30
diff changeset
   601
        	{
hgs
parents: 30
diff changeset
   602
        		mToolbarActions[ETBActionAddVideos]->setVisible(false);
hgs
parents: 30
diff changeset
   603
        	}
hgs
parents: 30
diff changeset
   604
       		hintWidget->setButtonShown(false);
hgs
parents: 30
diff changeset
   605
        } 
hgs
parents: 30
diff changeset
   606
        else 
hgs
parents: 30
diff changeset
   607
        {
hgs
parents: 30
diff changeset
   608
            hintWidget->setButtonShown(true);
hgs
parents: 30
diff changeset
   609
        }
30
hgs
parents:
diff changeset
   610
    } 
34
hgs
parents: 30
diff changeset
   611
    else if(mToolbarViewsActionGroup && mToolbarCollectionActionGroup)
30
hgs
parents:
diff changeset
   612
    {
hgs
parents:
diff changeset
   613
    	if(!mIsService)
hgs
parents:
diff changeset
   614
    	{
34
hgs
parents: 30
diff changeset
   615
			if(mToolbarActions[ETBActionRemoveVideos]->isVisible() == false) 
30
hgs
parents:
diff changeset
   616
			{
34
hgs
parents: 30
diff changeset
   617
				mToolbarActions[ETBActionRemoveVideos]->setVisible(true);
30
hgs
parents:
diff changeset
   618
			}
34
hgs
parents: 30
diff changeset
   619
	        if(mToolbarActions[ETBActionAddVideos]->isVisible() == false) 
hgs
parents: 30
diff changeset
   620
	        {
hgs
parents: 30
diff changeset
   621
	            mToolbarActions[ETBActionAddVideos]->setVisible(true);
hgs
parents: 30
diff changeset
   622
	        }
30
hgs
parents:
diff changeset
   623
    	}
34
hgs
parents: 30
diff changeset
   624
        hintWidget->setButtonShown(true);
hgs
parents: 30
diff changeset
   625
    }
hgs
parents: 30
diff changeset
   626
    
hgs
parents: 30
diff changeset
   627
    if (subLabel)
hgs
parents: 30
diff changeset
   628
    {
hgs
parents: 30
diff changeset
   629
        if (show &&
35
hgs
parents: 34
diff changeset
   630
            subLabel->isVisible() &&
34
hgs
parents: 30
diff changeset
   631
            mCurrentList->getLevel() == VideoCollectionCommon::ELevelVideos)
30
hgs
parents:
diff changeset
   632
        {
34
hgs
parents: 30
diff changeset
   633
            subLabel->hide();
hgs
parents: 30
diff changeset
   634
        }
35
hgs
parents: 34
diff changeset
   635
        else if (!subLabel->isVisible())
34
hgs
parents: 30
diff changeset
   636
        {
hgs
parents: 30
diff changeset
   637
            subLabel->show();
30
hgs
parents:
diff changeset
   638
        }
hgs
parents:
diff changeset
   639
    }
hgs
parents:
diff changeset
   640
}
hgs
parents:
diff changeset
   641
hgs
parents:
diff changeset
   642
// ---------------------------------------------------------------------------
34
hgs
parents: 30
diff changeset
   643
// setHintLevel
hgs
parents: 30
diff changeset
   644
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   645
//
hgs
parents: 30
diff changeset
   646
void VideoListView::setHintLevel(VideoHintWidget::HintLevel level)
hgs
parents: 30
diff changeset
   647
{
35
hgs
parents: 34
diff changeset
   648
	mHintLevel = level;
34
hgs
parents: 30
diff changeset
   649
}
hgs
parents: 30
diff changeset
   650
hgs
parents: 30
diff changeset
   651
// ---------------------------------------------------------------------------
30
hgs
parents:
diff changeset
   652
// updateSubLabel
hgs
parents:
diff changeset
   653
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   654
//
hgs
parents:
diff changeset
   655
void VideoListView::updateSubLabel()
hgs
parents:
diff changeset
   656
{
34
hgs
parents: 30
diff changeset
   657
    VideoSortFilterProxyModel *model = 0;
hgs
parents: 30
diff changeset
   658
    if(mCurrentList)
hgs
parents: 30
diff changeset
   659
    {
hgs
parents: 30
diff changeset
   660
        model = &mCurrentList->getModel(); 
hgs
parents: 30
diff changeset
   661
    }
hgs
parents: 30
diff changeset
   662
    
hgs
parents: 30
diff changeset
   663
    if (model)
30
hgs
parents:
diff changeset
   664
    {
34
hgs
parents: 30
diff changeset
   665
        int itemCount = model->rowCount();
hgs
parents: 30
diff changeset
   666
        VideoListWidget *videoListWidget =
hgs
parents: 30
diff changeset
   667
            mUiLoader->findWidget<VideoListWidget>(
hgs
parents: 30
diff changeset
   668
                DOCML_NAME_VC_VIDEOLISTWIDGET);
hgs
parents: 30
diff changeset
   669
        
hgs
parents: 30
diff changeset
   670
        VideoListWidget *collectionWidget =
hgs
parents: 30
diff changeset
   671
            mUiLoader->findWidget<VideoListWidget>(
hgs
parents: 30
diff changeset
   672
                DOCML_NAME_VC_COLLECTIONWIDGET);
hgs
parents: 30
diff changeset
   673
        
hgs
parents: 30
diff changeset
   674
        VideoListWidget *collectionContentWidget =
hgs
parents: 30
diff changeset
   675
            mUiLoader->findWidget<VideoListWidget>(
hgs
parents: 30
diff changeset
   676
                DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
hgs
parents: 30
diff changeset
   677
        
hgs
parents: 30
diff changeset
   678
        HbGroupBox *subLabel = 
hgs
parents: 30
diff changeset
   679
            mUiLoader->findWidget<HbGroupBox>(
hgs
parents: 30
diff changeset
   680
                DOCML_NAME_VC_HEADINGBANNER);
35
hgs
parents: 34
diff changeset
   681
hgs
parents: 34
diff changeset
   682
        if(subLabel)
34
hgs
parents: 30
diff changeset
   683
        {
35
hgs
parents: 34
diff changeset
   684
			if (mCurrentList == videoListWidget)
hgs
parents: 34
diff changeset
   685
			{
hgs
parents: 34
diff changeset
   686
				subLabel->setHeading(hbTrId("txt_videos_subtitle_ln_videos", itemCount));
hgs
parents: 34
diff changeset
   687
			}
hgs
parents: 34
diff changeset
   688
			else if (mCurrentList == collectionWidget)
hgs
parents: 34
diff changeset
   689
			{
hgs
parents: 34
diff changeset
   690
				subLabel->setHeading(hbTrId("txt_videos_subtitle_ln_collections", itemCount));
hgs
parents: 34
diff changeset
   691
			}
hgs
parents: 34
diff changeset
   692
			else if(mCurrentList == collectionContentWidget)
hgs
parents: 34
diff changeset
   693
			{
hgs
parents: 34
diff changeset
   694
				subLabel->setHeading(hbTrId("txt_videos_subtitle_1_l2").arg(mCollectionName).arg(itemCount));
hgs
parents: 34
diff changeset
   695
			}
34
hgs
parents: 30
diff changeset
   696
        }
hgs
parents: 30
diff changeset
   697
    }
hgs
parents: 30
diff changeset
   698
}
30
hgs
parents:
diff changeset
   699
34
hgs
parents: 30
diff changeset
   700
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   701
// showAction()
hgs
parents: 30
diff changeset
   702
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   703
//
hgs
parents: 30
diff changeset
   704
void VideoListView::showAction(bool show, const QString &name)
hgs
parents: 30
diff changeset
   705
{
hgs
parents: 30
diff changeset
   706
    HbAction *action = mUiLoader->findObject<HbAction>(name);
hgs
parents: 30
diff changeset
   707
    if (!action)
hgs
parents: 30
diff changeset
   708
    {
hgs
parents: 30
diff changeset
   709
        // must be menu widget
hgs
parents: 30
diff changeset
   710
        HbMenu *menu = mUiLoader->findWidget<HbMenu>(name);
hgs
parents: 30
diff changeset
   711
        if (menu)
30
hgs
parents:
diff changeset
   712
        {
34
hgs
parents: 30
diff changeset
   713
            action = menu->menuAction();
30
hgs
parents:
diff changeset
   714
        }
34
hgs
parents: 30
diff changeset
   715
    }
hgs
parents: 30
diff changeset
   716
hgs
parents: 30
diff changeset
   717
    // hide or show action
hgs
parents: 30
diff changeset
   718
    if (action)
hgs
parents: 30
diff changeset
   719
    {
hgs
parents: 30
diff changeset
   720
        action->setVisible(show);
hgs
parents: 30
diff changeset
   721
    }
hgs
parents: 30
diff changeset
   722
}
hgs
parents: 30
diff changeset
   723
hgs
parents: 30
diff changeset
   724
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   725
// isActionChecked()
hgs
parents: 30
diff changeset
   726
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   727
//
hgs
parents: 30
diff changeset
   728
bool VideoListView::isActionChecked(const QString &name)
hgs
parents: 30
diff changeset
   729
{
hgs
parents: 30
diff changeset
   730
    bool isChecked = false;
hgs
parents: 30
diff changeset
   731
    
hgs
parents: 30
diff changeset
   732
    HbAction *action = mUiLoader->findObject<HbAction>(name);
hgs
parents: 30
diff changeset
   733
    if (!action)
hgs
parents: 30
diff changeset
   734
    {
hgs
parents: 30
diff changeset
   735
        // must be menu widget
hgs
parents: 30
diff changeset
   736
        HbMenu *menu = mUiLoader->findWidget<HbMenu>(name);
hgs
parents: 30
diff changeset
   737
        if (menu)
30
hgs
parents:
diff changeset
   738
        {
34
hgs
parents: 30
diff changeset
   739
            action = menu->menuAction();
hgs
parents: 30
diff changeset
   740
        }
hgs
parents: 30
diff changeset
   741
    }
hgs
parents: 30
diff changeset
   742
hgs
parents: 30
diff changeset
   743
    // check if action is checked
hgs
parents: 30
diff changeset
   744
    if (action)
hgs
parents: 30
diff changeset
   745
    {
hgs
parents: 30
diff changeset
   746
        isChecked = action->isChecked();
hgs
parents: 30
diff changeset
   747
    }
hgs
parents: 30
diff changeset
   748
    
hgs
parents: 30
diff changeset
   749
    return isChecked;
hgs
parents: 30
diff changeset
   750
}
hgs
parents: 30
diff changeset
   751
hgs
parents: 30
diff changeset
   752
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   753
// isActionChecked()
hgs
parents: 30
diff changeset
   754
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   755
//
hgs
parents: 30
diff changeset
   756
void VideoListView::setActionChecked(bool setChecked, const QString &name)
hgs
parents: 30
diff changeset
   757
{
hgs
parents: 30
diff changeset
   758
    HbAction *action = mUiLoader->findObject<HbAction>(name);
hgs
parents: 30
diff changeset
   759
    if (!action)
hgs
parents: 30
diff changeset
   760
    {
hgs
parents: 30
diff changeset
   761
        // must be menu widget
hgs
parents: 30
diff changeset
   762
        HbMenu *menu = mUiLoader->findWidget<HbMenu>(name);
hgs
parents: 30
diff changeset
   763
        if (menu)
30
hgs
parents:
diff changeset
   764
        {
34
hgs
parents: 30
diff changeset
   765
            action = menu->menuAction();
30
hgs
parents:
diff changeset
   766
        }
hgs
parents:
diff changeset
   767
    }
34
hgs
parents: 30
diff changeset
   768
hgs
parents: 30
diff changeset
   769
    // update action check state
hgs
parents: 30
diff changeset
   770
    if (action)
hgs
parents: 30
diff changeset
   771
    {
hgs
parents: 30
diff changeset
   772
        action->setChecked(setChecked);
hgs
parents: 30
diff changeset
   773
    }
30
hgs
parents:
diff changeset
   774
}
hgs
parents:
diff changeset
   775
hgs
parents:
diff changeset
   776
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   777
// openAllVideosViewSlot()
hgs
parents:
diff changeset
   778
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   779
//
hgs
parents:
diff changeset
   780
void VideoListView::openAllVideosViewSlot()
hgs
parents:
diff changeset
   781
{
35
hgs
parents: 34
diff changeset
   782
	if(!mListsLoaded)
hgs
parents: 34
diff changeset
   783
	{
hgs
parents: 34
diff changeset
   784
		loadLists(false);
hgs
parents: 34
diff changeset
   785
	}
hgs
parents: 34
diff changeset
   786
34
hgs
parents: 30
diff changeset
   787
    VideoListWidget *videoListWidget =
hgs
parents: 30
diff changeset
   788
        mUiLoader->findWidget<VideoListWidget>(
hgs
parents: 30
diff changeset
   789
            DOCML_NAME_VC_VIDEOLISTWIDGET);
35
hgs
parents: 34
diff changeset
   790
    
34
hgs
parents: 30
diff changeset
   791
    if (mCurrentList &&
hgs
parents: 30
diff changeset
   792
        videoListWidget &&
hgs
parents: 30
diff changeset
   793
        mCurrentList != videoListWidget)
hgs
parents: 30
diff changeset
   794
    {
hgs
parents: 30
diff changeset
   795
        // deactivate old list
hgs
parents: 30
diff changeset
   796
        mCurrentList->deactivate();
hgs
parents: 30
diff changeset
   797
        
hgs
parents: 30
diff changeset
   798
        // activate all videos list
hgs
parents: 30
diff changeset
   799
        mCurrentList = videoListWidget;
hgs
parents: 30
diff changeset
   800
        mCurrentList->activate(VideoCollectionCommon::ELevelVideos);
hgs
parents: 30
diff changeset
   801
hgs
parents: 30
diff changeset
   802
        // since collection is not to be opened at this point,
hgs
parents: 30
diff changeset
   803
        // we do not receive lauoutChanged for updating the hind -widget
hgs
parents: 30
diff changeset
   804
        // if needed, need to show it here is needed
hgs
parents: 30
diff changeset
   805
        setHintLevel(VideoHintWidget::AllVideos);
hgs
parents: 30
diff changeset
   806
        showHint();
hgs
parents: 30
diff changeset
   807
    }
30
hgs
parents:
diff changeset
   808
}
hgs
parents:
diff changeset
   809
hgs
parents:
diff changeset
   810
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   811
// openCollectionViewSlot()
hgs
parents:
diff changeset
   812
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   813
//
hgs
parents:
diff changeset
   814
void VideoListView::openCollectionViewSlot()
hgs
parents:
diff changeset
   815
{
35
hgs
parents: 34
diff changeset
   816
	if(!mListsLoaded)
hgs
parents: 34
diff changeset
   817
	{
hgs
parents: 34
diff changeset
   818
		loadLists(false);
hgs
parents: 34
diff changeset
   819
	}
hgs
parents: 34
diff changeset
   820
34
hgs
parents: 30
diff changeset
   821
    VideoListWidget *collectionWidget =
hgs
parents: 30
diff changeset
   822
        mUiLoader->findWidget<VideoListWidget>(
hgs
parents: 30
diff changeset
   823
            DOCML_NAME_VC_COLLECTIONWIDGET);
35
hgs
parents: 34
diff changeset
   824
    
34
hgs
parents: 30
diff changeset
   825
    if (mCurrentList &&
hgs
parents: 30
diff changeset
   826
        mCurrentList != collectionWidget)
hgs
parents: 30
diff changeset
   827
    {
hgs
parents: 30
diff changeset
   828
        // deactivate all videos widget
hgs
parents: 30
diff changeset
   829
        mCurrentList->deactivate();
hgs
parents: 30
diff changeset
   830
        
hgs
parents: 30
diff changeset
   831
        // activate video collection widget
hgs
parents: 30
diff changeset
   832
        mCurrentList = collectionWidget;
hgs
parents: 30
diff changeset
   833
        mCurrentList->activate(VideoCollectionCommon::ELevelCategory);
hgs
parents: 30
diff changeset
   834
        
hgs
parents: 30
diff changeset
   835
        VideoSortFilterProxyModel &model = mCurrentList->getModel(); 
hgs
parents: 30
diff changeset
   836
        VideoCollectionViewUtils::sortModel(&model, false);
hgs
parents: 30
diff changeset
   837
hgs
parents: 30
diff changeset
   838
        // the collection view is not empty, so we can hide the hint in advance.
hgs
parents: 30
diff changeset
   839
        showHint(false);
hgs
parents: 30
diff changeset
   840
    }
hgs
parents: 30
diff changeset
   841
}
hgs
parents: 30
diff changeset
   842
hgs
parents: 30
diff changeset
   843
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   844
// openNewAlbumSlot()
hgs
parents: 30
diff changeset
   845
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   846
//
hgs
parents: 30
diff changeset
   847
void VideoListView::openNewAlbumSlot(const QModelIndex &parent,
hgs
parents: 30
diff changeset
   848
    int start,
hgs
parents: 30
diff changeset
   849
    int end)
hgs
parents: 30
diff changeset
   850
{
hgs
parents: 30
diff changeset
   851
    Q_UNUSED(end);
hgs
parents: 30
diff changeset
   852
    if(!mCurrentList)
hgs
parents: 30
diff changeset
   853
    {
hgs
parents: 30
diff changeset
   854
        return;
hgs
parents: 30
diff changeset
   855
    }
hgs
parents: 30
diff changeset
   856
    // invalidate model
hgs
parents: 30
diff changeset
   857
    VideoSortFilterProxyModel &model = mCurrentList->getModel();
hgs
parents: 30
diff changeset
   858
    model.invalidate();
hgs
parents: 30
diff changeset
   859
        
hgs
parents: 30
diff changeset
   860
    // activate new index
hgs
parents: 30
diff changeset
   861
    QModelIndex index = model.index(start, 0, parent);
hgs
parents: 30
diff changeset
   862
    if (index.isValid())
hgs
parents: 30
diff changeset
   863
    {
hgs
parents: 30
diff changeset
   864
        // disconnect rowsInserted signal to prevent obsolete slot calls
hgs
parents: 30
diff changeset
   865
        disconnect( &model, SIGNAL(rowsInserted(const QModelIndex&, int, int)),
hgs
parents: 30
diff changeset
   866
                    this, SLOT(openNewAlbumSlot(const QModelIndex&, int, int)));
hgs
parents: 30
diff changeset
   867
hgs
parents: 30
diff changeset
   868
        mCurrentList->emitActivated(index);        
hgs
parents: 30
diff changeset
   869
    }
30
hgs
parents:
diff changeset
   870
}
hgs
parents:
diff changeset
   871
hgs
parents:
diff changeset
   872
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   873
// openservicesViewSlot()
hgs
parents:
diff changeset
   874
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   875
//
hgs
parents:
diff changeset
   876
void VideoListView::openServicesViewSlot()
hgs
parents:
diff changeset
   877
{
hgs
parents:
diff changeset
   878
    debugNotImplementedYet();
hgs
parents:
diff changeset
   879
}
hgs
parents:
diff changeset
   880
hgs
parents:
diff changeset
   881
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   882
// startSorting()
hgs
parents:
diff changeset
   883
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   884
//
hgs
parents:
diff changeset
   885
void VideoListView::startSorting()
hgs
parents:
diff changeset
   886
{
34
hgs
parents: 30
diff changeset
   887
    HbMenu *optionsMenu =
hgs
parents: 30
diff changeset
   888
        mUiLoader->findWidget<HbMenu>(
hgs
parents: 30
diff changeset
   889
            DOCML_NAME_OPTIONS_MENU);
hgs
parents: 30
diff changeset
   890
    if (optionsMenu)
30
hgs
parents:
diff changeset
   891
    {
34
hgs
parents: 30
diff changeset
   892
        // get sorting role from active action
hgs
parents: 30
diff changeset
   893
        HbAction *action = optionsMenu->activeAction()->menu()->activeAction();
35
hgs
parents: 34
diff changeset
   894
        if(action)
hgs
parents: 34
diff changeset
   895
		{
hgs
parents: 34
diff changeset
   896
			doSorting(mSortingRoles[action]);
hgs
parents: 34
diff changeset
   897
		}
hgs
parents: 34
diff changeset
   898
    }
hgs
parents: 34
diff changeset
   899
}
30
hgs
parents:
diff changeset
   900
35
hgs
parents: 34
diff changeset
   901
// ---------------------------------------------------------------------------
hgs
parents: 34
diff changeset
   902
// doSorting()
hgs
parents: 34
diff changeset
   903
// ---------------------------------------------------------------------------
hgs
parents: 34
diff changeset
   904
//
hgs
parents: 34
diff changeset
   905
void VideoListView::doSorting(int role)
hgs
parents: 34
diff changeset
   906
{
hgs
parents: 34
diff changeset
   907
	// sort model
hgs
parents: 34
diff changeset
   908
	Qt::SortOrder order(Qt::AscendingOrder);
hgs
parents: 34
diff changeset
   909
	VideoSortFilterProxyModel &model = mCurrentList->getModel();
hgs
parents: 34
diff changeset
   910
	if(model.sortRole() == role && model.sortOrder() == Qt::AscendingOrder)
hgs
parents: 34
diff changeset
   911
	{
hgs
parents: 34
diff changeset
   912
		order = Qt::DescendingOrder;
hgs
parents: 34
diff changeset
   913
	}
hgs
parents: 34
diff changeset
   914
	model.doSorting(role, order);
30
hgs
parents:
diff changeset
   915
35
hgs
parents: 34
diff changeset
   916
	// save sorting values
hgs
parents: 34
diff changeset
   917
	mUiUtils.saveSortingValues(role, order);
30
hgs
parents:
diff changeset
   918
}
hgs
parents:
diff changeset
   919
hgs
parents:
diff changeset
   920
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   921
// aboutToChangeOrientationSlot()
hgs
parents:
diff changeset
   922
// hide all items in the window during orientation change
hgs
parents:
diff changeset
   923
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   924
//
hgs
parents:
diff changeset
   925
void VideoListView::aboutToChangeOrientationSlot()
hgs
parents:
diff changeset
   926
{
hgs
parents:
diff changeset
   927
    // this method is required for changing from to mediawall
hgs
parents:
diff changeset
   928
}
hgs
parents:
diff changeset
   929
hgs
parents:
diff changeset
   930
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   931
// orientationChangedSlot()
hgs
parents:
diff changeset
   932
// orientation changed, items can be put back to visible after view has handled the change
hgs
parents:
diff changeset
   933
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   934
//
hgs
parents:
diff changeset
   935
void VideoListView::orientationChangedSlot( Qt::Orientation orientation )
hgs
parents:
diff changeset
   936
{
hgs
parents:
diff changeset
   937
    // this method is required for changing from to mediawall
hgs
parents:
diff changeset
   938
    
hgs
parents:
diff changeset
   939
    // in landscape we need to hide the title and the toolbar. (also required for the mediawall?)
hgs
parents:
diff changeset
   940
    // TODO: how about the feature where the toolbar comes visible if screen is tapped?
hgs
parents:
diff changeset
   941
    this->setItemVisible(Hb::AllItems, orientation == Qt::Vertical);
hgs
parents:
diff changeset
   942
}
hgs
parents:
diff changeset
   943
hgs
parents:
diff changeset
   944
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   945
// deleteItemsSlot
hgs
parents:
diff changeset
   946
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   947
//
hgs
parents:
diff changeset
   948
void VideoListView::deleteItemsSlot()
hgs
parents:
diff changeset
   949
{
34
hgs
parents: 30
diff changeset
   950
    if(!mCurrentList)
30
hgs
parents:
diff changeset
   951
    {
hgs
parents:
diff changeset
   952
        return;
hgs
parents:
diff changeset
   953
    }
35
hgs
parents: 34
diff changeset
   954
hgs
parents: 34
diff changeset
   955
    if(!mMultiselectionLoaded)
hgs
parents: 34
diff changeset
   956
    {
hgs
parents: 34
diff changeset
   957
    	loadMultiSelection();
hgs
parents: 34
diff changeset
   958
    }
hgs
parents: 34
diff changeset
   959
34
hgs
parents: 30
diff changeset
   960
    VideoListSelectionDialog *dialog =
hgs
parents: 30
diff changeset
   961
        mUiLoader->findWidget<VideoListSelectionDialog>(
hgs
parents: 30
diff changeset
   962
            DOCML_NAME_DIALOG);
hgs
parents: 30
diff changeset
   963
    if (dialog)
30
hgs
parents:
diff changeset
   964
    {
34
hgs
parents: 30
diff changeset
   965
        TMPXItemId collectionId = mCurrentList->getModel().getOpenItem();
hgs
parents: 30
diff changeset
   966
        dialog->setupContent(VideoListSelectionDialog::EDeleteVideos, collectionId); 
hgs
parents: 30
diff changeset
   967
        dialog->exec();
30
hgs
parents:
diff changeset
   968
    }
hgs
parents:
diff changeset
   969
}
hgs
parents:
diff changeset
   970
hgs
parents:
diff changeset
   971
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   972
// createCollectionSlot
hgs
parents:
diff changeset
   973
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   974
//
hgs
parents:
diff changeset
   975
void VideoListView::createCollectionSlot()
hgs
parents:
diff changeset
   976
{
34
hgs
parents: 30
diff changeset
   977
    if(!mCurrentList)
hgs
parents: 30
diff changeset
   978
    {
hgs
parents: 30
diff changeset
   979
        return;
hgs
parents: 30
diff changeset
   980
    }
hgs
parents: 30
diff changeset
   981
    
hgs
parents: 30
diff changeset
   982
    VideoSortFilterProxyModel &model = mCurrentList->getModel();
hgs
parents: 30
diff changeset
   983
hgs
parents: 30
diff changeset
   984
    
hgs
parents: 30
diff changeset
   985
    bool ok = false;
hgs
parents: 30
diff changeset
   986
    // query a name for the collection
35
hgs
parents: 34
diff changeset
   987
    QString label(hbTrId("txt_videos_title_enter_name"));
hgs
parents: 34
diff changeset
   988
    QString text(hbTrId("txt_videos_dialog_entry_new_collection"));
34
hgs
parents: 30
diff changeset
   989
    text = HbInputDialog::getText(label, text, &ok);
hgs
parents: 30
diff changeset
   990
    if (ok && text.length())
hgs
parents: 30
diff changeset
   991
    {
hgs
parents: 30
diff changeset
   992
        // resolve collection true name and add new album
hgs
parents: 30
diff changeset
   993
        text = model.resolveAlbumName(text);
hgs
parents: 30
diff changeset
   994
        
hgs
parents: 30
diff changeset
   995
        // when collection reports about new collection, we open it right away,
hgs
parents: 30
diff changeset
   996
        // for that, connect to rowsInserted so that the new album can be opened
hgs
parents: 30
diff changeset
   997
        if(!connect(&model, SIGNAL(rowsInserted(const QModelIndex&, int, int)),
hgs
parents: 30
diff changeset
   998
                    this, SLOT(openNewAlbumSlot(const QModelIndex&, int, int))))
hgs
parents: 30
diff changeset
   999
        {
hgs
parents: 30
diff changeset
  1000
            return;
hgs
parents: 30
diff changeset
  1001
        }
hgs
parents: 30
diff changeset
  1002
        
hgs
parents: 30
diff changeset
  1003
        model.addNewAlbum(text);
hgs
parents: 30
diff changeset
  1004
    }
30
hgs
parents:
diff changeset
  1005
}
hgs
parents:
diff changeset
  1006
hgs
parents:
diff changeset
  1007
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
  1008
// addVideosToCollectionSlot
hgs
parents:
diff changeset
  1009
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
  1010
//
hgs
parents:
diff changeset
  1011
void VideoListView::addVideosToCollectionSlot()
hgs
parents:
diff changeset
  1012
{
34
hgs
parents: 30
diff changeset
  1013
    if(!mCurrentList)
hgs
parents: 30
diff changeset
  1014
    {
hgs
parents: 30
diff changeset
  1015
        return;
hgs
parents: 30
diff changeset
  1016
    }
35
hgs
parents: 34
diff changeset
  1017
hgs
parents: 34
diff changeset
  1018
    if(!mMultiselectionLoaded)
hgs
parents: 34
diff changeset
  1019
    {
hgs
parents: 34
diff changeset
  1020
    	loadMultiSelection();
hgs
parents: 34
diff changeset
  1021
    }
hgs
parents: 34
diff changeset
  1022
34
hgs
parents: 30
diff changeset
  1023
    VideoListSelectionDialog *dialog =
hgs
parents: 30
diff changeset
  1024
        mUiLoader->findWidget<VideoListSelectionDialog>(
hgs
parents: 30
diff changeset
  1025
            DOCML_NAME_DIALOG);
35
hgs
parents: 34
diff changeset
  1026
    if (!dialog)
34
hgs
parents: 30
diff changeset
  1027
    {
35
hgs
parents: 34
diff changeset
  1028
        // fatal: no selection dialog
hgs
parents: 34
diff changeset
  1029
        return;
hgs
parents: 34
diff changeset
  1030
    }
hgs
parents: 34
diff changeset
  1031
    if(mCurrentList->getLevel() == VideoCollectionCommon::ELevelAlbum)
hgs
parents: 34
diff changeset
  1032
    {
hgs
parents: 34
diff changeset
  1033
        // album is opened, do not proceed in case it already have same amount
hgs
parents: 34
diff changeset
  1034
        // of videos than all videos view.
hgs
parents: 34
diff changeset
  1035
        VideoListWidget *allVideos = mUiLoader->findWidget<VideoListWidget>(
hgs
parents: 34
diff changeset
  1036
                    DOCML_NAME_VC_VIDEOLISTWIDGET);
hgs
parents: 34
diff changeset
  1037
        if(allVideos)
34
hgs
parents: 30
diff changeset
  1038
        {
35
hgs
parents: 34
diff changeset
  1039
            int count = allVideos->getModel().rowCount();
hgs
parents: 34
diff changeset
  1040
            if(count == mCurrentList->getModel().rowCount())
34
hgs
parents: 30
diff changeset
  1041
            {
35
hgs
parents: 34
diff changeset
  1042
                if(count)
34
hgs
parents: 30
diff changeset
  1043
                {
hgs
parents: 30
diff changeset
  1044
                    QVariant emptyAdditional;
hgs
parents: 30
diff changeset
  1045
                    mUiUtils.showStatusMsgSlot(
hgs
parents: 30
diff changeset
  1046
                            VideoCollectionCommon::statusAllVideosAlreadyInCollection,
hgs
parents: 30
diff changeset
  1047
                            emptyAdditional);
35
hgs
parents: 34
diff changeset
  1048
                }
hgs
parents: 34
diff changeset
  1049
                return;
hgs
parents: 34
diff changeset
  1050
            }  
34
hgs
parents: 30
diff changeset
  1051
        }
35
hgs
parents: 34
diff changeset
  1052
    }
hgs
parents: 34
diff changeset
  1053
    TMPXItemId collectionId = mCurrentList->getModel().getOpenItem();
hgs
parents: 34
diff changeset
  1054
    dialog->setupContent(VideoListSelectionDialog::EAddToCollection, collectionId);
hgs
parents: 34
diff changeset
  1055
    dialog->exec();
hgs
parents: 34
diff changeset
  1056
}
hgs
parents: 34
diff changeset
  1057
hgs
parents: 34
diff changeset
  1058
// -------------------------------------------------------------------------------------------------
hgs
parents: 34
diff changeset
  1059
// removeVideosFromCollectionSlot
hgs
parents: 34
diff changeset
  1060
// -------------------------------------------------------------------------------------------------
hgs
parents: 34
diff changeset
  1061
//
hgs
parents: 34
diff changeset
  1062
void VideoListView::removeVideosFromCollectionSlot()
hgs
parents: 34
diff changeset
  1063
{
hgs
parents: 34
diff changeset
  1064
    if(!mCurrentList)
hgs
parents: 34
diff changeset
  1065
    {
hgs
parents: 34
diff changeset
  1066
        return;
hgs
parents: 34
diff changeset
  1067
    }
hgs
parents: 34
diff changeset
  1068
    // not allowed if for some reason current widget 
hgs
parents: 34
diff changeset
  1069
    // is all videos or collection or there are no items
hgs
parents: 34
diff changeset
  1070
    if(mCurrentList->getLevel() < VideoCollectionCommon::ELevelDefaultColl ||
hgs
parents: 34
diff changeset
  1071
       !mCurrentList->getModel().rowCount())
hgs
parents: 34
diff changeset
  1072
    {
hgs
parents: 34
diff changeset
  1073
        return;
hgs
parents: 34
diff changeset
  1074
    }
hgs
parents: 34
diff changeset
  1075
hgs
parents: 34
diff changeset
  1076
    if(!mMultiselectionLoaded)
hgs
parents: 34
diff changeset
  1077
    {
hgs
parents: 34
diff changeset
  1078
    	loadMultiSelection();
hgs
parents: 34
diff changeset
  1079
    }
hgs
parents: 34
diff changeset
  1080
hgs
parents: 34
diff changeset
  1081
    VideoListSelectionDialog *dialog =
hgs
parents: 34
diff changeset
  1082
            mUiLoader->findWidget<VideoListSelectionDialog>(
hgs
parents: 34
diff changeset
  1083
                        DOCML_NAME_DIALOG);
hgs
parents: 34
diff changeset
  1084
    if (!dialog)
hgs
parents: 34
diff changeset
  1085
    {
hgs
parents: 34
diff changeset
  1086
        // fatal: no selection dialog
hgs
parents: 34
diff changeset
  1087
        return;
hgs
parents: 34
diff changeset
  1088
    }
hgs
parents: 34
diff changeset
  1089
    TMPXItemId collectionId = mCurrentList->getModel().getOpenItem();
hgs
parents: 34
diff changeset
  1090
    if(collectionId != TMPXItemId::InvalidId() && collectionId.iId2 != KVcxMvcMediaTypeVideo)
hgs
parents: 34
diff changeset
  1091
    {
hgs
parents: 34
diff changeset
  1092
        dialog->setupContent(VideoListSelectionDialog::ERemoveFromCollection, collectionId);
34
hgs
parents: 30
diff changeset
  1093
        dialog->exec();
hgs
parents: 30
diff changeset
  1094
    }
30
hgs
parents:
diff changeset
  1095
}
hgs
parents:
diff changeset
  1096
hgs
parents:
diff changeset
  1097
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
  1098
// aboutToShowMainMenuSlot
hgs
parents:
diff changeset
  1099
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
  1100
//
hgs
parents:
diff changeset
  1101
void VideoListView::aboutToShowMainMenuSlot()
hgs
parents:
diff changeset
  1102
{
34
hgs
parents: 30
diff changeset
  1103
	if (!mCurrentList ||
hgs
parents: 30
diff changeset
  1104
	    !mToolbarViewsActionGroup ||
hgs
parents: 30
diff changeset
  1105
	    !mToolbarCollectionActionGroup)
30
hgs
parents:
diff changeset
  1106
	{
hgs
parents:
diff changeset
  1107
		return;
hgs
parents:
diff changeset
  1108
	}
34
hgs
parents: 30
diff changeset
  1109
	
hgs
parents: 30
diff changeset
  1110
	// hide all actions by default
hgs
parents: 30
diff changeset
  1111
    showAction(false, DOCML_NAME_ADD_TO_COLLECTION);
hgs
parents: 30
diff changeset
  1112
    showAction(false, DOCML_NAME_CREATE_COLLECTION);
hgs
parents: 30
diff changeset
  1113
    showAction(false, DOCML_NAME_DELETE_MULTIPLE);
hgs
parents: 30
diff changeset
  1114
    showAction(false, DOCML_NAME_SORT_BY_DATE);
hgs
parents: 30
diff changeset
  1115
    showAction(false, DOCML_NAME_SORT_BY_NAME);
hgs
parents: 30
diff changeset
  1116
    showAction(false, DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS);
hgs
parents: 30
diff changeset
  1117
    showAction(false, DOCML_NAME_SORT_BY_RATING);
hgs
parents: 30
diff changeset
  1118
    showAction(false, DOCML_NAME_SORT_BY_SIZE);
hgs
parents: 30
diff changeset
  1119
    showAction(false, DOCML_NAME_SORT_MENU);
hgs
parents: 30
diff changeset
  1120
    
hgs
parents: 30
diff changeset
  1121
    VideoSortFilterProxyModel &model = mCurrentList->getModel();
hgs
parents: 30
diff changeset
  1122
    if (!model.rowCount(QModelIndex()))
30
hgs
parents:
diff changeset
  1123
    {
hgs
parents:
diff changeset
  1124
        return;
hgs
parents:
diff changeset
  1125
    }
34
hgs
parents: 30
diff changeset
  1126
    
hgs
parents: 30
diff changeset
  1127
    // get current sorting values
hgs
parents: 30
diff changeset
  1128
    int role;
hgs
parents: 30
diff changeset
  1129
    Qt::SortOrder order;
hgs
parents: 30
diff changeset
  1130
    model.getSorting(role, order);
30
hgs
parents:
diff changeset
  1131
hgs
parents:
diff changeset
  1132
    HbAction *firstAction = (HbAction*)(toolBar()->actions().first());
hgs
parents:
diff changeset
  1133
hgs
parents:
diff changeset
  1134
    if(mToolbarViewsActionGroup->checkedAction() == mToolbarActions[ETBActionAllVideos] &&
hgs
parents:
diff changeset
  1135
       firstAction == mToolbarActions[ETBActionAllVideos])
hgs
parents:
diff changeset
  1136
    {
34
hgs
parents: 30
diff changeset
  1137
        showAction(true, DOCML_NAME_SORT_MENU);
hgs
parents: 30
diff changeset
  1138
        showAction(true, DOCML_NAME_SORT_BY_DATE);
35
hgs
parents: 34
diff changeset
  1139
        if (isActionChecked(DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS))
34
hgs
parents: 30
diff changeset
  1140
        {
hgs
parents: 30
diff changeset
  1141
            //TODO: when changing between videos and categories, sorting order needs to be changed, if new
hgs
parents: 30
diff changeset
  1142
            //      view does not have the previously active sorting order supported
hgs
parents: 30
diff changeset
  1143
            showAction(true, DOCML_NAME_SORT_BY_DATE);
hgs
parents: 30
diff changeset
  1144
        }
hgs
parents: 30
diff changeset
  1145
        else
hgs
parents: 30
diff changeset
  1146
        {
hgs
parents: 30
diff changeset
  1147
            HbAction* action = mSortingRoles.key(role);
hgs
parents: 30
diff changeset
  1148
            if (action)
hgs
parents: 30
diff changeset
  1149
            {
hgs
parents: 30
diff changeset
  1150
                action->setChecked(true);
hgs
parents: 30
diff changeset
  1151
            }
hgs
parents: 30
diff changeset
  1152
        }
hgs
parents: 30
diff changeset
  1153
        
hgs
parents: 30
diff changeset
  1154
        showAction(true, DOCML_NAME_SORT_BY_NAME);
hgs
parents: 30
diff changeset
  1155
        showAction(true, DOCML_NAME_SORT_BY_SIZE);
30
hgs
parents:
diff changeset
  1156
hgs
parents:
diff changeset
  1157
        if (!mIsService)
hgs
parents:
diff changeset
  1158
        {
34
hgs
parents: 30
diff changeset
  1159
            showAction(true, DOCML_NAME_ADD_TO_COLLECTION);
hgs
parents: 30
diff changeset
  1160
            showAction(true, DOCML_NAME_DELETE_MULTIPLE);
30
hgs
parents:
diff changeset
  1161
        }
hgs
parents:
diff changeset
  1162
    }
hgs
parents:
diff changeset
  1163
    else if(mToolbarViewsActionGroup->checkedAction() == mToolbarActions[ETBActionCollections] &&
hgs
parents:
diff changeset
  1164
    		firstAction == mToolbarActions[ETBActionAllVideos] )
hgs
parents:
diff changeset
  1165
    {
hgs
parents:
diff changeset
  1166
        if (!mIsService)
hgs
parents:
diff changeset
  1167
        {
34
hgs
parents: 30
diff changeset
  1168
            showAction(true, DOCML_NAME_CREATE_COLLECTION);
30
hgs
parents:
diff changeset
  1169
        }
34
hgs
parents: 30
diff changeset
  1170
        showAction(true, DOCML_NAME_SORT_MENU);
hgs
parents: 30
diff changeset
  1171
        showAction(true, DOCML_NAME_SORT_BY_NAME);
hgs
parents: 30
diff changeset
  1172
    	
hgs
parents: 30
diff changeset
  1173
        if (isActionChecked(DOCML_NAME_SORT_BY_DATE) ||
hgs
parents: 30
diff changeset
  1174
            isActionChecked(DOCML_NAME_SORT_BY_SIZE))
hgs
parents: 30
diff changeset
  1175
    	{
hgs
parents: 30
diff changeset
  1176
            //TODO: when changing between videos and categories, sorting order needs to be changed, if new
hgs
parents: 30
diff changeset
  1177
            //      view does not have the previously active sorting order supported
hgs
parents: 30
diff changeset
  1178
            setActionChecked(true, DOCML_NAME_SORT_BY_NAME);
hgs
parents: 30
diff changeset
  1179
    	}
hgs
parents: 30
diff changeset
  1180
        else
hgs
parents: 30
diff changeset
  1181
        {
hgs
parents: 30
diff changeset
  1182
            HbAction* action = mSortingRoles.key(role);
hgs
parents: 30
diff changeset
  1183
            if (action)
hgs
parents: 30
diff changeset
  1184
            {
hgs
parents: 30
diff changeset
  1185
                action->setChecked(true);
hgs
parents: 30
diff changeset
  1186
            }
hgs
parents: 30
diff changeset
  1187
        }
hgs
parents: 30
diff changeset
  1188
        
hgs
parents: 30
diff changeset
  1189
        showAction(true, DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS);
30
hgs
parents:
diff changeset
  1190
    }
hgs
parents:
diff changeset
  1191
    else if(firstAction != mToolbarActions[ETBActionAllVideos])
hgs
parents:
diff changeset
  1192
    {
35
hgs
parents: 34
diff changeset
  1193
        showAction(true, DOCML_NAME_SORT_MENU);
hgs
parents: 34
diff changeset
  1194
        showAction(true, DOCML_NAME_SORT_BY_DATE);
hgs
parents: 34
diff changeset
  1195
        if (isActionChecked(DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS))
hgs
parents: 34
diff changeset
  1196
        {
hgs
parents: 34
diff changeset
  1197
            //TODO: when changing between videos and categories, sorting order needs to be changed, if new
hgs
parents: 34
diff changeset
  1198
            //      view does not have the previously active sorting order supported
hgs
parents: 34
diff changeset
  1199
            showAction(true, DOCML_NAME_SORT_BY_DATE);
hgs
parents: 34
diff changeset
  1200
        }
hgs
parents: 34
diff changeset
  1201
        else
hgs
parents: 34
diff changeset
  1202
        {
hgs
parents: 34
diff changeset
  1203
            HbAction* action = mSortingRoles.key(role);
hgs
parents: 34
diff changeset
  1204
            if (action)
hgs
parents: 34
diff changeset
  1205
            {
hgs
parents: 34
diff changeset
  1206
                action->setChecked(true);
hgs
parents: 34
diff changeset
  1207
            }
hgs
parents: 34
diff changeset
  1208
        }
hgs
parents: 34
diff changeset
  1209
hgs
parents: 34
diff changeset
  1210
        showAction(true, DOCML_NAME_SORT_BY_NAME);
hgs
parents: 34
diff changeset
  1211
        showAction(true, DOCML_NAME_SORT_BY_SIZE);
hgs
parents: 34
diff changeset
  1212
30
hgs
parents:
diff changeset
  1213
        if (!mIsService)
hgs
parents:
diff changeset
  1214
        {
34
hgs
parents: 30
diff changeset
  1215
            showAction(true, DOCML_NAME_DELETE_MULTIPLE);
30
hgs
parents:
diff changeset
  1216
        }
hgs
parents:
diff changeset
  1217
    }
hgs
parents:
diff changeset
  1218
}
hgs
parents:
diff changeset
  1219
hgs
parents:
diff changeset
  1220
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
  1221
// handleAsyncStatusSlot
hgs
parents:
diff changeset
  1222
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
  1223
//
hgs
parents:
diff changeset
  1224
void VideoListView::handleAsyncStatusSlot(int statusCode, QVariant &additional)
hgs
parents:
diff changeset
  1225
{
hgs
parents:
diff changeset
  1226
    // show msg from status
hgs
parents:
diff changeset
  1227
    mUiUtils.showStatusMsgSlot(statusCode, additional);
hgs
parents:
diff changeset
  1228
}
hgs
parents:
diff changeset
  1229
hgs
parents:
diff changeset
  1230
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
  1231
// collectionOpenedSlot
hgs
parents:
diff changeset
  1232
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
  1233
//
34
hgs
parents: 30
diff changeset
  1234
void VideoListView::collectionOpenedSlot(bool collectionOpened,
hgs
parents: 30
diff changeset
  1235
    const QString& collection,
hgs
parents: 30
diff changeset
  1236
    const QModelIndex &index)
30
hgs
parents:
diff changeset
  1237
{
35
hgs
parents: 34
diff changeset
  1238
	if(mTransitionOngoing)
hgs
parents: 34
diff changeset
  1239
	{
hgs
parents: 34
diff changeset
  1240
		return;
hgs
parents: 34
diff changeset
  1241
	}
hgs
parents: 34
diff changeset
  1242
	else
hgs
parents: 34
diff changeset
  1243
	{
hgs
parents: 34
diff changeset
  1244
	    // clear toolbar actions.
hgs
parents: 34
diff changeset
  1245
	    toolBar()->clearActions();
hgs
parents: 34
diff changeset
  1246
	}
hgs
parents: 34
diff changeset
  1247
	
34
hgs
parents: 30
diff changeset
  1248
    // update collection specific information
hgs
parents: 30
diff changeset
  1249
    mCollectionName = collection;
30
hgs
parents:
diff changeset
  1250
35
hgs
parents: 34
diff changeset
  1251
    if(collectionOpened)
30
hgs
parents:
diff changeset
  1252
    {
34
hgs
parents: 30
diff changeset
  1253
        if(!index.isValid())
hgs
parents: 30
diff changeset
  1254
        {   
hgs
parents: 30
diff changeset
  1255
            return;
hgs
parents: 30
diff changeset
  1256
        }
35
hgs
parents: 34
diff changeset
  1257
        
34
hgs
parents: 30
diff changeset
  1258
        // open album view
hgs
parents: 30
diff changeset
  1259
        VideoListWidget *collectionContentWidget =
hgs
parents: 30
diff changeset
  1260
            mUiLoader->findWidget<VideoListWidget>(
hgs
parents: 30
diff changeset
  1261
                DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
35
hgs
parents: 34
diff changeset
  1262
        
34
hgs
parents: 30
diff changeset
  1263
        if (mCurrentList &&
hgs
parents: 30
diff changeset
  1264
            mCurrentList != collectionContentWidget)
hgs
parents: 30
diff changeset
  1265
        {
hgs
parents: 30
diff changeset
  1266
            // get item id before deactivating
hgs
parents: 30
diff changeset
  1267
            TMPXItemId itemId = TMPXItemId::InvalidId();
hgs
parents: 30
diff changeset
  1268
            itemId = mCurrentList->getModel().getMediaIdAtIndex(index);
hgs
parents: 30
diff changeset
  1269
            
hgs
parents: 30
diff changeset
  1270
            // only category or album can be activated here
hgs
parents: 30
diff changeset
  1271
            if(itemId == TMPXItemId::InvalidId() ||
hgs
parents: 30
diff changeset
  1272
               (itemId.iId2 != KVcxMvcMediaTypeCategory && 
hgs
parents: 30
diff changeset
  1273
                itemId.iId2 != KVcxMvcMediaTypeAlbum))
hgs
parents: 30
diff changeset
  1274
            {
hgs
parents: 30
diff changeset
  1275
                return;
hgs
parents: 30
diff changeset
  1276
            }
hgs
parents: 30
diff changeset
  1277
            
35
hgs
parents: 34
diff changeset
  1278
            // Send level that is opened with the effect.
hgs
parents: 34
diff changeset
  1279
            QVariant nextLevel;
34
hgs
parents: 30
diff changeset
  1280
            if(itemId.iId2 ==  KVcxMvcMediaTypeCategory)
hgs
parents: 30
diff changeset
  1281
            {
35
hgs
parents: 34
diff changeset
  1282
                nextLevel = QVariant(VideoCollectionCommon::ELevelDefaultColl);
34
hgs
parents: 30
diff changeset
  1283
            }
hgs
parents: 30
diff changeset
  1284
            else if(itemId.iId2 == KVcxMvcMediaTypeAlbum)
hgs
parents: 30
diff changeset
  1285
            {
35
hgs
parents: 34
diff changeset
  1286
                nextLevel = QVariant(VideoCollectionCommon::ELevelAlbum);
hgs
parents: 34
diff changeset
  1287
            }            
hgs
parents: 34
diff changeset
  1288
            
hgs
parents: 34
diff changeset
  1289
            // Start fetching content.
hgs
parents: 34
diff changeset
  1290
            collectionContentWidget->getModel().openItem(itemId);
34
hgs
parents: 30
diff changeset
  1291
            
35
hgs
parents: 34
diff changeset
  1292
            HbEffect::start(collectionContentWidget,
hgs
parents: 34
diff changeset
  1293
                            EFFECT_SLIDE_IN_TO_LEFT,
hgs
parents: 34
diff changeset
  1294
                            this,
hgs
parents: 34
diff changeset
  1295
                            "finishCollectionOpenedSlot",
hgs
parents: 34
diff changeset
  1296
                            nextLevel);
34
hgs
parents: 30
diff changeset
  1297
            
35
hgs
parents: 34
diff changeset
  1298
            mTransitionOngoing = true;
34
hgs
parents: 30
diff changeset
  1299
        }
30
hgs
parents:
diff changeset
  1300
    }
hgs
parents:
diff changeset
  1301
    else
hgs
parents:
diff changeset
  1302
    {
35
hgs
parents: 34
diff changeset
  1303
        // open categories view.
hgs
parents: 34
diff changeset
  1304
        VideoListWidget *collectionContentWidget =
hgs
parents: 34
diff changeset
  1305
            mUiLoader->findWidget<VideoListWidget>(
hgs
parents: 34
diff changeset
  1306
                DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
34
hgs
parents: 30
diff changeset
  1307
        
35
hgs
parents: 34
diff changeset
  1308
        HbEffect::start(collectionContentWidget,
hgs
parents: 34
diff changeset
  1309
                        EFFECT_SLIDE_OUT_TO_LEFT,
hgs
parents: 34
diff changeset
  1310
                        this,
hgs
parents: 34
diff changeset
  1311
                        "finishCollectionClosedSlot");
hgs
parents: 34
diff changeset
  1312
        
hgs
parents: 34
diff changeset
  1313
        mTransitionOngoing = true;
30
hgs
parents:
diff changeset
  1314
    }
hgs
parents:
diff changeset
  1315
}
hgs
parents:
diff changeset
  1316
hgs
parents:
diff changeset
  1317
// -------------------------------------------------------------------------------------------------
35
hgs
parents: 34
diff changeset
  1318
// finishCollectionOpenedSlot
30
hgs
parents:
diff changeset
  1319
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
  1320
//
35
hgs
parents: 34
diff changeset
  1321
void VideoListView::finishCollectionOpenedSlot(const HbEffect::EffectStatus &status)
30
hgs
parents:
diff changeset
  1322
{
35
hgs
parents: 34
diff changeset
  1323
    Q_UNUSED(status);
hgs
parents: 34
diff changeset
  1324
    
hgs
parents: 34
diff changeset
  1325
    mTransitionOngoing = false;
hgs
parents: 34
diff changeset
  1326
    
hgs
parents: 34
diff changeset
  1327
    // deactivat current widget.
hgs
parents: 34
diff changeset
  1328
    mCurrentList->deactivate();
hgs
parents: 34
diff changeset
  1329
    
hgs
parents: 34
diff changeset
  1330
    // activate video collection content widget.
hgs
parents: 34
diff changeset
  1331
    mCurrentList = mUiLoader->findWidget<VideoListWidget>(
hgs
parents: 34
diff changeset
  1332
                    DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
hgs
parents: 34
diff changeset
  1333
hgs
parents: 34
diff changeset
  1334
    if(!mCurrentList || !status.userData.isValid())
30
hgs
parents:
diff changeset
  1335
    {
hgs
parents:
diff changeset
  1336
        return;
hgs
parents:
diff changeset
  1337
    }
34
hgs
parents: 30
diff changeset
  1338
    
35
hgs
parents: 34
diff changeset
  1339
    updateSubLabel();
hgs
parents: 34
diff changeset
  1340
hgs
parents: 34
diff changeset
  1341
    VideoCollectionCommon::TCollectionLevels level =
hgs
parents: 34
diff changeset
  1342
            static_cast<VideoCollectionCommon::TCollectionLevels>(status.userData.toInt());
hgs
parents: 34
diff changeset
  1343
    mCurrentList->activate(level);
34
hgs
parents: 30
diff changeset
  1344
    
35
hgs
parents: 34
diff changeset
  1345
    // update hint widget
hgs
parents: 34
diff changeset
  1346
    setHintLevel(VideoHintWidget::Collection);
hgs
parents: 34
diff changeset
  1347
    showHint();
hgs
parents: 34
diff changeset
  1348
hgs
parents: 34
diff changeset
  1349
    // update toolbar for albums, default categories don't have one.
hgs
parents: 34
diff changeset
  1350
    if(level == VideoCollectionCommon::ELevelAlbum && 
hgs
parents: 34
diff changeset
  1351
       mToolbarCollectionActionGroup && mToolbarActions.contains(ETBActionCollections))
34
hgs
parents: 30
diff changeset
  1352
    {
35
hgs
parents: 34
diff changeset
  1353
        mToolbarActions[ETBActionCollections]->setChecked(false);
hgs
parents: 34
diff changeset
  1354
        toolBar()->addActions(mToolbarCollectionActionGroup->actions());
hgs
parents: 34
diff changeset
  1355
    }
hgs
parents: 34
diff changeset
  1356
}
30
hgs
parents:
diff changeset
  1357
35
hgs
parents: 34
diff changeset
  1358
// -------------------------------------------------------------------------------------------------
hgs
parents: 34
diff changeset
  1359
// finishCollectionClosedSlot
hgs
parents: 34
diff changeset
  1360
// -------------------------------------------------------------------------------------------------
hgs
parents: 34
diff changeset
  1361
//
hgs
parents: 34
diff changeset
  1362
void VideoListView::finishCollectionClosedSlot(const HbEffect::EffectStatus &status)
hgs
parents: 34
diff changeset
  1363
{
hgs
parents: 34
diff changeset
  1364
    Q_UNUSED(status);
hgs
parents: 34
diff changeset
  1365
    
hgs
parents: 34
diff changeset
  1366
    mTransitionOngoing = false;
hgs
parents: 34
diff changeset
  1367
    
hgs
parents: 34
diff changeset
  1368
    // open collection view
hgs
parents: 34
diff changeset
  1369
    openCollectionViewSlot();
hgs
parents: 34
diff changeset
  1370
    
hgs
parents: 34
diff changeset
  1371
    // update toolbar
hgs
parents: 34
diff changeset
  1372
    if(mToolbarViewsActionGroup && mToolbarActions.contains(ETBActionCollections))
hgs
parents: 34
diff changeset
  1373
    {
hgs
parents: 34
diff changeset
  1374
        toolBar()->addActions(mToolbarViewsActionGroup->actions());
hgs
parents: 34
diff changeset
  1375
        mToolbarActions[ETBActionCollections]->setChecked(true);
34
hgs
parents: 30
diff changeset
  1376
    }
hgs
parents: 30
diff changeset
  1377
}
hgs
parents: 30
diff changeset
  1378
hgs
parents: 30
diff changeset
  1379
// -------------------------------------------------------------------------------------------------
hgs
parents: 30
diff changeset
  1380
// widgetReadySlot
hgs
parents: 30
diff changeset
  1381
// -------------------------------------------------------------------------------------------------
hgs
parents: 30
diff changeset
  1382
//
hgs
parents: 30
diff changeset
  1383
void VideoListView::widgetReadySlot(QGraphicsWidget *widget, const QString &name)
hgs
parents: 30
diff changeset
  1384
{
hgs
parents: 30
diff changeset
  1385
    if (name.compare(DOCML_NAME_VC_VIDEOLISTWIDGET) == 0)
hgs
parents: 30
diff changeset
  1386
    {
hgs
parents: 30
diff changeset
  1387
        connect(widget, SIGNAL(command(int)), this, SIGNAL(command(int)));
35
hgs
parents: 34
diff changeset
  1388
        connect(this, SIGNAL(doDelayeds()), widget, SLOT(doDelayedsSlot()));
34
hgs
parents: 30
diff changeset
  1389
    }
hgs
parents: 30
diff changeset
  1390
    else if (name.compare(DOCML_NAME_VC_COLLECTIONWIDGET) == 0)
hgs
parents: 30
diff changeset
  1391
    {
hgs
parents: 30
diff changeset
  1392
        connect(
hgs
parents: 30
diff changeset
  1393
            widget, SIGNAL(collectionOpened(bool, const QString&, const QModelIndex&)),
hgs
parents: 30
diff changeset
  1394
            this, SLOT(collectionOpenedSlot(bool, const QString&, const QModelIndex&)));
35
hgs
parents: 34
diff changeset
  1395
            connect(this, SIGNAL(doDelayeds()), widget, SLOT(doDelayedsSlot()));
hgs
parents: 34
diff changeset
  1396
            emit(doDelayeds());
34
hgs
parents: 30
diff changeset
  1397
    }
hgs
parents: 30
diff changeset
  1398
    else if (name.compare(DOCML_NAME_VC_COLLECTIONCONTENTWIDGET) == 0)
hgs
parents: 30
diff changeset
  1399
    {
hgs
parents: 30
diff changeset
  1400
        connect(widget, SIGNAL(command(int)), this, SIGNAL(command(int)));
hgs
parents: 30
diff changeset
  1401
        connect(
hgs
parents: 30
diff changeset
  1402
            widget, SIGNAL(collectionOpened(bool, const QString&, const QModelIndex&)),
hgs
parents: 30
diff changeset
  1403
            this, SLOT(collectionOpenedSlot(bool, const QString&, const QModelIndex&)));
35
hgs
parents: 34
diff changeset
  1404
            connect(this, SIGNAL(doDelayeds()), widget, SLOT(doDelayedsSlot()));
hgs
parents: 34
diff changeset
  1405
            emit(doDelayeds());
34
hgs
parents: 30
diff changeset
  1406
    }
hgs
parents: 30
diff changeset
  1407
    else if (name.compare(DOCML_NAME_OPTIONS_MENU) == 0)
hgs
parents: 30
diff changeset
  1408
    {
hgs
parents: 30
diff changeset
  1409
        connect(
hgs
parents: 30
diff changeset
  1410
            widget, SIGNAL(aboutToShow()), this, SLOT(aboutToShowMainMenuSlot()));
hgs
parents: 30
diff changeset
  1411
    }
hgs
parents: 30
diff changeset
  1412
    else if (name.compare(DOCML_NAME_HINT_BUTTON) == 0)
hgs
parents: 30
diff changeset
  1413
    {
hgs
parents: 30
diff changeset
  1414
        connect(widget, SIGNAL(clicked(bool)), this, SLOT(openServicesViewSlot()));
hgs
parents: 30
diff changeset
  1415
    }
hgs
parents: 30
diff changeset
  1416
}
30
hgs
parents:
diff changeset
  1417
34
hgs
parents: 30
diff changeset
  1418
// -------------------------------------------------------------------------------------------------
hgs
parents: 30
diff changeset
  1419
// objectReadySlot
hgs
parents: 30
diff changeset
  1420
// -------------------------------------------------------------------------------------------------
hgs
parents: 30
diff changeset
  1421
//
hgs
parents: 30
diff changeset
  1422
void VideoListView::objectReadySlot(QObject *object, const QString &name)
hgs
parents: 30
diff changeset
  1423
{
hgs
parents: 30
diff changeset
  1424
	if (name.compare(DOCML_NAME_SORT_BY_DATE) == 0)
hgs
parents: 30
diff changeset
  1425
    {
hgs
parents: 30
diff changeset
  1426
        HbAction *action = qobject_cast<HbAction*>(object);
hgs
parents: 30
diff changeset
  1427
        if (action)
hgs
parents: 30
diff changeset
  1428
        {
hgs
parents: 30
diff changeset
  1429
        	connect(action, SIGNAL(triggered()), this, SLOT(startSorting()));
hgs
parents: 30
diff changeset
  1430
            mSortingRoles[action] = VideoCollectionCommon::KeyDateTime;
hgs
parents: 30
diff changeset
  1431
        }
hgs
parents: 30
diff changeset
  1432
    }
hgs
parents: 30
diff changeset
  1433
    else if (name.compare(DOCML_NAME_SORT_BY_NAME) == 0)
hgs
parents: 30
diff changeset
  1434
    {
hgs
parents: 30
diff changeset
  1435
        HbAction *action = qobject_cast<HbAction*>(object);
hgs
parents: 30
diff changeset
  1436
        if (action)
hgs
parents: 30
diff changeset
  1437
        {
hgs
parents: 30
diff changeset
  1438
        	connect(action, SIGNAL(triggered()), this, SLOT(startSorting()));
hgs
parents: 30
diff changeset
  1439
            mSortingRoles[action] = Qt::DisplayRole;
hgs
parents: 30
diff changeset
  1440
        }
hgs
parents: 30
diff changeset
  1441
    }
hgs
parents: 30
diff changeset
  1442
    else if (name.compare(DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS) == 0)
hgs
parents: 30
diff changeset
  1443
    {
hgs
parents: 30
diff changeset
  1444
        HbAction *action = qobject_cast<HbAction*>(object);
hgs
parents: 30
diff changeset
  1445
        if (action)
hgs
parents: 30
diff changeset
  1446
        {
hgs
parents: 30
diff changeset
  1447
        	// TODO: implement
hgs
parents: 30
diff changeset
  1448
            connect(action, SIGNAL(triggered()), this, SLOT(debugNotImplementedYet()));
hgs
parents: 30
diff changeset
  1449
            mSortingRoles[action] = 0;
hgs
parents: 30
diff changeset
  1450
        }
hgs
parents: 30
diff changeset
  1451
    }
hgs
parents: 30
diff changeset
  1452
    else if (name.compare(DOCML_NAME_SORT_BY_SIZE) == 0)
hgs
parents: 30
diff changeset
  1453
    {
hgs
parents: 30
diff changeset
  1454
        HbAction *action = qobject_cast<HbAction*>(object);
hgs
parents: 30
diff changeset
  1455
        if (action)
hgs
parents: 30
diff changeset
  1456
        {
hgs
parents: 30
diff changeset
  1457
        	connect(action, SIGNAL(triggered()), this, SLOT(startSorting()));
hgs
parents: 30
diff changeset
  1458
            mSortingRoles[action] = VideoCollectionCommon::KeySizeValue;
hgs
parents: 30
diff changeset
  1459
        }
hgs
parents: 30
diff changeset
  1460
    }
hgs
parents: 30
diff changeset
  1461
    else if (name.compare(DOCML_NAME_ADD_TO_COLLECTION) == 0)
hgs
parents: 30
diff changeset
  1462
    {
hgs
parents: 30
diff changeset
  1463
        HbAction *action = qobject_cast<HbAction*>(object);
hgs
parents: 30
diff changeset
  1464
        if (action)
hgs
parents: 30
diff changeset
  1465
        {
hgs
parents: 30
diff changeset
  1466
            connect(action, SIGNAL(triggered()), this, SLOT(addVideosToCollectionSlot()));
hgs
parents: 30
diff changeset
  1467
        }
hgs
parents: 30
diff changeset
  1468
    }
hgs
parents: 30
diff changeset
  1469
    else if (name.compare(DOCML_NAME_CREATE_COLLECTION) == 0)
hgs
parents: 30
diff changeset
  1470
    {
hgs
parents: 30
diff changeset
  1471
        HbAction *action = qobject_cast<HbAction*>(object);
hgs
parents: 30
diff changeset
  1472
        if (action)
hgs
parents: 30
diff changeset
  1473
        {
hgs
parents: 30
diff changeset
  1474
            connect(action, SIGNAL(triggered()), this, SLOT(createCollectionSlot()));
hgs
parents: 30
diff changeset
  1475
        }
hgs
parents: 30
diff changeset
  1476
    }
hgs
parents: 30
diff changeset
  1477
    else if (name.compare(DOCML_NAME_DELETE_MULTIPLE) == 0)
hgs
parents: 30
diff changeset
  1478
    {
hgs
parents: 30
diff changeset
  1479
        HbAction *action = qobject_cast<HbAction*>(object);
hgs
parents: 30
diff changeset
  1480
        if (action)
hgs
parents: 30
diff changeset
  1481
        {
hgs
parents: 30
diff changeset
  1482
            connect(action, SIGNAL(triggered()), this, SLOT(deleteItemsSlot()));
hgs
parents: 30
diff changeset
  1483
        }
hgs
parents: 30
diff changeset
  1484
    }
30
hgs
parents:
diff changeset
  1485
}
hgs
parents:
diff changeset
  1486
hgs
parents:
diff changeset
  1487
// Just for testing, remove this
hgs
parents:
diff changeset
  1488
void VideoListView::debugNotImplementedYet()
hgs
parents:
diff changeset
  1489
{
hgs
parents:
diff changeset
  1490
    HbMessageBox::information(tr("Not implemented yet"));
hgs
parents:
diff changeset
  1491
}
hgs
parents:
diff changeset
  1492
hgs
parents:
diff changeset
  1493
// end of file
hgs
parents:
diff changeset
  1494