videocollection/videocollectionview/src/videolistwidget.cpp
author hgs
Fri, 06 Aug 2010 09:43:48 +0300
changeset 50 21fe8338c6bf
parent 44 518105d52e45
child 55 4bfa887905cf
permissions -rw-r--r--
201031
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2008 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 content widget implementation
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
36
hgs
parents: 35
diff changeset
    18
#include "videocollectiontrace.h"
30
hgs
parents:
diff changeset
    19
#include "videolistwidget.h"
hgs
parents:
diff changeset
    20
39
hgs
parents: 38
diff changeset
    21
#include <xqserviceutil.h>
34
hgs
parents: 30
diff changeset
    22
#include <qcoreapplication.h>
30
hgs
parents:
diff changeset
    23
#include <qtimer.h>
hgs
parents:
diff changeset
    24
#include <hbscrollbar.h>
hgs
parents:
diff changeset
    25
#include <xqserviceutil.h>
hgs
parents:
diff changeset
    26
#include <hbmenu.h>
hgs
parents:
diff changeset
    27
#include <hbaction.h>
hgs
parents:
diff changeset
    28
#include <hbinstance.h>
hgs
parents:
diff changeset
    29
#include <hbmainwindow.h>
hgs
parents:
diff changeset
    30
#include <hblistviewitem.h>
hgs
parents:
diff changeset
    31
#include <hbmessagebox.h>
36
hgs
parents: 35
diff changeset
    32
#include <hbinputdialog.h>
44
hgs
parents: 41
diff changeset
    33
#include <hbparameterlengthlimiter.h>
30
hgs
parents:
diff changeset
    34
#include <vcxmyvideosdefs.h>
hgs
parents:
diff changeset
    35
34
hgs
parents: 30
diff changeset
    36
#include "videocollectionviewutils.h"
hgs
parents: 30
diff changeset
    37
#include "videocollectionuiloader.h"
hgs
parents: 30
diff changeset
    38
#include "videolistselectiondialog.h"
30
hgs
parents:
diff changeset
    39
#include "videothumbnaildata.h"
hgs
parents:
diff changeset
    40
#include "videosortfilterproxymodel.h"
hgs
parents:
diff changeset
    41
#include "videocollectioncommon.h"
hgs
parents:
diff changeset
    42
#include "mpxhbvideocommondefs.h"
hgs
parents:
diff changeset
    43
38
hgs
parents: 37
diff changeset
    44
// Object names.
hgs
parents: 37
diff changeset
    45
const char* const LIST_WIDGET_OBJECT_NAME_CONTEXT_MENU             = "vc:ListWidgetContextMenu";
hgs
parents: 37
diff changeset
    46
const char* const LIST_WIDGET_OBJECT_NAME_DELETE_VIDEO             = "vc:ListWidgetMessageBoxDeleteVideo";
hgs
parents: 37
diff changeset
    47
const char* const LIST_WIDGET_OBJECT_NAME_RENAME_VIDEO             = "vc:ListWidgetInputDialogRenameVideo";
hgs
parents: 37
diff changeset
    48
const char* const LIST_WIDGET_OBJECT_NAME_REMOVE_COLLECTION        = "vc:ListWidgetMessageBoxRemoveCollection";
hgs
parents: 37
diff changeset
    49
const char* const LIST_WIDGET_OBJECT_NAME_NAV_KEY_BACK             = "vc:ListWidgetNavKeyBack";
hgs
parents: 37
diff changeset
    50
const char* const LIST_WIDGET_OBJECT_NAME_NAV_KEY_QUIT             = "vc:ListWidgetNavKeyQuit";
hgs
parents: 37
diff changeset
    51
const char* const LIST_WIDGET_OBJECT_NAME_ACTION_ATTACH            = "vc:ListWidgetActionAttach";
hgs
parents: 37
diff changeset
    52
const char* const LIST_WIDGET_OBJECT_NAME_ACTION_PLAY              = "vc:ListWidgetActionPlay";
hgs
parents: 37
diff changeset
    53
const char* const LIST_WIDGET_OBJECT_NAME_ACTION_DETAILS           = "vc:ListWidgetActionDetails";
hgs
parents: 37
diff changeset
    54
const char* const LIST_WIDGET_OBJECT_NAME_ACTION_DELETE            = "vc:ListWidgetActionDelete";
hgs
parents: 37
diff changeset
    55
const char* const LIST_WIDGET_OBJECT_NAME_ACTION_OPEN              = "vc:ListWidgetActionOpen";
hgs
parents: 37
diff changeset
    56
const char* const LIST_WIDGET_OBJECT_NAME_ACTION_ADD_TO            = "vc:ListWidgetActionAddToCollection";
hgs
parents: 37
diff changeset
    57
const char* const LIST_WIDGET_OBJECT_NAME_ACTION_REMOVE_FROM       = "vc:ListWidgetActionRemoveFromCollection";
hgs
parents: 37
diff changeset
    58
const char* const LIST_WIDGET_OBJECT_NAME_ACTION_RENAME            = "vc:ListWidgetActionRename";
hgs
parents: 37
diff changeset
    59
const char* const LIST_WIDGET_OBJECT_NAME_ACTION_REMOVE_COLLECTION = "vc:ListWidgetActionRemoveCollection";
hgs
parents: 37
diff changeset
    60
30
hgs
parents:
diff changeset
    61
// Interval in ms to report the scroll position.
hgs
parents:
diff changeset
    62
const int SCROLL_POSITION_TIMER_TIMEOUT = 100;
hgs
parents:
diff changeset
    63
hgs
parents:
diff changeset
    64
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    65
// Constructor
hgs
parents:
diff changeset
    66
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    67
//
34
hgs
parents: 30
diff changeset
    68
VideoListWidget::VideoListWidget(VideoCollectionUiLoader *uiLoader, HbView *parent) :
30
hgs
parents:
diff changeset
    69
HbListView(parent),
hgs
parents:
diff changeset
    70
mModel(0),
hgs
parents:
diff changeset
    71
mVideoServices(0),
34
hgs
parents: 30
diff changeset
    72
mCurrentLevel(VideoCollectionCommon::ELevelInvalid),
30
hgs
parents:
diff changeset
    73
mSignalsConnected(false),
36
hgs
parents: 35
diff changeset
    74
mNavKeyAction(0),
30
hgs
parents:
diff changeset
    75
mContextMenu(0),
34
hgs
parents: 30
diff changeset
    76
mSelectionMode(HbAbstractItemView::NoSelection),
hgs
parents: 30
diff changeset
    77
mScrollPositionTimer(0),
39
hgs
parents: 38
diff changeset
    78
mUiLoader(uiLoader),
hgs
parents: 38
diff changeset
    79
mService(VideoServices::ENoService)
30
hgs
parents:
diff changeset
    80
{
36
hgs
parents: 35
diff changeset
    81
	FUNC_LOG_ADDR(this);
30
hgs
parents:
diff changeset
    82
}
hgs
parents:
diff changeset
    83
hgs
parents:
diff changeset
    84
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    85
// Destructor
hgs
parents:
diff changeset
    86
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    87
//
hgs
parents:
diff changeset
    88
VideoListWidget::~VideoListWidget()
hgs
parents:
diff changeset
    89
{
36
hgs
parents: 35
diff changeset
    90
	FUNC_LOG_ADDR(this);
30
hgs
parents:
diff changeset
    91
    delete mScrollPositionTimer;
hgs
parents:
diff changeset
    92
    mScrollPositionTimer = 0;
hgs
parents:
diff changeset
    93
	mContextMenuActions.clear();
hgs
parents:
diff changeset
    94
	disconnect();
hgs
parents:
diff changeset
    95
    delete mContextMenu;
hgs
parents:
diff changeset
    96
    mContextMenu = 0;
36
hgs
parents: 35
diff changeset
    97
    delete mNavKeyAction;
hgs
parents: 35
diff changeset
    98
    mNavKeyAction = 0;
41
hgs
parents: 40
diff changeset
    99
    
hgs
parents: 40
diff changeset
   100
    if(mVideoServices)
hgs
parents: 40
diff changeset
   101
    {
hgs
parents: 40
diff changeset
   102
        mVideoServices->decreaseReferenceCount();
hgs
parents: 40
diff changeset
   103
        mVideoServices = 0;
hgs
parents: 40
diff changeset
   104
    }
30
hgs
parents:
diff changeset
   105
}
hgs
parents:
diff changeset
   106
hgs
parents:
diff changeset
   107
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   108
// initialize
hgs
parents:
diff changeset
   109
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   110
//
39
hgs
parents: 38
diff changeset
   111
int VideoListWidget::initialize(VideoSortFilterProxyModel &model, 
41
hgs
parents: 40
diff changeset
   112
                                bool isService,
39
hgs
parents: 38
diff changeset
   113
                                VideoCollectionCommon::TCollectionLevels level)
