Commit 68a59bd1 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Moving metatags to Clip class.

Adapting MediaProperty window to use Clip
parent 52f58b90
......@@ -51,6 +51,7 @@ void Clip::init()
{
m_uuid = QUuid::createUuid();
computeLength();
m_metaTags << "Toto" << "titi" << "tutu";
}
float Clip::getBegin() const
......@@ -92,3 +93,27 @@ const QUuid& Clip::getUuid() const
{
return m_uuid;
}
const QStringList& Clip::getMetaTags() const
{
return m_metaTags;
}
void Clip::setMetaTags( const QStringList& tags )
{
m_metaTags = tags;
}
bool Clip::matchMetaTag( const QString& tag ) const
{
if ( tag.length() == 0 )
return true;
QString metaTag;
foreach ( metaTag, m_metaTags )
{
if ( metaTag.startsWith( tag, Qt::CaseInsensitive ) == true )
return true;
}
return false;
// m_metaTags.contains( tag, Qt::CaseInsensitive );
}
......@@ -86,7 +86,12 @@ class Clip : public QObject
\return The Clip's Uuid as a QUuid
*/
const QUuid& getUuid() const;
const QUuid& getUuid() const;
const QStringList& getMetaTags() const;
void setMetaTags( const QStringList& tags );
bool matchMetaTag( const QString& tag ) const;
private:
void computeLength();
......@@ -98,6 +103,8 @@ class Clip : public QObject
qint64 m_length;
qint64 m_lengthSeconds;
QUuid m_uuid;
QStringList m_metaTags;
};
#endif //CLIP_H__
......@@ -46,7 +46,6 @@ Media::Media( const QFileInfo* fileInfo)
else
m_mrl = "fake:///" + fileInfo->absoluteFilePath();
m_vlcMedia = new LibVLCpp::Media( m_mrl );
m_metaTags << "Toto" << "titi" << "tutu";
}
Media::~Media()
......@@ -202,31 +201,7 @@ void Media::addAudioFrame( void* datas, unsigned char* buffer, si
// qDebug() << m_audioData.frameList.size();
}
const QStringList& Media::getMetaTags() const
{
return m_metaTags;
}
void Media::setMetaTags( const QStringList& tags )
{
m_metaTags = tags;
}
bool Media::matchMetaTag( const QString& tag ) const
{
if ( tag.length() == 0 )
return true;
QString metaTag;
foreach ( metaTag, m_metaTags )
{
if ( metaTag.startsWith( tag, Qt::CaseInsensitive ) == true )
return true;
}
return false;
// m_metaTags.contains( tag, Qt::CaseInsensitive );
}
void Media::emitMetaDataComputed()
void Media::emitMetaDataComputed()
{
emit metaDataComputed();
emit metaDataComputed( this );
......
......@@ -126,9 +126,6 @@ public:
QVector<int*> getAudioFrameList() { return m_audioData.frameList; }
unsigned int getAudioNbSample() { return m_audioData.nbSample; }
const QStringList& getMetaTags() const;
void setMetaTags( const QStringList& tags );
bool matchMetaTag( const QString& tag ) const;
void emitMetaDataComputed();
private:
......@@ -150,7 +147,6 @@ protected:
int* m_audioSpectrum;
audioData m_audioData;
FileType m_fileType;
QStringList m_metaTags;
signals:
void metaDataComputed();
......
......@@ -232,7 +232,7 @@ void LibraryWidget::updateFilter( const QString& filter )
ListViewMediaItem* item = static_cast<ListViewMediaItem*>( mediaList->item( i ) );
if ( item != NULL )
{
item->setHidden( !(item->getClip()->getParent()->matchMetaTag( filter )) );
item->setHidden( !(item->getClip()->matchMetaTag( filter )) );
}
}
}
......
......@@ -259,6 +259,6 @@ void MainWindow::registerWidgetInViewMenu( QDockWidget* widget )
void MainWindow::mediaListItemDoubleClicked( QListWidgetItem* qItem )
{
ListViewMediaItem* item = static_cast<ListViewMediaItem*>( qItem );
MediaProperty* mp = new MediaProperty( item->getClip()->getParent(), this );
MediaProperty* mp = new MediaProperty( item->getClip(), this );
mp->show();
}
......@@ -7,30 +7,30 @@
#include "MediaProperty.h"
#include "ui_MediaProperty.h"
MediaProperty::MediaProperty( Media* media, QWidget *parent ) :
MediaProperty::MediaProperty( Clip* clip, QWidget *parent ) :
QDialog( parent ),
ui( new Ui::MediaProperty ),
m_media( media )
m_clip( clip )
{
QTime duration;
duration = duration.addMSecs( m_media->getLength() );
duration = duration.addSecs( m_clip->getLengthSecond() );
ui->setupUi(this);
connect( this, SIGNAL( accepted() ), this, SLOT( deleteLater() ) );
connect( this, SIGNAL( rejected() ), this, SLOT( deleteLater() ) );
ui->durationValueLabel->setText( duration.toString( "hh:mm:ss" ) );
ui->nameValueLabel->setText( m_media->getFileInfo()->fileName() );
ui->resolutionValueLabel->setText( QString::number( m_media->getWidth() )
+ " x " + QString::number( m_media->getHeight() ) );
ui->fpsValueLabel->setText( QString::number( m_media->getFps() ) );
ui->snapshotLabel->setPixmap( m_media->getSnapshot().scaled( 128, 128, Qt::KeepAspectRatio ) );
setWindowTitle( m_media->getFileInfo()->fileName() + " " + tr( "properties" ) );
ui->nameValueLabel->setText( m_clip->getParent()->getFileInfo()->fileName() );
ui->resolutionValueLabel->setText( QString::number( m_clip->getParent()->getWidth() )
+ " x " + QString::number( m_clip->getParent()->getHeight() ) );
ui->fpsValueLabel->setText( QString::number( m_clip->getParent()->getFps() ) );
ui->snapshotLabel->setPixmap( m_clip->getParent()->getSnapshot().scaled( 128, 128, Qt::KeepAspectRatio ) );
setWindowTitle( m_clip->getParent()->getFileInfo()->fileName() + " " + tr( "properties" ) );
const QPushButton* button = ui->buttonBox->button( QDialogButtonBox::Apply );
Q_ASSERT( button != NULL);
connect( button, SIGNAL( clicked() ), this, SLOT( apply() ) );
QStringListModel* model = new QStringListModel( media->getMetaTags(), this );
QStringListModel* model = new QStringListModel( m_clip->getMetaTags(), this );
ui->metaTagsView->setModel( model );
connect( ui->addTagsButton, SIGNAL( clicked() ), this, SLOT( addTagsRequired() ) );
......@@ -60,7 +60,7 @@ void MediaProperty::apply()
QStringListModel* model = dynamic_cast<QStringListModel*>( ui->metaTagsView->model() );
if ( model == NULL )
return ;
m_media->setMetaTags( model->stringList() );
m_clip->setMetaTags( model->stringList() );
}
void MediaProperty::addTagsRequired()
......
......@@ -24,7 +24,7 @@
#define MEDIAPROPERTY_H
#include <QDialog>
#include "Media.h"
#include "Clip.h"
#include <QAbstractButton>
namespace Ui {
......@@ -35,7 +35,7 @@ class MediaProperty : public QDialog
{
Q_OBJECT
public:
MediaProperty( Media* media, QWidget *parent = 0 );
MediaProperty( Clip* clip, QWidget *parent = 0 );
~MediaProperty();
protected:
......@@ -48,7 +48,7 @@ private slots:
private:
Ui::MediaProperty* ui;
Media* m_media;
Clip* m_clip;
};
#endif // MEDIAPROPERTY_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment