videocollection/videocollectionwrapper/src/videocollectionutils.cpp
branchRCL_3
changeset 56 839377eedc2b
equal deleted inserted replaced
54:315810614048 56:839377eedc2b
       
     1 /*
       
     2 * Copyright (c) 2009 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: VideoCollectionUtils class implementation
       
    15 * 
       
    16 */
       
    17 
       
    18 // Version : %version: 15 %
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <qobject.h>
       
    22 #include <QTime>
       
    23 #include <hbglobal.h>
       
    24 #include <hbextendedlocale.h>
       
    25 
       
    26 #include "videocollectionutils.h"
       
    27 #include "videocollectiontrace.h"
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // instance
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 VideoCollectionUtils& VideoCollectionUtils::instance()
       
    34 {
       
    35     static VideoCollectionUtils _collectionUtilsInstance;
       
    36     return _collectionUtilsInstance;
       
    37 }
       
    38 	
       
    39 // -----------------------------------------------------------------------------
       
    40 // VideoCollectionUtils
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 VideoCollectionUtils::VideoCollectionUtils()
       
    44 {
       
    45 	FUNC_LOG;
       
    46 }
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // ~CVideoCollectionUtils
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 VideoCollectionUtils::~VideoCollectionUtils()
       
    53 {
       
    54 	FUNC_LOG;
       
    55 }
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // prepareLengthString
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 QString VideoCollectionUtils::prepareLengthString(quint32 length)
       
    62 {
       
    63 	FUNC_LOG;
       
    64     const int secondsInMinute( 60 );
       
    65     const int secondsInHour( 3600 );
       
    66     
       
    67 	quint32 hours = length / secondsInHour;
       
    68 	quint32 minutes = length / secondsInMinute % secondsInMinute;
       
    69 	quint32 seconds = length % secondsInMinute;
       
    70 	
       
    71     QString hrs(QString::number(hours));
       
    72     if(hours < 10)
       
    73     {
       
    74     	hrs.prepend(QString::number(0));
       
    75     }
       
    76     QString mins(QString::number(minutes));
       
    77     if(minutes < 10)
       
    78     {
       
    79     	mins.prepend(QString::number(0));
       
    80     }
       
    81     QString secs(QString::number(seconds));
       
    82     if(seconds < 10)
       
    83     {
       
    84     	secs.prepend(QString::number(0));
       
    85     }
       
    86     
       
    87     QString lengthStr(hbTrId( "txt_videos_list_l1l2l3" ).arg( hrs ).arg( mins ).arg( secs ));
       
    88     
       
    89     return lengthStr.trimmed();
       
    90 }
       
    91 
       
    92 // -----------------------------------------------------------------------------
       
    93 // prepareSizeString
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 QString VideoCollectionUtils::prepareSizeString(quint32 size)
       
    97 {
       
    98 	FUNC_LOG;
       
    99     const int videoSizeGB( 0x40000000 );
       
   100     const int videoSizeHalfGB( 0x20000000 );
       
   101     const int videoSizeMB( 0x100000 );
       
   102     const int videoSizeHalfMB( 0x80000 );
       
   103     const int videoSizeKB( 0x400 );
       
   104 
       
   105     QString sizeStr("");
       
   106     
       
   107     if ( size > 0 )
       
   108     {
       
   109         quint32 dispSize = 0;
       
   110      
       
   111         HbExtendedLocale locale = HbExtendedLocale::system();
       
   112         
       
   113         if ( size >= videoSizeGB )
       
   114         {
       
   115             dispSize  = size + videoSizeHalfGB;
       
   116             dispSize /= videoSizeGB;
       
   117             sizeStr = QString(hbTrId("txt_videos_list_l1_gb").arg(locale.toString(dispSize)));
       
   118         }
       
   119         else if ( size >= videoSizeMB )
       
   120         {
       
   121             dispSize  = size + videoSizeHalfMB;
       
   122             dispSize /= videoSizeMB;
       
   123             sizeStr = QString(hbTrId("txt_videos_list_l1_mb").arg(locale.toString(dispSize)));
       
   124         }
       
   125         else
       
   126         {
       
   127             dispSize  = size + videoSizeKB;
       
   128             dispSize /= videoSizeKB;
       
   129             sizeStr = QString(hbTrId("txt_videos_list_l1_kb").arg(locale.toString(dispSize)));
       
   130         }
       
   131     }
       
   132 
       
   133     return sizeStr;
       
   134 }
       
   135 
       
   136 // End of file