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