videoplayback/hbvideoplaybackview/tsrc/testmpxvideoplaybackbuttonbar/stub/src/mpxvideoplaybackdocumentloader.cpp
changeset 20 b9e04db066d4
parent 17 69946d1824c4
child 22 9b6761e5bd30
child 24 7d93ee07fb27
equal deleted inserted replaced
17:69946d1824c4 20:b9e04db066d4
     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 #include "hbpushbutton.h"
       
    23 
       
    24 #include "mpxvideo_debug.h"
       
    25 #include "mpxvideoplaybackdocumentloader.h"
       
    26 
       
    27 
       
    28 // -------------------------------------------------------------------------------------------------
       
    29 // QMPXVideoPlaybackDocumentLoader::QMPXVideoPlaybackDocumentLoader
       
    30 // -------------------------------------------------------------------------------------------------
       
    31 //
       
    32 QMPXVideoPlaybackDocumentLoader::QMPXVideoPlaybackDocumentLoader()
       
    33 {
       
    34     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackDocumentLoader::QMPXVideoPlaybackDocumentLoader()"));
       
    35 }
       
    36 
       
    37 // -------------------------------------------------------------------------------------------------
       
    38 // QMPXVideoPlaybackDocumentLoader::~QMPXVideoPlaybackDocumentLoader
       
    39 // -------------------------------------------------------------------------------------------------
       
    40 //
       
    41 QMPXVideoPlaybackDocumentLoader::~QMPXVideoPlaybackDocumentLoader()
       
    42 {
       
    43     MPX_DEBUG(_L("QMPXVideoPlaybackDocumentLoader::QMPXVideoPlaybackDocumentLoader") );
       
    44 
       
    45     for ( int i = 0 ; i < mWidgets.count() ; i++ )
       
    46     {
       
    47         mWidgets.removeAt( 0 );
       
    48     }
       
    49 }
       
    50 
       
    51 // -------------------------------------------------------------------------------------------------
       
    52 // QMPXVideoPlaybackDocumentLoader::findWidget()
       
    53 // -------------------------------------------------------------------------------------------------
       
    54 //
       
    55 QGraphicsWidget *QMPXVideoPlaybackDocumentLoader::findWidget( const QString &name )
       
    56 {
       
    57     MPX_DEBUG(_L("QMPXVideoPlaybackDocumentLoader::findWidget( %s )"), name.data() );
       
    58 
       
    59     QGraphicsWidget *object = NULL;
       
    60 
       
    61     int index = exist( name );
       
    62 
       
    63     if ( index == -1 )
       
    64     {
       
    65         object = createWidget( name );
       
    66     }
       
    67     else
       
    68     {
       
    69         object = mWidgets[ index ];
       
    70     }
       
    71 
       
    72     return object;
       
    73 }
       
    74 
       
    75 // -------------------------------------------------------------------------------------------------
       
    76 // QMPXVideoPlaybackDocumentLoader::createWidget()
       
    77 // -------------------------------------------------------------------------------------------------
       
    78 //
       
    79 QGraphicsWidget *QMPXVideoPlaybackDocumentLoader::createWidget( const QString &name )
       
    80 {
       
    81     MPX_DEBUG(_L("QMPXVideoPlaybackDocumentLoader::createWidget( %s )"), name.data() );
       
    82 
       
    83     QGraphicsWidget *object = NULL;
       
    84         
       
    85     if ( name == "rwButton" ||  name == "pauseButton" || name == "playButton" || 
       
    86         name == "ffButton" || name == "naturalButton" || name == "stretchButton" ||
       
    87         name == "zoomButton" || name == "detailsButton" || "attachButton" || "aspectRatioButtons" )
       
    88     {
       
    89         object = new HbPushButton();
       
    90         object->setObjectName( name );
       
    91         mWidgets.append( object );
       
    92     }
       
    93 
       
    94     return object;
       
    95 }
       
    96 
       
    97 // -------------------------------------------------------------------------------------------------
       
    98 // QMPXVideoPlaybackDocumentLoader::exist()
       
    99 // -------------------------------------------------------------------------------------------------
       
   100 //
       
   101 int QMPXVideoPlaybackDocumentLoader::exist( const QString &name )
       
   102 {
       
   103     int i = 0;
       
   104 
       
   105     for ( ; i < mWidgets.count() ; i++ )
       
   106     {
       
   107         if( mWidgets[i]->objectName() == name )
       
   108         {
       
   109             break;
       
   110         }
       
   111     }
       
   112 
       
   113     if ( i == mWidgets.count() )
       
   114     {
       
   115         i = -1;
       
   116     }
       
   117 
       
   118     MPX_DEBUG(_L("QMPXVideoPlaybackDocumentLoader::exist( %s ) ret %d"), name.data(), i );
       
   119 
       
   120     return i;
       
   121 }
       
   122 
       
   123 // End of file