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