videoplayback/hbvideoplaybackview/tsrc/testdetailsplaybackwindow/stub/src/mpxvideoplaybackdocumentloader.cpp
changeset 36 8aed59de29f9
child 20 b9e04db066d4
equal deleted inserted replaced
35:3738fe97f027 36:8aed59de29f9
       
     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 == "detailsViewPlayButton" || name == "detailsAttachButton" ||
       
    86          name == "detailsShareButton" )
       
    87     {
       
    88         object = new HbPushButton();
       
    89         object->setObjectName( name );
       
    90         mWidgets.append( object );
       
    91     }
       
    92 
       
    93     return object;
       
    94 }
       
    95 
       
    96 // -------------------------------------------------------------------------------------------------
       
    97 // QMPXVideoPlaybackDocumentLoader::exist()
       
    98 // -------------------------------------------------------------------------------------------------
       
    99 //
       
   100 int QMPXVideoPlaybackDocumentLoader::exist( const QString &name )
       
   101 {
       
   102     int i = 0;
       
   103 
       
   104     for ( ; i < mWidgets.count() ; i++ )
       
   105     {
       
   106         if( mWidgets[i]->objectName() == name )
       
   107         {
       
   108             break;
       
   109         }
       
   110     }
       
   111 
       
   112     if ( i == mWidgets.count() )
       
   113     {
       
   114         i = -1;
       
   115     }
       
   116 
       
   117     MPX_DEBUG(_L("QMPXVideoPlaybackDocumentLoader::exist( %s ) ret %d"), name.data(), i );
       
   118 
       
   119     return i;
       
   120 }
       
   121 
       
   122 // End of file