30
hgs
parents:
diff changeset
   114
{
36
hgs
parents: 35
diff changeset
   115
	FUNC_LOG_ADDR(this);
39
hgs
parents: 38
diff changeset
   116
    mModel = &model;    
hgs
parents: 38
diff changeset
   117
	mCurrentLevel = level;
30
hgs
parents:
diff changeset
   118
41
hgs
parents: 40
diff changeset
   119
	if(isService)
30
hgs
parents:
diff changeset
   120
	{
41
hgs
parents: 40
diff changeset
   121
		if(!mVideoServices)
hgs
parents: 40
diff changeset
   122
		{
hgs
parents: 40
diff changeset
   123
		    mVideoServices = VideoServices::instance();
hgs
parents: 40
diff changeset
   124
		}
39
hgs
parents: 38
diff changeset
   125
    	if(XQServiceUtil::interfaceName().contains("IVideoFetch"))
hgs
parents: 38
diff changeset
   126
    	{
hgs
parents: 38
diff changeset
   127
    		mService = VideoServices::EUriFetcher;
hgs
parents: 38
diff changeset
   128
    	}
hgs
parents: 38
diff changeset
   129
    	else if (XQServiceUtil::interfaceName().contains("IVideoBrowse"))
hgs
parents: 38
diff changeset
   130
    	{
hgs
parents: 38
diff changeset
   131
    		mService = VideoServices::EBrowse;
hgs
parents: 38
diff changeset
   132
    	}
30
hgs
parents:
diff changeset
   133
	}
41
hgs
parents: 40
diff changeset
   134
    else
hgs
parents: 40
diff changeset
   135
    {
hgs
parents: 40
diff changeset
   136
        if(mVideoServices)
hgs
parents: 40
diff changeset
   137
        {
hgs
parents: 40
diff changeset
   138
		    mVideoServices->decreaseReferenceCount();
hgs
parents: 40
diff changeset
   139
            mVideoServices = 0;    
hgs
parents: 40
diff changeset
   140
        }
hgs
parents: 40
diff changeset
   141
    }
30
hgs
parents:
diff changeset
   142
34
hgs
parents: 30
diff changeset
   143
    // init list view
hgs
parents: 30
diff changeset
   144
    VideoCollectionViewUtils::initListView(this);
30
hgs
parents:
diff changeset
   145
hgs
parents:
diff changeset
   146
	mScrollPositionTimer = new QTimer();
hgs
parents:
diff changeset
   147
	mScrollPositionTimer->setSingleShot(true);
hgs
parents:
diff changeset
   148
41
hgs
parents: 40
diff changeset
   149
	if (mVideoServices)
30
hgs
parents:
diff changeset
   150
	{
hgs
parents:
diff changeset
   151
		connect(this, SIGNAL(fileUri(const QString&)), mVideoServices, SLOT(itemSelected(const QString&)));
hgs
parents:
diff changeset
   152
	}
hgs
parents:
diff changeset
   153
50
hgs
parents: 44
diff changeset
   154
	setItemPixmapCacheEnabled(true);
35
hgs
parents: 34
diff changeset
   155
	setModel(mModel);
34
hgs
parents: 30
diff changeset
   156
	
30
hgs
parents:
diff changeset
   157
    return 0;
hgs
parents:
diff changeset
   158
}
hgs
parents:
diff changeset
   159
hgs
parents:
diff changeset
   160
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   161
// activate
hgs
parents:
diff changeset
   162
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   163
//
hgs
parents:
diff changeset
   164
int VideoListWidget::activate()
hgs
parents:
diff changeset
   165
{
36
hgs
parents: 35
diff changeset
   166
	FUNC_LOG_ADDR(this);
30
hgs
parents:
diff changeset
   167
    return activate(mCurrentLevel);
hgs
parents:
diff changeset
   168
}
hgs
parents:
diff changeset
   169
hgs
parents:
diff changeset
   170
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   171
// activate
hgs
parents:
diff changeset
   172
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   173
//
34
hgs
parents: 30
diff changeset
   174
int VideoListWidget::activate(VideoCollectionCommon::TCollectionLevels level)
30
hgs
parents:
diff changeset
   175
{
36
hgs
parents: 35
diff changeset
   176
	FUNC_LOG_ADDR(this);
hgs
parents: 35
diff changeset
   177
	INFO_2("VideoListWidget::activate() [0x%x]: level: %d", this, level);
hgs
parents: 35
diff changeset
   178
	
41
hgs
parents: 40
diff changeset
   179
    if(!mModel || level == VideoCollectionCommon::ELevelInvalid)
30
hgs
parents:
diff changeset
   180
    {
hgs
parents:
diff changeset
   181
        return -1;
hgs
parents:
diff changeset
   182
    }
35
hgs
parents: 34
diff changeset
   183
    
30
hgs
parents:
diff changeset
   184
	mCurrentLevel = level;
35
hgs
parents: 34
diff changeset
   185
    setVisible(true);
30
hgs
parents:
diff changeset
   186
36
hgs
parents: 35
diff changeset
   187
    setNavigationAction();
hgs
parents: 35
diff changeset
   188
hgs
parents: 35
diff changeset
   189
    if (connectSignals() < 0)
30
hgs
parents:
diff changeset
   190
    {
36
hgs
parents: 35
diff changeset
   191
        ERROR_1(-1, "VideoListWidget::activate() [0x%x]: connecting signals failed.", this);
30
hgs
parents:
diff changeset
   192
        return -1;
hgs
parents:
diff changeset
   193
    }
hgs
parents:
diff changeset
   194
34
hgs
parents: 30
diff changeset
   195
    // open model to the current level in case not in album or category
36
hgs
parents: 35
diff changeset
   196
    if (level != VideoCollectionCommon::ELevelAlbum &&
34
hgs
parents: 30
diff changeset
   197
        level != VideoCollectionCommon::ELevelDefaultColl)
hgs
parents: 30
diff changeset
   198
    {
hgs
parents: 30
diff changeset
   199
         mModel->open(level);
hgs
parents: 30
diff changeset
   200
    }
hgs
parents: 30
diff changeset
   201
    
30
hgs
parents:
diff changeset
   202
    // Enable thumbnail background fetching.
hgs
parents:
diff changeset
   203
    VideoThumbnailData &thumbnailData = VideoThumbnailData::instance();
hgs
parents:
diff changeset
   204
    thumbnailData.enableBackgroundFetching(true);
44
hgs
parents: 41
diff changeset
   205
    fetchThumbnailsForVisibleItems();
30
hgs
parents:
diff changeset
   206
hgs
parents:
diff changeset
   207
    return 0;
hgs
parents:
diff changeset
   208
}
hgs
parents:
diff changeset
   209
hgs
parents:
diff changeset
   210
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   211
// deactivate
hgs
parents:
diff changeset
   212
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   213
//
hgs
parents:
diff changeset
   214
void VideoListWidget::deactivate()
hgs
parents:
diff changeset
   215
{
36
hgs
parents: 35
diff changeset
   216
	FUNC_LOG_ADDR(this);
30
hgs
parents:
diff changeset
   217
    if(mContextMenu) 
hgs
parents:
diff changeset
   218
    {
hgs
parents:
diff changeset
   219
        mContextMenu->hide();
hgs
parents:
diff changeset
   220
    }
35
hgs
parents: 34
diff changeset
   221
hgs
parents: 34
diff changeset
   222
    setVisible(false);
30
hgs
parents:
diff changeset
   223
    disConnectSignals();
36
hgs
parents: 35
diff changeset
   224
30
hgs
parents:
diff changeset
   225
    // Free allocated memory for list thumbnails and disable background fetching.
hgs
parents:
diff changeset
   226
    VideoThumbnailData &thumbnailData = VideoThumbnailData::instance();
hgs
parents:
diff changeset
   227
    thumbnailData.enableBackgroundFetching(false);
hgs
parents:
diff changeset
   228
    thumbnailData.freeThumbnailData();
hgs
parents:
diff changeset
   229
}
hgs
parents:
diff changeset
   230
hgs
parents:
diff changeset
   231
// ---------------------------------------------------------------------------
34
hgs
parents: 30
diff changeset
   232
// getLevel
hgs
parents: 30
diff changeset
   233
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   234
//
hgs
parents: 30
diff changeset
   235
VideoCollectionCommon::TCollectionLevels VideoListWidget::getLevel()
hgs
parents: 30
diff changeset
   236
{
36
hgs
parents: 35
diff changeset
   237
	FUNC_LOG_ADDR(this);
34
hgs
parents: 30
diff changeset
   238
    return mCurrentLevel;
hgs
parents: 30
diff changeset
   239
}
hgs
parents: 30
diff changeset
   240
hgs
parents: 30
diff changeset
   241
// ---------------------------------------------------------------------------
30
hgs
parents:
diff changeset
   242
// connectSignals
hgs
parents:
diff changeset
   243
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   244
//
hgs
parents:
diff changeset
   245
int VideoListWidget::connectSignals()
hgs
parents:
diff changeset
   246
{
36
hgs
parents: 35
diff changeset
   247
	FUNC_LOG_ADDR(this);
hgs
parents: 35
diff changeset
   248
	
41
hgs
parents: 40
diff changeset
   249
    if (mSignalsConnected)
hgs
parents: 40
diff changeset
   250
    {
hgs
parents: 40
diff changeset
   251
        return 0;
hgs
parents: 40
diff changeset
   252
    }
hgs
parents: 40
diff changeset
   253
    
hgs
parents: 40
diff changeset
   254
    if(!connect(this, SIGNAL(scrollingStarted()), this, SLOT(scrollingStartedSlot())) ||
hgs
parents: 40
diff changeset
   255
       !connect(this, SIGNAL(scrollingEnded()), this, SLOT(scrollingEndedSlot())) ||
hgs
parents: 40
diff changeset
   256
       !connect(this, SIGNAL(scrollPositionChanged(const QPointF &)), 
hgs
parents: 40
diff changeset
   257
               this, SLOT(scrollPositionChangedSlot(const QPointF &))) ||
hgs
parents: 40
diff changeset
   258
       !connect(mScrollPositionTimer, SIGNAL(timeout()), this, SLOT(scrollPositionTimerSlot())) || 
hgs
parents: 40
diff changeset
   259
       !connect(this, SIGNAL(longPressed(HbAbstractViewItem *, const QPointF &)), 
hgs
parents: 40
diff changeset
   260
                this, SLOT(longPressedSlot(HbAbstractViewItem *, const QPointF &))))
30
hgs
parents:
diff changeset
   261
    {
41
hgs
parents: 40
diff changeset
   262
        return -1;
hgs
parents: 40
diff changeset
   263
    }
36
hgs
parents: 35
diff changeset
   264
41
hgs
parents: 40
diff changeset
   265
    // handle navi key trigger -signal connection
hgs
parents: 40
diff changeset
   266
    const char *slot = SLOT(quit()); 
hgs
parents: 40
diff changeset
   267
    QObject *receiver = qApp;
hgs
parents: 40
diff changeset
   268
    
hgs
parents: 40
diff changeset
   269
    if(mVideoServices && mService == VideoServices::EBrowse)
hgs
parents: 40
diff changeset
   270
    {
hgs
parents: 40
diff changeset
   271
        receiver = mVideoServices;
hgs
parents: 40
diff changeset
   272
        slot = SLOT(browsingEnded());
hgs
parents: 40
diff changeset
   273
    }
hgs
parents: 40
diff changeset
   274
    else 
hgs
parents: 40
diff changeset
   275
    {        
hgs
parents: 40
diff changeset
   276
        if(mCurrentLevel == VideoCollectionCommon::ELevelAlbum || 
hgs
parents: 40
diff changeset
   277
           mCurrentLevel == VideoCollectionCommon::ELevelDefaultColl)
36
hgs
parents: 35
diff changeset
   278
        {
41
hgs
parents: 40
diff changeset
   279
            receiver = this;
hgs
parents: 40
diff changeset
   280
            slot = SLOT(back());
hgs
parents: 40
diff changeset
   281
        }
hgs
parents: 40
diff changeset
   282
        else if(mVideoServices && mService == VideoServices::EUriFetcher)
hgs
parents: 40
diff changeset
   283
        {
hgs
parents: 40
diff changeset
   284
            receiver = this;
hgs
parents: 40
diff changeset
   285
            slot = SLOT(endVideoFecthingSlot());            
36
hgs
parents: 35
diff changeset
   286
        }
30
hgs
parents:
diff changeset
   287
    }
41
hgs
parents: 40
diff changeset
   288
    if(!connect(mNavKeyAction, SIGNAL(triggered()), receiver, slot))
hgs
parents: 40
diff changeset
   289
    {
hgs
parents: 40
diff changeset
   290
        return -1;
hgs
parents: 40
diff changeset
   291
    }
hgs
parents: 40
diff changeset
   292
    mSignalsConnected = true;
hgs
parents: 40
diff changeset
   293
    
hgs
parents: 40
diff changeset
   294
	return 0;
30
hgs
parents:
diff changeset
   295
}
hgs
parents:
diff changeset
   296
