videoplayback/hbvideoplaybackview/controlsrc/mpxvideoplaybackfiledetailswidget.cpp
author hgs
Fri, 30 Apr 2010 09:52:11 +0300
changeset 37 4eb2df7f7cbe
parent 36 8aed59de29f9
child 38 ff53afa8ad05
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:  Implementation of QMPXVideoPlaybackFileDetailsWidget
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 %
30
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
34
hgs
parents: 30
diff changeset
    21
#include <QDir>
hgs
parents: 30
diff changeset
    22
#include <QDateTime>
hgs
parents: 30
diff changeset
    23
#include <QFileInfo>
30
hgs
parents:
diff changeset
    24
34
hgs
parents: 30
diff changeset
    25
#include <hbglobal.h>
30
hgs
parents:
diff changeset
    26
#include <hblistwidgetitem.h>
hgs
parents:
diff changeset
    27
#include <hbratingslider.h>
hgs
parents:
diff changeset
    28
#include <hblistwidget.h>
34
hgs
parents: 30
diff changeset
    29
#include <hblistviewitem.h>
36
hgs
parents: 34
diff changeset
    30
#include <hbextendedlocale.h>
30
hgs
parents:
diff changeset
    31
hgs
parents:
diff changeset
    32
#include "mpxvideo_debug.h"
hgs
parents:
diff changeset
    33
#include "mpxvideoplaybackdocumentloader.h"
hgs
parents:
diff changeset
    34
#include "mpxvideoplaybackfiledetailswidget.h"
hgs
parents:
diff changeset
    35
#include "mpxvideoplaybackdocumentloader.h"
hgs
parents:
diff changeset
    36
#include "mpxvideoplaybackcontrolscontroller.h"
hgs
parents:
diff changeset
    37
hgs
parents:
diff changeset
    38
const float KILOBYTE = 1024 ;
hgs
parents:
diff changeset
    39
hgs
parents:
diff changeset
    40
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    41
// QMPXVideoPlaybackFileDetailsWidget::QMPXVideoPlaybackFileDetailsWidget
hgs
parents:
diff changeset
    42
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    43
//
hgs
parents:
diff changeset
    44
QMPXVideoPlaybackFileDetailsWidget::QMPXVideoPlaybackFileDetailsWidget( 
hgs
parents:
diff changeset
    45
        QMPXVideoPlaybackControlsController* controller )
hgs
parents:
diff changeset
    46
    : mController( controller )
hgs
parents:
diff changeset
    47
    , mListWidget( 0 )
hgs
parents:
diff changeset
    48
    , mFileDetailsUpdated( false )
hgs
parents:
diff changeset
    49
{
hgs
parents:
diff changeset
    50
    MPX_ENTER_EXIT(_L("QMPXVideoPlaybackFileDetailsWidget::QMPXVideoPlaybackFileDetailsWidget()"));
hgs
parents:
diff changeset
    51
}
hgs
parents:
diff changeset
    52
hgs
parents:
diff changeset
    53
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    54
// QMPXVideoPlaybackFileDetailsWidget::~QMPXVideoPlaybackFileDetailsWidget
hgs
parents:
diff changeset
    55
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    56
//
hgs
parents:
diff changeset
    57
QMPXVideoPlaybackFileDetailsWidget::~QMPXVideoPlaybackFileDetailsWidget()
hgs
parents:
diff changeset
    58
{
hgs
parents:
diff changeset
    59
    MPX_ENTER_EXIT(_L("QMPXVideoPlaybackFileDetailsWidget::~QMPXVideoPlaybackFileDetailsWidget()"));
hgs
parents:
diff changeset
    60
hgs
parents:
diff changeset
    61
    if ( mListWidget ) 
hgs
parents:
diff changeset
    62
    {
hgs
parents:
diff changeset
    63
        delete mListWidget;
hgs
parents:
diff changeset
    64
    }
hgs
parents:
diff changeset
    65
}
hgs
parents:
diff changeset
    66
hgs
parents:
diff changeset
    67
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    68
// QMPXVideoPlaybackFileDetailsWidget::initialize
hgs
parents:
diff changeset
    69
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    70
//
hgs
parents:
diff changeset
    71
