videocollection/videocollectionview/src/videocollectionviewplugin.cpp
author hgs
Fri, 03 Sep 2010 12:37:43 +0300
changeset 58 d2b028fd1f7d
parent 41 229f037ce963
permissions -rw-r--r--
201035
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:   VideoCollectionViewPlugin class implementation
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
58
hgs
parents: 41
diff changeset
    18
// Version : %version: 25 %
36
hgs
parents: 35
diff changeset
    19
30
hgs
parents:
diff changeset
    20
// INCLUDE FILES
hgs
parents:
diff changeset
    21
#include <xqplugin.h>
hgs
parents:
diff changeset
    22
#include <hbaction.h>
hgs
parents:
diff changeset
    23
#include <hbapplication.h>
hgs
parents:
diff changeset
    24
#include <hbinstance.h>
36
hgs
parents: 35
diff changeset
    25
#include <mpxitemid.h>
30
hgs
parents:
diff changeset
    26
36
hgs
parents: 35
diff changeset
    27
#include "videoservices.h"
hgs
parents: 35
diff changeset
    28
#include "vcxmyvideosdefs.h"
30
hgs
parents:
diff changeset
    29
#include "videocollectionviewplugin.h"
hgs
parents:
diff changeset
    30
#include "videolistview.h"
hgs
parents:
diff changeset
    31
#include "videocollectionuiloader.h"
58
hgs
parents: 41
diff changeset
    32
#include "videocollectionviewutils.h"
35
hgs
parents: 30
diff changeset
    33
#include "mpxhbvideocommondefs.h"
36
hgs
parents: 35
diff changeset
    34
#include "videocollectiontrace.h"
30
hgs
parents:
diff changeset
    35
hgs
parents:
diff changeset
    36
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    37
// Constructor
hgs
parents:
diff changeset
    38
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    39
//
hgs
parents:
diff changeset
    40
VideoCollectionViewPlugin::VideoCollectionViewPlugin()
36
hgs
parents: 35
diff changeset
    41
    : mUiLoader( 0 )
hgs
parents: 35
diff changeset
    42
    , mView( 0 )
58
hgs
parents: 41
diff changeset
    43
    , mUiUtils( VideoCollectionViewUtils::instance() )
36
hgs
parents: 35
diff changeset
    44
    , mActivated( false )
41
hgs
parents: 37
diff changeset
    45
    , mVideoServices( 0 )
30
hgs
parents:
diff changeset
    46
{
36
hgs
parents: 35
diff changeset
    47
	FUNC_LOG;
30
hgs
parents:
diff changeset
    48
}
hgs
parents:
diff changeset
    49
hgs
parents:
diff changeset
    50
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    51
// Destructor
hgs
parents:
diff changeset
    52
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    53
//
hgs
parents:
diff changeset
    54
VideoCollectionViewPlugin::~VideoCollectionViewPlugin()
hgs
parents:
diff changeset
    55
{
36
hgs
parents: 35
diff changeset
    56
	FUNC_LOG;
30
hgs
parents:
diff changeset
    57
    destroyView();
hgs
parents:
diff changeset
    58
}
hgs
parents:
diff changeset
    59
hgs
parents:
diff changeset
    60
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    61
// Create view
hgs
parents:
diff changeset
    62
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    63
//
hgs
parents:
diff changeset
    64
void VideoCollectionViewPlugin::createView()
hgs
parents:
diff changeset
    65
{
36
hgs
parents: 35
diff changeset
    66
	FUNC_LOG;
30
hgs
parents:
diff changeset
    67
	mActivated = false;
hgs
parents:
diff changeset
    68
    if ( !mView ) {
hgs
parents:
diff changeset
    69
hgs
parents:
diff changeset
    70
        if(!mUiLoader)
hgs
parents:
diff changeset
    71
        {
hgs
parents:
diff changeset
    72
            mUiLoader = new VideoCollectionUiLoader();
hgs
parents:
diff changeset
    73
        }
hgs
parents:
diff changeset
    74
hgs
parents:
diff changeset
    75
        mUiLoader->reset();
35
hgs
parents: 30
diff changeset
    76
        
58
hgs
parents: 41
diff changeset
    77
        mUiUtils.setIsService();
hgs
parents: 41
diff changeset
    78
        
hgs
parents: 41
diff changeset
    79
        mUiLoader->setIsService(mUiUtils.isService());
35
hgs
parents: 30
diff changeset
    80
30
hgs
parents:
diff changeset
    81
		bool ok(false);
hgs
parents:
diff changeset
    82
36
hgs
parents: 35
diff changeset
    83
		mUiLoader->load(DOCML_VIDEOCOLLECTIONVIEW_FILE, &ok);
hgs
parents: 35
diff changeset
    84
	    
hgs
parents: 35
diff changeset
    85
		if (!ok)
30
hgs
parents:
diff changeset
    86
	    {
hgs
parents:
diff changeset
    87
	    	return;
hgs
parents:
diff changeset
    88
	    }
hgs
parents:
diff changeset
    89
hgs
parents:
diff changeset
    90
	    mView = mUiLoader->findObject<VideoListView>( DOCML_NAME_VIEW );
hgs
parents:
diff changeset
    91
hgs
parents:
diff changeset
    92
        if(!mView)
hgs
parents:
diff changeset
    93
        {
36
hgs
parents: 35
diff changeset
    94
            ERROR(-1, "VideoCollectionViewPlugin::createView() failed to create view.");
30
hgs
parents:
diff changeset
    95
            return;
hgs
parents:
diff changeset
    96
        }
hgs
parents:
diff changeset
    97
35
hgs
parents: 30
diff changeset
    98
        if(!connect( mView, SIGNAL(command(int)), this, SIGNAL(command(int)) ) ||
37
hgs
parents: 36
diff changeset
    99
           !connect( this, SIGNAL(doDelayeds()), mView, SLOT(doDelayedsSlot()) ) ||
hgs
parents: 36
diff changeset
   100
           !connect( mView, SIGNAL(viewReady()), this, SLOT(viewReadySlot()) ) ) {
36
hgs
parents: 35
diff changeset
   101
            ERROR(-1, "VideoCollectionViewPlugin::createView() failed to connect signals.");
30
hgs
parents:
diff changeset
   102
            delete mView;
hgs
parents:
diff changeset
   103
            mView = 0;
hgs
parents:
diff changeset
   104
            return;
hgs
parents:
diff changeset
   105
        }
hgs
parents:
diff changeset
   106
        mView->initializeView();
35
hgs
parents: 30
diff changeset
   107
    }
hgs
parents: 30
diff changeset
   108
}
30
hgs
parents:
diff changeset
   109
35
hgs
parents: 30
diff changeset
   110
hgs
parents: 30
diff changeset
   111
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   112
// timerEvent
hgs
parents: 30
diff changeset
   113
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   114
//
hgs
parents: 30
diff changeset
   115
void VideoCollectionViewPlugin::timerEvent(QTimerEvent *event)
hgs
parents: 30
diff changeset
   116
{
36
hgs
parents: 35
diff changeset
   117
	FUNC_LOG;
35
hgs
parents: 30
diff changeset
   118
    if (event)
hgs
parents: 30
diff changeset
   119
    {
hgs
parents: 30
diff changeset
   120
        if (event->timerId() == mTimerId)
hgs
parents: 30
diff changeset
   121
        {
hgs
parents: 30
diff changeset
   122
        	killTimer(mTimerId);
hgs
parents: 30
diff changeset
   123
        	mTimerId = 0;
hgs
parents: 30
diff changeset
   124
hgs
parents: 30
diff changeset
   125
        	emit command(MpxHbVideoCommon::DoDelayedLoad);
hgs
parents: 30
diff changeset
   126
        	emit doDelayeds();
hgs
parents: 30
diff changeset
   127
        }
30
hgs
parents:
diff changeset
   128
    }
hgs
parents:
diff changeset
   129
}
hgs
parents:
diff changeset
   130
