ClipMetadataDisplayer.cpp 2.68 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*****************************************************************************
 * ClipMetadataDisplayer.cpp: Display the basic metadata about a clip.
 *****************************************************************************
 * Copyright (C) 2008-2010 VideoLAN
 *
 * Authors: Hugo Beauzée-Luyssen <beauze.h@gmail.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#include "ClipMetadataDisplayer.h"

#include "Clip.h"
#include "Media.h"

#include <QTime>

30
ClipMetadataDisplayer::ClipMetadataDisplayer( const Clip *clip, QWidget *parent /*= NULL*/ ) :
31
32
33
34
35
    QWidget( parent ),
    m_ui( new Ui::ClipMetadataDisplayer ),
    m_watchedClip( clip )
{
    m_ui->setupUi( this );
36
37
    if ( clip != NULL )
        setWatchedClip( clip );
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
}

void
ClipMetadataDisplayer::metadataUpdated( const Media *media )
{
    QTime   duration;
    duration = duration.addSecs( m_watchedClip->lengthSecond() );

    //Duration
    m_ui->durationValueLabel->setText( duration.toString( "hh:mm:ss" ) );
    //Filename || title
    m_ui->nameValueLabel->setText( media->fileInfo()->fileName() );
    //Resolution
    m_ui->resolutionValueLabel->setText( QString::number( media->width() )
                                       + " x " + QString::number( media->height() ) );
    //FPS
    m_ui->fpsValueLabel->setText( QString::number( media->fps() ) );
    //nb tracks :
    m_ui->nbVideoTracksValueLabel->setText( QString::number( media->nbVideoTracks() ) );
    m_ui->nbAudioTracksValueLabel->setText( QString::number( media->nbAudioTracks() ) );
}
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

void
ClipMetadataDisplayer::setWatchedClip( const Clip *clip )
{
    if ( m_watchedMedia )
        disconnect( m_watchedMedia );

    m_watchedClip = clip;
    m_watchedMedia = clip->getMedia();
    if ( m_watchedMedia->isMetadataComputed() == true )
        metadataUpdated( m_watchedMedia );
    else
    {
        connect( m_watchedMedia, SIGNAL( metaDataComputed(const Media*) ),
                 this, SLOT( metadataUpdated( const Media*) ) );
    }
}