void QMPXVideoPlaybackFileDetailsWidget::initialize()
hgs
parents:
diff changeset
    72
{
hgs
parents:
diff changeset
    73
    MPX_ENTER_EXIT(_L("QMPXVideoPlaybackFileDetailsWidget::initialize"));
hgs
parents:
diff changeset
    74
hgs
parents:
diff changeset
    75
    updateWithFileDetails( mController->fileDetails() );
hgs
parents:
diff changeset
    76
}
hgs
parents:
diff changeset
    77
hgs
parents:
diff changeset
    78
// -------------------------------------------------------------------------------------------------
34
hgs
parents: 30
diff changeset
    79
// QMPXVideoPlaybackFileDetailsWidget::updateWithFileDetails
30
hgs
parents:
diff changeset
    80
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    81
//
hgs
parents:
diff changeset
    82
void QMPXVideoPlaybackFileDetailsWidget::updateWithFileDetails(
hgs
parents:
diff changeset
    83
        QMPXVideoPlaybackViewFileDetails* details )
hgs
parents:
diff changeset
    84
{
hgs
parents:
diff changeset
    85
    QMPXVideoPlaybackDocumentLoader *loader = mController->layoutLoader();
hgs
parents:
diff changeset
    86
hgs
parents:
diff changeset
    87
    if ( loader )
hgs
parents:
diff changeset
    88
    {
hgs
parents:
diff changeset
    89
        //
hgs
parents:
diff changeset
    90
        // load fileDetails widget
hgs
parents:
diff changeset
    91
        //
hgs
parents:
diff changeset
    92
        QGraphicsWidget *widget = loader->findWidget( QString( "fileDetails" ) );
hgs
parents:
diff changeset
    93
        
hgs
parents:
diff changeset
    94
        //
hgs
parents:
diff changeset
    95
        // cast fileDetails widget to HbListWidget
hgs
parents:
diff changeset
    96
        //
hgs
parents:
diff changeset
    97
        mListWidget = qobject_cast<HbListWidget*>( widget );
hgs
parents:
diff changeset
    98
34
hgs
parents: 30
diff changeset
    99
        //
hgs
parents: 30
diff changeset
   100
        // set the min/max number of lines in the second row
hgs
parents: 30
diff changeset
   101
        //
hgs
parents: 30
diff changeset
   102
        HbListViewItem *prototype = mListWidget->listItemPrototype();
36
hgs
parents: 34
diff changeset
   103
        prototype->setSecondaryTextRowCount( 1, 30 );
34
hgs
parents: 30
diff changeset
   104
        
30
hgs
parents:
diff changeset
   105
        if ( ! mFileDetailsUpdated )
36
hgs
parents: 34
diff changeset
   106
        {
hgs
parents: 34
diff changeset
   107
            HbExtendedLocale locale = HbExtendedLocale::system();
hgs
parents: 34
diff changeset
   108
30
hgs
parents:
diff changeset
   109
            mFileDetailsUpdated = true;
hgs
parents:
diff changeset
   110
            
hgs
parents:
diff changeset
   111
            //
hgs
parents:
diff changeset
   112
            // Title
hgs
parents:
diff changeset
   113
            //            
hgs
parents:
diff changeset
   114
            makeTitleItem( details );
hgs
parents:
diff changeset
   115
            
hgs
parents:
diff changeset
   116
            //
hgs
parents:
diff changeset
   117
            // Description
hgs
parents:
diff changeset
   118
            //
34
hgs
parents: 30
diff changeset
   119
            addItemToListWidget( 
hgs
parents: 30
diff changeset
   120
                    hbTrId( "txt_videos_list_description" ), details->mDescription ); 
hgs
parents: 30
diff changeset
   121
30
hgs
parents:
diff changeset
   122
            
hgs
parents:
diff changeset
   123
            //
hgs
parents:
diff changeset
   124
            // Duration
hgs
parents:
diff changeset
   125
            //
hgs
parents:
diff changeset
   126
            if ( details->mPlaybackMode != EMPXVideoLiveStreaming && details->mDuration > 0 )
hgs
parents:
diff changeset
   127
            {
36
hgs
parents: 34
diff changeset
   128
                int value = (qreal)details->mDuration / (qreal)KPbMilliMultiplier;
hgs
parents: 34
diff changeset
   129
                QString hour = locale.toString( value / 3600 );
hgs
parents: 34
diff changeset
   130
                value = value % 3600;
hgs
parents: 34
diff changeset
   131
                QString min = locale.toString( value / 60 );
hgs
parents: 34
diff changeset
   132
                value = value % 60;
hgs
parents: 34
diff changeset
   133
                QString sec = locale.toString( value );
hgs
parents: 34
diff changeset
   134
hgs
parents: 34
diff changeset
   135
                addItemToListWidget( 
hgs
parents: 34
diff changeset
   136
                        hbTrId( "txt_videos_list_duration" ),
hgs
parents: 34
diff changeset
   137
                        hbTrId( "txt_videos_list_l1_l2_l3" ).arg( hour ).arg( min ).arg( sec ) );                                                                        
30
hgs
parents:
diff changeset
   138
            }    
hgs
parents:
diff changeset
   139
            
hgs
parents:
diff changeset
   140
            //
36
hgs
parents: 34
diff changeset
   141
            // Date/Time
30
hgs
parents:
diff changeset
   142
            //
36
hgs
parents: 34
diff changeset
   143
            makeDateTimeItem( details );
30
hgs
parents:
diff changeset
   144
hgs
parents:
diff changeset
   145
            //
hgs
parents:
diff changeset
   146
            // Location
hgs
parents:
diff changeset
   147
            //
34
hgs
parents: 30
diff changeset
   148
            addItemToListWidget( hbTrId( "txt_videos_list_location" ), details->mLocation );                                                
30
hgs
parents:
diff changeset
   149
            
hgs
parents:
diff changeset
   150
            //
hgs
parents:
diff changeset
   151
            // Author
hgs
parents:
diff changeset
   152
            //
34
hgs
parents: 30
diff changeset
   153
            addItemToListWidget( hbTrId( "txt_videos_list_author" ), details->mArtist );                                            
30
hgs
parents:
diff changeset
   154
            
hgs
parents:
diff changeset
   155
            //
hgs
parents:
diff changeset
   156
            // Copyright
hgs
parents:
diff changeset
   157
            //
34
hgs
parents: 30
diff changeset
   158
            addItemToListWidget( hbTrId( "txt_videos_list_copyright" ), details->mCopyright );                                        
30
hgs
parents:
diff changeset
   159
            
hgs
parents:
diff changeset
   160
            //
hgs
parents:
diff changeset
   161
            // Language
hgs
parents:
diff changeset
   162
            //
34
hgs
parents: 30
diff changeset
   163
            addItemToListWidget( hbTrId( "txt_videos_list_language" ), details->mLanguage );                                    
30
hgs
parents:
diff changeset
   164
            
hgs
parents:
diff changeset
   165
            //
hgs
parents:
diff changeset
   166
            // Keywords
hgs
parents:
diff changeset
   167
            //
34
hgs
parents: 30
diff changeset
   168
            addItemToListWidget( hbTrId( "txt_videos_list_keywords" ), details->mKeywords );                                
30
hgs
parents:
diff changeset
   169
            
hgs
parents:
diff changeset
   170
            //
hgs
parents:
diff changeset
   171
            // Size
hgs
parents:
diff changeset
   172
            //
hgs
parents:
diff changeset
   173
            makeSizeItem( details );
hgs
parents:
diff changeset
   174
hgs
parents:
diff changeset
   175
            //
hgs
parents:
diff changeset
   176
            // Resolution
hgs
parents:
diff changeset
   177
            //
hgs
parents:
diff changeset
   178
            if ( details->mVideoEnabled )
hgs
parents:
diff changeset
   179
            {
36
hgs
parents: 34
diff changeset
   180
                QString resolution = hbTrId( "txt_videos_list_l1l2" )
hgs
parents: 34
diff changeset
   181
                       .arg( locale.toString( details->mVideoWidth ) )
hgs
parents: 34
diff changeset
   182
                       .arg( locale.toString( details->mVideoHeight ) );            
34
hgs
parents: 30
diff changeset
   183
                addItemToListWidget( hbTrId( "txt_videos_list_resolution" ), resolution );                    
30
hgs
parents:
diff changeset
   184
            }
hgs
parents:
diff changeset
   185
            
hgs
parents:
diff changeset
   186
            //
hgs
parents:
diff changeset
   187
            // Format
hgs
parents:
diff changeset
   188
            //
34
hgs
parents: 30
diff changeset
   189
            addItemToListWidget( hbTrId( "txt_videos_list_format" ), details->mMimeType );                    
30
hgs
parents:
diff changeset
   190
            
hgs
parents:
diff changeset
   191
            //
hgs
parents:
diff changeset
   192
            // Bitrate
hgs
parents:
diff changeset
   193
            //
hgs
parents:
diff changeset
   194
            makeBitRateItem( details );
hgs
parents:
diff changeset
   195
            
hgs
parents:
diff changeset
   196
            //
hgs
parents:
diff changeset
   197
            // Folder
hgs
parents:
diff changeset
   198
            //
hgs
parents:
diff changeset
   199
            if ( details->mPlaybackMode == EMPXVideoLocal ||
hgs
parents:
diff changeset
   200
                 details->mPlaybackMode == EMPXVideoProgressiveDownload)
hgs
parents:
diff changeset
   201
            {
36
hgs
parents: 34
diff changeset
   202
                QFileInfo fileInfo( details->mClipName );     
34
hgs
parents: 30
diff changeset
   203
                QString folder = fileInfo.dir().dirName();
hgs
parents: 30
diff changeset
   204
                addItemToListWidget( hbTrId( "txt_videos_list_collection_name" ), folder );
30
hgs
parents:
diff changeset
   205
            }
hgs
parents:
diff changeset
   206
            
hgs
parents:
diff changeset
   207
        }
hgs
parents:
diff changeset
   208
hgs
parents:
diff changeset
   209
        //
hgs
parents:
diff changeset
   210
        // Set the rect size dynamically based on the view mode
hgs
parents:
diff changeset
   211
        //
hgs
parents:
diff changeset
   212
        QString sectionName;
hgs
parents:
diff changeset
   213
hgs
parents:
diff changeset
   214
        if ( mController->viewMode() == EDetailsView )
hgs
parents:
diff changeset
   215
        {
hgs
parents:
diff changeset
   216
            sectionName = "detailsView";
hgs
parents:
diff changeset
   217
        }
hgs
parents:
diff changeset
   218
        else if ( mController->viewMode() == EAudioOnlyView )
hgs
parents:
diff changeset
   219
        {
37
hgs
parents: 36
diff changeset
   220
            sectionName = "audioOnlyView";
30
hgs
parents:
diff changeset
   221
        }
hgs
parents:
diff changeset
   222
hgs
parents:
diff changeset
   223
        bool ok = false;
hgs
parents:
diff changeset
   224
        loader->load( KMPXPLAYBACKVIEW_XML, sectionName, &ok );
34
hgs
parents: 30
diff changeset
   225
hgs
parents: 30
diff changeset
   226
        if ( ! ok )
hgs
parents: 30
diff changeset
   227
        {
hgs
parents: 30
diff changeset
   228
            MPX_DEBUG(_L("QMPXVideoPlaybackFileDetailsWidget failed to load section"));
hgs
parents: 30
diff changeset
   229
        }
30
hgs
parents:
diff changeset
   230
    }
hgs
parents:
diff changeset
   231
}
hgs
parents:
diff changeset
   232