hgs
parents:
diff changeset
   131
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   132
// Destroy view
hgs
parents:
diff changeset
   133
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   134
//
hgs
parents:
diff changeset
   135
void VideoCollectionViewPlugin::destroyView()
hgs
parents:
diff changeset
   136
{
36
hgs
parents: 35
diff changeset
   137
	FUNC_LOG;
30
hgs
parents:
diff changeset
   138
    deactivateView();
hgs
parents:
diff changeset
   139
    disconnect();
hgs
parents:
diff changeset
   140
hgs
parents:
diff changeset
   141
    delete mView; 
hgs
parents:
diff changeset
   142
    mView = 0;
hgs
parents:
diff changeset
   143
    delete mUiLoader;
hgs
parents:
diff changeset
   144
    mUiLoader = 0;
41
hgs
parents: 37
diff changeset
   145
    
hgs
parents: 37
diff changeset
   146
    if(mVideoServices)
hgs
parents: 37
diff changeset
   147
    {
hgs
parents: 37
diff changeset
   148
        mVideoServices->decreaseReferenceCount();
hgs
parents: 37
diff changeset
   149
        mVideoServices = 0;
hgs
parents: 37
diff changeset
   150
    }
30
hgs
parents:
diff changeset
   151
}
hgs
parents:
diff changeset
   152
hgs
parents:
diff changeset
   153
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   154
// Activate view
hgs
parents:
diff changeset
   155
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   156
//
hgs
parents:
diff changeset
   157
void VideoCollectionViewPlugin::activateView()
hgs
parents:
diff changeset
   158
{
36
hgs
parents: 35
diff changeset
   159
	FUNC_LOG;
hgs
parents: 35
diff changeset
   160
    if (!mActivated)
hgs
parents: 35
diff changeset
   161
    {
30
hgs
parents:
diff changeset
   162
        HbMainWindow *wnd = mView->mainWindow();
hgs
parents:
diff changeset
   163
        if(wnd)
hgs
parents:
diff changeset
   164
        {
36
hgs
parents: 35
diff changeset
   165
            TMPXItemId itemId = TMPXItemId::InvalidId();
58
hgs
parents: 41
diff changeset
   166
            bool isService = mUiUtils.isService();
36
hgs
parents: 35
diff changeset
   167
            if (isService)
hgs
parents: 35
diff changeset
   168
            {
41
hgs
parents: 37
diff changeset
   169
                if(!mVideoServices)
36
hgs
parents: 35
diff changeset
   170
                {
41
hgs
parents: 37
diff changeset
   171
                    mVideoServices = VideoServices::instance();
hgs
parents: 37
diff changeset
   172
                }
hgs
parents: 37
diff changeset
   173
hgs
parents: 37
diff changeset
   174
                VideoServices::TVideoService serviceType =
hgs
parents: 37
diff changeset
   175
                        mVideoServices->currentService();
hgs
parents: 37
diff changeset
   176
                if (serviceType == VideoServices::EBrowse)
hgs
parents: 37
diff changeset
   177
                {
hgs
parents: 37
diff changeset
   178
                    // activate browsing service
hgs
parents: 37
diff changeset
   179
                    itemId.iId1 = mVideoServices->getBrowseCategory();
hgs
parents: 37
diff changeset
   180
                    itemId.iId2 = KVcxMvcMediaTypeCategory;
36
hgs
parents: 35
diff changeset
   181
                }
hgs
parents: 35
diff changeset
   182
            }
hgs
parents: 35
diff changeset
   183
            int err = mView->activateView(itemId);
hgs
parents: 35
diff changeset
   184
            if (err != 0)
hgs
parents: 35
diff changeset
   185
            {
hgs
parents: 35
diff changeset
   186
                return;
hgs
parents: 35
diff changeset
   187
            }
30
hgs
parents:
diff changeset
   188
            mActivated = true;
hgs
parents:
diff changeset
   189
        }
hgs
parents:
diff changeset
   190
    }
hgs
parents:
diff changeset
   191
}
hgs
parents:
diff changeset
   192
