videocollection/videofiledetailsview/src/videofiledetailsviewplugin.cpp
author hgs
Fri, 03 Sep 2010 12:37:43 +0300
changeset 58 d2b028fd1f7d
parent 55 4bfa887905cf
permissions -rw-r--r--
201035
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30
hgs
parents:
diff changeset
     1
/*
34
hgs
parents: 30
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
30
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:   VideoCollectionViewPlugin class implementation
34
hgs
parents: 30
diff changeset
    15
*
30
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
58
hgs
parents: 55
diff changeset
    18
// Version : %version: 76.1.9 %
36
hgs
parents: 35
diff changeset
    19
30
hgs
parents:
diff changeset
    20
// INCLUDE FILES
34
hgs
parents: 30
diff changeset
    21
#include <qcoreapplication.h>
30
hgs
parents:
diff changeset
    22
#include <xqserviceutil.h>
hgs
parents:
diff changeset
    23
#include <xqplugin.h>
hgs
parents:
diff changeset
    24
#include <hbview.h>
hgs
parents:
diff changeset
    25
#include <hbinstance.h>
hgs
parents:
diff changeset
    26
#include <hbstackedwidget.h>
hgs
parents:
diff changeset
    27
#include <hbmarqueeitem.h>
hgs
parents:
diff changeset
    28
#include <hbpushbutton.h>
hgs
parents:
diff changeset
    29
#include <hbaction.h>
hgs
parents:
diff changeset
    30
#include <qabstractitemmodel.h>
hgs
parents:
diff changeset
    31
#include <hbmessagebox.h>
34
hgs
parents: 30
diff changeset
    32
#include <hblistwidget.h>
hgs
parents: 30
diff changeset
    33
#include <hblistwidgetitem.h>
hgs
parents: 30
diff changeset
    34
#include <hblistviewitem.h>
44
hgs
parents: 41
diff changeset
    35
#include <hbparameterlengthlimiter.h>
50
hgs
parents: 44
diff changeset
    36
#include <hbtextitem.h>
55
hgs
parents: 50
diff changeset
    37
#include <hbscrollbar.h>
30
hgs
parents:
diff changeset
    38
#include <cmath>
hgs
parents:
diff changeset
    39
#include <thumbnailmanager_qt.h>
36
hgs
parents: 35
diff changeset
    40
#include <shareui.h>
hgs
parents: 35
diff changeset
    41
30
hgs
parents:
diff changeset
    42
#include "videocollectionclient.h"
hgs
parents:
diff changeset
    43
#include "videofiledetailsviewplugin.h"
hgs
parents:
diff changeset
    44
#include "videocollectioncommon.h"
hgs
parents:
diff changeset
    45
#include "mpxhbvideocommondefs.h"
hgs
parents:
diff changeset
    46
#include "videocollectionwrapper.h"
58
hgs
parents: 55
diff changeset
    47
#include "videoproxymodelgeneric.h"
30
hgs
parents:
diff changeset
    48
#include "videoservices.h"
34
hgs
parents: 30
diff changeset
    49
#include "videodetailslabel.h"
36
hgs
parents: 35
diff changeset
    50
#include "videocollectiontrace.h"
30
hgs
parents:
diff changeset
    51
38
hgs
parents: 37
diff changeset
    52
// Object names.
hgs
parents: 37
diff changeset
    53
const char* const VIDEO_DETAILS_OBJECT_NAME_THUMBLABEL          = "vc:FileDetailsThumbnailLabel";
hgs
parents: 37
diff changeset
    54
const char* const VIDEO_DETAILS_OBJECT_NAME_DELETE_VIDEO        = "vc:FileDetailsMessageBoxDeleteVideo";
hgs
parents: 37
diff changeset
    55
const char* const VIDEO_DETAILS_OBJECT_NAME_MESSAGE_BOX_WARNING = "vc:FileDetailsMessageBoxWarning";
hgs
parents: 37
diff changeset
    56
const char* const VIDEO_DETAILS_OBJECT_NAME_DELETE_ACTION       = "vc:FileDetailsDelete";
hgs
parents: 37
diff changeset
    57
const char* const VIDEO_DETAILS_OBJECT_NAME_NAVKEY_BACK         = "vc:FileDetailsNavKeyBack";
hgs
parents: 37
diff changeset
    58
const char* const VIDEO_DETAILS_OBJECT_NAME_TITLE_ANIM          = "vc:FileDetailsTitleAnim";
hgs
parents: 37
diff changeset
    59
hgs
parents: 37
diff changeset
    60
// Docml constants.
36
hgs
parents: 35
diff changeset
    61
const char* const VIDEO_DETAILS_DOCML             = ":/xml/videofiledetails.docml";
hgs
parents: 35
diff changeset
    62
const char* const VIDEO_DETAILS_PORTRAIT          = "portrait";
hgs
parents: 35
diff changeset
    63
const char* const VIDEO_DETAILS_LANDSCAPE         = "landscape";
hgs
parents: 35
diff changeset
    64
const char* const VIDEO_DETAILS_VIEW              = "videofiledetailsview";
hgs
parents: 35
diff changeset
    65
const char* const VIDEO_DETAILS_TITLE             = "mLblTitle";
hgs
parents: 35
diff changeset
    66
const char* const VIDEO_DETAILS_THUMBNAIL         = "mDetailsLabel";
hgs
parents: 35
diff changeset
    67
const char* const VIDEO_DETAILS_BUTTON            = "mButton";
30
hgs
parents:
diff changeset
    68
const char* const VIDEO_DETAILS_MENUACTION_DELETE = "mOptionsDelete";
36
hgs
parents: 35
diff changeset
    69
const char* const VIDEO_DETAILS_LISTWIDGET        = "mDetailsList";
30
hgs
parents:
diff changeset
    70
38
hgs
parents: 37
diff changeset
    71
// Default thumbnail.
hgs
parents: 37
diff changeset
    72
const char* const VIDEO_DETAILS_GFX_DEFAULT       = "qtg_large_video";
hgs
parents: 37
diff changeset
    73
hgs
parents: 37
diff changeset
    74
const int VIDEO_DETAILS_SECONDARY_TEXT_ROW_COUNT  = 255;
hgs
parents: 37
diff changeset
    75
30
hgs
parents:
diff changeset
    76
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    77
// Constructor
hgs
parents:
diff changeset
    78
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    79
//
hgs
parents:
diff changeset
    80
VideoFileDetailsViewPlugin::VideoFileDetailsViewPlugin()
36
hgs
parents: 35
diff changeset
    81
    : mModel( 0 )
hgs
parents: 35
diff changeset
    82
    , mVideoServices( 0 )
hgs
parents: 35
diff changeset
    83
    , mActivated( false )
hgs
parents: 35
diff changeset
    84
    , mIsService( false )
hgs
parents: 35
diff changeset
    85
    , mVideoId( TMPXItemId::InvalidId() )
hgs
parents: 35
diff changeset
    86
    , mDeletedIndex( -1 )
hgs
parents: 35
diff changeset
    87
    , mPreviousOrietation( Qt::Vertical )
hgs
parents: 35
diff changeset
    88
    , mNavKeyBackAction( 0 )
hgs
parents: 35
diff changeset
    89
    , mTitleAnim( 0 )
hgs
parents: 35
diff changeset
    90
    , mThumbLabel( 0 )
hgs
parents: 35
diff changeset
    91
    , mThumbnailManager( 0 )
hgs
parents: 35
diff changeset
    92
    , mCollectionWrapper( VideoCollectionWrapper::instance() )
50
hgs
parents: 44
diff changeset
    93
    , mShareUi(0)
30
hgs
parents:
diff changeset
    94
{
36
hgs
parents: 35
diff changeset
    95
	FUNC_LOG;
30
hgs
parents:
diff changeset
    96
}
hgs
parents:
diff changeset
    97
hgs
parents:
diff changeset
    98
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    99
// Destructor
hgs
parents:
diff changeset
   100
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   101
//
hgs
parents:
diff changeset
   102
VideoFileDetailsViewPlugin::~VideoFileDetailsViewPlugin()
hgs
parents:
diff changeset
   103
{
36
hgs
parents: 35
diff changeset
   104
	FUNC_LOG;
34
hgs
parents: 30
diff changeset
   105
	destroyView();
30
hgs
parents:
diff changeset
   106
}
hgs
parents:
diff changeset
   107
hgs
parents:
diff changeset
   108
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   109
// Create view
hgs
parents:
diff changeset
   110
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   111
//
hgs
parents:
diff changeset
   112
void VideoFileDetailsViewPlugin::createView()
hgs
parents:
diff changeset
   113
{
36
hgs
parents: 35
diff changeset
   114
	FUNC_LOG;
35
hgs
parents: 34
diff changeset
   115
	mLoader.reset();
30
hgs
parents:
diff changeset
   116
hgs
parents:
diff changeset
   117
	mActivated = false;
34
hgs
parents: 30
diff changeset
   118
35
hgs
parents: 34
diff changeset
   119
	bool ok = false;
44
hgs
parents: 41
diff changeset
   120
35
hgs
parents: 34
diff changeset
   121
	//Load the details view docml first
hgs
parents: 34
diff changeset
   122
	mLoader.load(VIDEO_DETAILS_DOCML, &ok);
44
hgs
parents: 41
diff changeset
   123
35
hgs
parents: 34
diff changeset
   124
	if(!ok)
30
hgs
parents:
diff changeset
   125
	{
36
hgs
parents: 35
diff changeset
   126
	    ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to load docml.");
35
hgs
parents: 34
diff changeset
   127
		return;
30
hgs
parents:
diff changeset
   128
	}
35
hgs
parents: 34
diff changeset
   129
hgs
parents: 34
diff changeset
   130
	//Load portrait section by default as only vertical orientation is currently supported by videoplayer
hgs
parents: 34
diff changeset
   131
	mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_PORTRAIT, &ok);
44
hgs
parents: 41
diff changeset
   132
35
hgs
parents: 34
diff changeset
   133
	if(!ok)
hgs
parents: 34
diff changeset
   134
	{
36
hgs
parents: 35
diff changeset
   135
	    ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to load portrait view.");
35
hgs
parents: 34
diff changeset
   136
		return;
hgs
parents: 34
diff changeset
   137
	}
30
hgs
parents:
diff changeset
   138
58
hgs
parents: 55
diff changeset
   139
	mModel = mCollectionWrapper.getAllVideosModel();
30
hgs
parents:
diff changeset
   140
hgs
parents:
diff changeset
   141
	if (!mModel)
hgs
parents:
diff changeset
   142
		{
36
hgs
parents: 35
diff changeset
   143
	    ERROR(-1, "VideoFileDetailsViewPlugin::createView() get model failed.");
30
hgs
parents:
diff changeset
   144
		return;
hgs
parents:
diff changeset
   145
		}
hgs
parents:
diff changeset
   146
hgs
parents:
diff changeset
   147
	mIsService = XQServiceUtil::isService();
hgs
parents:
diff changeset
   148
hgs
parents:
diff changeset
   149
	// no deallocation needed for this since
hgs
parents:
diff changeset
   150
	// stackedwidget takes ownership
hgs
parents:
diff changeset
   151
	mTitleAnim = new HbMarqueeItem;
34
hgs
parents: 30
diff changeset
   152
	HbFontSpec spec = mTitleAnim->fontSpec();
hgs
parents: 30
diff changeset
   153
    spec.setRole( HbFontSpec::Primary );
hgs
parents: 30
diff changeset
   154
    mTitleAnim->setFontSpec( spec );
hgs
parents: 30
diff changeset
   155
    mTitleAnim->setLoopCount(-1);
38
hgs
parents: 37
diff changeset
   156
    mTitleAnim->setObjectName(VIDEO_DETAILS_OBJECT_NAME_TITLE_ANIM);
34
hgs
parents: 30
diff changeset
   157
hgs
parents: 30
diff changeset
   158
	connect(mModel->sourceModel(),
hgs
parents: 30
diff changeset
   159
			SIGNAL(shortDetailsReady(TMPXItemId)),
hgs
parents: 30
diff changeset
   160
			this, SLOT(shortDetailsReadySlot(TMPXItemId)));
30
hgs
parents:
diff changeset
   161
35
hgs
parents: 34
diff changeset
   162
	connect(mModel->sourceModel(),
36
hgs
parents: 35
diff changeset
   163
			SIGNAL(fullVideoDetailsReady(QVariant&)),
hgs
parents: 35
diff changeset
   164
			this, SLOT(fullDetailsReadySlot(QVariant&)));
30
hgs
parents:
diff changeset
   165
hgs
parents:
diff changeset
   166
	connect(mModel,
hgs
parents:
diff changeset
   167
			SIGNAL(rowsRemoved(const QModelIndex&, int, int)),
hgs
parents:
diff changeset
   168
			this, SLOT(rowsRemovedSlot(const QModelIndex&, int, int)));
hgs
parents:
diff changeset
   169
36
hgs
parents: 35
diff changeset
   170
	// Setup thumbnail widget.
34
hgs
parents: 30
diff changeset
   171
	HbStackedWidget* thumbWidget = findWidget<HbStackedWidget>(VIDEO_DETAILS_THUMBNAIL);
36
hgs
parents: 35
diff changeset
   172
	if(!thumbWidget)
hgs
parents: 35
diff changeset
   173
	{
hgs
parents: 35
diff changeset
   174
	    ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to load thumbnail widget.");
hgs
parents: 35
diff changeset
   175
	    return;
hgs
parents: 35
diff changeset
   176
	}
34
hgs
parents: 30
diff changeset
   177
hgs
parents: 30
diff changeset
   178
	// no deallocation needed for this since
hgs
parents: 30
diff changeset
   179
	// stackedwidget takes ownership
hgs
parents: 30
diff changeset
   180
	mThumbLabel = new VideoDetailsLabel;
hgs
parents: 30
diff changeset
   181
	mThumbLabel->setAlignment(Qt::AlignCenter);
38
hgs
parents: 37
diff changeset
   182
	mThumbLabel->setObjectName(VIDEO_DETAILS_OBJECT_NAME_THUMBLABEL);
44
hgs
parents: 41
diff changeset
   183
34
hgs
parents: 30
diff changeset
   184
	connect(mThumbLabel, SIGNAL(clicked(bool)), this, SLOT(startPlaybackSlot()));
hgs
parents: 30
diff changeset
   185
hgs
parents: 30
diff changeset
   186
	thumbWidget->addWidget(mThumbLabel);
hgs
parents: 30
diff changeset
   187
36
hgs
parents: 35
diff changeset
   188
	// Load details title.
30
hgs
parents:
diff changeset
   189
	HbStackedWidget* title = findObject<HbStackedWidget>(VIDEO_DETAILS_TITLE);
36
hgs
parents: 35
diff changeset
   190
	if(!title)
hgs
parents: 35
diff changeset
   191
	{
hgs
parents: 35
diff changeset
   192
	    ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to load title.");
hgs
parents: 35
diff changeset
   193
	    return;
hgs
parents: 35
diff changeset
   194
	}
30
hgs
parents:
diff changeset
   195
	title->addWidget(mTitleAnim);
hgs
parents:
diff changeset
   196
36
hgs
parents: 35
diff changeset
   197
	// Load delete action.
30
hgs
parents:
diff changeset
   198
	HbAction* deleteAction = findObject<HbAction>(VIDEO_DETAILS_MENUACTION_DELETE);
36
hgs
parents: 35
diff changeset
   199
    if(!deleteAction)
hgs
parents: 35
diff changeset
   200
    {
hgs
parents: 35
diff changeset
   201
        ERROR(-1, "VideoFileDetailsViewPlugin::createView() failed to delete action.");
hgs
parents: 35
diff changeset
   202
        return;
hgs
parents: 35
diff changeset
   203
    }
38
hgs
parents: 37
diff changeset
   204
    deleteAction->setObjectName(VIDEO_DETAILS_OBJECT_NAME_DELETE_ACTION);
30
hgs
parents:
diff changeset
   205
hgs
parents:
diff changeset
   206
	if (mIsService)
hgs
parents:
diff changeset
   207
	{
hgs
parents:
diff changeset
   208
		deleteAction->setVisible(false);
hgs
parents:
diff changeset
   209
	}
hgs
parents:
diff changeset
   210
	else
hgs
parents:
diff changeset
   211
	{
hgs
parents:
diff changeset
   212
		connect(deleteAction, SIGNAL(triggered(bool)), this, SLOT(deleteVideoSlot()));
hgs
parents:
diff changeset
   213
	}
35
hgs
parents: 34
diff changeset
   214
34
hgs
parents: 30
diff changeset
   215
	// Create navigation keys.
hgs
parents: 30
diff changeset
   216
	mNavKeyBackAction = new HbAction(Hb::BackNaviAction);
38
hgs
parents: 37
diff changeset
   217
	mNavKeyBackAction->setObjectName(VIDEO_DETAILS_OBJECT_NAME_NAVKEY_BACK);
44
hgs
parents: 41
diff changeset
   218
35
hgs
parents: 34
diff changeset
   219
	if (!mThumbnailManager)
hgs
parents: 34
diff changeset
   220
	{
hgs
parents: 34
diff changeset
   221
		mThumbnailManager = new ThumbnailManager();
hgs
parents: 34
diff changeset
   222
	}
hgs
parents: 34
diff changeset
   223
34
hgs
parents: 30
diff changeset
   224
	connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap,void*,int,int)),
30
hgs
parents:
diff changeset
   225
			this, SLOT(thumbnailReadySlot(QPixmap,void*,int,int)));
44
hgs
parents: 41
diff changeset
   226
37
hgs
parents: 36
diff changeset
   227
    HbListWidget* list = findWidget<HbListWidget>(VIDEO_DETAILS_LISTWIDGET);
hgs
parents: 36
diff changeset
   228
    if(!list)
hgs
parents: 36
diff changeset
   229
    {
hgs
parents: 36
diff changeset
   230
        ERROR(-1, "VideoFileDetailsViewPlugin::activateView() failed to load details list widget.");
hgs
parents: 36
diff changeset
   231
        return;
hgs
parents: 36
diff changeset
   232
    }
44
hgs
parents: 41
diff changeset
   233
37
hgs
parents: 36
diff changeset
   234
    list->setEnabledAnimations(HbAbstractItemView::None);
55
hgs
parents: 50
diff changeset
   235
    
hgs
parents: 50
diff changeset
   236
    list->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded);
hgs
parents: 50
diff changeset
   237
    
hgs
parents: 50
diff changeset
   238
    HbScrollBar* bar = list->verticalScrollBar();
hgs
parents: 50
diff changeset
   239
    
hgs
parents: 50
diff changeset
   240
    if(bar)
hgs
parents: 50
diff changeset
   241
    {
hgs
parents: 50
diff changeset
   242
        bar->setInteractive(true);
hgs
parents: 50
diff changeset
   243
    }
30
hgs
parents:
diff changeset
   244
}
hgs
parents:
diff changeset
   245
hgs
parents:
diff changeset
   246
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   247
// Destroy view
hgs
parents:
diff changeset
   248
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   249
//
hgs
parents:
diff changeset
   250
void VideoFileDetailsViewPlugin::destroyView()
hgs
parents:
diff changeset
   251
{
36
hgs
parents: 35
diff changeset
   252
	FUNC_LOG;
30
hgs
parents:
diff changeset
   253
    if (mActivated)
hgs
parents:
diff changeset
   254
    {
hgs
parents:
diff changeset
   255
        deactivateView();
hgs
parents:
diff changeset
   256
    }
hgs
parents:
diff changeset
   257
hgs
parents:
diff changeset
   258
    if(mVideoServices)
hgs
parents:
diff changeset
   259
    {
hgs
parents:
diff changeset
   260
    	mVideoServices->decreaseReferenceCount();
hgs
parents:
diff changeset
   261
    	mVideoServices = 0;
hgs
parents:
diff changeset
   262
    }
hgs
parents:
diff changeset
   263
36
hgs
parents: 35
diff changeset
   264
    delete mNavKeyBackAction;
hgs
parents: 35
diff changeset
   265
    mNavKeyBackAction = 0;
44
hgs
parents: 41
diff changeset
   266
36
hgs
parents: 35
diff changeset
   267
    delete mThumbnailManager;
hgs
parents: 35
diff changeset
   268
    mThumbnailManager = 0;
44
hgs
parents: 41
diff changeset
   269
30
hgs
parents:
diff changeset
   270
    disconnect();
35
hgs
parents: 34
diff changeset
   271
    mLoader.reset();
30
hgs
parents:
diff changeset
   272
}
hgs
parents:
diff changeset
   273
hgs
parents:
diff changeset
   274
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   275
// Activate view
hgs
parents:
diff changeset
   276
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   277
//
hgs
parents:
diff changeset
   278
void VideoFileDetailsViewPlugin::activateView()
hgs
parents:
diff changeset
   279
{
36
hgs
parents: 35
diff changeset
   280
	FUNC_LOG;
35
hgs
parents: 34
diff changeset
   281
	if (!mActivated)
30
hgs
parents:
diff changeset
   282
    {
hgs
parents:
diff changeset
   283
        HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
hgs
parents:
diff changeset
   284
34
hgs
parents: 30
diff changeset
   285
        HbView *currentView = mainWnd->currentView();
hgs
parents: 30
diff changeset
   286
        if(currentView && mNavKeyBackAction)
hgs
parents: 30
diff changeset
   287
        {
50
hgs
parents: 44
diff changeset
   288
        	if (connect(mNavKeyBackAction, SIGNAL(triggered()), this, SLOT(back())), Qt::UniqueConnection)
34
hgs
parents: 30
diff changeset
   289
        	{
hgs
parents: 30
diff changeset
   290
        		currentView->setNavigationAction(mNavKeyBackAction);
hgs
parents: 30
diff changeset
   291
        	}
hgs
parents: 30
diff changeset
   292
        	else
hgs
parents: 30
diff changeset
   293
        	{
36
hgs
parents: 35
diff changeset
   294
        	    ERROR(-1, "VideoFileDetailsViewPlugin::activateView() failed to connect navkey signal.");
34
hgs
parents: 30
diff changeset
   295
        		return;
hgs
parents: 30
diff changeset
   296
        	}
hgs
parents: 30
diff changeset
   297
        }
35
hgs
parents: 34
diff changeset
   298
34
hgs
parents: 30
diff changeset
   299
        mainWnd->setOrientation(Qt::Vertical, false);
hgs
parents: 30
diff changeset
   300
hgs
parents: 30
diff changeset
   301
        // following if is for the future implementations where we should support
hgs
parents: 30
diff changeset
   302
        // also landscape configuration.
30
hgs
parents:
diff changeset
   303
        Qt::Orientation orientation = mainWnd->orientation();
35
hgs
parents: 34
diff changeset
   304
        if ( (orientation == Qt::Vertical) && (orientation != mPreviousOrietation) )
30
hgs
parents:
diff changeset
   305
        {
35
hgs
parents: 34
diff changeset
   306
    		mPreviousOrietation = orientation;
hgs
parents: 34
diff changeset
   307
        	mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_PORTRAIT);
30
hgs
parents:
diff changeset
   308
        }
35
hgs
parents: 34
diff changeset
   309
        else if ( (orientation == Qt::Horizontal) && (orientation != mPreviousOrietation) )
30
hgs
parents:
diff changeset
   310
        {
35
hgs
parents: 34
diff changeset
   311
    		mPreviousOrietation = orientation;
hgs
parents: 34
diff changeset
   312
    		mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_LANDSCAPE);
30
hgs
parents:
diff changeset
   313
        }
hgs
parents:
diff changeset
   314
hgs
parents:
diff changeset
   315
    	if (mIsService && !mVideoServices)
hgs
parents:
diff changeset
   316
    	{
hgs
parents:
diff changeset
   317
    		mVideoServices = VideoServices::instance();
hgs
parents:
diff changeset
   318
hgs
parents:
diff changeset
   319
			if (!mVideoServices)
hgs
parents:
diff changeset
   320
			{
36
hgs
parents: 35
diff changeset
   321
			    ERROR(-1, "VideoFileDetailsViewPlugin::activateView() failed to get video services instance.");
30
hgs
parents:
diff changeset
   322
				return;
hgs
parents:
diff changeset
   323
			}
34
hgs
parents: 30
diff changeset
   324
    	}
35
hgs
parents: 34
diff changeset
   325
36
hgs
parents: 35
diff changeset
   326
		VideoServices::TVideoService service = VideoServices::ENoService;
35
hgs
parents: 34
diff changeset
   327
		if (mIsService && mVideoServices)
34
hgs
parents: 30
diff changeset
   328
		{
36
hgs
parents: 35
diff changeset
   329
		    service = mVideoServices->currentService();
44
hgs
parents: 41
diff changeset
   330
34
hgs
parents: 30
diff changeset
   331
            HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
hgs
parents: 30
diff changeset
   332
            mainWnd->currentView()->setTitle(mVideoServices->contextTitle());
hgs
parents: 30
diff changeset
   333
		}
36
hgs
parents: 35
diff changeset
   334
hgs
parents: 35
diff changeset
   335
        HbPushButton* button = findWidget<HbPushButton>(VIDEO_DETAILS_BUTTON);
hgs
parents: 35
diff changeset
   336
		if(!button)
hgs
parents: 35
diff changeset
   337
		{
hgs
parents: 35
diff changeset
   338
		    ERROR(-1, "VideoFileDetailsViewPlugin::activateView() failed to load details button.");
hgs
parents: 35
diff changeset
   339
		    return;
hgs
parents: 35
diff changeset
   340
		}
44
hgs
parents: 41
diff changeset
   341
41
hgs
parents: 38
diff changeset
   342
	    // Fix the size of the thumbnail, as that needs to be in 16:9
hgs
parents: 38
diff changeset
   343
	    qreal width = button->size().width();
hgs
parents: 38
diff changeset
   344
	    qreal height = width * 9 / 16;
44
hgs
parents: 41
diff changeset
   345
41
hgs
parents: 38
diff changeset
   346
	    HbStackedWidget* thumbWidget = findWidget<HbStackedWidget>(VIDEO_DETAILS_THUMBNAIL);
hgs
parents: 38
diff changeset
   347
	    thumbWidget->setPreferredWidth(width);
hgs
parents: 38
diff changeset
   348
	    thumbWidget->setPreferredHeight(height);
44
hgs
parents: 41
diff changeset
   349
36
hgs
parents: 35
diff changeset
   350
		if (service == VideoServices::EUriFetcher)
hgs
parents: 35
diff changeset
   351
		{
44
hgs
parents: 41
diff changeset
   352
			HbIcon icon = HbIcon("qtg_mono_attach");
hgs
parents: 41
diff changeset
   353
			button->setIcon(icon);
36
hgs
parents: 35
diff changeset
   354
50
hgs
parents: 44
diff changeset
   355
            connect(button, SIGNAL(clicked(bool)), this, SLOT(getFileUri()), Qt::UniqueConnection);
hgs
parents: 44
diff changeset
   356
            connect(this, SIGNAL(fileUri(const QString&)), mVideoServices, SLOT(itemSelected(const QString&)), Qt::UniqueConnection);
36
hgs
parents: 35
diff changeset
   357
		}
hgs
parents: 35
diff changeset
   358
		else
hgs
parents: 35
diff changeset
   359
		{
50
hgs
parents: 44
diff changeset
   360
			connect(button, SIGNAL(clicked(bool)), this, SLOT(sendVideoSlot()), Qt::UniqueConnection);
44
hgs
parents: 41
diff changeset
   361
hgs
parents: 41
diff changeset
   362
			HbIcon icon = HbIcon("qtg_mono_share");
hgs
parents: 41
diff changeset
   363
			button->setIcon(icon);
30
hgs
parents:
diff changeset
   364
    	}
hgs
parents:
diff changeset
   365
hgs
parents:
diff changeset
   366
        connect(mainWnd,
hgs
parents:
diff changeset
   367
                SIGNAL(orientationChanged(Qt::Orientation)),
50
hgs
parents: 44
diff changeset
   368
                this, SLOT(orientationChange(Qt::Orientation)),
hgs
parents: 44
diff changeset
   369
                Qt::UniqueConnection);
34
hgs
parents: 30
diff changeset
   370
hgs
parents: 30
diff changeset
   371
        connect(&mCollectionWrapper,
hgs
parents: 30
diff changeset
   372
               SIGNAL(asyncStatus(int, QVariant&)),
50
hgs
parents: 44
diff changeset
   373
               this, SLOT(handleErrorSlot(int, QVariant&)),
hgs
parents: 44
diff changeset
   374
               Qt::UniqueConnection);
30
hgs
parents:
diff changeset
   375
hgs
parents:
diff changeset
   376
        // setup title size in order for animation to be enabled if needed
34
hgs
parents: 30
diff changeset
   377
        mTitleAnim->setMinimumWidth(hbInstance->allMainWindows().value(0)->width()-50);
30
hgs
parents:
diff changeset
   378
        mTitleAnim->adjustSize();
34
hgs
parents: 30
diff changeset
   379
30
hgs
parents:
diff changeset
   380
        mActivated = true;
hgs
parents:
diff changeset
   381
    }
hgs
parents:
diff changeset
   382
}
hgs
parents:
diff changeset
   383
hgs
parents:
diff changeset
   384
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   385
// Deactivate view
hgs
parents:
diff changeset
   386
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   387
//
hgs
parents:
diff changeset
   388
void VideoFileDetailsViewPlugin::deactivateView()
hgs
parents:
diff changeset
   389
{
36
hgs
parents: 35
diff changeset
   390
	FUNC_LOG;
30
hgs
parents:
diff changeset
   391
    if ( mActivated )
hgs
parents:
diff changeset
   392
    {
34
hgs
parents: 30
diff changeset
   393
        mVideoId = TMPXItemId::InvalidId();
hgs
parents: 30
diff changeset
   394
hgs
parents: 30
diff changeset
   395
        mDeletedIndex = -1;  // set index as invalid.
hgs
parents: 30
diff changeset
   396
30
hgs
parents:
diff changeset
   397
        HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
34
hgs
parents: 30
diff changeset
   398
hgs
parents: 30
diff changeset
   399
        mainWnd->unsetOrientation();
hgs
parents: 30
diff changeset
   400
hgs
parents: 30
diff changeset
   401
        HbView *currentView = mainWnd->currentView();
hgs
parents: 30
diff changeset
   402
        if(currentView)
hgs
parents: 30
diff changeset
   403
        {
hgs
parents: 30
diff changeset
   404
       		currentView->setNavigationAction(0);
hgs
parents: 30
diff changeset
   405
        }
hgs
parents: 30
diff changeset
   406
hgs
parents: 30
diff changeset
   407
        disconnect(mNavKeyBackAction, SIGNAL(triggered()), this, SLOT(back()));
30
hgs
parents:
diff changeset
   408
hgs
parents:
diff changeset
   409
        disconnect(mainWnd, SIGNAL( orientationChanged( Qt::Orientation ) ),
hgs
parents:
diff changeset
   410
             this, SLOT( orientationChange( Qt::Orientation ) ));
hgs
parents:
diff changeset
   411
34
hgs
parents: 30
diff changeset
   412
        disconnect(&mCollectionWrapper,
hgs
parents: 30
diff changeset
   413
                       SIGNAL(asyncStatus(int, QVariant&)),
30
hgs
parents:
diff changeset
   414
                       this, SLOT(handleErrorSlot(int, QVariant&)));
hgs
parents:
diff changeset
   415
hgs
parents:
diff changeset
   416
        mTitleAnim->stopAnimation();
hgs
parents:
diff changeset
   417
        mTitleAnim->setText("");
34
hgs
parents: 30
diff changeset
   418
30
hgs
parents:
diff changeset
   419
        mActivated = false;
hgs
parents:
diff changeset
   420
34
hgs
parents: 30
diff changeset
   421
    	mThumbLabel->setIcon(HbIcon());
hgs
parents: 30
diff changeset
   422
hgs
parents: 30
diff changeset
   423
   		HbPushButton* button = findWidget<HbPushButton>(VIDEO_DETAILS_BUTTON);
30
hgs
parents:
diff changeset
   424
hgs
parents:
diff changeset
   425
    	if (mIsService)
hgs
parents:
diff changeset
   426
    	{
34
hgs
parents: 30
diff changeset
   427
			disconnect(button, SIGNAL(clicked(bool)), this, SLOT(getFileUri()));
30
hgs
parents:
diff changeset
   428
			disconnect(this, SIGNAL(fileUri(const QString&)), mVideoServices, SLOT(itemSelected(const QString&)));
hgs
parents:
diff changeset
   429
    	}
34
hgs
parents: 30
diff changeset
   430
		else
hgs
parents: 30
diff changeset
   431
		{
35
hgs
parents: 34
diff changeset
   432
			disconnect(button, SIGNAL(clicked(bool)), this, SLOT(sendVideoSlot()));
34
hgs
parents: 30
diff changeset
   433
		}
30
hgs
parents:
diff changeset
   434
    }
50
hgs
parents: 44
diff changeset
   435
    delete mShareUi;
hgs
parents: 44
diff changeset
   436
    mShareUi = 0;
30
hgs
parents:
diff changeset
   437
}
hgs
parents:
diff changeset
   438
hgs
parents:
diff changeset
   439
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   440
// Get view
hgs
parents:
diff changeset
   441
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   442
//
hgs
parents:
diff changeset
   443
QGraphicsWidget* VideoFileDetailsViewPlugin::getView()
hgs
parents:
diff changeset
   444
{
36
hgs
parents: 35
diff changeset
   445
	FUNC_LOG;
35
hgs
parents: 34
diff changeset
   446
    return mLoader.findWidget(VIDEO_DETAILS_VIEW);
30
hgs
parents:
diff changeset
   447
}
hgs
parents:
diff changeset
   448
hgs
parents:
diff changeset
   449
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   450
// Slot: Orientation change
hgs
parents:
diff changeset
   451
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   452
//
hgs
parents:
diff changeset
   453
void VideoFileDetailsViewPlugin::orientationChange( Qt::Orientation orientation )
34
hgs
parents: 30
diff changeset
   454
{
36
hgs
parents: 35
diff changeset
   455
	FUNC_LOG;
hgs
parents: 35
diff changeset
   456
    if (orientation == Qt::Vertical)
30
hgs
parents:
diff changeset
   457
    {
35
hgs
parents: 34
diff changeset
   458
    	mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_PORTRAIT);
30
hgs
parents:
diff changeset
   459
    }
34
hgs
parents: 30
diff changeset
   460
36
hgs
parents: 35
diff changeset
   461
    else if (orientation == Qt::Horizontal)
30
hgs
parents:
diff changeset
   462
    {
35
hgs
parents: 34
diff changeset
   463
       	mLoader.load(VIDEO_DETAILS_DOCML, VIDEO_DETAILS_LANDSCAPE);
30
hgs
parents:
diff changeset
   464
    }
hgs
parents:
diff changeset
   465
    mTitleAnim->adjustSize();
hgs
parents:
diff changeset
   466
    mTitleAnim->startAnimation();
hgs
parents:
diff changeset
   467
}
hgs
parents:
diff changeset
   468
hgs
parents:
diff changeset
   469
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   470
// Slot: back
hgs
parents:
diff changeset
   471
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   472
//
hgs
parents:
diff changeset
   473
void VideoFileDetailsViewPlugin::back()
hgs
parents:
diff changeset
   474
{
36
hgs
parents: 35
diff changeset
   475
	FUNC_LOG;
hgs
parents: 35
diff changeset
   476
    if (mActivated)
30
hgs
parents:
diff changeset
   477
    {
hgs
parents:
diff changeset
   478
        emit command( MpxHbVideoCommon::ActivateCollectionView );
hgs
parents:
diff changeset
   479
    }
hgs
parents:
diff changeset
   480
}
hgs
parents:
diff changeset
   481
hgs
parents:
diff changeset
   482
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   483
// Slot: shortDetailsReadySlot
hgs
parents:
diff changeset
   484
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   485
//
34
hgs
parents: 30
diff changeset
   486
void VideoFileDetailsViewPlugin::shortDetailsReadySlot(TMPXItemId id)
30
hgs
parents:
diff changeset
   487
{
36
hgs
parents: 35
diff changeset
   488
	FUNC_LOG;
30
hgs
parents:
diff changeset
   489
    // first clear all details, so that the view doesn't display the old data.
34
hgs
parents: 30
diff changeset
   490
    findWidget<HbListWidget>(VIDEO_DETAILS_LISTWIDGET)->clear();
30
hgs
parents:
diff changeset
   491
34
hgs
parents: 30
diff changeset
   492
    QModelIndex modelIndex = mModel->indexOfId(id);
hgs
parents: 30
diff changeset
   493
hgs
parents: 30
diff changeset
   494
    mVideoId = id;
30
hgs
parents:
diff changeset
   495
36
hgs
parents: 35
diff changeset
   496
    QVariant variant = mModel->data(modelIndex, VideoCollectionCommon::KeyTitle);
30
hgs
parents:
diff changeset
   497
34
hgs
parents: 30
diff changeset
   498
    if (variant.isValid() && mTitleAnim)
30
hgs
parents:
diff changeset
   499
    {
36
hgs
parents: 35
diff changeset
   500
        mTitleAnim->setText(variant.toString());
34
hgs
parents: 30
diff changeset
   501
    }
30
hgs
parents:
diff changeset
   502
    startFetchingThumbnail();
hgs
parents:
diff changeset
   503
}
hgs
parents:
diff changeset
   504
hgs
parents:
diff changeset
   505
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   506
// Slot: fullDetailsReadySlot
hgs
parents:
diff changeset
   507
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   508
//
36
hgs
parents: 35
diff changeset
   509
void VideoFileDetailsViewPlugin::fullDetailsReadySlot(QVariant& variant)
30
hgs
parents:
diff changeset
   510
{
36
hgs
parents: 35
diff changeset
   511
	FUNC_LOG;
30
hgs
parents:
diff changeset
   512
    using namespace VideoCollectionCommon;
34
hgs
parents: 30
diff changeset
   513
30
hgs
parents:
diff changeset
   514
    int detailCount = sizeof(VideoDetailLabelKeys) / sizeof(int);
hgs
parents:
diff changeset
   515
hgs
parents:
diff changeset
   516
    QMap<QString, QVariant> metadata = variant.toMap();
44
hgs
parents: 41
diff changeset
   517
34
hgs
parents: 30
diff changeset
   518
    HbListWidget* list = findWidget<HbListWidget>(VIDEO_DETAILS_LISTWIDGET);
36
hgs
parents: 35
diff changeset
   519
    if(!list)
hgs
parents: 35
diff changeset
   520
    {
hgs
parents: 35
diff changeset
   521
        ERROR(-1, "VideoFileDetailsViewPlugin::activateView() failed to load details list widget.");
hgs
parents: 35
diff changeset
   522
        return;
hgs
parents: 35
diff changeset
   523
    }
44
hgs
parents: 41
diff changeset
   524
34
hgs
parents: 30
diff changeset
   525
    if(list->count())
hgs
parents: 30
diff changeset
   526
    {
hgs
parents: 30
diff changeset
   527
        list->clear();
hgs
parents: 30
diff changeset
   528
    }
hgs
parents: 30
diff changeset
   529
hgs
parents: 30
diff changeset
   530
    HbListViewItem *prototype = list->listItemPrototype();
38
hgs
parents: 37
diff changeset
   531
    prototype->setSecondaryTextRowCount(1, VIDEO_DETAILS_SECONDARY_TEXT_ROW_COUNT);
34
hgs
parents: 30
diff changeset
   532
30
hgs
parents:
diff changeset
   533
    for(int i = 0; i< detailCount; i++) {
34
hgs
parents: 30
diff changeset
   534
        if (metadata.contains(VideoDetailLabelKeys[i]))
hgs
parents: 30
diff changeset
   535
        {
hgs
parents: 30
diff changeset
   536
            HbListWidgetItem* listWidgetItem = new HbListWidgetItem();
38
hgs
parents: 37
diff changeset
   537
            listWidgetItem->setText( hbTrId(VideoDetailLabels[i]));
hgs
parents: 37
diff changeset
   538
            listWidgetItem->setSecondaryText(metadata[VideoDetailLabelKeys[i]].toString());
hgs
parents: 37
diff changeset
   539
            list->addItem(listWidgetItem);
50
hgs
parents: 44
diff changeset
   540
            
hgs
parents: 44
diff changeset
   541
            // following is required to change wrapping-mode for the second row
hgs
parents: 44
diff changeset
   542
            HbListViewItem *viewItem = static_cast<HbListViewItem*>(list->viewItem(list->row(listWidgetItem)));
hgs
parents: 44
diff changeset
   543
            if(viewItem)
hgs
parents: 44
diff changeset
   544
            {
hgs
parents: 44
diff changeset
   545
                HbTextItem *secondLine = static_cast<HbTextItem*>(viewItem->primitive("text-2"));
hgs
parents: 44
diff changeset
   546
                if(secondLine)
hgs
parents: 44
diff changeset
   547
                {
hgs
parents: 44
diff changeset
   548
                    secondLine->setTextWrapping(Hb::TextWrapAnywhere);
hgs
parents: 44
diff changeset
   549
                }
hgs
parents: 44
diff changeset
   550
            }
30
hgs
parents:
diff changeset
   551
        }
hgs
parents:
diff changeset
   552
    }
hgs
parents:
diff changeset
   553
hgs
parents:
diff changeset
   554
    // start title animation
hgs
parents:
diff changeset
   555
    mTitleAnim->startAnimation();
hgs
parents:
diff changeset
   556
}
hgs
parents:
diff changeset
   557
hgs
parents:
diff changeset
   558
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   559
// Slot: getFileUri
hgs
parents:
diff changeset
   560
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   561
//
hgs
parents:
diff changeset
   562
void VideoFileDetailsViewPlugin::getFileUri()
hgs
parents:
diff changeset
   563
{
36
hgs
parents: 35
diff changeset
   564
	FUNC_LOG;
34
hgs
parents: 30
diff changeset
   565
	if (mVideoId != TMPXItemId::InvalidId())
30
hgs
parents:
diff changeset
   566
    {
34
hgs
parents: 30
diff changeset
   567
        QModelIndex modelIndex = mModel->indexOfId(mVideoId);
hgs
parents: 30
diff changeset
   568
		QVariant variant = mModel->data(modelIndex, VideoCollectionCommon::KeyFilePath);
36
hgs
parents: 35
diff changeset
   569
		if (variant.isValid())
30
hgs
parents:
diff changeset
   570
		{
hgs
parents:
diff changeset
   571
			QString itemPath = variant.value<QString>();
hgs
parents:
diff changeset
   572
    		emit(fileUri(itemPath));
hgs
parents:
diff changeset
   573
		}
hgs
parents:
diff changeset
   574
    }
hgs
parents:
diff changeset
   575
}
hgs
parents:
diff changeset
   576
hgs
parents:
diff changeset
   577
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   578
// Slot: startPlaybackSlot
hgs
parents:
diff changeset
   579
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   580
//
hgs
parents:
diff changeset
   581
void VideoFileDetailsViewPlugin::startPlaybackSlot()
hgs
parents:
diff changeset
   582
{
36
hgs
parents: 35
diff changeset
   583
	FUNC_LOG;
34
hgs
parents: 30
diff changeset
   584
	if (mVideoId != TMPXItemId::InvalidId())
hgs
parents: 30
diff changeset
   585
	{
hgs
parents: 30
diff changeset
   586
    	mModel->openItem(mVideoId);
hgs
parents: 30
diff changeset
   587
	}
30
hgs
parents:
diff changeset
   588
}
hgs
parents:
diff changeset
   589
hgs
parents:
diff changeset
   590
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   591
// Slot: sendVideo
hgs
parents:
diff changeset
   592
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   593
//
hgs
parents:
diff changeset
   594
void VideoFileDetailsViewPlugin::sendVideoSlot()
hgs
parents:
diff changeset
   595
{
36
hgs
parents: 35
diff changeset
   596
	FUNC_LOG;
44
hgs
parents: 41
diff changeset
   597
37
hgs
parents: 36
diff changeset
   598
    if(mVideoId != TMPXItemId::InvalidId())
36
hgs
parents: 35
diff changeset
   599
    {
50
hgs
parents: 44
diff changeset
   600
        if(!mShareUi)
hgs
parents: 44
diff changeset
   601
        {
hgs
parents: 44
diff changeset
   602
            mShareUi = new ShareUi();
hgs
parents: 44
diff changeset
   603
        }
36
hgs
parents: 35
diff changeset
   604
        QModelIndex modelIndex = mModel->indexOfId(mVideoId);
hgs
parents: 35
diff changeset
   605
        QVariant variant = mModel->data(modelIndex, VideoCollectionCommon::KeyFilePath);
hgs
parents: 35
diff changeset
   606
        if(variant.isValid())
hgs
parents: 35
diff changeset
   607
        {
hgs
parents: 35
diff changeset
   608
            QStringList fileList;
hgs
parents: 35
diff changeset
   609
            fileList.append(variant.toString());
50
hgs
parents: 44
diff changeset
   610
            mShareUi->send(fileList, true);
36
hgs
parents: 35
diff changeset
   611
        }
37
hgs
parents: 36
diff changeset
   612
    }
30
hgs
parents:
diff changeset
   613
}
hgs
parents:
diff changeset
   614
hgs
parents:
diff changeset
   615
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   616
// Slot: deleteVideo
hgs
parents:
diff changeset
   617
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   618
//
hgs
parents:
diff changeset
   619
void VideoFileDetailsViewPlugin::deleteVideoSlot()
hgs
parents:
diff changeset
   620
{
36
hgs
parents: 35
diff changeset
   621
	FUNC_LOG;
34
hgs
parents: 30
diff changeset
   622
	if (mVideoId != TMPXItemId::InvalidId())
30
hgs
parents:
diff changeset
   623
        {
34
hgs
parents: 30
diff changeset
   624
		QModelIndex modelIndex = mModel->indexOfId(mVideoId);
36
hgs
parents: 35
diff changeset
   625
		QVariant variant = mModel->data(modelIndex, VideoCollectionCommon::KeyTitle);
30
hgs
parents:
diff changeset
   626
34
hgs
parents: 30
diff changeset
   627
        if (variant.isValid())
hgs
parents: 30
diff changeset
   628
        {
44
hgs
parents: 41
diff changeset
   629
        	QString text = HbParameterLengthLimiter(hbTrId("txt_videos_info_do_you_want_to_delete_1")).
hgs
parents: 41
diff changeset
   630
        			arg(variant.toString());
30
hgs
parents:
diff changeset
   631
37
hgs
parents: 36
diff changeset
   632
            HbMessageBox *messageBox = new HbMessageBox(text, HbMessageBox::MessageTypeQuestion);
hgs
parents: 36
diff changeset
   633
            messageBox->setAttribute(Qt::WA_DeleteOnClose);
44
hgs
parents: 41
diff changeset
   634
            messageBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
38
hgs
parents: 37
diff changeset
   635
            messageBox->setObjectName(VIDEO_DETAILS_OBJECT_NAME_DELETE_VIDEO);
44
hgs
parents: 41
diff changeset
   636
            messageBox->open(this, SLOT(deleteVideoDialogFinished(int)));
30
hgs
parents:
diff changeset
   637
        }
hgs
parents:
diff changeset
   638
    }
hgs
parents:
diff changeset
   639
}
hgs
parents:
diff changeset
   640
hgs
parents:
diff changeset
   641
// ---------------------------------------------------------------------------
37
hgs
parents: 36
diff changeset
   642
// deleteVideoDialogFinished
hgs
parents: 36
diff changeset
   643
// ---------------------------------------------------------------------------
hgs
parents: 36
diff changeset
   644
//
44
hgs
parents: 41
diff changeset
   645
void VideoFileDetailsViewPlugin::deleteVideoDialogFinished(int action)
37
hgs
parents: 36
diff changeset
   646
{
hgs
parents: 36
diff changeset
   647
    FUNC_LOG;
hgs
parents: 36
diff changeset
   648
    QModelIndex modelIndex = mModel->indexOfId(mVideoId);
44
hgs
parents: 41
diff changeset
   649
    if(action == HbMessageBox::Yes && modelIndex.isValid())
37
hgs
parents: 36
diff changeset
   650
    {
hgs
parents: 36
diff changeset
   651
        deleteItem(modelIndex);
hgs
parents: 36
diff changeset
   652
    }
hgs
parents: 36
diff changeset
   653
}
hgs
parents: 36
diff changeset
   654
hgs
parents: 36
diff changeset
   655
// ---------------------------------------------------------------------------
30
hgs
parents:
diff changeset
   656
// deleteItem
hgs
parents:
diff changeset
   657
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   658
//
hgs
parents:
diff changeset
   659
void VideoFileDetailsViewPlugin::deleteItem(QModelIndex index)
hgs
parents:
diff changeset
   660
{
36
hgs
parents: 35
diff changeset
   661
	FUNC_LOG;
34
hgs
parents: 30
diff changeset
   662
    mDeletedIndex = index.row();
hgs
parents: 30
diff changeset
   663
30
hgs
parents:
diff changeset
   664
    QModelIndexList list;
hgs
parents:
diff changeset
   665
    list.append(index);
hgs
parents:
diff changeset
   666
    mModel->deleteItems(list);
hgs
parents:
diff changeset
   667
}
hgs
parents:
diff changeset
   668
hgs
parents:
diff changeset
   669
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   670
// Slot: rowsRemovedSlot
hgs
parents:
diff changeset
   671
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   672
//
34
hgs
parents: 30
diff changeset
   673
void VideoFileDetailsViewPlugin::rowsRemovedSlot(const QModelIndex& parent,
30
hgs
parents:
diff changeset
   674
                                                 int first, int last)
hgs
parents:
diff changeset
   675
{
36
hgs
parents: 35
diff changeset
   676
	FUNC_LOG;
34
hgs
parents: 30
diff changeset
   677
	Q_UNUSED(parent);
hgs
parents: 30
diff changeset
   678
hgs
parents: 30
diff changeset
   679
	if(mActivated && mDeletedIndex > -1 &&
hgs
parents: 30
diff changeset
   680
       (mDeletedIndex >= first && mDeletedIndex <= last))
30
hgs
parents:
diff changeset
   681
    {
hgs
parents:
diff changeset
   682
        // item is withing the group of removed items, deactivate view
hgs
parents:
diff changeset
   683
        emit command(MpxHbVideoCommon::ActivateCollectionView);
hgs
parents:
diff changeset
   684
    }
hgs
parents:
diff changeset
   685
}
hgs
parents:
diff changeset
   686
hgs
parents:
diff changeset
   687
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   688
// Slot: handleErrorSlot()
hgs
parents:
diff changeset
   689
// error signal received from collectionwrapper
hgs
parents:
diff changeset
   690
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   691
//
hgs
parents:
diff changeset
   692
void VideoFileDetailsViewPlugin::handleErrorSlot(int errorCode, QVariant &additional)
hgs
parents:
diff changeset
   693
{
36
hgs
parents: 35
diff changeset
   694
	FUNC_LOG;
30
hgs
parents:
diff changeset
   695
    QString msg("");
hgs
parents:
diff changeset
   696
    if(errorCode == VideoCollectionCommon::statusSingleDeleteFail)
hgs
parents:
diff changeset
   697
    {
38
hgs
parents: 37
diff changeset
   698
        QString format = hbTrId("txt_videos_info_unable_to_delete_1_it_is_current");
30
hgs
parents:
diff changeset
   699
        if(additional.isValid())
hgs
parents:
diff changeset
   700
        {
44
hgs
parents: 41
diff changeset
   701
           msg = HbParameterLengthLimiter(format).arg(additional.toString());
30
hgs
parents:
diff changeset
   702
        }
hgs
parents:
diff changeset
   703
    }
hgs
parents:
diff changeset
   704
    if(msg.count() > 0)
hgs
parents:
diff changeset
   705
    {
hgs
parents:
diff changeset
   706
        // show msg box if there's something to show
38
hgs
parents: 37
diff changeset
   707
        HbMessageBox *messageBox = new HbMessageBox(msg, HbMessageBox::MessageTypeWarning);
hgs
parents: 37
diff changeset
   708
        messageBox->setAttribute(Qt::WA_DeleteOnClose);
hgs
parents: 37
diff changeset
   709
        messageBox->setObjectName(VIDEO_DETAILS_OBJECT_NAME_MESSAGE_BOX_WARNING);
hgs
parents: 37
diff changeset
   710
        messageBox->show();
34
hgs
parents: 30
diff changeset
   711
    }
30
hgs
parents:
diff changeset
   712
}
hgs
parents:
diff changeset
   713
hgs
parents:
diff changeset
   714
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   715
// Slot: thumbnailReadySlot
hgs
parents:
diff changeset
   716
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   717
//
34
hgs
parents: 30
diff changeset
   718
void VideoFileDetailsViewPlugin::thumbnailReadySlot(QPixmap pixmap,
30
hgs
parents:
diff changeset
   719
        void * clientData, int id, int errorCode)
hgs
parents:
diff changeset
   720
{
36
hgs
parents: 35
diff changeset
   721
	FUNC_LOG;
30
hgs
parents:
diff changeset
   722
    Q_UNUSED(clientData);
hgs
parents:
diff changeset
   723
    Q_UNUSED(id);
hgs
parents:
diff changeset
   724
44
hgs
parents: 41
diff changeset
   725
	HbStackedWidget* thumbWidget = findWidget<HbStackedWidget>(VIDEO_DETAILS_THUMBNAIL);
hgs
parents: 41
diff changeset
   726
	if(!thumbWidget)
hgs
parents: 41
diff changeset
   727
	{
hgs
parents: 41
diff changeset
   728
	    ERROR(-1, "VideoFileDetailsViewPlugin::thumbnailReadySlot() failed to load thumbnail widget.");
hgs
parents: 41
diff changeset
   729
	    return;
hgs
parents: 41
diff changeset
   730
	}
hgs
parents: 41
diff changeset
   731
hgs
parents: 41
diff changeset
   732
	QSize size(thumbWidget->size().toSize());
30
hgs
parents:
diff changeset
   733
34
hgs
parents: 30
diff changeset
   734
	if (!errorCode)
hgs
parents: 30
diff changeset
   735
	{
30
hgs
parents:
diff changeset
   736
		QImage sourceImage = pixmap.toImage();
hgs
parents:
diff changeset
   737
34
hgs
parents: 30
diff changeset
   738
		if ((sourceImage.size().height() != size.height()) || (sourceImage.size().width() != size.width()))
30
hgs
parents:
diff changeset
   739
		{
hgs
parents:
diff changeset
   740
			// Smooth scaling is very expensive (size^2). Therefore we reduce the size
hgs
parents:
diff changeset
   741
			// to 2x of the destination size and using fast transformation before doing final smooth scaling.
hgs
parents:
diff changeset
   742
			if (sourceImage.size().width() > (4*size.width()) || sourceImage.size().height() > (4*size.height()))
hgs
parents:
diff changeset
   743
			{
hgs
parents:
diff changeset
   744
				QSize intermediate_size = QSize( size.width() * 2, size.height() * 2 );
34
hgs
parents: 30
diff changeset
   745
				sourceImage = sourceImage.scaled(intermediate_size, Qt::KeepAspectRatioByExpanding, Qt::FastTransformation );
30
hgs
parents:
diff changeset
   746
			}
34
hgs
parents: 30
diff changeset
   747
			sourceImage = sourceImage.scaled(size, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
30
hgs
parents:
diff changeset
   748
		}
hgs
parents:
diff changeset
   749
34
hgs
parents: 30
diff changeset
   750
		int difference(0);
44
hgs
parents: 41
diff changeset
   751
		QRect rect = thumbWidget->rect().toRect();
34
hgs
parents: 30
diff changeset
   752
hgs
parents: 30
diff changeset
   753
		if(sourceImage.width() > size.width())
hgs
parents: 30
diff changeset
   754
		{
hgs
parents: 30
diff changeset
   755
			difference = sourceImage.width() - size.width();
hgs
parents: 30
diff changeset
   756
			difference = (difference/2)+1;
hgs
parents: 30
diff changeset
   757
			rect.moveLeft(rect.left()+difference);
hgs
parents: 30
diff changeset
   758
		}
hgs
parents: 30
diff changeset
   759
		else if(sourceImage.height() > size.height())
hgs
parents: 30
diff changeset
   760
		{
hgs
parents: 30
diff changeset
   761
			difference = sourceImage.height() - size.height();
hgs
parents: 30
diff changeset
   762
			difference = (difference/2)+1;
hgs
parents: 30
diff changeset
   763
			rect.moveBottom(rect.bottom()+difference);
hgs
parents: 30
diff changeset
   764
		}
hgs
parents: 30
diff changeset
   765
hgs
parents: 30
diff changeset
   766
		sourceImage = sourceImage.copy(rect);
30
hgs
parents:
diff changeset
   767
		QImage resultImage = QImage(sourceImage.size(), QImage::Format_ARGB32_Premultiplied);
34
hgs
parents: 30
diff changeset
   768
30
hgs
parents:
diff changeset
   769
		QPainter painter(&resultImage);
35
hgs
parents: 34
diff changeset
   770
        painter.setCompositionMode(QPainter::CompositionMode_Source);
30
hgs
parents:
diff changeset
   771
		painter.fillRect(resultImage.rect(), Qt::transparent);
hgs
parents:
diff changeset
   772
		painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
35
hgs
parents: 34
diff changeset
   773
		painter.drawPixmap( (int)(sourceImage.width() - playIcon().width())/2,
hgs
parents: 34
diff changeset
   774
				           (int)(sourceImage.height() - playIcon().height())/2,
hgs
parents: 34
diff changeset
   775
				            playIcon() );
30
hgs
parents:
diff changeset
   776
		painter.setCompositionMode(QPainter::CompositionMode_Screen);
35
hgs
parents: 34
diff changeset
   777
        painter.drawImage(0, 0, sourceImage);
30
hgs
parents:
diff changeset
   778
		painter.end();
hgs
parents:
diff changeset
   779
hgs
parents:
diff changeset
   780
		HbIcon compsedIcon(QPixmap::fromImage(resultImage));
34
hgs
parents: 30
diff changeset
   781
	    mThumbLabel->setIcon(compsedIcon);
30
hgs
parents:
diff changeset
   782
	}
34
hgs
parents: 30
diff changeset
   783
    else
hgs
parents: 30
diff changeset
   784
    {
36
hgs
parents: 35
diff changeset
   785
        ERROR(errorCode, "VideoFileDetailsViewPlugin::thumbnailReadySlot() tbn fetch failed.");
34
hgs
parents: 30
diff changeset
   786
		mThumbLabel->setIcon(HbIcon(VIDEO_DETAILS_GFX_DEFAULT));
30
hgs
parents:
diff changeset
   787
	}
hgs
parents:
diff changeset
   788
}
hgs
parents:
diff changeset
   789
hgs
parents:
diff changeset
   790
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   791
// startFetchingThumbnail
hgs
parents:
diff changeset
   792
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   793
//
hgs
parents:
diff changeset
   794
void VideoFileDetailsViewPlugin::startFetchingThumbnail()
hgs
parents:
diff changeset
   795
{
36
hgs
parents: 35
diff changeset
   796
	FUNC_LOG;
30
hgs
parents:
diff changeset
   797
    int tnId = -1;
34
hgs
parents: 30
diff changeset
   798
hgs
parents: 30
diff changeset
   799
    if(mModel && mThumbnailManager)
hgs
parents: 30
diff changeset
   800
    {
hgs
parents: 30
diff changeset
   801
    	QModelIndex modelIndex = mModel->indexOfId(mVideoId);
hgs
parents: 30
diff changeset
   802
		QVariant variant = mModel->data(modelIndex, VideoCollectionCommon::KeyFilePath);
hgs
parents: 30
diff changeset
   803
        if(variant.isValid())
hgs
parents: 30
diff changeset
   804
        {
30
hgs
parents:
diff changeset
   805
            mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailLarge);
hgs
parents:
diff changeset
   806
            tnId = mThumbnailManager->getThumbnail(variant.toString(), 0, 5000);
hgs
parents:
diff changeset
   807
        }
34
hgs
parents: 30
diff changeset
   808
    }
hgs
parents: 30
diff changeset
   809
hgs
parents: 30
diff changeset
   810
    if(tnId == -1)
hgs
parents: 30
diff changeset
   811
    {
36
hgs
parents: 35
diff changeset
   812
        ERROR(-1, "VideoFileDetailsViewPlugin::startFetchingThumbnail() starting the fetch failed.");
34
hgs
parents: 30
diff changeset
   813
    	mThumbLabel->setIcon(HbIcon(VIDEO_DETAILS_GFX_DEFAULT));
30
hgs
parents:
diff changeset
   814
    }
hgs
parents:
diff changeset
   815
}
hgs
parents:
diff changeset
   816
hgs
parents:
diff changeset
   817
// ---------------------------------------------------------------------------
35
hgs
parents: 34
diff changeset
   818
// playIcon
hgs
parents: 34
diff changeset
   819
// ---------------------------------------------------------------------------
hgs
parents: 34
diff changeset
   820
//
hgs
parents: 34
diff changeset
   821
const QPixmap &VideoFileDetailsViewPlugin::playIcon()
hgs
parents: 34
diff changeset
   822
{
36
hgs
parents: 35
diff changeset
   823
	FUNC_LOG;
35
hgs
parents: 34
diff changeset
   824
    // Check if we have already the icon.
hgs
parents: 34
diff changeset
   825
    if(!mPlayIcon.isNull())
hgs
parents: 34
diff changeset
   826
    {
hgs
parents: 34
diff changeset
   827
        return mPlayIcon;
hgs
parents: 34
diff changeset
   828
    }
44
hgs
parents: 41
diff changeset
   829
35
hgs
parents: 34
diff changeset
   830
    // Compose the icon.
hgs
parents: 34
diff changeset
   831
    HbIcon play =        HbIcon("qtg_mono_play");
hgs
parents: 34
diff changeset
   832
    HbIcon topLeft =     HbIcon("qtg_fr_popup_trans_tl");
hgs
parents: 34
diff changeset
   833
    HbIcon top =         HbIcon("qtg_fr_popup_trans_t");
hgs
parents: 34
diff changeset
   834
    HbIcon topRight =    HbIcon("qtg_fr_popup_trans_tr");
hgs
parents: 34
diff changeset
   835
    HbIcon left =        HbIcon("qtg_fr_popup_trans_l");
hgs
parents: 34
diff changeset
   836
    HbIcon center =      HbIcon("qtg_fr_popup_trans_c");
hgs
parents: 34
diff changeset
   837
    HbIcon right =       HbIcon("qtg_fr_popup_trans_r");
hgs
parents: 34
diff changeset
   838
    HbIcon bottomLeft =  HbIcon("qtg_fr_popup_trans_bl");
hgs
parents: 34
diff changeset
   839
    HbIcon bottom =      HbIcon("qtg_fr_popup_trans_b");
hgs
parents: 34
diff changeset
   840
    HbIcon bottomRight = HbIcon("qtg_fr_popup_trans_br");
hgs
parents: 34
diff changeset
   841
hgs
parents: 34
diff changeset
   842
    int width = topLeft.width() + top.width() + topRight.width();
hgs
parents: 34
diff changeset
   843
    int height = topLeft.height() + center.height() + bottomLeft.height();
44
hgs
parents: 41
diff changeset
   844
35
hgs
parents: 34
diff changeset
   845
    mPlayIcon = QPixmap(width, height);
44
hgs
parents: 41
diff changeset
   846
35
hgs
parents: 34
diff changeset
   847
    QPainter painter(&mPlayIcon);
hgs
parents: 34
diff changeset
   848
    painter.fillRect(mPlayIcon.rect(), Qt::white);
44
hgs
parents: 41
diff changeset
   849
35
hgs
parents: 34
diff changeset
   850
    painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
44
hgs
parents: 41
diff changeset
   851
35
hgs
parents: 34
diff changeset
   852
    int x = 0;
hgs
parents: 34
diff changeset
   853
    int y = 0;
hgs
parents: 34
diff changeset
   854
hgs
parents: 34
diff changeset
   855
    // Draw top
hgs
parents: 34
diff changeset
   856
    painter.drawPixmap(QPoint(x, y), topLeft.pixmap());
hgs
parents: 34
diff changeset
   857
    x += left.width();
44
hgs
parents: 41
diff changeset
   858
35
hgs
parents: 34
diff changeset
   859
    painter.drawPixmap(QPoint(x, y), top.pixmap());
hgs
parents: 34
diff changeset
   860
    x += top.width();
hgs
parents: 34
diff changeset
   861
hgs
parents: 34
diff changeset
   862
    painter.drawPixmap(QPoint(x, y), topRight.pixmap());
hgs
parents: 34
diff changeset
   863
    y += top.height();
44
hgs
parents: 41
diff changeset
   864
35
hgs
parents: 34
diff changeset
   865
    // Draw center
hgs
parents: 34
diff changeset
   866
    x = 0;
hgs
parents: 34
diff changeset
   867
    painter.drawPixmap(QPoint(x, y), left.pixmap());
hgs
parents: 34
diff changeset
   868
    x += left.width();
44
hgs
parents: 41
diff changeset
   869
35
hgs
parents: 34
diff changeset
   870
    painter.drawPixmap(QPoint(x, y), center.pixmap());
hgs
parents: 34
diff changeset
   871
    x += center.width();
hgs
parents: 34
diff changeset
   872
hgs
parents: 34
diff changeset
   873
    painter.drawPixmap(QPoint(x, y), right.pixmap());
hgs
parents: 34
diff changeset
   874
    y += center.height();
44
hgs
parents: 41
diff changeset
   875
35
hgs
parents: 34
diff changeset
   876
    // Draw bottom
hgs
parents: 34
diff changeset
   877
    x = 0;
hgs
parents: 34
diff changeset
   878
    painter.drawPixmap(QPoint(x, y), bottomLeft.pixmap());
hgs
parents: 34
diff changeset
   879
    x += left.width();
44
hgs
parents: 41
diff changeset
   880
35
hgs
parents: 34
diff changeset
   881
    painter.drawPixmap(QPoint(x, y), bottom.pixmap());
hgs
parents: 34
diff changeset
   882
    x += top.width();
44
hgs
parents: 41
diff changeset
   883
35
hgs
parents: 34
diff changeset
   884
    painter.drawPixmap(QPoint(x, y), bottomRight.pixmap());
44
hgs
parents: 41
diff changeset
   885
35
hgs
parents: 34
diff changeset
   886
    // Draw play icon
hgs
parents: 34
diff changeset
   887
    play.setSize(mPlayIcon.size());
hgs
parents: 34
diff changeset
   888
    play.setColor(Qt::white);
hgs
parents: 34
diff changeset
   889
    painter.drawPixmap(mPlayIcon.rect(), play.pixmap());
hgs
parents: 34
diff changeset
   890
    painter.end();
44
hgs
parents: 41
diff changeset
   891
35
hgs
parents: 34
diff changeset
   892
    return mPlayIcon;
hgs
parents: 34
diff changeset
   893
}
hgs
parents: 34
diff changeset
   894
hgs
parents: 34
diff changeset
   895
// ---------------------------------------------------------------------------
30
hgs
parents:
diff changeset
   896
// findWidget
hgs
parents:
diff changeset
   897
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   898
//
hgs
parents:
diff changeset
   899
template<class T>
hgs
parents:
diff changeset
   900
T* VideoFileDetailsViewPlugin::findWidget(QString name)
hgs
parents:
diff changeset
   901
{
36
hgs
parents: 35
diff changeset
   902
	FUNC_LOG;
35
hgs
parents: 34
diff changeset
   903
    return qobject_cast<T *>(mLoader.findWidget(name));
30
hgs
parents:
diff changeset
   904
}
hgs
parents:
diff changeset
   905
hgs
parents:
diff changeset
   906
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   907
// findObject
hgs
parents:
diff changeset
   908
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   909
//
hgs
parents:
diff changeset
   910
template<class T>
hgs
parents:
diff changeset
   911
T* VideoFileDetailsViewPlugin::findObject(QString name)
hgs
parents:
diff changeset
   912
{
36
hgs
parents: 35
diff changeset
   913
	FUNC_LOG;
35
hgs
parents: 34
diff changeset
   914
    return qobject_cast<T *>(mLoader.findObject(name));
30
hgs
parents:
diff changeset
   915
}
hgs
parents:
diff changeset
   916
hgs
parents:
diff changeset
   917
XQ_EXPORT_PLUGIN2( videofiledetailsview, VideoFileDetailsViewPlugin );
hgs
parents:
diff changeset
   918
38
hgs
parents: 37
diff changeset
   919
// End of file