hgs
parents:
diff changeset
   233
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   234
// QMPXVideoPlaybackFileDetailsWidget::makeTitleItem
hgs
parents:
diff changeset
   235
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   236
//
hgs
parents:
diff changeset
   237
void QMPXVideoPlaybackFileDetailsWidget::makeTitleItem( QMPXVideoPlaybackViewFileDetails* details )
hgs
parents:
diff changeset
   238
{    
hgs
parents:
diff changeset
   239
    MPX_DEBUG(_L("QMPXVideoPlaybackFileDetailsWidget::makeTitleItem()"));
hgs
parents:
diff changeset
   240
hgs
parents:
diff changeset
   241
    //
hgs
parents:
diff changeset
   242
    // Title should be the first item in file details list
hgs
parents:
diff changeset
   243
    //
hgs
parents:
diff changeset
   244
    if ( mController->viewMode() == EAudioOnlyView )
hgs
parents:
diff changeset
   245
    {    
hgs
parents:
diff changeset
   246
        //
hgs
parents:
diff changeset
   247
        // show the title for audio-only view 
hgs
parents:
diff changeset
   248
        //
hgs
parents:
diff changeset
   249
        if ( mListWidget->count() == 0 || ! mListWidget->item( 0 )->text().contains( "Title", Qt::CaseInsensitive ) )
hgs
parents:
diff changeset
   250
        {
hgs
parents:
diff changeset
   251
            QString title = details->mTitle;
hgs
parents:
diff changeset
   252
hgs
parents:
diff changeset
   253
            if ( title.count() == 0 )
hgs
parents:
diff changeset
   254
            {
hgs
parents:
diff changeset
   255
                //
hgs
parents:
diff changeset
   256
                // If title is not available, show clip name
hgs
parents:
diff changeset
   257
                //            
hgs
parents:
diff changeset
   258
                QFileInfo fileInfo( details->mClipName );
hgs
parents:
diff changeset
   259
                title = fileInfo.baseName ();
hgs
parents:
diff changeset
   260
            }
hgs
parents:
diff changeset
   261
hgs
parents:
diff changeset
   262
            //
hgs
parents:
diff changeset
   263
            // populate Title and its associated text
hgs
parents:
diff changeset
   264
            //
hgs
parents:
diff changeset
   265
            HbListWidgetItem* listWidgetItem = new HbListWidgetItem();
36
hgs
parents: 34
diff changeset
   266
            listWidgetItem->setText( hbTrId( "txt_videos_list_title" ) );
30
hgs
parents:
diff changeset
   267
            listWidgetItem->setSecondaryText( title );
hgs
parents:
diff changeset
   268
            mListWidget->insertItem( 0, listWidgetItem );
hgs
parents:
diff changeset
   269
        }
hgs
parents:
diff changeset
   270
    }
hgs
parents:
diff changeset
   271
    else if ( mListWidget->count() &&
hgs
parents:
diff changeset
   272
              mListWidget->item( 0 )->text().contains( "Title", Qt::CaseInsensitive ) )
hgs
parents:
diff changeset
   273
    {
hgs
parents:
diff changeset
   274
        // 
hgs
parents:
diff changeset
   275
        // title is displayed under the status pane for video clips,
hgs
parents:
diff changeset
   276
        // so hide the title for this details view
hgs
parents:
diff changeset
   277
        //
hgs
parents:
diff changeset
   278
        delete mListWidget->takeItem ( 0 );
hgs
parents:
diff changeset
   279
    }
hgs
parents:
diff changeset
   280
}
hgs
parents:
diff changeset
   281
