videocollection/videocollectionview/src/videocollectionviewplugin.cpp
author hgs
Fri, 30 Apr 2010 09:52:11 +0300
changeset 37 4eb2df7f7cbe
parent 36 8aed59de29f9
child 41 229f037ce963
permissions -rw-r--r--
201017
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
37
hgs
parents: 36
diff changeset
    18
// Version : %version: 23 %
36
hgs
parents: 35
diff changeset
    19
30
hgs
parents:
diff changeset
    20
// INCLUDE FILES
hgs
parents:
diff changeset
    21
#include <xqplugin.h>
35
hgs
parents: 30
diff changeset
    22
#include <xqserviceutil.h>
30
hgs
parents:
diff changeset
    23
#include <hbaction.h>
hgs
parents:
diff changeset
    24
#include <hbapplication.h>
hgs
parents:
diff changeset
    25
#include <hbinstance.h>
36
hgs
parents: 35
diff changeset
    26
#include <mpxitemid.h>
30
hgs
parents:
diff changeset
    27
36
hgs
parents: 35
diff changeset
    28
#include "videoservices.h"
hgs
parents: 35
diff changeset
    29
#include "vcxmyvideosdefs.h"
30
hgs
parents:
diff changeset
    30
#include "videocollectionviewplugin.h"
hgs
parents:
diff changeset
    31
#include "videolistview.h"
hgs
parents:
diff changeset
    32
#include "videocollectionuiloader.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 )
hgs
parents: 35
diff changeset
    43
    , mActivated( false )
hgs
parents: 35
diff changeset
    44
    , mIsService( false )
30
hgs
parents:
diff changeset
    45
{
36
hgs
parents: 35
diff changeset
    46
	FUNC_LOG;
30
hgs
parents:
diff changeset
    47
}
hgs
parents:
diff changeset
    48
hgs
parents:
diff changeset
    49
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    50
// Destructor
hgs
parents:
diff changeset
    51
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    52
//
hgs
parents:
diff changeset
    53
VideoCollectionViewPlugin::~VideoCollectionViewPlugin()
hgs
parents:
diff changeset
    54
{
36
hgs
parents: 35
diff changeset
    55
	FUNC_LOG;
30
hgs
parents:
diff changeset
    56
    destroyView();
hgs
parents:
diff changeset
    57
}
hgs
parents:
diff changeset
    58
hgs
parents:
diff changeset
    59
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    60
// Create view
hgs
parents:
diff changeset
    61
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    62
//
hgs
parents:
diff changeset
    63
void VideoCollectionViewPlugin::createView()
hgs
parents:
diff changeset
    64
{
36
hgs
parents: 35
diff changeset
    65
	FUNC_LOG;
30
hgs
parents:
diff changeset
    66
	mActivated = false;
hgs
parents:
diff changeset
    67
    if ( !mView ) {
hgs
parents:
diff changeset
    68
hgs
parents:
diff changeset
    69
        if(!mUiLoader)
hgs
parents:
diff changeset
    70
        {
hgs
parents:
diff changeset
    71
            mUiLoader = new VideoCollectionUiLoader();
hgs
parents:
diff changeset
    72
        }
hgs
parents:
diff changeset
    73
hgs
parents:
diff changeset
    74
        mUiLoader->reset();
hgs
parents:
diff changeset
    75
35
hgs
parents: 30
diff changeset
    76
        if (XQServiceUtil::isService())
hgs
parents: 30
diff changeset
    77
        {
36
hgs
parents: 35
diff changeset
    78
        	INFO("VideoCollectionViewPlugin::createView() service flag set to true.");
hgs
parents: 35
diff changeset
    79
            mIsService = true;
35
hgs
parents: 30
diff changeset
    80
        }
hgs
parents: 30
diff changeset
    81
        
hgs
parents: 30
diff changeset
    82
        mUiLoader->setIsService(mIsService);
hgs
parents: 30
diff changeset
    83
30
hgs
parents:
diff changeset
    84
		bool ok(false);
hgs
parents:
diff changeset
    85
36
hgs
parents: 35
diff changeset
    86
		mUiLoader->load(DOCML_VIDEOCOLLECTIONVIEW_FILE, &ok);
hgs
parents: 35
diff changeset
    87
	    
hgs
parents: 35
diff changeset
    88
		if (!ok)
30
hgs
parents:
diff changeset
    89
	    {
hgs
parents:
diff changeset
    90
	    	return;
hgs
parents:
diff changeset
    91
	    }
hgs
parents:
diff changeset
    92
hgs
parents:
diff changeset
    93
	    mView = mUiLoader->findObject<VideoListView>( DOCML_NAME_VIEW );
hgs
parents:
diff changeset
    94
hgs
parents:
diff changeset
    95
        if(!mView)
hgs
parents:
diff changeset
    96
        {
36
hgs
parents: 35
diff changeset
    97
            ERROR(-1, "VideoCollectionViewPlugin::createView() failed to create view.");
30
hgs
parents:
diff changeset
    98
            return;
hgs
parents:
diff changeset
    99
        }
hgs
parents:
diff changeset
   100
35
hgs
parents: 30
diff changeset
   101
        if(!connect( mView, SIGNAL(command(int)), this, SIGNAL(command(int)) ) ||
37
hgs
parents: 36
diff changeset
   102
           !connect( this, SIGNAL(doDelayeds()), mView, SLOT(doDelayedsSlot()) ) ||
hgs
parents: 36
diff changeset
   103
           !connect( mView, SIGNAL(viewReady()), this, SLOT(viewReadySlot()) ) ) {
36
hgs
parents: 35
diff changeset
   104
            ERROR(-1, "VideoCollectionViewPlugin::createView() failed to connect signals.");
30
hgs
parents:
diff changeset
   105
            delete mView;
hgs
parents:
diff changeset
   106
            mView = 0;
hgs
parents:
diff changeset
   107
            return;
hgs
parents:
diff changeset
   108
        }
hgs
parents:
diff changeset
   109
        mView->initializeView();
35
hgs
parents: 30
diff changeset
   110
    }
hgs
parents: 30
diff changeset
   111
}
30
hgs
parents:
diff changeset
   112
