videoplayback/hbvideoplaybackview/tsrc/teststatuspanecontrol/stub/src/mpxvideoplaybackdocumentloader.cpp
changeset 52 e3cecb93e76a
parent 47 45e72b57a2fd
child 59 a76e86df7ccd
equal deleted inserted replaced
47:45e72b57a2fd 52:e3cecb93e76a
     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 #include <QGraphicsWidget>
       
    22 
       
    23 #include "hblabel.h"
       
    24 #include "hbgroupbox.h"
       
    25 
       
    26 #include "mpxvideo_debug.h"
       
    27 #include "mpxvideoplaybackdocumentloader.h"
       
    28 
       
    29 
       
    30 // -------------------------------------------------------------------------------------------------
       
    31 // QMPXVideoPlaybackDocumentLoader::QMPXVideoPlaybackDocumentLoader
       
    32 // -------------------------------------------------------------------------------------------------
       
    33 //
       
    34 QMPXVideoPlaybackDocumentLoader::QMPXVideoPlaybackDocumentLoader()
       
    35 {
       
    36     MPX_ENTER_EXIT(_L("QMPXVideoPlaybackDocumentLoader::QMPXVideoPlaybackDocumentLoader()"));    
       
    37 }
       
    38 
       
    39 // -------------------------------------------------------------------------------------------------
       
    40 // QMPXVideoPlaybackDocumentLoader::~QMPXVideoPlaybackDocumentLoader
       
    41 // -------------------------------------------------------------------------------------------------
       
    42 //
       
    43 QMPXVideoPlaybackDocumentLoader::~QMPXVideoPlaybackDocumentLoader()
       
    44 {
       
    45     MPX_DEBUG(_L("QMPXVideoPlaybackDocumentLoader::QMPXVideoPlaybackDocumentLoader") );
       
    46 
       
    47     for ( int i = 0 ; i < mWidgets.count() ; i++ )
       
    48     {
       
    49         mWidgets.removeAt( 0 );
       
    50     }
       
    51 }
       
    52 
       
    53 // -------------------------------------------------------------------------------------------------
       
    54 // QMPXVideoPlaybackDocumentLoader::findWidget()
       
    55 // -------------------------------------------------------------------------------------------------
       
    56 //
       
    57 QGraphicsWidget *QMPXVideoPlaybackDocumentLoader::findWidget( const QString &name )
       
    58 {
       
    59     MPX_DEBUG(_L("QMPXVideoPlaybackDocumentLoader::findWidget") );
       
    60 
       
    61     QGraphicsWidget *object = NULL;
       
    62 
       
    63     int index = exist( name );
       
    64 
       
    65     if ( index == -1 )
       
    66     {
       
    67         object = createWidget( name );
       
    68     }
       
    69     else
       
    70     {
       
    71         object = mWidgets[ index ];
       
    72     }
       
    73 
       
    74     return object;
       
    75 }
       
    76 
       
    77 // -------------------------------------------------------------------------------------------------
       
    78 // QMPXVideoPlaybackDocumentLoader::createWidget()
       
    79 // -------------------------------------------------------------------------------------------------
       
    80 //
       
    81 QGraphicsWidget *QMPXVideoPlaybackDocumentLoader::createWidget( const QString &name )
       
    82 {
       
    83     MPX_DEBUG(_L("QMPXVideoPlaybackDocumentLoader::createWidget") );
       
    84 
       
    85     QGraphicsWidget *object = NULL;
       
    86         
       
    87     if ( name == "titleLayout" )
       
    88     {        
       
    89         object = new QGraphicsWidget();
       
    90 		object->setObjectName( name );
       
    91         
       
    92         mWidgets.append( object );                
       
    93     }
       
    94     else if ( name == "title" )
       
    95     {        
       
    96         object = new HbLabel();
       
    97 		object->setObjectName( name );
       
    98         mWidgets.append( object );
       
    99     }
       
   100     else if ( name == "titleGroupBox" )
       
   101     {
       
   102         object = new HbGroupBox();
       
   103         object->setObjectName( name );
       
   104         mWidgets.append( object );
       
   105     }
       
   106 
       
   107     return object;
       
   108 }
       
   109 
       
   110 // -------------------------------------------------------------------------------------------------
       
   111 // QMPXVideoPlaybackDocumentLoader::exist()
       
   112 // -------------------------------------------------------------------------------------------------
       
   113 //
       
   114 int QMPXVideoPlaybackDocumentLoader::exist( const QString &name )
       
   115 {
       
   116     int i = 0;
       
   117 
       
   118     for ( ; i < mWidgets.count() ; i++ )
       
   119     {
       
   120         if( mWidgets[i]->objectName() == name )
       
   121         {
       
   122             break;
       
   123         }
       
   124     }
       
   125 
       
   126     if ( i == mWidgets.count() )
       
   127     {
       
   128         i = -1;
       
   129     }
       
   130 
       
   131     MPX_DEBUG(_L("QMPXVideoPlaybackDocumentLoader::exist %d"), i );
       
   132 
       
   133     return i;
       
   134 }
       
   135 
       
   136 // End of file