ClipMetadataDisplayer.cpp 4.26 KB
Newer Older
1 2 3 4 5
/*****************************************************************************
 * ClipMetadataDisplayer.cpp: Display the basic metadata about a clip.
 *****************************************************************************
 * Copyright (C) 2008-2010 VideoLAN
 *
6
 * Authors: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 *
 * 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"
26
#include "ISource.h"
27 28 29 30
#include "Media.h"

#include <QTime>

31
ClipMetadataDisplayer::ClipMetadataDisplayer( QWidget *parent /*= NULL*/ ) :
32 33
    QWidget( parent ),
    m_ui( new Ui::ClipMetadataDisplayer ),
34
    m_watchedClip( NULL )
35 36 37 38 39
{
    m_ui->setupUi( this );
}

void
40
ClipMetadataDisplayer::metadataUpdated()
41 42 43 44
{
    QTime   duration;
    duration = duration.addSecs( m_watchedClip->lengthSecond() );

45
    const Backend::ISource* source = m_watchedMedia->source();
46
    updateInterface();
47 48 49
    //Duration
    m_ui->durationValueLabel->setText( duration.toString( "hh:mm:ss" ) );
    //Filename || title
50
    m_ui->nameValueLabel->setText( m_watchedMedia->fileInfo()->fileName() );
51
    //Resolution
52 53
    m_ui->resolutionValueLabel->setText( QString::number( source->width() )
                                       + " x " + QString::number( source->height() ) );
54
    //FPS
55
    m_ui->fpsValueLabel->setText( QString::number( source->fps() ) );
56
    //nb tracks :
57 58
    m_ui->nbVideoTracksValueLabel->setText( QString::number( source->nbVideoTracks() ) );
    m_ui->nbAudioTracksValueLabel->setText( QString::number( source->nbAudioTracks() ) );
59
    //Path:
60
    m_ui->pathValueLabel->setText( m_watchedMedia->fileInfo()->absoluteFilePath() );
61
    //Workspace:
62
    workspaceStateChanged( m_watchedMedia->isInWorkspace() );
63
}
64

65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
void
ClipMetadataDisplayer::clear()
{
    m_ui->durationValueLabel->setText( "---" );
    //Filename || title
    m_ui->nameValueLabel->setText( "---" );
    //Resolution
    m_ui->resolutionValueLabel->setText( "---" );
    //FPS
    m_ui->fpsValueLabel->setText( "---" );
    //nb tracks :
    m_ui->nbVideoTracksValueLabel->setText( "---" );
    m_ui->nbAudioTracksValueLabel->setText( "---" );
    //Path:
    m_ui->pathValueLabel->setText( "---" );
}

void
ClipMetadataDisplayer::clipDestroyed( Clip* clip )
{
    if ( m_watchedClip == clip )
        clear();
}

89 90 91 92 93
void
ClipMetadataDisplayer::setWatchedClip( const Clip *clip )
{
    if ( m_watchedMedia )
        disconnect( m_watchedMedia );
94 95
    if ( m_watchedClip )
        disconnect( m_watchedClip );
96 97 98

    m_watchedClip = clip;
    m_watchedMedia = clip->getMedia();
99
    connect( m_watchedClip, SIGNAL( unloaded( Clip* ) ), this, SLOT( clipDestroyed( Clip* ) ) );
100
    if ( m_watchedMedia->isMetadataComputed() == true )
101
        metadataUpdated();
102 103
    else
    {
104 105
        connect( m_watchedMedia, SIGNAL( metaDataComputed() ),
                 this, SLOT( metadataUpdated() ) );
106
    }
107 108 109 110 111 112 113 114 115 116 117
    connect( m_watchedMedia, SIGNAL( workspaceStateChanged( bool ) ),
             this, SLOT( workspaceStateChanged( bool ) ) );
}

void
ClipMetadataDisplayer::workspaceStateChanged( bool state )
{
    if ( state == true )
        m_ui->inProjectWorkspaceValueLabel->setPixmap( QPixmap( ":/images/ok" ).scaled( 16, 16 ) );
    else
        m_ui->inProjectWorkspaceValueLabel->setPixmap( QPixmap( ":/images/ko" ).scaled( 16, 16 ) );
118
}
119 120 121 122

void
ClipMetadataDisplayer::updateInterface()
{
123 124 125 126 127
    bool visible = m_watchedMedia->source()->hasVideo();
    m_ui->fpsLabel->setVisible( visible );
    m_ui->fpsValueLabel->setVisible( visible );
    m_ui->resolutionLabel->setVisible( visible );
    m_ui->resolutionValueLabel->setVisible( visible );
128
}