hgs
parents:
diff changeset
   282
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   283
// QMPXVideoPlaybackFileDetailsWidget::makeSizeItem
hgs
parents:
diff changeset
   284
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   285
//
hgs
parents:
diff changeset
   286
void QMPXVideoPlaybackFileDetailsWidget::makeSizeItem( QMPXVideoPlaybackViewFileDetails* details )
hgs
parents:
diff changeset
   287
{        
hgs
parents:
diff changeset
   288
    if ( details->mPlaybackMode == EMPXVideoLocal ||
hgs
parents:
diff changeset
   289
         details->mPlaybackMode == EMPXVideoProgressiveDownload )
hgs
parents:
diff changeset
   290
    {
hgs
parents:
diff changeset
   291
        QFileInfo fileInfo( details->mClipName );     
34
hgs
parents: 30
diff changeset
   292
        
hgs
parents: 30
diff changeset
   293
        //
hgs
parents: 30
diff changeset
   294
        // to prevent overflow, get an unsigned value of file size
hgs
parents: 30
diff changeset
   295
        //
hgs
parents: 30
diff changeset
   296
        ulong fileSize = fileInfo.size();
hgs
parents: 30
diff changeset
   297
                
hgs
parents: 30
diff changeset
   298
        //
hgs
parents: 30
diff changeset
   299
        // convert file size to KB, MB, GB accordingly
hgs
parents: 30
diff changeset
   300
        //
hgs
parents: 30
diff changeset
   301
        if ( fileSize > 0 )
36
hgs
parents: 34
diff changeset
   302
        {
hgs
parents: 34
diff changeset
   303
            HbExtendedLocale locale = HbExtendedLocale::system();
hgs
parents: 34
diff changeset
   304
hgs
parents: 34
diff changeset
   305
            QString scale;
hgs
parents: 34
diff changeset
   306
34
hgs
parents: 30
diff changeset
   307
            //
hgs
parents: 30
diff changeset
   308
            // cast for later conversion with floating point
hgs
parents: 30
diff changeset
   309
            //
hgs
parents: 30
diff changeset
   310
            float size = (float) fileSize;
36
hgs
parents: 34
diff changeset
   311
30
hgs
parents:
diff changeset
   312
            if ( size > KILOBYTE )
hgs
parents:
diff changeset
   313
            {
hgs
parents:
diff changeset
   314
                size /= KILOBYTE;
36
hgs
parents: 34
diff changeset
   315
                scale = hbTrId( "txt_videos_list_l1_kb" );
30
hgs
parents:
diff changeset
   316
            }
36
hgs
parents: 34
diff changeset
   317
30
hgs
parents:
diff changeset
   318
            if ( size > KILOBYTE )
hgs
parents:
diff changeset
   319
            {
hgs
parents:
diff changeset
   320
                size /= KILOBYTE;
36
hgs
parents: 34
diff changeset
   321
                scale = hbTrId( "txt_videos_list_l1_mb" );
30
hgs
parents:
diff changeset
   322
            }
36
hgs
parents: 34
diff changeset
   323
30
hgs
parents:
diff changeset
   324
            if ( size > KILOBYTE )
hgs
parents:
diff changeset
   325
            {
hgs
parents:
diff changeset
   326
                size /= KILOBYTE;
36
hgs
parents: 34
diff changeset
   327
                scale = hbTrId( "txt_videos_list_l1_gb" );
30
hgs
parents:
diff changeset
   328
            }
36
hgs
parents: 34
diff changeset
   329
30
hgs
parents:
diff changeset
   330
            int temp = size * 10;
hgs
parents:
diff changeset
   331
            size = (float)temp / 10;
36
hgs
parents: 34
diff changeset
   332
hgs
parents: 34
diff changeset
   333
            addItemToListWidget( 
hgs
parents: 34
diff changeset
   334
                    hbTrId( "txt_videos_list_file_size" ), scale.arg( locale.toString( size ) ) );
30
hgs
parents:
diff changeset
   335
        }    
hgs
parents:
diff changeset
   336
    }
hgs
parents:
diff changeset
   337
}
hgs
parents:
diff changeset
   338
