videoplayback/hbvideoplaybackview/tsrc/testmpxvideoplaybackcontrolbar/stub/src/mpxvideoplaybackdocumentloader.cpp
branchGCC_SURGE
changeset 48 ebbeb6bcda56
parent 27 7bf7319dbddd
parent 47 45e72b57a2fd
equal deleted inserted replaced
27:7bf7319dbddd 48:ebbeb6bcda56
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implementation of QMPXVideoPlaybackDocumentLoader
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version:   2 %
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 #include "mpxvideo_debug.h"
       
    24 #include "mpxvideoplaybackprogressbar.h"
       
    25 #include "mpxvideoplaybackdocumentloader.h"
       
    26 #include "mpxvideoplaybackcontrolscontroller.h"
       
    27 
       
    28 // -------------------------------------------------------------------------------------------------
       
    29 // QMPXVideoPlaybackDocumentLoader::QMPXVideoPlaybackDocumentLoader
       
    30 // -------------------------------------------------------------------------------------------------
       
    31 //
       
    32 QMPXVideoPlaybackDocumentLoader::QMPXVideoPlaybackDocumentLoader(
       
    33      QMPXVideoPlaybackControlsController *controller )
       
    34 {
       
    35     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackDocumentLoader::QMPXVideoPlaybackDocumentLoader()"));
       
    36 
       
    37     mController = controller;
       
    38 }
       
    39 
       
    40 // -------------------------------------------------------------------------------------------------
       
    41 // QMPXVideoPlaybackDocumentLoader::~QMPXVideoPlaybackDocumentLoader
       
    42 // -------------------------------------------------------------------------------------------------
       
    43 //
       
    44 QMPXVideoPlaybackDocumentLoader::~QMPXVideoPlaybackDocumentLoader()
       
    45 {
       
    46     MPX_DEBUG(_L("QMPXVideoPlaybackDocumentLoader::QMPXVideoPlaybackDocumentLoader") );
       
    47 
       
    48     for ( int i = 0 ; i < mWidgets.count() ; i++ )
       
    49     {
       
    50         mWidgets.removeAt( 0 );
       
    51     }
       
    52 }
       
    53 
       
    54 // -------------------------------------------------------------------------------------------------
       
    55 // QMPXVideoPlaybackDocumentLoader::findWidget()
       
    56 // -------------------------------------------------------------------------------------------------
       
    57 //
       
    58 QGraphicsWidget *QMPXVideoPlaybackDocumentLoader::findWidget( const QString &name )
       
    59 {
       
    60     MPX_DEBUG(_L("QMPXVideoPlaybackDocumentLoader::findWidget") );
       
    61 
       
    62     QGraphicsWidget *object = NULL;
       
    63 
       
    64     int index = exist( name );
       
    65 
       
    66     if ( index == -1 )
       
    67     {
       
    68         object = createWidget( name );
       
    69     }
       
    70     else
       
    71     {
       
    72         object = mWidgets[ index ];
       
    73     }
       
    74 
       
    75     return object;
       
    76 }
       
    77 
       
    78 // -------------------------------------------------------------------------------------------------
       
    79 // QMPXVideoPlaybackDocumentLoader::createWidget()
       
    80 // -------------------------------------------------------------------------------------------------
       
    81 //
       
    82 QGraphicsWidget *QMPXVideoPlaybackDocumentLoader::createWidget( const QString &name )
       
    83 {
       
    84     MPX_DEBUG(_L("QMPXVideoPlaybackDocumentLoader::createWidget") );
       
    85 
       
    86     QGraphicsWidget *object = NULL;
       
    87         
       
    88     if ( name == "progressBarLayout" )
       
    89     {
       
    90         object = new QMPXVideoPlaybackProgressBar( mController );
       
    91         object->setObjectName( name );
       
    92         mWidgets.append( object );
       
    93     }
       
    94 
       
    95     return object;
       
    96 }
       
    97 
       
    98 // -------------------------------------------------------------------------------------------------
       
    99 // QMPXVideoPlaybackDocumentLoader::exist()
       
   100 // -------------------------------------------------------------------------------------------------
       
   101 //
       
   102 int QMPXVideoPlaybackDocumentLoader::exist( const QString &name )
       
   103 {
       
   104     int i = 0;
       
   105 
       
   106     for ( ; i < mWidgets.count() ; i++ )
       
   107     {
       
   108         if( mWidgets[i]->objectName() == name )
       
   109         {
       
   110             break;
       
   111         }
       
   112     }
       
   113 
       
   114     if ( i == mWidgets.count() )
       
   115     {
       
   116         i = -1;
       
   117     }
       
   118 
       
   119     MPX_DEBUG(_L("QMPXVideoPlaybackDocumentLoader::exist %d"), i );
       
   120 
       
   121     return i;
       
   122 }
       
   123 
       
   124 // End of file