hgs
parents:
diff changeset
   297
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   298
// disConnectSignals
hgs
parents:
diff changeset
   299
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   300
//
hgs
parents:
diff changeset
   301
void VideoListWidget::disConnectSignals()
hgs
parents:
diff changeset
   302
{
36
hgs
parents: 35
diff changeset
   303
    FUNC_LOG_ADDR(this);
hgs
parents: 35
diff changeset
   304
    
hgs
parents: 35
diff changeset
   305
    // safe to disconnect these always
hgs
parents: 35
diff changeset
   306
    disconnect(
hgs
parents: 35
diff changeset
   307
        this, SIGNAL(scrollingStarted()),
hgs
parents: 35
diff changeset
   308
        this, SLOT(scrollingStartedSlot()));
hgs
parents: 35
diff changeset
   309
    disconnect(
hgs
parents: 35
diff changeset
   310
        this, SIGNAL(scrollingEnded()),
hgs
parents: 35
diff changeset
   311
        this, SLOT(scrollingEndedSlot()));
hgs
parents: 35
diff changeset
   312
    disconnect(
hgs
parents: 35
diff changeset
   313
        this, SIGNAL(scrollPositionChanged(const QPointF&)), 
hgs
parents: 35
diff changeset
   314
        this, SLOT(scrollPositionChangedSlot(const QPointF&)));
hgs
parents: 35
diff changeset
   315
    disconnect(this, SIGNAL(longPressed(HbAbstractViewItem *, const QPointF &)), 
hgs
parents: 35
diff changeset
   316
             this, SLOT(longPressedSlot(HbAbstractViewItem *, const QPointF &)));
hgs
parents: 35
diff changeset
   317
    
hgs
parents: 35
diff changeset
   318
    // check that scroll position timer is created
hgs
parents: 35
diff changeset
   319
    if (mScrollPositionTimer)
hgs
parents: 35
diff changeset
   320
    {
hgs
parents: 35
diff changeset
   321
        disconnect(
hgs
parents: 35
diff changeset
   322
            mScrollPositionTimer, SIGNAL(timeout()),
hgs
parents: 35
diff changeset
   323
            this, SLOT(scrollPositionTimerSlot()));
hgs
parents: 35
diff changeset
   324
    }
41
hgs
parents: 40
diff changeset
   325
    if(mNavKeyAction)
36
hgs
parents: 35
diff changeset
   326
    {
41
hgs
parents: 40
diff changeset
   327
        mNavKeyAction->disconnect(SIGNAL(triggered()));
36
hgs
parents: 35
diff changeset
   328
    }
34
hgs
parents: 30
diff changeset
   329
30
hgs
parents:
diff changeset
   330
	mSignalsConnected = false;
hgs
parents:
diff changeset
   331
}
hgs
parents:
diff changeset
   332
hgs
parents:
diff changeset
   333
// ---------------------------------------------------------------------------
36
hgs
parents: 35
diff changeset
   334
// setNavigationAction
hgs
parents: 35
diff changeset
   335
// ---------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   336
//
hgs
parents: 35
diff changeset
   337
void VideoListWidget::setNavigationAction()
hgs
parents: 35
diff changeset
   338
{
hgs
parents: 35
diff changeset
   339
    FUNC_LOG_ADDR(this);
hgs
parents: 35
diff changeset
   340
    
hgs
parents: 35
diff changeset
   341
    // Create navigation action if not already created
hgs
parents: 35
diff changeset
   342
    if (!mNavKeyAction)
hgs
parents: 35
diff changeset
   343
    {
41
hgs
parents: 40
diff changeset
   344
        Hb::NavigationAction navAction = Hb::QuitNaviAction;
hgs
parents: 40
diff changeset
   345
        QString objectName = LIST_WIDGET_OBJECT_NAME_NAV_KEY_QUIT;
hgs
parents: 40
diff changeset
   346
        if(mCurrentLevel == VideoCollectionCommon::ELevelAlbum || 
hgs
parents: 40
diff changeset
   347
           mCurrentLevel == VideoCollectionCommon::ELevelDefaultColl)
36
hgs
parents: 35
diff changeset
   348
        {
41
hgs
parents: 40
diff changeset
   349
            navAction = Hb::BackNaviAction; 
hgs
parents: 40
diff changeset
   350
            objectName = LIST_WIDGET_OBJECT_NAME_NAV_KEY_BACK;
36
hgs
parents: 35
diff changeset
   351
        }
41
hgs
parents: 40
diff changeset
   352
        mNavKeyAction = new HbAction(navAction);
hgs
parents: 40
diff changeset
   353
        mNavKeyAction->setObjectName(LIST_WIDGET_OBJECT_NAME_NAV_KEY_BACK);       
36
hgs
parents: 35
diff changeset
   354
    }
hgs
parents: 35
diff changeset
   355
        
hgs
parents: 35
diff changeset
   356
    // Set navigation action only when widget is not in selection mode
hgs
parents: 35
diff changeset
   357
    if (mSelectionMode == HbAbstractItemView::NoSelection)
hgs
parents: 35
diff changeset
   358
    {
hgs
parents: 35
diff changeset
   359
        HbView *currentView = hbInstance->allMainWindows().value(0)->currentView();
hgs
parents: 35
diff changeset
   360
        if (currentView)
hgs
parents: 35
diff changeset
   361
        {
hgs
parents: 35
diff changeset
   362
            currentView->setNavigationAction(mNavKeyAction);
hgs
parents: 35
diff changeset
   363
        }
hgs
parents: 35
diff changeset
   364
    }
hgs
parents: 35
diff changeset
   365
}
hgs
parents: 35
diff changeset
   366
hgs
parents: 35
diff changeset
   367
// ---------------------------------------------------------------------------
30
hgs
parents:
diff changeset
   368
// deleteItemSlot
hgs
parents:
diff changeset
   369
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   370
//
hgs
parents:
diff changeset
   371
void VideoListWidget::deleteItemSlot()
hgs
parents:
diff changeset
   372
{
36
hgs
parents: 35
diff changeset
   373
	FUNC_LOG_ADDR(this);
30
hgs
parents:
diff changeset
   374
    if(!mModel)
hgs
parents:
diff changeset
   375
    {
hgs
parents:
diff changeset
   376
        return;
hgs
parents:
diff changeset
   377
    }
hgs
parents:
diff changeset
   378
    
hgs
parents:
diff changeset
   379
    QVariant variant;
hgs
parents:
diff changeset
   380
    QModelIndex index = currentIndex();
36
hgs
parents: 35
diff changeset
   381
    variant = mModel->data(index, VideoCollectionCommon::KeyTitle);
30
hgs
parents:
diff changeset
   382
hgs
parents:
diff changeset
   383
    if (variant.isValid())
hgs
parents:
diff changeset
   384
    {
44
hgs
parents: 41
diff changeset
   385
        QString text = HbParameterLengthLimiter(
hgs
parents: 41
diff changeset
   386
                hbTrId("txt_videos_info_do_you_want_to_delete_1")).arg(variant.toString()); 
37
hgs
parents: 36
diff changeset
   387
        
hgs
parents: 36
diff changeset
   388
        HbMessageBox *messageBox = new HbMessageBox(text, HbMessageBox::MessageTypeQuestion);
44
hgs
parents: 41
diff changeset
   389
        messageBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
37
hgs
parents: 36
diff changeset
   390
        messageBox->setAttribute(Qt::WA_DeleteOnClose);
38
hgs
parents: 37
diff changeset
   391
        messageBox->setObjectName(LIST_WIDGET_OBJECT_NAME_DELETE_VIDEO);
44
hgs
parents: 41
diff changeset
   392
        messageBox->open(this, SLOT(deleteItemDialogFinished(int)));
37
hgs
parents: 36
diff changeset
   393
    }
hgs
parents: 36
diff changeset
   394
}
hgs
parents: 36
diff changeset
   395
hgs
parents: 36
diff changeset
   396
// ---------------------------------------------------------------------------
hgs
parents: 36
diff changeset
   397
// deleteItemDialogFinished
hgs
parents: 36
diff changeset
   398
// ---------------------------------------------------------------------------
hgs
parents: 36
diff changeset
   399
//
44
hgs
parents: 41
diff changeset
   400
void VideoListWidget::deleteItemDialogFinished(int action)
37
hgs
parents: 36
diff changeset
   401
{
44
hgs
parents: 41
diff changeset
   402
    if(action == HbMessageBox::Yes)
37
hgs
parents: 36
diff changeset
   403
    {
hgs
parents: 36
diff changeset
   404
        QModelIndex index = currentIndex();
hgs
parents: 36
diff changeset
   405
        if(index.isValid())
30
hgs
parents:
diff changeset
   406
        {
hgs
parents:
diff changeset
   407
            QModelIndexList list;
hgs
parents:
diff changeset
   408
            list.append(index);
hgs
parents:
diff changeset
   409
            mModel->deleteItems(list);
hgs
parents:
diff changeset
   410
        }
hgs
parents:
diff changeset
   411
    }
hgs
parents:
diff changeset
   412
}
hgs
parents:
diff changeset
   413
