Commit 390c0fc3 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Added a Clip getter in the library. Library now uses Clip, no more Media.

parent 4ee7255c
......@@ -28,6 +28,7 @@ Clip::Clip( const QString& mrl )
{
m_instance = LibVLCpp::Instance::getInstance();
m_vlcMedia = new LibVLCpp::Media( m_instance, mrl );
m_uuid = QUuid::createUuid();
}
Clip::~Clip()
......@@ -73,3 +74,8 @@ const QPixmap& Clip::getSnapshot() const
//TODO: instanciate this as a static pixmap
return QPixmap( ":/images/images/vlmc.png" );
}
const QUuid& Clip::getUuid() const
{
return m_uuid;
}
......@@ -26,6 +26,7 @@
#include <QList>
#include <QString>
#include <QPixmap>
#include <QUuid>
#include "VLCMedia.h"
......@@ -46,6 +47,8 @@ public:
void setSnapshot( QPixmap* snapshot );
const QPixmap& getSnapshot() const;
const QUuid& getUuid() const;
protected:
//TODO: is this really usefull now ?!
LibVLCpp::Instance* m_instance;
......@@ -53,6 +56,7 @@ protected:
QString m_mrl;
QList<QString> m_parameters;
QPixmap* m_snapshot;
QUuid m_uuid;
};
#endif // MEDIA_H
#ifndef SINGLETON_HPP
#define SINGLETON_HPP
template <typename T>
class Singleton
{
public:
T* getInstance()
{
if ( m_instance == NULL )
m_instance = new T;
return m_instance;
}
void destroyInstance()
{
if ( m_instance != NULL )
{
delete m_instance;
m_instance = NULL;
}
}
protected:
Singleton(){}
virtual ~Singleton(){}
//Not implemented since these methods should *NEVER* been called. If they do, it probably won't compile :)
Singleton(const Singleton<T>&);
Singleton<T>& operator=(const Singleton<T>&);
private:
static T* m_instance;
};
template <typename T>
T* Singleton<T>::m_instance = NULL;
#endif // SINGLETON_HPP
......@@ -56,6 +56,7 @@ ListViewMediaItem* LibraryWidget::addMedia( QFileInfo* fileInfo, ListViewMediaI
ListViewMediaItem* item = new ListViewMediaItem( fileInfo, fileType );
emit listViewMediaAdded( item );
m_medias->append( item );
m_mediaHash[item->getClip()->getUuid()] = item->getClip();
switch ( fileType )
{
case ListViewMediaItem::Audio:
......@@ -164,3 +165,11 @@ void LibraryWidget::changeEvent( QEvent *e )
break;
}
}
Clip* LibraryWidget::getClip( const QUuid& uuid )
{
QHash<QUuid, Clip*>::iterator it = m_mediaHash.find( uuid );
if ( it == m_mediaHash.end() )
return NULL;
return *it;
}
......@@ -33,11 +33,15 @@
#include <QMimeData>
#include <QDrag>
#include <QList>
#include <QHash>
#include <QUuid>
#include <QSettings>
#include "ListViewMediaItem.h"
#include "ui_LibraryWidget.h"
#include "Clip.h"
#include "Singleton.hpp"
class LibraryWidget : public QWidget
class LibraryWidget : public QWidget, public Singleton<LibraryWidget>
{
Q_OBJECT
......@@ -48,14 +52,16 @@ public:
ListViewMediaItem* addMedia( QFileInfo* fileInfo, ListViewMediaItem::fType fileType );
bool removeMedia( ListViewMediaItem* item );
int getIndex( ListViewMediaItem* media );
Clip* getClip( const QUuid& uuid );
protected:
virtual void changeEvent( QEvent *e );
private:
ListViewMediaItem* insertNewMedia( QString filename, ListViewMediaItem::fType fileType );
void insertNewMediasFromFileDialog( QString title, QString filter, ListViewMediaItem::fType fileType );
Ui::LibraryWidget m_ui;
static QList<ListViewMediaItem*>* m_medias;
Ui::LibraryWidget m_ui;
static QList<ListViewMediaItem*>* m_medias;
QHash<QUuid, Clip*> m_mediaHash;
private slots:
void on_pushButtonAddMedia_clicked();
......@@ -63,6 +69,8 @@ private slots:
signals:
void listViewMediaAdded(ListViewMediaItem* item);
friend class Singleton<LibraryWidget>;
};
#endif /* !LIBRARYWIDGET_H */
......@@ -54,7 +54,8 @@ HEADERS += src/gui/MainWindow.h \
src/gui/Transcode.h \
src/gui/Slider.h \
src/MetaDataManager.h \
src/LibVLCpp/VLCMediaList.h
src/LibVLCpp/VLCMediaList.h \
src/Singleton.hpp
FORMS += src/gui/ui/MainWindow.ui \
src/gui/ui/PreviewWidget.ui \
src/gui/ui/Preferences.ui \
......
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