hgs
parents:
diff changeset
   339
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   340
// QMPXVideoPlaybackFileDetailsWidget::makeBitRateItem
hgs
parents:
diff changeset
   341
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   342
//
hgs
parents:
diff changeset
   343
void QMPXVideoPlaybackFileDetailsWidget::makeBitRateItem( QMPXVideoPlaybackViewFileDetails* details  )
hgs
parents:
diff changeset
   344
{        
hgs
parents:
diff changeset
   345
    if ( details->mBitRate > 0 )
hgs
parents:
diff changeset
   346
    {
36
hgs
parents: 34
diff changeset
   347
        HbExtendedLocale locale = HbExtendedLocale::system();
hgs
parents: 34
diff changeset
   348
30
hgs
parents:
diff changeset
   349
        float bitrate = details->mBitRate;
36
hgs
parents: 34
diff changeset
   350
hgs
parents: 34
diff changeset
   351
        QString scale = hbTrId( "txt_videos_list_l1_kbps" );
hgs
parents: 34
diff changeset
   352
30
hgs
parents:
diff changeset
   353
        if ( bitrate > KILOBYTE )
hgs
parents:
diff changeset
   354
        {
hgs
parents:
diff changeset
   355
             bitrate /= KILOBYTE;
hgs
parents:
diff changeset
   356
        }
hgs
parents:
diff changeset
   357
        
hgs
parents:
diff changeset
   358
        if ( bitrate > KILOBYTE )
hgs
parents:
diff changeset
   359
        {
hgs
parents:
diff changeset
   360
             bitrate /= KILOBYTE;
36
hgs
parents: 34
diff changeset
   361
             scale = hbTrId( "txt_videos_list_l1_mbps" );
30
hgs
parents:
diff changeset
   362
        }
hgs
parents:
diff changeset
   363
    
hgs
parents:
diff changeset
   364
        int temp = bitrate * 10;
hgs
parents:
diff changeset
   365
        bitrate = (float)temp / 10;
36
hgs
parents: 34
diff changeset
   366
hgs
parents: 34
diff changeset
   367
        addItemToListWidget( 
hgs
parents: 34
diff changeset
   368
                hbTrId( "txt_videos_list_bitrate" ), scale.arg( locale.toString( bitrate ) ) );
30
hgs
parents:
diff changeset
   369
    }
hgs
parents:
diff changeset
   370
}
hgs
parents:
diff changeset
   371