hgs
parents:
diff changeset
   414
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   415
// createContextMenu
hgs
parents:
diff changeset
   416
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   417
//
hgs
parents:
diff changeset
   418
void VideoListWidget::createContextMenu()
hgs
parents:
diff changeset
   419
{
36
hgs
parents: 35
diff changeset
   420
	FUNC_LOG_ADDR(this);
30
hgs
parents:
diff changeset
   421
    if(mContextMenu)
hgs
parents:
diff changeset
   422
    {
hgs
parents:
diff changeset
   423
        return;
hgs
parents:
diff changeset
   424
    }
35
hgs
parents: 34
diff changeset
   425
    
30
hgs
parents:
diff changeset
   426
    mContextMenu = new HbMenu();
38
hgs
parents: 37
diff changeset
   427
    mContextMenu->setDismissPolicy(HbPopup::TapAnywhere);
hgs
parents: 37
diff changeset
   428
    mContextMenu->setObjectName(LIST_WIDGET_OBJECT_NAME_CONTEXT_MENU);
hgs
parents: 37
diff changeset
   429
39
hgs
parents: 38
diff changeset
   430
    if (mService == VideoServices::EUriFetcher)
38
hgs
parents: 37
diff changeset
   431
    {
hgs
parents: 37
diff changeset
   432
        mContextMenuActions[EActionAttach] = 
hgs
parents: 37
diff changeset
   433
                mContextMenu->addAction(hbTrId("txt_videos_menu_attach"), this, SLOT(openItemSlot()));
hgs
parents: 37
diff changeset
   434
        mContextMenuActions[EActionAttach]->setObjectName(LIST_WIDGET_OBJECT_NAME_ACTION_ATTACH);
36
hgs
parents: 35
diff changeset
   435
        
41
hgs
parents: 40
diff changeset
   436
        mContextMenuActions[EActionOpen]   = 
hgs
parents: 40
diff changeset
   437
                                    mContextMenu->addAction(hbTrId("txt_common_menu_open"), this, SLOT(openItemSlot()));
hgs
parents: 40
diff changeset
   438
        mContextMenuActions[EActionOpen]->setObjectName(LIST_WIDGET_OBJECT_NAME_ACTION_OPEN);
hgs
parents: 40
diff changeset
   439
        
38
hgs
parents: 37
diff changeset
   440
        mContextMenuActions[EActionPlay]    = 
hgs
parents: 37
diff changeset
   441
                mContextMenu->addAction(hbTrId("txt_videos_menu_play"), this, SLOT(playItemSlot()));
hgs
parents: 37
diff changeset
   442
        mContextMenuActions[EActionPlay]->setObjectName(LIST_WIDGET_OBJECT_NAME_ACTION_PLAY);
hgs
parents: 37
diff changeset
   443
        
hgs
parents: 37
diff changeset
   444
        mContextMenuActions[EActionDetails] = 
hgs
parents: 37
diff changeset
   445
                mContextMenu->addAction(hbTrId("txt_common_menu_details"), this, SLOT(openDetailsSlot()));
hgs
parents: 37
diff changeset
   446
        mContextMenuActions[EActionDetails]->setObjectName(LIST_WIDGET_OBJECT_NAME_ACTION_DETAILS);
hgs
parents: 37
diff changeset
   447
    }
39
hgs
parents: 38
diff changeset
   448
    else if (mService == VideoServices::EBrowse)
38
hgs
parents: 37
diff changeset
   449
    {
hgs
parents: 37
diff changeset
   450
        mContextMenuActions[EActionPlay]    = 
hgs
parents: 37
diff changeset
   451
                mContextMenu->addAction(hbTrId("txt_videos_menu_play"), this, SLOT(playItemSlot()));
hgs
parents: 37
diff changeset
   452
        mContextMenuActions[EActionPlay]->setObjectName(LIST_WIDGET_OBJECT_NAME_ACTION_PLAY);
hgs
parents: 37
diff changeset
   453
        
hgs
parents: 37
diff changeset
   454
        mContextMenuActions[EActionDelete]           = 
hgs
parents: 37
diff changeset
   455
                mContextMenu->addAction(hbTrId("txt_common_menu_delete"), this, SLOT(deleteItemSlot()));
hgs
parents: 37
diff changeset
   456
        mContextMenuActions[EActionDelete]->setObjectName(LIST_WIDGET_OBJECT_NAME_ACTION_DELETE);
36
hgs
parents: 35
diff changeset
   457
        
38
hgs
parents: 37
diff changeset
   458
        mContextMenuActions[EActionDetails] = 
hgs
parents: 37
diff changeset
   459
                mContextMenu->addAction(hbTrId("txt_common_menu_details"), this, SLOT(openDetailsSlot()));
hgs
parents: 37
diff changeset
   460
        mContextMenuActions[EActionDetails]->setObjectName(LIST_WIDGET_OBJECT_NAME_ACTION_DETAILS);
hgs
parents: 37
diff changeset
   461
    }
hgs
parents: 37
diff changeset
   462
    else
hgs
parents: 37
diff changeset
   463
    {
hgs
parents: 37
diff changeset
   464
        mContextMenuActions[EActionPlay]    = 
hgs
parents: 37
diff changeset
   465
                mContextMenu->addAction(hbTrId("txt_videos_menu_play"), this, SLOT(playItemSlot()));
hgs
parents: 37
diff changeset
   466
        mContextMenuActions[EActionPlay]->setObjectName(LIST_WIDGET_OBJECT_NAME_ACTION_PLAY);
hgs
parents: 37
diff changeset
   467
        
hgs
parents: 37
diff changeset
   468
        mContextMenuActions[EActionOpen]    = 
hgs
parents: 37
diff changeset
   469
                            mContextMenu->addAction(hbTrId("txt_common_menu_open"), this, SLOT(openItemSlot()));
hgs
parents: 37
diff changeset
   470
        mContextMenuActions[EActionOpen]->setObjectName(LIST_WIDGET_OBJECT_NAME_ACTION_OPEN);
hgs
parents: 37
diff changeset
   471
        
hgs
parents: 37
diff changeset
   472
        mContextMenuActions[EActionAddToCollection] = 
hgs
parents: 37
diff changeset
   473
                mContextMenu->addAction(hbTrId("txt_videos_menu_add_to_collection"), this, SLOT(addToCollectionSlot()));
hgs
parents: 37
diff changeset
   474
        mContextMenuActions[EActionAddToCollection]->setObjectName(LIST_WIDGET_OBJECT_NAME_ACTION_ADD_TO);
hgs
parents: 37
diff changeset
   475
        
hgs
parents: 37
diff changeset
   476
        mContextMenuActions[EActionRemove]           = 
hgs
parents: 37
diff changeset
   477
                mContextMenu->addAction(hbTrId("txt_videos_menu_remove_from_collection"), this, SLOT(removeFromCollectionSlot()));
hgs
parents: 37
diff changeset
   478
        mContextMenuActions[EActionRemove]->setObjectName(LIST_WIDGET_OBJECT_NAME_ACTION_REMOVE_FROM);
hgs
parents: 37
diff changeset
   479
        
hgs
parents: 37
diff changeset
   480
        mContextMenuActions[EActionRename]           = 
hgs
parents: 37
diff changeset
   481
                mContextMenu->addAction(hbTrId("txt_common_menu_rename_item"), this, SLOT(renameSlot()));
hgs
parents: 37
diff changeset
   482
        mContextMenuActions[EActionRename]->setObjectName(LIST_WIDGET_OBJECT_NAME_ACTION_RENAME);
hgs
parents: 37
diff changeset
   483
        
hgs
parents: 37
diff changeset
   484
        mContextMenuActions[EActionRemoveCollection] = 
hgs
parents: 37
diff changeset
   485
                mContextMenu->addAction(hbTrId("txt_videos_menu_remove_collection"), this, SLOT(removeCollectionSlot()));
hgs
parents: 37
diff changeset
   486
        mContextMenuActions[EActionRemoveCollection]->setObjectName(LIST_WIDGET_OBJECT_NAME_ACTION_REMOVE_COLLECTION);
hgs
parents: 37
diff changeset
   487
        
hgs
parents: 37
diff changeset
   488
        mContextMenuActions[EActionDelete]           = 
hgs
parents: 37
diff changeset
   489
                mContextMenu->addAction(hbTrId("txt_common_menu_delete"), this, SLOT(deleteItemSlot()));
hgs
parents: 37
diff changeset
   490
        mContextMenuActions[EActionDelete]->setObjectName(LIST_WIDGET_OBJECT_NAME_ACTION_DELETE);
hgs
parents: 37
diff changeset
   491
        
hgs
parents: 37
diff changeset
   492
        mContextMenuActions[EActionDetails]          = 
hgs
parents: 37
diff changeset
   493
                mContextMenu->addAction(hbTrId("txt_common_menu_details"), this, SLOT(openDetailsSlot()));
hgs
parents: 37
diff changeset
   494
        mContextMenuActions[EActionDetails]->setObjectName(LIST_WIDGET_OBJECT_NAME_ACTION_DETAILS);
30
hgs
parents:
diff changeset
   495
    }
hgs
parents:
diff changeset
   496
}
hgs
parents:
diff changeset
   497
hgs
parents:
diff changeset
   498
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   499
// setContextMenu
hgs
parents:
diff changeset
   500
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   501
//
34
hgs
parents: 30
diff changeset
   502
