Commit a63f0e5d authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Library: Don't inherit MediaContainer

parent 34508ae4
......@@ -94,31 +94,27 @@ void
Library::addMedia( Media* media )
{
setCleanState( false );
MediaContainer::addMedia( media );
}
Media*
Library::addMedia( const QFileInfo &fileInfo )
{
Media* media = MediaContainer::addMedia( fileInfo );
if ( media != nullptr )
{
setCleanState( false );
connect( media, SIGNAL( metaDataComputed( const Media* ) ),
this, SLOT( mediaLoaded( const Media* ) ), Qt::QueuedConnection );
m_medias[fileInfo.absoluteFilePath()] = media;
}
return media;
if ( m_medias.contains( media->fileInfo()->absoluteFilePath() ) )
return;
m_medias[media->fileInfo()->absoluteFilePath()] = media;
}
bool
Library::addClip( Clip *clip )
{
bool ret = MediaContainer::addClip( clip );
if ( ret != false )
setCleanState( false );
foreach ( Clip* c, m_clips.values() )
{
if ( clip->uuid() == c->uuid() ||
( clip->media()->fileInfo() == c->media()->fileInfo() &&
( clip->begin() == c->begin() && clip->end() == c->end() ) ) )
{
vlmcWarning() << "Clip already loaded.";
return false;
}
}
setCleanState( false );
m_medias[clip->media()->fileInfo()->absoluteFilePath()] = clip->media();
return ret;
return true;
}
bool
......@@ -133,6 +129,26 @@ Library::media(const QString& mrl)
return m_medias.value( mrl );
}
Clip*
Library::clip( const QString& uuid )
{
return m_clips.value( uuid );
}
Clip*
Library::clip( const QUuid& uuid )
{
return clip( uuid.toString() );
}
void
Library::clear()
{
m_medias.clear();
m_clips.clear();
setCleanState( true );
}
void
Library::setCleanState( bool newState )
{
......
......@@ -30,8 +30,8 @@
#ifndef LIBRARY_H
#define LIBRARY_H
#include "MediaContainer.h"
#include <QObject>
#include <QHash>
class Clip;
class Media;
......@@ -42,7 +42,7 @@ class Settings;
* \class Library
* \brief Library Object that handles public Clips
*/
class Library : public MediaContainer
class Library : public QObject
{
Q_OBJECT
Q_DISABLE_COPY( Library )
......@@ -51,10 +51,18 @@ public:
Library( Settings* projectSettings );
virtual ~Library();
virtual void addMedia( Media* media );
virtual Media *addMedia( const QFileInfo &fileInfo );
virtual bool addClip( Clip *clip );
bool isInCleanState() const;
Media* media( const QString& mrl );
/**
* @brief clip returns an existing clip
* @param uuid the clip's UUID
* @return The clip if it exists, or nullptr
* This can be any clip, the given UUID doesn't have to refer to a root clip
*/
Clip* clip( const QString& uuid );
Clip* clip( const QUuid& uuid );
void clear();
private:
void setCleanState( bool newState );
......@@ -63,6 +71,13 @@ private:
bool m_cleanState;
Settings* m_settings;
QHash<QString, Media*> m_medias;
/**
* @brief m_clips contains all the clips loaded in the library, without any
* subclip hierarchy
*/
QHash<QUuid, Clip*> m_clips;
void preSave();
void postLoad();
......
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