35
hgs
parents: 30
diff changeset
   113
hgs
parents: 30
diff changeset
   114
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   115
// timerEvent
hgs
parents: 30
diff changeset
   116
// ---------------------------------------------------------------------------
hgs
parents: 30
diff changeset
   117
//
hgs
parents: 30
diff changeset
   118
void VideoCollectionViewPlugin::timerEvent(QTimerEvent *event)
hgs
parents: 30
diff changeset
   119
{
36
hgs
parents: 35
diff changeset
   120
	FUNC_LOG;
35
hgs
parents: 30
diff changeset
   121
    if (event)
hgs
parents: 30
diff changeset
   122
    {
hgs
parents: 30
diff changeset
   123
        if (event->timerId() == mTimerId)
hgs
parents: 30
diff changeset
   124
        {
hgs
parents: 30
diff changeset
   125
        	killTimer(mTimerId);
hgs
parents: 30
diff changeset
   126
        	mTimerId = 0;
hgs
parents: 30
diff changeset
   127
hgs
parents: 30
diff changeset
   128
        	emit command(MpxHbVideoCommon::DoDelayedLoad);
hgs
parents: 30
diff changeset
   129
        	emit doDelayeds();
hgs
parents: 30
diff changeset
   130
        }
30
hgs
parents:
diff changeset
   131
    }
hgs
parents:
diff changeset
   132
}
hgs
parents:
diff changeset
   133
hgs
parents:
diff changeset
   134
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   135
// Destroy view
hgs
parents:
diff changeset
   136
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   137
//
hgs
parents:
diff changeset
   138
void VideoCollectionViewPlugin::destroyView()
hgs
parents:
diff changeset
   139
{
36
hgs
parents: 35
diff changeset
   140
	FUNC_LOG;
30
hgs
parents:
diff changeset
   141
    deactivateView();
hgs
parents:
diff changeset
   142
    disconnect();
hgs
parents:
diff changeset
   143
hgs
parents:
diff changeset
   144
    delete mView; 
hgs
parents:
diff changeset
   145
    mView = 0;
hgs
parents:
diff changeset
   146
    delete mUiLoader;
hgs
parents:
diff changeset
   147
    mUiLoader = 0;
hgs
parents:
diff changeset
   148
}
hgs
parents:
diff changeset
   149
hgs
parents:
diff changeset
   150
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   151
// Activate view
hgs
parents:
diff changeset
   152
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   153
//
hgs
parents:
diff changeset
   154
