34
|
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 |
|
37
|
18 |
// Version : %version: 15 %
|
34
|
19 |
|
36
|
20 |
// INCLUDE FILES
|
34
|
21 |
#include <qobject.h>
|
36
|
22 |
#include <QTime>
|
|
23 |
#include <hbglobal.h>
|
|
24 |
#include <hbextendedlocale.h>
|
|
25 |
|
34
|
26 |
#include "videocollectionutils.h"
|
36
|
27 |
#include "videocollectiontrace.h"
|
34
|
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 |
{
|
36
|
45 |
FUNC_LOG;
|
34
|
46 |
}
|
|
47 |
|
|
48 |
// -----------------------------------------------------------------------------
|
|
49 |
// ~CVideoCollectionUtils
|
|
50 |
// -----------------------------------------------------------------------------
|
|
51 |
//
|
|
52 |
VideoCollectionUtils::~VideoCollectionUtils()
|
|
53 |
{
|
36
|
54 |
FUNC_LOG;
|
34
|
55 |
}
|
|
56 |
|
|
57 |
// -----------------------------------------------------------------------------
|
|
58 |
// prepareLengthString
|
|
59 |
// -----------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
QString VideoCollectionUtils::prepareLengthString(quint32 length)
|
|
62 |
{
|
36
|
63 |
FUNC_LOG;
|
34
|
64 |
const int secondsInMinute( 60 );
|
|
65 |
const int secondsInHour( 3600 );
|
36
|
66 |
|
37
|
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)
|
34
|
73 |
{
|
37
|
74 |
hrs.prepend(QString::number(0));
|
|
75 |
}
|
|
76 |
QString mins(QString::number(minutes));
|
|
77 |
if(minutes < 10)
|
36
|
78 |
{
|
37
|
79 |
mins.prepend(QString::number(0));
|
|
80 |
}
|
|
81 |
QString secs(QString::number(seconds));
|
|
82 |
if(seconds < 10)
|
|
83 |
{
|
|
84 |
secs.prepend(QString::number(0));
|
34
|
85 |
}
|
|
86 |
|
37
|
87 |
QString lengthStr(hbTrId( "txt_videos_list_l1l2l3" ).arg( hrs ).arg( mins ).arg( secs ));
|
36
|
88 |
|
|
89 |
return lengthStr.trimmed();
|
34
|
90 |
}
|
|
91 |
|
|
92 |
// -----------------------------------------------------------------------------
|
|
93 |
// prepareSizeString
|
|
94 |
// -----------------------------------------------------------------------------
|
|
95 |
//
|
|
96 |
QString VideoCollectionUtils::prepareSizeString(quint32 size)
|
|
97 |
{
|
36
|
98 |
FUNC_LOG;
|
34
|
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 );
|
36
|
104 |
|
34
|
105 |
QString sizeStr("");
|
|
106 |
|
|
107 |
if ( size > 0 )
|
|
108 |
{
|
|
109 |
quint32 dispSize = 0;
|
36
|
110 |
|
|
111 |
HbExtendedLocale locale = HbExtendedLocale::system();
|
34
|
112 |
|
|
113 |
if ( size >= videoSizeGB )
|
|
114 |
{
|
|
115 |
dispSize = size + videoSizeHalfGB;
|
|
116 |
dispSize /= videoSizeGB;
|
36
|
117 |
sizeStr = QString(hbTrId("txt_videos_list_l1_gb").arg(locale.toString(dispSize)));
|
34
|
118 |
}
|
|
119 |
else if ( size >= videoSizeMB )
|
|
120 |
{
|
|
121 |
dispSize = size + videoSizeHalfMB;
|
|
122 |
dispSize /= videoSizeMB;
|
36
|
123 |
sizeStr = QString(hbTrId("txt_videos_list_l1_mb").arg(locale.toString(dispSize)));
|
34
|
124 |
}
|
|
125 |
else
|
|
126 |
{
|
36
|
127 |
dispSize = size + videoSizeKB;
|
|
128 |
dispSize /= videoSizeKB;
|
|
129 |
sizeStr = QString(hbTrId("txt_videos_list_l1_kb").arg(locale.toString(dispSize)));
|
34
|
130 |
}
|
|
131 |
}
|
36
|
132 |
|
34
|
133 |
return sizeStr;
|
|
134 |
}
|
|
135 |
|
|
136 |
// End of file
|