void VideoListWidget::setContextMenu()
30
hgs
parents:
diff changeset
   503
{
36
hgs
parents: 35
diff changeset
   504
	FUNC_LOG_ADDR(this);
30
hgs
parents:
diff changeset
   505
    if(!mContextMenu)
hgs
parents:
diff changeset
   506
    {
hgs
parents:
diff changeset
   507
        createContextMenu();
hgs
parents:
diff changeset
   508
    }
35
hgs
parents: 34
diff changeset
   509
    
hgs
parents: 34
diff changeset
   510
    if (!mContextMenu)
hgs
parents: 34
diff changeset
   511
    {
36
hgs
parents: 35
diff changeset
   512
        ERROR_1(-1, "VideoListWidget::setContextMenu() [0x%x]: failed to create context menu.", this);
35
hgs
parents: 34
diff changeset
   513
        return;
hgs
parents: 34
diff changeset
   514
    }
hgs
parents: 34
diff changeset
   515
    
30
hgs
parents:
diff changeset
   516
	int menuActionCount = 0;
hgs
parents:
diff changeset
   517
    HbAction *action = 0;
hgs
parents:
diff changeset
   518
    foreach(action, mContextMenuActions.values())
hgs
parents:
diff changeset
   519
    {
hgs
parents:
diff changeset
   520
        if(action)
hgs
parents:
diff changeset
   521
        {
hgs
parents:
diff changeset
   522
			++menuActionCount;
hgs
parents:
diff changeset
   523
			action->setVisible(false);
hgs
parents:
diff changeset
   524
        }
hgs
parents:
diff changeset
   525
    }
hgs
parents:
diff changeset
   526
    if(menuActionCount != mContextMenuActions.values().count() || mContextMenuActions.values().count() == 0)
hgs
parents:
diff changeset
   527
    {
36
hgs
parents: 35
diff changeset
   528
        ERROR_1(-1, "VideoListWidget::setContextMenu() [0x%x]: all actions have not been created.", this);
30
hgs
parents:
diff changeset
   529
        delete mContextMenu;
hgs
parents:
diff changeset
   530
        mContextMenu = 0;
hgs
parents:
diff changeset
   531
        mContextMenuActions.clear();
hgs
parents:
diff changeset
   532
    	return;
hgs
parents:
diff changeset
   533
    }
hgs
parents:
diff changeset
   534
41
hgs
parents: 40
diff changeset
   535
    if (mVideoServices)
36
hgs
parents: 35
diff changeset
   536
    {
41
hgs
parents: 40
diff changeset
   537
        setServiceContextMenu();
36
hgs
parents: 35
diff changeset
   538
        return;
hgs
parents: 35
diff changeset
   539
    }
30
hgs
parents:
diff changeset
   540
34
hgs
parents: 30
diff changeset
   541
    if(mCurrentLevel == VideoCollectionCommon::ELevelVideos ||
hgs
parents: 30
diff changeset
   542
       mCurrentLevel == VideoCollectionCommon::ELevelDefaultColl)
36
hgs
parents: 35
diff changeset
   543
    {        
41
hgs
parents: 40
diff changeset
   544
    	mContextMenuActions[EActionAddToCollection]->setVisible(true);
hgs
parents: 40
diff changeset
   545
    	mContextMenuActions[EActionDelete]->setVisible(true);
36
hgs
parents: 35
diff changeset
   546
    	mContextMenuActions[EActionPlay]->setVisible(true);
30
hgs
parents:
diff changeset
   547
		mContextMenuActions[EActionDetails]->setVisible(true);
50
hgs
parents: 44
diff changeset
   548
		mContextMenuActions[EActionRename]->setVisible(true);
30
hgs
parents:
diff changeset
   549
    }
34
hgs
parents: 30
diff changeset
   550
    else if(mCurrentLevel == VideoCollectionCommon::ELevelCategory) 
30
hgs
parents:
diff changeset
   551
    {
36
hgs
parents: 35
diff changeset
   552
        mContextMenuActions[EActionOpen]->setVisible(true);
hgs
parents: 35
diff changeset
   553
        TMPXItemId mpxId = mModel->getMediaIdAtIndex(currentIndex());
41
hgs
parents: 40
diff changeset
   554
		if(mpxId.iId2 == KVcxMvcMediaTypeAlbum)
30
hgs
parents:
diff changeset
   555
		{
hgs
parents:
diff changeset
   556
            mContextMenuActions[EActionRename]->setVisible(true);
35
hgs
parents: 34
diff changeset
   557
            mContextMenuActions[EActionRemoveCollection]->setVisible(true);
30
hgs
parents:
diff changeset
   558
		}
hgs
parents:
diff changeset
   559
    }
34
hgs
parents: 30
diff changeset
   560
    else if(mCurrentLevel == VideoCollectionCommon::ELevelAlbum)
30
hgs
parents:
diff changeset
   561
    {
41
hgs
parents: 40
diff changeset
   562
    	mContextMenuActions[EActionRemove]->setVisible(true);
hgs
parents: 40
diff changeset
   563
        mContextMenuActions[EActionDelete]->setVisible(true);
36
hgs
parents: 35
diff changeset
   564
    	mContextMenuActions[EActionPlay]->setVisible(true);
30
hgs
parents:
diff changeset
   565
		mContextMenuActions[EActionDetails]->setVisible(true);
50
hgs
parents: 44
diff changeset
   566
		mContextMenuActions[EActionRename]->setVisible(true);
30
hgs
parents:
diff changeset
   567
    }
hgs
parents:
diff changeset
   568
}
hgs
parents:
diff changeset
   569
36
hgs
parents: 35
diff changeset
   570
// ---------------------------------------------------------------------------
41
hgs
parents: 40
diff changeset
   571
// setServiceContextMenu
36
hgs
parents: 35
diff changeset
   572
// ---------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   573
//
41
hgs
parents: 40
diff changeset
   574
void VideoListWidget::setServiceContextMenu()
36
hgs
parents: 35
diff changeset
   575
{
hgs
parents: 35
diff changeset
   576
    FUNC_LOG_ADDR(this);
41
hgs
parents: 40
diff changeset
   577
    
hgs
parents: 40
diff changeset
   578
    if(mCurrentLevel == VideoCollectionCommon::ELevelCategory) 
hgs
parents: 40
diff changeset
   579
    {
hgs
parents: 40
diff changeset
   580
        mContextMenuActions[EActionOpen]->setVisible(true);   
hgs
parents: 40
diff changeset
   581
    } 
hgs
parents: 40
diff changeset
   582
    else if(mCurrentLevel > VideoCollectionCommon::ELevelCategory)
hgs
parents: 40
diff changeset
   583
    {        
hgs
parents: 40
diff changeset
   584
        mContextMenuActions[EActionDetails]->setVisible(true);
hgs
parents: 40
diff changeset
   585
        mContextMenuActions[EActionPlay]->setVisible(true);
hgs
parents: 40
diff changeset
   586
        if(mService == VideoServices::EBrowse)
hgs
parents: 40
diff changeset
   587
        {            
hgs
parents: 40
diff changeset
   588
            mContextMenuActions[EActionDelete]->setVisible(true);
hgs
parents: 40
diff changeset
   589
        }
hgs
parents: 40
diff changeset
   590
        else if(mService == VideoServices::EUriFetcher)
hgs
parents: 40
diff changeset
   591
        {
hgs
parents: 40
diff changeset
   592
            mContextMenuActions[EActionAttach]->setVisible(true);
hgs
parents: 40
diff changeset
   593
        }
hgs
parents: 40
diff changeset
   594
    }
36
hgs
parents: 35
diff changeset
   595
}
30
hgs
parents:
diff changeset
   596
hgs
parents:
diff changeset
   597
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   598
// getModel
hgs
parents:
diff changeset
   599
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   600
//
40
hgs
parents: 39
diff changeset
   601
VideoSortFilterProxyModel* VideoListWidget::getModel()
30
hgs
parents:
diff changeset
   602
{ 
36
hgs
parents: 35
diff changeset
   603
	FUNC_LOG_ADDR(this);
40
hgs
parents: 39
diff changeset
   604
    return mModel; 
30
hgs
parents:
diff changeset
   605
}
hgs
parents:
diff changeset
   606
hgs
parents:
diff changeset
   607
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   608
// emitActivated
hgs
parents:
diff changeset
   609
// This slot is called by the fw when viewitem is activated
hgs
parents:
diff changeset
   610
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   611
//
hgs
parents:
diff changeset
   612
void VideoListWidget::emitActivated (const QModelIndex &modelIndex)
hgs
parents:
diff changeset
   613
{
36
hgs
parents: 35
diff changeset
   614
	FUNC_LOG_ADDR(this);
hgs
parents: 35
diff changeset
   615
    // surprisingly interesting feature: after long press also single press
35
hgs
parents: 34
diff changeset
   616
    // is executed. as a workaround the following hack check is needed.
hgs
parents: 34
diff changeset
   617
    // otherwise after the context menu is shown also single press action
hgs
parents: 34
diff changeset
   618
    // is executed.
hgs
parents: 34
diff changeset
   619
    if (mContextMenu &&
hgs
parents: 34
diff changeset
   620
        mContextMenu->isVisible())
hgs
parents: 34
diff changeset
   621
    {
hgs
parents: 34
diff changeset
   622
        // do not activate context menu if it is already visible
hgs
parents: 34
diff changeset
   623
        return;
hgs
parents: 34
diff changeset
   624
    }
34
hgs
parents: 30
diff changeset
   625
    if(mSelectionMode != HbAbstractItemView::NoSelection)
30
hgs
parents:
diff changeset
   626
    {
34
hgs
parents: 30
diff changeset
   627
        // no custom functionality defined
hgs
parents: 30
diff changeset
   628
        emit activated(modelIndex);
hgs
parents: 30
diff changeset
   629
        return;
30
hgs
parents:
diff changeset
   630
    }
37
hgs
parents: 36
diff changeset
   631
    doEmitActivated(modelIndex);
hgs
parents: 36
diff changeset
   632
}
hgs
parents: 36
diff changeset
   633
hgs
parents: 36
diff changeset
   634
// ---------------------------------------------------------------------------
hgs
parents: 36
diff changeset
   635
// doEmitActivated
hgs
parents: 36
diff changeset
   636
// ---------------------------------------------------------------------------
hgs
parents: 36
diff changeset
   637
//
hgs
parents: 36
diff changeset
   638
void VideoListWidget::doEmitActivated (const QModelIndex &index)
hgs
parents: 36
diff changeset
   639
{
41
hgs
parents: 40
diff changeset
   640
    if(mVideoServices &&
39
hgs
parents: 38
diff changeset
   641
       mService == VideoServices::EUriFetcher &&
36
hgs
parents: 35
diff changeset
   642
       mCurrentLevel != VideoCollectionCommon::ELevelCategory)
hgs
parents: 35
diff changeset
   643
    {
37
hgs
parents: 36
diff changeset
   644
        QVariant variant = mModel->data(index, VideoCollectionCommon::KeyFilePath);
36
hgs
parents: 35
diff changeset
   645
        if ( variant.isValid()  )
hgs
parents: 35
diff changeset
   646
        {
hgs
parents: 35
diff changeset
   647
            QString itemPath = variant.value<QString>();
hgs
parents: 35
diff changeset
   648
            emit(fileUri(itemPath));
hgs
parents: 35
diff changeset
   649
        }
hgs
parents: 35
diff changeset
   650
    }
hgs
parents: 35
diff changeset
   651
    else
hgs
parents: 35
diff changeset
   652
    {
37
hgs
parents: 36
diff changeset
   653
        doActivateItem(index);
36
hgs
parents: 35
diff changeset
   654
    }
hgs
parents: 35
diff changeset
   655
}
30
hgs
parents:
diff changeset
   656