hgs
parents:
diff changeset
   372
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   373
// QMPXVideoPlaybackFileDetailsWidget::addItemToListWidget
hgs
parents:
diff changeset
   374
// -------------------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   375
//
hgs
parents:
diff changeset
   376
void QMPXVideoPlaybackFileDetailsWidget::addItemToListWidget( QString item, QString text  )
hgs
parents:
diff changeset
   377
{    
36
hgs
parents: 34
diff changeset
   378
    MPX_ENTER_EXIT(_L("QMPXVideoPlaybackFileDetailsWidget::addItemToListWidget"));
hgs
parents: 34
diff changeset
   379
	
30
hgs
parents:
diff changeset
   380
    if ( text.count() > 0 )
hgs
parents:
diff changeset
   381
    {
36
hgs
parents: 34
diff changeset
   382
        MPX_DEBUG(_L("QMPXVideoPlaybackFileDetailsWidget::addItemToListWidget( %s %s )"), 
hgs
parents: 34
diff changeset
   383
		    item.data(), text.data() );
30
hgs
parents:
diff changeset
   384
		
hgs
parents:
diff changeset
   385
        HbListWidgetItem* listWidgetItem = new HbListWidgetItem();
hgs
parents:
diff changeset
   386
        listWidgetItem->setText( item );
hgs
parents:
diff changeset
   387
        listWidgetItem->setSecondaryText( text );
hgs
parents:
diff changeset
   388
        
hgs
parents:
diff changeset
   389
        mListWidget->addItem( listWidgetItem );
hgs
parents:
diff changeset
   390
    }
hgs
parents:
diff changeset
   391
}
hgs
parents:
diff changeset
   392
