Commit b91cd5fe authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen Committed by Ludovic Fauvet

Moving enum FileType to Media class.

parent 96c27f1e
......@@ -68,6 +68,7 @@ void Library::removingMediaAsked( const QUuid& uuid )
void Library::newMediaLoadingAsked( const QString& filePath )
{
//Is this necessary ??
QMutexLocker locker( &m_mutex );
Media* media;
foreach ( media, m_medias )
......
......@@ -44,16 +44,6 @@ class Library : public QObject, public Singleton<Library>
Q_OBJECT
Q_DISABLE_COPY( Library );
public:
/**
* \enum fType
* \brief enum to determine file type
*/
enum FileType
{
Audio,
Video,
Image
};
Media* getMedia( const QUuid& uuid );
Media* getMedia( const QString& path );
......
......@@ -139,6 +139,11 @@ void Media::setHeight( int height )
m_height = height;
}
Media::FileType Media::getFileType() const
{
return m_fileType;
}
void Media::initAudioData( void* datas, unsigned int* freq, unsigned int* nbChannels, unsigned int* fourCCFormat, unsigned int* frameSize )
{
m_audioData.freq = freq;
......
......@@ -59,6 +59,16 @@ class Media : public QObject
Q_OBJECT
public:
/**
* \enum fType
* \brief enum to determine file type
*/
enum FileType
{
Audio,
Video,
Image
};
Media( const QFileInfo* fileInfo );
Media( const QString& mrl );
virtual ~Media();
......@@ -94,6 +104,8 @@ public:
const QUuid& getUuid() const;
FileType getFileType() const;
void initAudioData( void* datas, unsigned int* freq, unsigned int* nbChannels, unsigned int* fourCCFormat, unsigned int* frameSize );
void addAudioFrame( void* datas, unsigned char* buffer, size_t buffSize, unsigned int nbSample );
......@@ -115,6 +127,7 @@ protected:
unsigned int m_height;
int* m_audioSpectrum;
audioData m_audioData;
FileType m_fileType;
signals:
void snapshotChanged();
......
......@@ -32,7 +32,7 @@
class FileBrowser : public QWidget
{
Q_OBJECT
public:
public:
FileBrowser( QWidget* parent = NULL );
virtual ~FileBrowser();
private:
......
......@@ -31,9 +31,9 @@ LibraryWidget::LibraryWidget( QWidget *parent ) : QWidget( parent ), m_firstDire
{
m_ui.setupUi( this );
m_ui.listWidgetAudio->setType( Library::Audio );
m_ui.listWidgetImage->setType( Library::Image );
m_ui.listWidgetVideo->setType( Library::Video );
m_ui.listWidgetAudio->setType( Media::Audio );
m_ui.listWidgetImage->setType( Media::Image );
m_ui.listWidgetVideo->setType( Media::Video );
setAcceptDrops( true );
......@@ -54,7 +54,7 @@ LibraryWidget::~LibraryWidget()
}
}
ListViewMediaItem* LibraryWidget::addMedia( const Media* media, Library::FileType fileType )
ListViewMediaItem* LibraryWidget::addMedia( const Media* media, Media::FileType fileType )
{
ListViewMediaItem* item = new ListViewMediaItem( media, fileType );
//TODO: replace this :
......@@ -62,13 +62,13 @@ ListViewMediaItem* LibraryWidget::addMedia( const Media* media, Library::FileTy
m_medias->append( item );
switch ( fileType )
{
case Library::Audio:
case Media::Audio:
m_ui.listWidgetAudio->addItem( item );
break;
case Library::Video:
case Media::Video:
m_ui.listWidgetVideo->addItem( item );
break;
case Library::Image:
case Media::Image:
m_ui.listWidgetImage->addItem( item );
break;
}
......@@ -89,13 +89,13 @@ void LibraryWidget::removeMedia( const QUuid& uuid )
{
switch( item->getFileType() )
{
case Library::Audio:
case Media::Audio:
this->m_ui.listWidgetAudio->removeItemWidget( item );
break;
case Library::Image:
case Media::Image:
this->m_ui.listWidgetImage->removeItemWidget( item );
break;
case Library::Video:
case Media::Video:
this->m_ui.listWidgetVideo->removeItemWidget( item );
break;
}
......@@ -122,11 +122,11 @@ void LibraryWidget::removeMedia( const QUuid& uuid )
void LibraryWidget::newMediaLoaded( Media* media )
{
//From here, the clip is const.
addMedia( media, Library::Video );
addMedia( media, Media::Video );
m_ui.LibraryTabs->setCurrentIndex( 1 );
}
void LibraryWidget::insertNewMediasFromFileDialog( QString title, QString filter, Library::FileType fileType )
void LibraryWidget::insertNewMediasFromFileDialog( QString title, QString filter, Media::FileType fileType )
{
QSettings settings;
QString path;
......@@ -146,7 +146,7 @@ void LibraryWidget::insertNewMediasFromFileDialog( QString title, QString fil
foreach ( filePath, fileNames )
{
// item = insertNewMedia( fileName, filetype );
// if( fileType == Library::Video )
// if( fileType == Media::Video )
emit newMediaLoadingAsked( filePath );
}
// if ( item != NULL )
......@@ -161,17 +161,17 @@ void LibraryWidget::on_pushButtonAddMedia_clicked()
case 0:
insertNewMediasFromFileDialog( tr( "Open Audios" ),
tr( "Audio Files" ) + " (*.mp3 *.oga *.flac *.aac *.wav)" ,
Library::Audio );
Media::Audio );
break;
case 1:
insertNewMediasFromFileDialog( tr( "Open Videos" ),
tr( "Video Files" ) + " (*.mov *.avi *.mkv *.mpg *.mpeg *.wmv *.mp4)" ,
Library::Video );
Media::Video );
break;
case 2:
insertNewMediasFromFileDialog( tr( "Open Images" ),
tr( "Images Files" ) + " (*.gif *.png *.jpg)" ,
Library::Image );
Media::Image );
break;
}
}
......
......@@ -48,7 +48,7 @@ public:
explicit LibraryWidget( QWidget *parent = 0 );
virtual ~LibraryWidget();
ListViewMediaItem* addMedia( const Media* clip, Library::FileType fileType );
ListViewMediaItem* addMedia( const Media* clip, Media::FileType fileType );
void removeMedia( const QUuid& uuid );
int getIndex( ListViewMediaItem* media );
......@@ -58,8 +58,8 @@ protected:
virtual void dropEvent( QDropEvent* event );
private:
ListViewMediaItem* insertNewMedia( QString filename, Library::FileType fileType );
void insertNewMediasFromFileDialog( QString title, QString filter, Library::FileType fileType );
ListViewMediaItem* insertNewMedia( QString filename, Media::FileType fileType );
void insertNewMediasFromFileDialog( QString title, QString filter, Media::FileType fileType );
Ui::LibraryWidget m_ui;
static QList<ListViewMediaItem*>* m_medias;
......
......@@ -27,7 +27,7 @@
#define MAX_NAME_LENGTH 10
ListViewMediaItem::ListViewMediaItem( const Media* media, Library::FileType fType, QListWidget* parent, int type ) :
ListViewMediaItem::ListViewMediaItem( const Media* media, Media::FileType fType, QListWidget* parent, int type ) :
QListWidgetItem( parent, type ), m_media ( media )
{
m_fileType = fType;
......
......@@ -47,7 +47,7 @@ public:
* \param parent parent widget
* \param type
*/
ListViewMediaItem( const Media* media, Library::FileType fType, QListWidget* parent = 0, int type = Type );
ListViewMediaItem( const Media* media, Media::FileType fType, QListWidget* parent = 0, int type = Type );
/**
* \brief Destructor
......@@ -58,7 +58,7 @@ public:
* \brief Getter for filetype
* \return filetype of the item
*/
Library::FileType getFileType() const { return m_fileType; }
Media::FileType getFileType() const { return m_fileType; }
const Media* getMedia() const;
......@@ -68,7 +68,7 @@ private:
/**
* \brief fileType member
*/
Library::FileType m_fileType;
Media::FileType m_fileType;
/**
* \Instance of the InputMedia
......
......@@ -35,18 +35,18 @@ MediaListWidget::MediaListWidget( QWidget* parent ) : QListWidget( parent )
setAcceptDrops( true );
}
void MediaListWidget::setType( Library::FileType fileType )
void MediaListWidget::setType( Media::FileType fileType )
{
this->m_Type = fileType;
switch ( fileType )
{
case Library::Audio:
case Media::Audio:
m_svgRenderer->load( QString( ":/images/scalable/audio-scalable" ) );
break;
case Library::Image:
case Media::Image:
m_svgRenderer->load( QString( ":/images/scalable/image-scalable" ) );
break;
case Library::Video:
case Media::Video:
m_svgRenderer->load( QString( ":/images/scalable/video-scalable" ) );
break;
}
......
......@@ -31,21 +31,21 @@
#include <QApplication>
#include <QSvgRenderer>
#include "ListViewMediaItem.h"
#include "Library.h"
#include "Media.h"
class MediaListWidget : public QListWidget
{
Q_OBJECT
public:
MediaListWidget( QWidget* parent = 0 );
void setType( Library::FileType fileType );
void setType( Media::FileType fileType );
protected:
virtual void mousePressEvent( QMouseEvent* event );
virtual void mouseMoveEvent( QMouseEvent* event );
virtual void paintEvent( QPaintEvent* event );
private:
Library::FileType m_Type;
Media::FileType m_Type;
QPoint m_dragStartPos;
QSvgRenderer* m_svgRenderer;
};
......
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