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