Commit 8f04cd20 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen
Browse files

Little cosmetic : FileType enum is now part of the Library.

parent d07caad5
......@@ -36,6 +36,16 @@ 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
};
Clip* getClip( const QUuid& uuid );
private:
......
......@@ -30,9 +30,9 @@ LibraryWidget::LibraryWidget( QWidget *parent ) : QWidget( parent )
{
m_ui.setupUi( this );
m_ui.listWidgetAudio->setType( ListViewMediaItem::Audio );
m_ui.listWidgetImage->setType( ListViewMediaItem::Image );
m_ui.listWidgetVideo->setType( ListViewMediaItem::Video );
m_ui.listWidgetAudio->setType( Library::Audio );
m_ui.listWidgetImage->setType( Library::Image );
m_ui.listWidgetVideo->setType( Library::Video );
// *Always* force the selection of the first tab
m_ui.LibraryTabs->setCurrentIndex( 0 );
......@@ -51,7 +51,7 @@ LibraryWidget::~LibraryWidget()
}
}
ListViewMediaItem* LibraryWidget::addMedia( const Clip* clip, ListViewMediaItem::fType fileType )
ListViewMediaItem* LibraryWidget::addMedia( const Clip* clip, Library::FileType fileType )
{
ListViewMediaItem* item = new ListViewMediaItem( clip, fileType );
//TODO: replace this :
......@@ -59,13 +59,13 @@ ListViewMediaItem* LibraryWidget::addMedia( const Clip* clip, ListViewMediaItem
m_medias->append( item );
switch ( fileType )
{
case ListViewMediaItem::Audio:
case Library::Audio:
m_ui.listWidgetAudio->addItem( item );
break;
case ListViewMediaItem::Video:
case Library::Video:
m_ui.listWidgetVideo->addItem( item );
break;
case ListViewMediaItem::Image:
case Library::Image:
m_ui.listWidgetImage->addItem( item );
break;
}
......@@ -84,15 +84,15 @@ void LibraryWidget::removeMedia( const QUuid& uuid )
{
if ( item->getClip()->getUuid() == uuid )
{
switch( item->fileType() )
switch( item->getFileType() )
{
case ListViewMediaItem::Audio:
case Library::Audio:
this->m_ui.listWidgetAudio->removeItemWidget( item );
break;
case ListViewMediaItem::Image:
case Library::Image:
this->m_ui.listWidgetImage->removeItemWidget( item );
break;
case ListViewMediaItem::Video:
case Library::Video:
this->m_ui.listWidgetVideo->removeItemWidget( item );
break;
}
......@@ -119,10 +119,10 @@ void LibraryWidget::removeMedia( const QUuid& uuid )
void LibraryWidget::newClipLoaded( Clip* clip )
{
//From here, the clip is const.
addMedia( clip, ListViewMediaItem::Video );
addMedia( clip, Library::Video );
}
void LibraryWidget::insertNewMediasFromFileDialog( QString title, QString filter, ListViewMediaItem::fType filetype )
void LibraryWidget::insertNewMediasFromFileDialog( QString title, QString filter, Library::FileType fileType )
{
QSettings settings;
QString path = settings.value( "mediaLibraryDialogPath", QDir::homePath() ).toString();
......@@ -132,8 +132,11 @@ void LibraryWidget::insertNewMediasFromFileDialog( QString title, QString fil
QString filePath;
// ListViewMediaItem* item = NULL;
foreach ( filePath, fileNames )
{
// item = insertNewMedia( fileName, filetype );
emit newClipLoadingAsked( filePath );
if( fileType == Library::Video )
emit newClipLoadingAsked( filePath );
}
// if ( item != NULL )
// settings.setValue( "mediaLibraryDialogPath" , item->getClip()->getFileInfo()->absoluteDir().absolutePath() );
// return ;
......@@ -146,17 +149,17 @@ void LibraryWidget::on_pushButtonAddMedia_clicked()
case 0:
insertNewMediasFromFileDialog( tr( "Open Audios" ),
tr( "Audio Files" ) + " (*.mp3 *.oga *.flac *.aac *.wav)" ,
ListViewMediaItem::Audio );
Library::Audio );
break;
case 1:
insertNewMediasFromFileDialog( tr( "Open Videos" ),
tr( "Video Files" ) + " (*.mov *.avi *.mkv *.mpg *.mpeg *.wmv)" ,
ListViewMediaItem::Video );
Library::Video );
break;
case 2:
insertNewMediasFromFileDialog( tr( "Open Images" ),
tr( "Images Files" ) + " (*.gif *.png *.jpg)" ,
ListViewMediaItem::Image );
Library::Image );
break;
}
}
......
......@@ -34,6 +34,7 @@
#include <QDrag>
#include <QList>
#include <QSettings>
#include "Library.h"
#include "ListViewMediaItem.h"
#include "ui_LibraryWidget.h"
......@@ -45,7 +46,7 @@ public:
explicit LibraryWidget( QWidget *parent = 0 );
virtual ~LibraryWidget();
ListViewMediaItem* addMedia( const Clip* clip, ListViewMediaItem::fType fileType );
ListViewMediaItem* addMedia( const Clip* clip, Library::FileType fileType );
void removeMedia( const QUuid& uuid );
int getIndex( ListViewMediaItem* media );
......@@ -53,8 +54,8 @@ protected:
virtual void changeEvent( QEvent *e );
private:
ListViewMediaItem* insertNewMedia( QString filename, ListViewMediaItem::fType fileType );
void insertNewMediasFromFileDialog( QString title, QString filter, ListViewMediaItem::fType fileType );
ListViewMediaItem* insertNewMedia( QString filename, Library::FileType fileType );
void insertNewMediasFromFileDialog( QString title, QString filter, Library::FileType fileType );
Ui::LibraryWidget m_ui;
static QList<ListViewMediaItem*>* m_medias;
......
......@@ -24,7 +24,7 @@
#include <QPixmap>
#include <QDebug>
ListViewMediaItem::ListViewMediaItem( const Clip* clip, ListViewMediaItem::fType fType, QListWidget* parent, int type ) :
ListViewMediaItem::ListViewMediaItem( const Clip* clip, Library::FileType fType, QListWidget* parent, int type ) :
QListWidgetItem( parent, type ), m_clip( clip )
{
m_fileType = fType;
......
......@@ -27,6 +27,7 @@
#include <QFileInfo>
#include <QListWidgetItem>
#include "Clip.h"
#include "Library.h"
/**
* \class ListViewMediaItem
......@@ -38,17 +39,6 @@ class ListViewMediaItem : public QObject, public QListWidgetItem
Q_OBJECT
public:
/**
* \enum fType
* \brief enum to determine file type
*/
enum fType
{
Audio,
Video,
Image
};
/**
* \brief Constructor
*
......@@ -57,7 +47,7 @@ public:
* \param parent parent widget
* \param type
*/
ListViewMediaItem( const Clip* clip, ListViewMediaItem::fType fType, QListWidget* parent = 0, int type = Type );
ListViewMediaItem( const Clip* clip, Library::FileType fType, QListWidget* parent = 0, int type = Type );
/**
* \brief Destructor
......@@ -68,9 +58,9 @@ public:
* \brief Getter for filetype
* \return filetype of the item
*/
ListViewMediaItem::fType fileType() { return m_fileType; }
Library::FileType getFileType() const { return m_fileType; }
const Clip* getClip() const;
const Clip* getClip() const;
//void setInputMedia( InputMedia* inputMedia ) { m_inputMedia = inputMedia; }
......@@ -78,7 +68,7 @@ private:
/**
* \brief fileType member
*/
ListViewMediaItem::fType m_fileType;
Library::FileType m_fileType;
/**
* \Instance of the InputMedia
......
......@@ -30,18 +30,18 @@ MediaListWidget::MediaListWidget( QWidget* parent ) : QListWidget( parent )
setIconSize( QSize( 128, 128 ) );
}
void MediaListWidget::setType( ListViewMediaItem::fType fileType )
void MediaListWidget::setType( Library::FileType fileType )
{
this->m_Type = fileType;
switch ( fileType )
{
case ListViewMediaItem::Audio:
case Library::Audio:
m_svgRenderer->load( QString( ":/images/scalable/audio-scalable" ) );
break;
case ListViewMediaItem::Image:
case Library::Image:
m_svgRenderer->load( QString( ":/images/scalable/image-scalable" ) );
break;
case ListViewMediaItem::Video:
case Library::Video:
m_svgRenderer->load( QString( ":/images/scalable/video-scalable" ) );
break;
}
......
......@@ -31,21 +31,22 @@
#include <QApplication>
#include <QSvgRenderer>
#include "ListViewMediaItem.h"
#include "Library.h"
class MediaListWidget : public QListWidget
{
Q_OBJECT
public:
MediaListWidget( QWidget* parent = 0 );
void setType( ListViewMediaItem::fType fileType );
void setType( Library::FileType fileType );
protected:
virtual void mousePressEvent( QMouseEvent* event );
virtual void mouseMoveEvent( QMouseEvent* event );
virtual void paintEvent( QPaintEvent* event );
virtual void mousePressEvent( QMouseEvent* event );
virtual void mouseMoveEvent( QMouseEvent* event );
virtual void paintEvent( QPaintEvent* event );
private:
ListViewMediaItem::fType m_Type;
QPoint m_dragStartPos;
QSvgRenderer* m_svgRenderer;
Library::FileType m_Type;
QPoint m_dragStartPos;
QSvgRenderer* m_svgRenderer;
};
#endif // MEDIALISTWIDGET_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