36
hgs
parents: 35
diff changeset
   657
// ---------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   658
// doActivateItem
hgs
parents: 35
diff changeset
   659
// ---------------------------------------------------------------------------
hgs
parents: 35
diff changeset
   660
//
hgs
parents: 35
diff changeset
   661
void VideoListWidget::doActivateItem(const QModelIndex &index)
hgs
parents: 35
diff changeset
   662
{
hgs
parents: 35
diff changeset
   663
    FUNC_LOG_ADDR(this);
hgs
parents: 35
diff changeset
   664
    if (!mModel || !index.isValid())
30
hgs
parents:
diff changeset
   665
    {
hgs
parents:
diff changeset
   666
        return;
hgs
parents:
diff changeset
   667
    }
34
hgs
parents: 30
diff changeset
   668
    
hgs
parents: 30
diff changeset
   669
    if (mCurrentLevel == VideoCollectionCommon::ELevelCategory)
30
hgs
parents:
diff changeset
   670
    {
36
hgs
parents: 35
diff changeset
   671
        QVariant variant = mModel->data(index, VideoCollectionCommon::KeyTitle);
34
hgs
parents: 30
diff changeset
   672
        if (variant.isValid())
30
hgs
parents:
diff changeset
   673
        {
34
hgs
parents: 30
diff changeset
   674
            // signal view that item has been activated
hgs
parents: 30
diff changeset
   675
            emit(collectionOpened(true,
36
hgs
parents: 35
diff changeset
   676
                variant.toString(),
41
hgs
parents: 40
diff changeset
   677
                mModel->getMediaIdAtIndex(index)));                       
30
hgs
parents:
diff changeset
   678
        }
35
hgs
parents: 34
diff changeset
   679
        return;
30
hgs
parents:
diff changeset
   680
    }
hgs
parents:
diff changeset
   681
    else
hgs
parents:
diff changeset
   682
    {
36
hgs
parents: 35
diff changeset
   683
    	mModel->openItem(mModel->getMediaIdAtIndex(index));
30
hgs
parents:
diff changeset
   684
    }
hgs
parents:
diff changeset
   685
}
hgs
parents:
diff changeset
   686
hgs
parents:
diff changeset
   687
// ---------------------------------------------------------------------------
34
hgs
parents: 30
diff changeset
   688
// setSelectionMode
hgs
parents: 30
diff changeset
   689
// called by the fw when user long presses some item
hgs
parents: 30
diff changeset
   690
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   691
//
hgs
parents: 30
diff changeset
   692
void VideoListWidget::setSelectionMode(int mode)
hgs
parents: 30
diff changeset
   693
{
36
hgs
parents: 35
diff changeset
   694
	FUNC_LOG_ADDR(this);
34
hgs
parents: 30
diff changeset
   695
    HbAbstractItemView::SelectionMode selMode = HbAbstractItemView::NoSelection;
37
hgs
parents: 36
diff changeset
   696
    if(mode >= HbAbstractItemView::NoSelection && mode <= HbAbstractItemView::MultiSelection)
34
hgs
parents: 30
diff changeset
   697
    {
hgs
parents: 30
diff changeset
   698
        selMode = HbAbstractItemView::SelectionMode(mode);
hgs
parents: 30
diff changeset
   699
    }
hgs
parents: 30
diff changeset
   700
hgs
parents: 30
diff changeset
   701
    HbListView::setSelectionMode(selMode);
hgs
parents: 30
diff changeset
   702
    mSelectionMode = mode;
hgs
parents: 30
diff changeset
   703
}
hgs
parents: 30
diff changeset
   704
hgs
parents: 30
diff changeset
   705
// ---------------------------------------------------------------------------
36
hgs
parents: 35
diff changeset
   706
// longPressedSlot
30
hgs
parents:
diff changeset
   707
// called by the fw when user long presses some item
hgs
parents:
diff changeset
   708
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   709
//
36
hgs
parents: 35
diff changeset
   710
void VideoListWidget::longPressedSlot(HbAbstractViewItem *item, const QPointF &point)
30
hgs
parents:
diff changeset
   711
{
36
hgs
parents: 35
diff changeset
   712
    FUNC_LOG_ADDR(this);
34
hgs
parents: 30
diff changeset
   713
    if(mSelectionMode != HbAbstractItemView::NoSelection)
30
hgs
parents:
diff changeset
   714
    {
hgs
parents:
diff changeset
   715
        // do not activate context menu during selection mode
hgs
parents:
diff changeset
   716
        return;
hgs
parents:
diff changeset
   717
    }
hgs
parents:
diff changeset
   718
36
hgs
parents: 35
diff changeset
   719
    if(item)
35
hgs
parents: 34
diff changeset
   720
    {
36
hgs
parents: 35
diff changeset
   721
        QModelIndex index = item->modelIndex();
35
hgs
parents: 34
diff changeset
   722
        if(mModel && index.isValid())
36
hgs
parents: 35
diff changeset
   723
        {
hgs
parents: 35
diff changeset
   724
            setContextMenu();
hgs
parents: 35
diff changeset
   725
            // if menu not yet exists, it has been created
hgs
parents: 35
diff changeset
   726
            // setup might fail causing menu to be removed
hgs
parents: 35
diff changeset
   727
            if(mContextMenu)
34
hgs
parents: 30
diff changeset
   728
            {
36
hgs
parents: 35
diff changeset
   729
                mContextMenu->setPreferredPos(point);
hgs
parents: 35
diff changeset
   730
                mContextMenu->show();
34
hgs
parents: 30
diff changeset
   731
            }
35
hgs
parents: 34
diff changeset
   732
        }
30
hgs
parents:
diff changeset
   733
    }
36
hgs
parents: 35
diff changeset
   734
}
hgs
parents: 35
diff changeset
   735
hgs
parents: 35
diff changeset
   736
// ---------------------------------------------------------------------------
35
hgs
parents: 34
diff changeset
   737
// doDelayedsSlot
hgs
parents: 34
diff changeset
   738
// ---------------------------------------------------------------------------
hgs
parents: 34
diff changeset
   739
//
hgs
parents: 34
diff changeset
   740
void VideoListWidget::doDelayedsSlot()
hgs
parents: 34
diff changeset
   741
{
36
hgs
parents: 35
diff changeset
   742
	FUNC_LOG_ADDR(this);
35
hgs
parents: 34
diff changeset
   743
	if (!mContextMenu)
hgs
parents: 34
diff changeset
   744
	{
hgs
parents: 34
diff changeset
   745
		createContextMenu();
hgs
parents: 34
diff changeset
   746
	}
hgs
parents: 34
diff changeset
   747
}
hgs
parents: 34
diff changeset
   748
hgs
parents: 34
diff changeset
   749
// ---------------------------------------------------------------------------
37
hgs
parents: 36
diff changeset
   750
// openItemSlot
hgs
parents: 36
diff changeset
   751
// ---------------------------------------------------------------------------
hgs
parents: 36
diff changeset
   752
//
hgs
parents: 36
diff changeset
   753
void VideoListWidget::openItemSlot()
hgs
parents: 36
diff changeset
   754
{
hgs
parents: 36
diff changeset
   755
    FUNC_LOG_ADDR(this);
hgs
parents: 36
diff changeset
   756
    doEmitActivated(currentIndex());
hgs
parents: 36
diff changeset
   757
}
hgs
parents: 36
diff changeset
   758
hgs
parents: 36
diff changeset
   759
// ---------------------------------------------------------------------------
30
hgs
parents:
diff changeset
   760
// playItemSlot
hgs
parents:
diff changeset
   761
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   762
//
37
hgs
parents: 36
diff changeset
   763
void VideoListWidget::playItemSlot()
30
hgs
parents:
diff changeset
   764
{
36
hgs
parents: 35
diff changeset
   765
    FUNC_LOG_ADDR(this);
hgs
parents: 35
diff changeset
   766
    doActivateItem(currentIndex());
30
hgs
parents:
diff changeset
   767
}
hgs
parents:
diff changeset
   768
hgs
parents:
diff changeset
   769
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   770
// openDetailsSlot
hgs
parents:
diff changeset
   771
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   772
//
hgs
parents:
diff changeset
   773
void VideoListWidget::openDetailsSlot()
hgs
parents:
diff changeset
   774
{   
36
hgs
parents: 35
diff changeset
   775
	FUNC_LOG_ADDR(this);
30
hgs
parents:
diff changeset
   776
    if(mModel && mModel->fetchItemDetails(currentIndex()) == 0 ) 
hgs
parents:
diff changeset
   777
    {
hgs
parents:
diff changeset
   778
        emit command(MpxHbVideoCommon::ActivateVideoDetailsView);
hgs
parents:
diff changeset
   779
    }
hgs
parents:
diff changeset
   780
}
34
hgs
parents: 30
diff changeset
   781
30
hgs
parents:
diff changeset
   782
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   783
// renameSlot
hgs
parents:
diff changeset
   784
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   785
//
hgs
parents:
diff changeset
   786
void VideoListWidget::renameSlot()
hgs
parents:
diff changeset
   787
{
36
hgs
parents: 35
diff changeset
   788
	FUNC_LOG_ADDR(this);
hgs
parents: 35
diff changeset
   789
    if(!mModel)
hgs
parents: 35
diff changeset
   790
    {
hgs
parents: 35
diff changeset
   791
        return;
hgs
parents: 35
diff changeset
   792
    }
hgs
parents: 35
diff changeset
   793
    
hgs
parents: 35
diff changeset
   794
    QModelIndex index = currentIndex();
hgs
parents: 35
diff changeset
   795
    QVariant variant = mModel->data(index, VideoCollectionCommon::KeyTitle);
50
hgs
parents: 44
diff changeset
   796
     
hgs
parents: 44
diff changeset
   797
    if(variant.isValid())
36
hgs
parents: 35
diff changeset
   798
    {
hgs
parents: 35
diff changeset
   799
        QString label(hbTrId("txt_videos_title_enter_name"));
hgs
parents: 35
diff changeset
   800
        QString albumName = variant.toString();
37
hgs
parents: 36
diff changeset
   801
        
hgs
parents: 36
diff changeset
   802
        HbInputDialog *dialog = new HbInputDialog();
hgs
parents: 36
diff changeset
   803
        dialog->setAttribute(Qt::WA_DeleteOnClose);
38
hgs
parents: 37
diff changeset
   804
        dialog->setObjectName(LIST_WIDGET_OBJECT_NAME_RENAME_VIDEO);
hgs
parents: 37
diff changeset
   805
        dialog->setPromptText(label);
hgs
parents: 37
diff changeset
   806
        dialog->setValue(albumName);
hgs
parents: 37
diff changeset
   807
        dialog->open(this, SLOT(renameDialogFinished(HbAction *)));
37
hgs
parents: 36
diff changeset
   808
    }
hgs
parents: 36
diff changeset
   809
}
hgs
parents: 36
diff changeset
   810