void VideoCollectionViewPlugin::activateView()
hgs
parents:
diff changeset
   155
{
36
hgs
parents: 35
diff changeset
   156
	FUNC_LOG;
hgs
parents: 35
diff changeset
   157
    if (!mActivated)
hgs
parents: 35
diff changeset
   158
    {
30
hgs
parents:
diff changeset
   159
        HbMainWindow *wnd = mView->mainWindow();
hgs
parents:
diff changeset
   160
        if(wnd)
hgs
parents:
diff changeset
   161
        {
36
hgs
parents: 35
diff changeset
   162
            TMPXItemId itemId = TMPXItemId::InvalidId();
hgs
parents: 35
diff changeset
   163
            bool isService = XQServiceUtil::isService();
hgs
parents: 35
diff changeset
   164
            if (isService)
hgs
parents: 35
diff changeset
   165
            {
hgs
parents: 35
diff changeset
   166
                VideoServices *videoServices = VideoServices::instance();
hgs
parents: 35
diff changeset
   167
                if (videoServices)
hgs
parents: 35
diff changeset
   168
                {
hgs
parents: 35
diff changeset
   169
                    VideoServices::TVideoService serviceType =
hgs
parents: 35
diff changeset
   170
                        videoServices->currentService();
hgs
parents: 35
diff changeset
   171
                    if (serviceType == VideoServices::EBrowse)
hgs
parents: 35
diff changeset
   172
                    {
hgs
parents: 35
diff changeset
   173
                        // activate browsing service
hgs
parents: 35
diff changeset
   174
                        itemId.iId1 = videoServices->getBrowseCategory();
hgs
parents: 35
diff changeset
   175
                        itemId.iId2 = KVcxMvcMediaTypeCategory;
hgs
parents: 35
diff changeset
   176
                    }
hgs
parents: 35
diff changeset
   177
                }
hgs
parents: 35
diff changeset
   178
            }
hgs
parents: 35
diff changeset
   179
            int err = mView->activateView(itemId);
hgs
parents: 35
diff changeset
   180
            if (err != 0)
hgs
parents: 35
diff changeset
   181
            {
hgs
parents: 35
diff changeset
   182
                return;
hgs
parents: 35
diff changeset
   183
            }
30
hgs
parents:
diff changeset
   184
            mActivated = true;
hgs
parents:
diff changeset
   185
        }
hgs
parents:
diff changeset
   186
    }
hgs
parents:
diff changeset
   187
}
hgs
parents:
diff changeset
   188
hgs
parents:
diff changeset
   189
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   190
// Deactivate view
hgs
parents:
diff changeset
   191
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   192
//
hgs
parents:
diff changeset
   193
void VideoCollectionViewPlugin::deactivateView()
hgs
parents:
diff changeset
   194
{
36
hgs
parents: 35
diff changeset
   195
	FUNC_LOG;
30
hgs
parents:
diff changeset
   196
    if ( mActivated ) {
hgs
parents:
diff changeset
   197
        mView->deactivateView();
hgs
parents:
diff changeset
   198
        mActivated = false;
hgs
parents:
diff changeset
   199
    }
hgs
parents:
diff changeset
   200
}
hgs
parents:
diff changeset
   201
hgs
parents:
diff changeset
   202
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   203
// Get view
hgs
parents:
diff changeset
   204
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   205
//
hgs
parents:
diff changeset
   206
QGraphicsWidget* VideoCollectionViewPlugin::getView()
hgs
parents:
diff changeset
   207
{
36
hgs
parents: 35
diff changeset
   208
	FUNC_LOG;
30
hgs
parents:
diff changeset
   209
    return mView;
hgs
parents:
diff changeset
   210
}
hgs
parents:
diff changeset
   211
hgs
parents:
diff changeset
   212
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   213
// Slot: Orientation change
hgs
parents:
diff changeset
   214
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   215
//
36
hgs
parents: 35
diff changeset
   216
void VideoCollectionViewPlugin::orientationChange( Qt::Orientation  orientation)
30
hgs
parents:
diff changeset
   217
{
36
hgs
parents: 35
diff changeset
   218
	FUNC_LOG;
30
hgs
parents:
diff changeset
   219
    // view handles orientation individually
36
hgs
parents: 35
diff changeset
   220
    Q_UNUSED(orientation);
30
hgs
parents:
diff changeset
   221
}
hgs
parents:
diff changeset
   222
hgs
parents:
diff changeset
   223
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   224
// Slot: back
hgs
parents:
diff changeset
   225
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   226
//
hgs
parents:
diff changeset
   227
void VideoCollectionViewPlugin::back()
hgs
parents:
diff changeset
   228
{
36
hgs
parents: 35
diff changeset
   229
	FUNC_LOG;
30
hgs
parents:
diff changeset
   230
    if ( mActivated ) {
hgs
parents:
diff changeset
   231
        mView->back();
hgs
parents:
diff changeset
   232
    }
hgs
parents:
diff changeset
   233
}
hgs
parents:
diff changeset
   234
37
hgs
parents: 36
diff changeset
   235
// ---------------------------------------------------------------------------
hgs
parents: 36
diff changeset
   236
// Slot: viewReadySlot
hgs
parents: 36
diff changeset
   237
// ---------------------------------------------------------------------------
hgs
parents: 36
diff changeset
   238
//
hgs
parents: 36
diff changeset
   239
void VideoCollectionViewPlugin::viewReadySlot()
hgs
parents: 36
diff changeset
   240
{
hgs
parents: 36
diff changeset
   241
    FUNC_LOG;
hgs
parents: 36
diff changeset
   242
    mTimerId = startTimer(DELAYED_LOAD_TIMEOUT);
hgs
parents: 36
diff changeset
   243
}
hgs
parents: 36
diff changeset
   244
30
hgs
parents:
diff changeset
   245
XQ_EXPORT_PLUGIN2( videocollectionview, VideoCollectionViewPlugin );
hgs
parents:
diff changeset
   246
hgs
parents:
diff changeset
   247
// end of file