36
hgs
parents: 34
diff changeset
   393
// -------------------------------------------------------------------------------------------------
hgs
parents: 34
diff changeset
   394
// QMPXVideoPlaybackFileDetailsWidget::makeDateTimeItem
hgs
parents: 34
diff changeset
   395
// -------------------------------------------------------------------------------------------------
hgs
parents: 34
diff changeset
   396
//
hgs
parents: 34
diff changeset
   397
void QMPXVideoPlaybackFileDetailsWidget::makeDateTimeItem( QMPXVideoPlaybackViewFileDetails* details )
hgs
parents: 34
diff changeset
   398
{    
hgs
parents: 34
diff changeset
   399
    MPX_ENTER_EXIT(_L("QMPXVideoPlaybackFileDetailsWidget::makeDateTimeItem"));
hgs
parents: 34
diff changeset
   400
        
hgs
parents: 34
diff changeset
   401
    //
hgs
parents: 34
diff changeset
   402
    // attempt to get 'created' and 'last modified' date/time from metadata first,
hgs
parents: 34
diff changeset
   403
    // if it's not available, then get it from the file system
hgs
parents: 34
diff changeset
   404
    //
hgs
parents: 34
diff changeset
   405
    
hgs
parents: 34
diff changeset
   406
    if ( details->mPlaybackMode == EMPXVideoLocal ||
hgs
parents: 34
diff changeset
   407
         details->mPlaybackMode == EMPXVideoProgressiveDownload )
hgs
parents: 34
diff changeset
   408
    {        
hgs
parents: 34
diff changeset
   409
        QDateTime dateTime;
hgs
parents: 34
diff changeset
   410
        QFileInfo fileInfo( details->mClipName );     
hgs
parents: 34
diff changeset
   411
        HbExtendedLocale locale = HbExtendedLocale::system();
hgs
parents: 34
diff changeset
   412
        
hgs
parents: 34
diff changeset
   413
        //
hgs
parents: 34
diff changeset
   414
        // Date created
hgs
parents: 34
diff changeset
   415
        //
hgs
parents: 34
diff changeset
   416
        if ( details->mCreationTime > 0 )
hgs
parents: 34
diff changeset
   417
        {
hgs
parents: 34
diff changeset
   418
            dateTime.setTime_t( details->mCreationTime );
hgs
parents: 34
diff changeset
   419
        }
hgs
parents: 34
diff changeset
   420
        else
hgs
parents: 34
diff changeset
   421
        {
hgs
parents: 34
diff changeset
   422
            dateTime = fileInfo.created();
hgs
parents: 34
diff changeset
   423
        }
hgs
parents: 34
diff changeset
   424
        
hgs
parents: 34
diff changeset
   425
        //
hgs
parents: 34
diff changeset
   426
        // convert 'created' date/time to proper string format
hgs
parents: 34
diff changeset
   427
        // according to its current locale
hgs
parents: 34
diff changeset
   428
        //
hgs
parents: 34
diff changeset
   429
        QString date = locale.format( dateTime.date(), r_qtn_date_usual );
hgs
parents: 34
diff changeset
   430
        QString time = locale.format( dateTime.time(), r_qtn_time_long_with_zero );
hgs
parents: 34
diff changeset
   431
        addItemToListWidget( hbTrId( "txt_videos_list_date" ), date + "  " + time );      
hgs
parents: 34
diff changeset
   432
        
hgs
parents: 34
diff changeset
   433
        //
hgs
parents: 34
diff changeset
   434
        // Date modified
hgs
parents: 34
diff changeset
   435
        //
hgs
parents: 34
diff changeset
   436
        if ( details->mModificationTime > 0 )
hgs
parents: 34
diff changeset
   437
        {
hgs
parents: 34
diff changeset
   438
            dateTime.setTime_t( details->mModificationTime );
hgs
parents: 34
diff changeset
   439
        }
hgs
parents: 34
diff changeset
   440
        else
hgs
parents: 34
diff changeset
   441
        {
hgs
parents: 34
diff changeset
   442
            dateTime = fileInfo.lastModified();
hgs
parents: 34
diff changeset
   443
        }
hgs
parents: 34
diff changeset
   444
        
hgs
parents: 34
diff changeset
   445
        //
hgs
parents: 34
diff changeset
   446
        // convert 'last modified' date/time to proper string format
hgs
parents: 34
diff changeset
   447
        // according to its current locale
hgs
parents: 34
diff changeset
   448
        //
hgs
parents: 34
diff changeset
   449
        date = locale.format( dateTime.date(), r_qtn_date_usual );
hgs
parents: 34
diff changeset
   450
        time = locale.format( dateTime.time(), r_qtn_time_long_with_zero );
hgs
parents: 34
diff changeset
   451
        addItemToListWidget( hbTrId( "txt_videos_list_modified" ), date + "  " + time );           
hgs
parents: 34
diff changeset
   452
    }    
hgs
parents: 34
diff changeset
   453
}
hgs
parents: 34
diff changeset
   454
30
hgs
parents:
diff changeset
   455
//End of file