hgs
parents: 36
diff changeset
   811
// -------------------------------------------------------------------------------------------------
hgs
parents: 36
diff changeset
   812
// renameDialogFinished
hgs
parents: 36
diff changeset
   813
// -------------------------------------------------------------------------------------------------
hgs
parents: 36
diff changeset
   814
//
hgs
parents: 36
diff changeset
   815
void VideoListWidget::renameDialogFinished(HbAction *action)
hgs
parents: 36
diff changeset
   816
{
hgs
parents: 36
diff changeset
   817
    Q_UNUSED(action);
36
hgs
parents: 35
diff changeset
   818
37
hgs
parents: 36
diff changeset
   819
    HbInputDialog *dialog = static_cast<HbInputDialog*>(sender());
50
hgs
parents: 44
diff changeset
   820
    if(dialog->actions().first() != action)
hgs
parents: 44
diff changeset
   821
    {
hgs
parents: 44
diff changeset
   822
        return;
hgs
parents: 44
diff changeset
   823
    }
37
hgs
parents: 36
diff changeset
   824
    QModelIndex index = currentIndex();
hgs
parents: 36
diff changeset
   825
    TMPXItemId itemId = mModel->getMediaIdAtIndex(index);
hgs
parents: 36
diff changeset
   826
    QVariant newNameVariant = dialog->value();
hgs
parents: 36
diff changeset
   827
    QVariant oldNameVariant = mModel->data(index, VideoCollectionCommon::KeyTitle);
50
hgs
parents: 44
diff changeset
   828
    if(!newNameVariant.isValid() || !oldNameVariant.isValid())
hgs
parents: 44
diff changeset
   829
    {
hgs
parents: 44
diff changeset
   830
        // invalid data at index
hgs
parents: 44
diff changeset
   831
        return;
hgs
parents: 44
diff changeset
   832
    }
hgs
parents: 44
diff changeset
   833
    QString newAlbumName = newNameVariant.toString().trimmed();
hgs
parents: 44
diff changeset
   834
    QString oldAlbumName = oldNameVariant.toString();
hgs
parents: 44
diff changeset
   835
    if(!newAlbumName.length() || newAlbumName == oldAlbumName)
37
hgs
parents: 36
diff changeset
   836
    {
50
hgs
parents: 44
diff changeset
   837
        // no new name provided or name has not changed
hgs
parents: 44
diff changeset
   838
        return;
36
hgs
parents: 35
diff changeset
   839
    }
50
hgs
parents: 44
diff changeset
   840
    if(itemId.iId2 == KVcxMvcMediaTypeAlbum)
hgs
parents: 44
diff changeset
   841
    {     
hgs
parents: 44
diff changeset
   842
        // for album, we need to make sure name is unique
hgs
parents: 44
diff changeset
   843
        newAlbumName = mModel->resolveAlbumName(newAlbumName);
hgs
parents: 44
diff changeset
   844
    }
hgs
parents: 44
diff changeset
   845
    mModel->renameItem(itemId, newAlbumName);
30
hgs
parents:
diff changeset
   846
}
50
hgs
parents: 44
diff changeset
   847
30
hgs
parents:
diff changeset
   848
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   849
// addToCollectionSlot
hgs
parents:
diff changeset
   850
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   851
//
hgs
parents:
diff changeset
   852
void VideoListWidget::addToCollectionSlot()
hgs
parents:
diff changeset
   853
{
36
hgs
parents: 35
diff changeset
   854
	FUNC_LOG_ADDR(this);
34
hgs
parents: 30
diff changeset
   855
    VideoListSelectionDialog *dialog =
hgs
parents: 30
diff changeset
   856
       mUiLoader->findWidget<VideoListSelectionDialog>(
hgs
parents: 30
diff changeset
   857
           DOCML_NAME_DIALOG);
hgs
parents: 30
diff changeset
   858
    if (!dialog || !mModel)
hgs
parents: 30
diff changeset
   859
    {
36
hgs
parents: 35
diff changeset
   860
        ERROR_1(-1, "VideoListWidget::addToCollectionSlot() [0x%x]: failed to get selection dialog or model is null.", this);
34
hgs
parents: 30
diff changeset
   861
        return;
hgs
parents: 30
diff changeset
   862
    }
hgs
parents: 30
diff changeset
   863
    TMPXItemId itemId = mModel->getMediaIdAtIndex(currentIndex());
hgs
parents: 30
diff changeset
   864
    if(itemId != TMPXItemId::InvalidId())
hgs
parents: 30
diff changeset
   865
    {
hgs
parents: 30
diff changeset
   866
        dialog->setupContent(VideoListSelectionDialog::ESelectCollection, itemId);
hgs
parents: 30
diff changeset
   867
        dialog->exec();
hgs
parents: 30
diff changeset
   868
    }
30
hgs
parents:
diff changeset
   869
}
hgs
parents:
diff changeset
   870
34
hgs
parents: 30
diff changeset
   871
// ---------------------------------------------------------------------------
35
hgs
parents: 34
diff changeset
   872
// removeFromCollectionSlot
hgs
parents: 34
diff changeset
   873
// ---------------------------------------------------------------------------
hgs
parents: 34
diff changeset
   874
//
hgs
parents: 34
diff changeset
   875
void VideoListWidget::removeFromCollectionSlot()
hgs
parents: 34
diff changeset
   876
{
36
hgs
parents: 35
diff changeset
   877
	FUNC_LOG_ADDR(this);
35
hgs
parents: 34
diff changeset
   878
    if(!mModel)
hgs
parents: 34
diff changeset
   879
    {
hgs
parents: 34
diff changeset
   880
        return;
hgs
parents: 34
diff changeset
   881
    }
hgs
parents: 34
diff changeset
   882
    TMPXItemId collectionId = mModel->getOpenItem();
hgs
parents: 34
diff changeset
   883
    TMPXItemId itemId = mModel->getMediaIdAtIndex(currentIndex());
hgs
parents: 34
diff changeset
   884
    if(collectionId != TMPXItemId::InvalidId() && 
hgs
parents: 34
diff changeset
   885
       itemId != TMPXItemId::InvalidId())
hgs
parents: 34
diff changeset
   886
    {
hgs
parents: 34
diff changeset
   887
        QList<TMPXItemId> ids;
hgs
parents: 34
diff changeset
   888
        ids.append(itemId);
hgs
parents: 34
diff changeset
   889
        mModel->removeItemsFromAlbum(collectionId, ids);
hgs
parents: 34
diff changeset
   890
    }
hgs
parents: 34
diff changeset
   891
}
hgs
parents: 34
diff changeset
   892
hgs
parents: 34
diff changeset
   893
// ---------------------------------------------------------------------------
34
hgs
parents: 30
diff changeset
   894
// removeCollectionSlot
hgs
parents: 30
diff changeset
   895
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   896
//
hgs
parents: 30
diff changeset
   897
void VideoListWidget::removeCollectionSlot()
hgs
parents: 30
diff changeset
   898
{
36
hgs
parents: 35
diff changeset
   899
	FUNC_LOG_ADDR(this);
34
hgs
parents: 30
diff changeset
   900
    if(!mModel)
hgs
parents: 30
diff changeset
   901
    {
hgs
parents: 30
diff changeset
   902
        return;
hgs
parents: 30
diff changeset
   903
    }
hgs
parents: 30
diff changeset
   904
    
hgs
parents: 30
diff changeset
   905
    QVariant variant;
hgs
parents: 30
diff changeset
   906
    QModelIndex index = currentIndex();
36
hgs
parents: 35
diff changeset
   907
    variant = mModel->data(index, VideoCollectionCommon::KeyTitle);
34
hgs
parents: 30
diff changeset
   908
hgs
parents: 30
diff changeset
   909
    if (variant.isValid())
hgs
parents: 30
diff changeset
   910
    {
44
hgs
parents: 41
diff changeset
   911
        QString text = HbParameterLengthLimiter(
hgs
parents: 41
diff changeset
   912
                hbTrId("txt_videos_info_do_you_want_to_remove_collection")).arg(variant.toString()); 
hgs
parents: 41
diff changeset
   913
        
37
hgs
parents: 36
diff changeset
   914
        HbMessageBox *messageBox = new HbMessageBox(text, HbMessageBox::MessageTypeQuestion);
44
hgs
parents: 41
diff changeset
   915
        messageBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
37
hgs
parents: 36
diff changeset
   916
        messageBox->setAttribute(Qt::WA_DeleteOnClose);
44
hgs
parents: 41
diff changeset
   917
        messageBox->setObjectName(LIST_WIDGET_OBJECT_NAME_REMOVE_COLLECTION);
hgs
parents: 41
diff changeset
   918
        messageBox->open(this, SLOT(removeCollectionDialogFinished(int)));
37
hgs
parents: 36
diff changeset
   919
    }
hgs
parents: 36
diff changeset
   920
}
hgs
parents: 36
diff changeset
   921
hgs
parents: 36
diff changeset
   922
// ---------------------------------------------------------------------------
hgs
parents: 36
diff changeset
   923
// removeCollectionDialogFinished
hgs
parents: 36
diff changeset
   924
// ---------------------------------------------------------------------------
hgs
parents: 36
diff changeset
   925
//
44
hgs
parents: 41
diff changeset
   926
