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