36 // VideoCollectionUtils |
40 // VideoCollectionUtils |
37 // ----------------------------------------------------------------------------- |
41 // ----------------------------------------------------------------------------- |
38 // |
42 // |
39 VideoCollectionUtils::VideoCollectionUtils() |
43 VideoCollectionUtils::VideoCollectionUtils() |
40 { |
44 { |
41 |
45 FUNC_LOG; |
42 } |
46 } |
43 |
47 |
44 // ----------------------------------------------------------------------------- |
48 // ----------------------------------------------------------------------------- |
45 // ~CVideoCollectionUtils |
49 // ~CVideoCollectionUtils |
46 // ----------------------------------------------------------------------------- |
50 // ----------------------------------------------------------------------------- |
47 // |
51 // |
48 VideoCollectionUtils::~VideoCollectionUtils() |
52 VideoCollectionUtils::~VideoCollectionUtils() |
49 { |
53 { |
50 |
54 FUNC_LOG; |
51 } |
55 } |
52 |
56 |
53 // ----------------------------------------------------------------------------- |
57 // ----------------------------------------------------------------------------- |
54 // prepareLengthString |
58 // prepareLengthString |
55 // ----------------------------------------------------------------------------- |
59 // ----------------------------------------------------------------------------- |
56 // |
60 // |
57 QString VideoCollectionUtils::prepareLengthString(quint32 length) |
61 QString VideoCollectionUtils::prepareLengthString(quint32 length) |
58 { |
62 { |
|
63 FUNC_LOG; |
59 const int secondsInMinute( 60 ); |
64 const int secondsInMinute( 60 ); |
60 const int secondsInHour( 3600 ); |
65 const int secondsInHour( 3600 ); |
61 QString lengthStr(""); |
66 QString hour; |
|
67 QString min; |
|
68 QString sec; |
|
69 |
|
70 HbExtendedLocale locale = HbExtendedLocale::system(); |
62 |
71 |
63 if ( length > 0 ) |
72 if ( length > 0 ) |
64 { |
73 { |
65 quint32 hours = length / secondsInHour; |
74 quint32 hours = length / secondsInHour; |
66 quint32 minutes = length / secondsInMinute % secondsInMinute; |
75 quint32 minutes = length / secondsInMinute % secondsInMinute; |
68 |
77 |
69 if ( hours > 0 ) |
78 if ( hours > 0 ) |
70 { |
79 { |
71 if(hours == 1) |
80 if(hours == 1) |
72 { |
81 { |
73 lengthStr = QObject::tr("%1 hour ").arg(QString::number(hours)); //localisation |
82 hour = QObject::tr("%1 hour ").arg(locale.toString(hours)); //localisation |
74 } |
83 } |
75 else |
84 else |
76 { |
85 { |
77 lengthStr += QObject::tr("%1 hours ").arg(QString::number(hours)); //localisation |
86 hour = QObject::tr("%1 hours ").arg(locale.toString(hours)); //localisation |
78 } |
87 } |
79 } |
88 } |
80 |
89 |
81 if ( minutes > 0 ) |
90 if ( minutes > 0 ) |
82 { |
91 { |
83 if(minutes == 1) |
92 if(minutes == 1) |
84 { |
93 { |
85 lengthStr += QObject::tr("%1 minute ").arg(QString::number(minutes)); //localisation |
94 min = QObject::tr("%1 minute ").arg(locale.toString(minutes)); //localisation |
86 } |
95 } |
87 else |
96 else |
88 { |
97 { |
89 lengthStr += QObject::tr("%1 minutes ").arg(QString::number(minutes)); //localisation |
98 min = QObject::tr("%1 minutes ").arg(locale.toString(minutes)); //localisation |
90 } |
99 } |
91 } |
100 } |
92 if (seconds > 0 && hours == 0) |
101 if (seconds > 0) |
93 { |
102 { |
94 if(seconds == 1) |
103 if(seconds == 1) |
95 { |
104 { |
96 lengthStr += QObject::tr("%1 second").arg(QString::number(seconds)); //localisation |
105 sec = QObject::tr("%1 second").arg(locale.toString(seconds)); //localisation |
97 } |
106 } |
98 else |
107 else |
99 { |
108 { |
100 lengthStr += QObject::tr("%1 seconds").arg(QString::number(seconds)); //localisation |
109 sec = QObject::tr("%1 seconds").arg(locale.toString(seconds)); //localisation |
101 } |
110 } |
102 } |
111 } |
103 } else { |
112 } |
104 lengthStr += QObject::tr("0 seconds"); //TODO: Localisation |
113 else |
|
114 { |
|
115 sec = QObject::tr("0 seconds"); //localisation |
105 } |
116 } |
106 |
117 |
107 return lengthStr; |
118 QString lengthStr(hbTrId( "txt_videos_list_l1_l2_l3" ).arg( hour ).arg( min ).arg( sec )); |
|
119 |
|
120 return lengthStr.trimmed(); |
108 } |
121 } |
109 // ----------------------------------------------------------------------------- |
122 // ----------------------------------------------------------------------------- |
110 // VideoCollectionUtils::prepareLengthStrings() |
123 // VideoCollectionUtils::prepareShortLengthString() |
111 // ----------------------------------------------------------------------------- |
124 // ----------------------------------------------------------------------------- |
112 // |
125 // |
113 const QStringList VideoCollectionUtils::prepareLengthStrings(quint32 total) |
126 const QString VideoCollectionUtils::prepareShortLengthString(quint32 total) |
114 { |
127 { |
115 const int secondsInMinute( 60 ); |
128 const int secondsInMinute( 60 ); |
116 const int secondsInHour( 3600 ); |
129 const int secondsInHour( 3600 ); |
117 |
130 |
118 quint32 hours(0); |
131 int hour = total / secondsInHour; |
119 quint32 minutes(0); |
132 total = total % secondsInHour; |
120 quint32 seconds(0); |
133 int minutes = total / secondsInMinute; |
121 |
134 total = total % secondsInMinute; |
122 QString hrs(""); |
135 int second = total; |
123 QString mins(""); |
|
124 QString secs(""); |
|
125 |
136 |
126 if ( total > 0 ) |
137 QTime time( hour ,minutes ,second ); |
127 { |
138 QString str; |
128 hours = (total / secondsInHour); |
|
129 total = total - (hours * secondsInHour); |
|
130 minutes = (total / secondsInMinute); |
|
131 seconds = (total % secondsInMinute); |
|
132 } |
|
133 |
|
134 hrs = QString::number(hours); |
|
135 |
|
136 if (minutes < 10) |
|
137 { |
|
138 mins = "0" + QString::number(minutes); |
|
139 |
|
140 } |
|
141 else |
|
142 { |
|
143 mins = QString::number(minutes); |
|
144 } |
|
145 |
139 |
146 if (seconds < 10) |
140 HbExtendedLocale locale = HbExtendedLocale::system(); |
147 { |
141 |
148 secs = "0" + QString::number(seconds); |
142 str = locale.format( time, r_qtn_time_durat_long_with_zero ); |
149 |
143 |
150 } |
144 return str; |
151 else |
|
152 { |
|
153 secs = QString::number(seconds); |
|
154 } |
|
155 |
|
156 QStringList retVal; |
|
157 |
|
158 retVal.append(hrs); |
|
159 retVal.append(mins); |
|
160 retVal.append(secs); |
|
161 |
|
162 return retVal; |
|
163 } |
145 } |
164 |
|
165 |
146 |
166 // ----------------------------------------------------------------------------- |
147 // ----------------------------------------------------------------------------- |
167 // prepareSizeString |
148 // prepareSizeString |
168 // ----------------------------------------------------------------------------- |
149 // ----------------------------------------------------------------------------- |
169 // |
150 // |
170 QString VideoCollectionUtils::prepareSizeString(quint32 size) |
151 QString VideoCollectionUtils::prepareSizeString(quint32 size) |
171 { |
152 { |
|
153 FUNC_LOG; |
172 const int videoSizeGB( 0x40000000 ); |
154 const int videoSizeGB( 0x40000000 ); |
173 const int videoSizeHalfGB( 0x20000000 ); |
155 const int videoSizeHalfGB( 0x20000000 ); |
174 const int videoSizeMB( 0x100000 ); |
156 const int videoSizeMB( 0x100000 ); |
175 const int videoSizeHalfMB( 0x80000 ); |
157 const int videoSizeHalfMB( 0x80000 ); |
176 const int videoSizeKB( 0x400 ); |
158 const int videoSizeKB( 0x400 ); |
177 const int videoSizeHalfKB( 0x200 ); |
159 |
178 |
|
179 QString sizeStr(""); |
160 QString sizeStr(""); |
180 |
161 |
181 if ( size > 0 ) |
162 if ( size > 0 ) |
182 { |
163 { |
183 quint32 dispSize = 0; |
164 quint32 dispSize = 0; |
|
165 |
|
166 HbExtendedLocale locale = HbExtendedLocale::system(); |
184 |
167 |
185 if ( size >= videoSizeGB ) |
168 if ( size >= videoSizeGB ) |
186 { |
169 { |
187 dispSize = size + videoSizeHalfGB; |
170 dispSize = size + videoSizeHalfGB; |
188 dispSize /= videoSizeGB; |
171 dispSize /= videoSizeGB; |
189 sizeStr = QString(QObject::tr("%1 GB").arg(QString::number(dispSize))); //localisation |
172 sizeStr = QString(hbTrId("txt_videos_list_l1_gb").arg(locale.toString(dispSize))); |
190 } |
173 } |
191 else if ( size >= videoSizeMB ) |
174 else if ( size >= videoSizeMB ) |
192 { |
175 { |
193 dispSize = size + videoSizeHalfMB; |
176 dispSize = size + videoSizeHalfMB; |
194 dispSize /= videoSizeMB; |
177 dispSize /= videoSizeMB; |
195 sizeStr = QString(QObject::tr("%1 MB").arg(QString::number(dispSize))); //localisation |
178 sizeStr = QString(hbTrId("txt_videos_list_l1_mb").arg(locale.toString(dispSize))); |
196 } |
|
197 else if (size >= videoSizeKB) |
|
198 { |
|
199 dispSize = size + videoSizeHalfKB; |
|
200 dispSize /= videoSizeKB; |
|
201 sizeStr = QString(QObject::tr("%1 kB").arg(QString::number(dispSize))); //localisation |
|
202 } |
179 } |
203 else |
180 else |
204 { |
181 { |
205 sizeStr = QString(QObject::tr("%1B").arg(QString::number(size))); //localisation |
182 dispSize = size + videoSizeKB; |
|
183 dispSize /= videoSizeKB; |
|
184 sizeStr = QString(hbTrId("txt_videos_list_l1_kb").arg(locale.toString(dispSize))); |
206 } |
185 } |
207 } |
186 } |
208 |
187 |
209 return sizeStr; |
188 return sizeStr; |
210 } |
189 } |
211 |
190 |
212 // End of file |
191 // End of file |