void VideoListWidget::removeCollectionDialogFinished(int action)
37
hgs
parents: 36
diff changeset
   927
{
44
hgs
parents: 41
diff changeset
   928
    if(action == HbMessageBox::Yes)
37
hgs
parents: 36
diff changeset
   929
    {
hgs
parents: 36
diff changeset
   930
        QModelIndex index = currentIndex();
hgs
parents: 36
diff changeset
   931
        if(index.isValid())
34
hgs
parents: 30
diff changeset
   932
        {
hgs
parents: 30
diff changeset
   933
            QModelIndexList list;
hgs
parents: 30
diff changeset
   934
            list.append(index);
37
hgs
parents: 36
diff changeset
   935
            mModel->removeAlbums(list);
34
hgs
parents: 30
diff changeset
   936
        }
hgs
parents: 30
diff changeset
   937
    }
hgs
parents: 30
diff changeset
   938
}
30
hgs
parents:
diff changeset
   939
hgs
parents:
diff changeset
   940
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   941
// back
hgs
parents:
diff changeset
   942
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   943
//
hgs
parents:
diff changeset
   944
void VideoListWidget::back()
hgs
parents:
diff changeset
   945
{
36
hgs
parents: 35
diff changeset
   946
	FUNC_LOG_ADDR(this);
hgs
parents: 35
diff changeset
   947
30
hgs
parents:
diff changeset
   948
    if(mModel)
hgs
parents:
diff changeset
   949
    {
36
hgs
parents: 35
diff changeset
   950
    	// Empty the proxy model causing the items to be removed from list widget.
hgs
parents: 35
diff changeset
   951
        mModel->setAlbumInUse(TMPXItemId::InvalidId());
41
hgs
parents: 40
diff changeset
   952
		emit collectionOpened(false, QString(), TMPXItemId::InvalidId());
hgs
parents: 40
diff changeset
   953
    }
hgs
parents: 40
diff changeset
   954
}
hgs
parents: 40
diff changeset
   955
hgs
parents: 40
diff changeset
   956
// ---------------------------------------------------------------------------
hgs
parents: 40
diff changeset
   957
// endVideoFecthingSlot
hgs
parents: 40
diff changeset
   958
// ---------------------------------------------------------------------------
hgs
parents: 40
diff changeset
   959
//
hgs
parents: 40
diff changeset
   960
void VideoListWidget::endVideoFecthingSlot()
hgs
parents: 40
diff changeset
   961
{
hgs
parents: 40
diff changeset
   962
    if(mVideoServices && mService == VideoServices::EUriFetcher)
hgs
parents: 40
diff changeset
   963
    {        
hgs
parents: 40
diff changeset
   964
        QString empty = "";
hgs
parents: 40
diff changeset
   965
        emit fileUri(empty);
30
hgs
parents:
diff changeset
   966
    }
hgs
parents:
diff changeset
   967
}
hgs
parents:
diff changeset
   968
hgs
parents:
diff changeset
   969
// ---------------------------------------------------------------------------
34
hgs
parents: 30
diff changeset
   970
// scrollingStartedSlot
hgs
parents: 30
diff changeset
   971
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   972
//
hgs
parents: 30
diff changeset
   973
void VideoListWidget::scrollingStartedSlot()
hgs
parents: 30
diff changeset
   974
{
36
hgs
parents: 35
diff changeset
   975
	FUNC_LOG_ADDR(this);
34
hgs
parents: 30
diff changeset
   976
    VideoThumbnailData::instance().enableThumbnailCreation(false);
hgs
parents: 30
diff changeset
   977
}
hgs
parents: 30
diff changeset
   978
hgs
parents: 30
diff changeset
   979
// ---------------------------------------------------------------------------
30
hgs
parents:
diff changeset
   980
// scrollingEndedSlot
hgs
parents:
diff changeset
   981
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   982
//
hgs
parents:
diff changeset
   983
void VideoListWidget::scrollingEndedSlot()
hgs
parents:
diff changeset
   984
{
36
hgs
parents: 35
diff changeset
   985
	FUNC_LOG_ADDR(this);
30
hgs
parents:
diff changeset
   986
    if(mScrollPositionTimer)
36
hgs
parents: 35
diff changeset
   987
    {
hgs
parents: 35
diff changeset
   988
        mScrollPositionTimer->stop();
hgs
parents: 35
diff changeset
   989
    }
34
hgs
parents: 30
diff changeset
   990
    VideoThumbnailData::instance().enableThumbnailCreation(true);
hgs
parents: 30
diff changeset
   991
    fetchThumbnailsForVisibleItems();
30
hgs
parents:
diff changeset
   992
}
hgs
parents:
diff changeset
   993
hgs
parents:
diff changeset
   994
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   995
// scrollPositionChangedSlot
hgs
parents:
diff changeset
   996
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   997
//
hgs
parents:
diff changeset
   998
void VideoListWidget::scrollPositionChangedSlot(const QPointF &newPosition)
hgs
parents:
diff changeset
   999
{
hgs
parents:
diff changeset
  1000
    Q_UNUSED(newPosition);
hgs
parents:
diff changeset
  1001
	if(mScrollPositionTimer && !mScrollPositionTimer->isActive())
hgs
parents:
diff changeset
  1002
	    mScrollPositionTimer->start(SCROLL_POSITION_TIMER_TIMEOUT);
hgs
parents:
diff changeset
  1003
}
hgs
parents:
diff changeset
  1004
hgs
parents:
diff changeset
  1005
// ---------------------------------------------------------------------------
34
hgs
parents: 30
diff changeset
  1006
// scrollPositionTimerSlot
hgs
parents: 30
diff changeset
  1007
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
  1008
//
hgs
parents: 30
diff changeset
  1009
void VideoListWidget::scrollPositionTimerSlot()
hgs
parents: 30
diff changeset
  1010
{
36
hgs
parents: 35
diff changeset
  1011
	FUNC_LOG_ADDR(this);
34
hgs
parents: 30
diff changeset
  1012
    fetchThumbnailsForVisibleItems();
hgs
parents: 30
diff changeset
  1013
}
hgs
parents: 30
diff changeset
  1014
hgs
parents: 30
diff changeset
  1015
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
  1016
// fetchThumbnailsForVisibleItems
hgs
parents: 30
diff changeset
  1017
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
  1018
//
hgs
parents: 30
diff changeset
  1019
void VideoListWidget::fetchThumbnailsForVisibleItems()
hgs
parents: 30
diff changeset
  1020
{
36
hgs
parents: 35
diff changeset
  1021
	FUNC_LOG_ADDR(this);
50
hgs
parents: 44
diff changeset
  1022
	
hgs
parents: 44
diff changeset
  1023
	// No need to do anything if thumbnail fetching is not enabled.
hgs
parents: 44
diff changeset
  1024
	if(!VideoThumbnailData::instance().backgroundFetchingEnabled())
hgs
parents: 44
diff changeset
  1025
	{
hgs
parents: 44
diff changeset
  1026
	    return;
hgs
parents: 44
diff changeset
  1027
	}
hgs
parents: 44
diff changeset
  1028
	
34
hgs
parents: 30
diff changeset
  1029
    const QList<HbAbstractViewItem *> itemsVisible = visibleItems();
50
hgs
parents: 44
diff changeset
  1030
    
34
hgs
parents: 30
diff changeset
  1031
    if(itemsVisible.count() > 0)
hgs
parents: 30
diff changeset
  1032
    {
hgs
parents: 30
diff changeset
  1033
        int row = itemsVisible.value(0)->modelIndex().row();
hgs
parents: 30
diff changeset
  1034
        VideoThumbnailData::instance().startBackgroundFetching(mModel, row);
hgs
parents: 30
diff changeset
  1035
    }
44
hgs
parents: 41
diff changeset
  1036
    else
hgs
parents: 41
diff changeset
  1037
    {
hgs
parents: 41
diff changeset
  1038
        // Nothing visible yet, start from first index.
hgs
parents: 41
diff changeset
  1039
        VideoThumbnailData::instance().startBackgroundFetching(mModel, 0);
hgs
parents: 41
diff changeset
  1040
    }
hgs
parents: 41
diff changeset
  1041
}
hgs
parents: 41
diff changeset
  1042
hgs
parents: 41
diff changeset
  1043
// ---------------------------------------------------------------------------
hgs
parents: 41
diff changeset
  1044
// rowsInserted
hgs
parents: 41
diff changeset
  1045
// ---------------------------------------------------------------------------
hgs
parents: 41
diff changeset
  1046
//
hgs
parents: 41
diff changeset
  1047
void VideoListWidget::rowsInserted(const QModelIndex &parent, int start, int end)
hgs
parents: 41
diff changeset
  1048
{
hgs
parents: 41
diff changeset
  1049
    FUNC_LOG_ADDR(this);
hgs
parents: 41
diff changeset
  1050
    Q_UNUSED(parent);
hgs
parents: 41
diff changeset
  1051
    Q_UNUSED(start);
hgs
parents: 41
diff changeset
  1052
    Q_UNUSED(end);
hgs
parents: 41
diff changeset
  1053
    fetchThumbnailsForVisibleItems();
hgs
parents: 41
diff changeset
  1054
    HbListView::rowsInserted(parent, start, end);
hgs
parents: 41
diff changeset
  1055
}
hgs
parents: 41
diff changeset
  1056
hgs
parents: 41
diff changeset
  1057
// ---------------------------------------------------------------------------
hgs
parents: 41
diff changeset
  1058
// rowsRemoved
hgs
parents: 41
diff changeset
  1059
// ---------------------------------------------------------------------------
hgs
parents: 41
diff changeset
  1060
//
hgs
parents: 41
diff changeset
  1061
void VideoListWidget::rowsRemoved(const QModelIndex &parent, int start, int end)
hgs
parents: 41
diff changeset
  1062
{
hgs
parents: 41
diff changeset
  1063
    FUNC_LOG_ADDR(this);
hgs
parents: 41
diff changeset
  1064
    Q_UNUSED(parent);
hgs
parents: 41
diff changeset
  1065
    Q_UNUSED(start);
hgs
parents: 41
diff changeset
  1066
    Q_UNUSED(end);
hgs
parents: 41
diff changeset
  1067
    fetchThumbnailsForVisibleItems();
hgs
parents: 41
diff changeset
  1068
    HbListView::rowsRemoved(parent, start, end);
34
hgs
parents: 30
diff changeset
  1069
}
hgs
parents: 30
diff changeset
  1070
30
hgs
parents:
diff changeset
  1071
// end of file