hgs
parents:
diff changeset
   193
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   194
// Deactivate view
hgs
parents:
diff changeset
   195
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   196
//
hgs
parents:
diff changeset
   197
void VideoCollectionViewPlugin::deactivateView()
hgs
parents:
diff changeset
   198
{
36
hgs
parents: 35
diff changeset
   199
	FUNC_LOG;
30
hgs
parents:
diff changeset
   200
    if ( mActivated ) {
hgs
parents:
diff changeset
   201
        mView->deactivateView();
hgs
parents:
diff changeset
   202
        mActivated = false;
hgs
parents:
diff changeset
   203
    }
hgs
parents:
diff changeset
   204
}
hgs
parents:
diff changeset
   205
hgs
parents:
diff changeset
   206
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   207
// Get view
hgs
parents:
diff changeset
   208
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   209
//
hgs
parents:
diff changeset
   210
QGraphicsWidget* VideoCollectionViewPlugin::getView()
hgs
parents:
diff changeset
   211
{
36
hgs
parents: 35
diff changeset
   212
	FUNC_LOG;
30
hgs
parents:
diff changeset
   213
    return mView;
hgs
parents:
diff changeset
   214
}
hgs
parents:
diff changeset
   215
hgs
parents:
diff changeset
   216
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   217
// Slot: Orientation change
hgs
parents:
diff changeset
   218
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   219
//
36
hgs
parents: 35
diff changeset
   220
void VideoCollectionViewPlugin::orientationChange( Qt::Orientation  orientation)
30
hgs
parents:
diff changeset
   221
{
36
hgs
parents: 35
diff changeset
   222
	FUNC_LOG;
30
hgs
parents:
diff changeset
   223
    // view handles orientation individually
36
hgs
parents: 35
diff changeset
   224
    Q_UNUSED(orientation);
30
hgs
parents:
diff changeset
   225
}
hgs
parents:
diff changeset
   226
hgs
parents:
diff changeset
   227
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   228
// Slot: back
hgs
parents:
diff changeset
   229
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   230
//
hgs
parents:
diff changeset
   231
void VideoCollectionViewPlugin::back()
hgs
parents:
diff changeset
   232
{
36
hgs
parents: 35
diff changeset
   233
	FUNC_LOG;
30
hgs
parents:
diff changeset
   234
    if ( mActivated ) {
hgs
parents:
diff changeset
   235
        mView->back();
hgs
parents:
diff changeset
   236
    }
hgs
parents:
diff changeset
   237
}
hgs
parents:
diff changeset
   238
37
hgs
parents: 36
diff changeset
   239
// ---------------------------------------------------------------------------
hgs
parents: 36
diff changeset
   240
// Slot: viewReadySlot
hgs
parents: 36
diff changeset
   241
// ---------------------------------------------------------------------------
hgs
parents: 36
diff changeset
   242
//
hgs
parents: 36
diff changeset
   243
void VideoCollectionViewPlugin::viewReadySlot()
hgs
parents: 36
diff changeset
   244
{
hgs
parents: 36
diff changeset
   245
    FUNC_LOG;
hgs
parents: 36
diff changeset
   246
    mTimerId = startTimer(DELAYED_LOAD_TIMEOUT);
hgs
parents: 36
diff changeset
   247
}
hgs
parents: 36
diff changeset
   248
30
hgs
parents:
diff changeset
   249
XQ_EXPORT_PLUGIN2( videocollectionview, VideoCollectionViewPlugin );
hgs
parents:
diff changeset
   250
hgs
parents:
diff changeset
   251
// end of file