Commit bd5891da authored by Geoffroy Lacarriere's avatar Geoffroy Lacarriere

Remove of the clip list in the library. All the clip are stocked in their respective medias.

There is a const baseClip on each media that correspond to the full media lenth.
parent b4a452f1
......@@ -64,10 +64,23 @@ Library::temporaryMedia( const QUuid& uuid )
Clip*
Library::clip( const QUuid& uuid )
{
Clip* clip;
clip = getElementByUuid( m_clips, uuid );
QUuid mediaUuid;
foreach( mediaUuid, m_medias.keys() )
{
Media* media = m_medias.value( mediaUuid );
if ( media != NULL && media->clips()->contains( uuid ) )
return dynamic_cast<Clip*>( getElementByUuid( *media->clips(), uuid ) );
}
return NULL;
}
return clip;
Clip*
Library::clip( const QUuid& mediaUuid, const QUuid& clipUuid )
{
Media* media = m_medias.value( mediaUuid );
if ( media == NULL )
return NULL;
return dynamic_cast<Clip*>( getElementByUuid( *media->clips(), clipUuid ) );
}
void
......@@ -151,8 +164,6 @@ Library::addMedia( const QFileInfo& fileInfo )
m_temporaryMedias[media->getUuid()] = media;
Clip* clip = new Clip( media );
m_clips[media->getUuid()] = clip;
m_progressDialog->setValue(m_nbLoadedMedias);
emit newMediaLoaded( media->getUuid() );
}
......@@ -160,7 +171,8 @@ Library::addMedia( const QFileInfo& fileInfo )
void
Library::addClip( Clip* clip )
{
m_clips[clip->getUuid()] = clip;
Media* media = m_medias[clip->getParent()->getUuid()];
media->addClip( clip );
}
void
......@@ -199,18 +211,6 @@ Library::metaDataComputed( Media* media )
SIGNAL( metaDataComputed( Media* ) ),
this,
SLOT( metaDataComputed( Media* ) ) );
Clip* clip = new Clip( media );
m_clips[media->getUuid()] = clip;
//If the media have some clip, add then to m_clips
const QHash<QUuid, Clip*>* clips = media->clips();
if ( clips->size() != 0 )
{
QHash<QUuid, Clip*>::const_iterator it = clips->begin();
QHash<QUuid, Clip*>::const_iterator ed = clips->end();
for ( ; it != ed; ++it )
m_clips[it.key()] = it.value();
}
}
void
......@@ -266,7 +266,7 @@ Library::loadFile( const QFileInfo& fileInfo, int loadingMedias )
addMedia( fileInfo );
else
{
m_progressDialog->setMaximum( m_loadingMedias - 1 );
m_progressDialog->setMaximum( m_loadingMedias-- );
m_progressDialog->setValue( ++m_nbLoadedMedias );
}
}
......@@ -384,14 +384,6 @@ Library::clear()
++it;
}
m_medias.clear();
QHash<QUuid, Clip*>::iterator it2 = m_clips.begin();
QHash<QUuid, Clip*>::iterator end2 = m_clips.end();
while ( it2 != end2 )
{
delete it2.value();
++it2;
}
m_clips.clear();
}
void
......
......@@ -77,27 +77,33 @@ public:
* \sa media( const QUuid& uuid )
*/
Clip* clip( const QUuid& uuid );
/**
* \brief returns the clip that match the unique identifier
* \param mediaUuid the unique identifier of the media
* \param clipUuid the unique identifier of the clip
* \return a pointer to the required clip, or NULL if no clips matches
* \sa media( const QUuid& uuid )
*/
Clip* clip( const QUuid& mediaUuid, const QUuid& clipUuid );
/**
* \brief returns the medias qHash
* \return a pointer to the medias qHash, or NULL if no there is no medias
* \sa temporaryMedias( const QUuid& uuid )
*/
QHash<QUuid, Media*>* medias() { return &m_medias; }
QHash<QUuid, Media*>* medias() { return &m_medias; }
/**
* \brief returns the temporary medias qHash
* \return a pointer to the temporary medias qHash, or NULL if no there is no medias
* \sa medias( const QUuid& uuid )
*/
QHash<QUuid, Media*>* temporaryMedias() { return &m_temporaryMedias; }
// /**
// * \brief Add the media with already computed metadatas to the library
// * \param media The media to add.
// * \sa addClip( Clip* clip )
// * \sa media( const QUuid& uuid)
// * \sa clip( const QUuid& uuid )
// */
// void addMedia( Media* media );
/**
* \brief Add the media with already computed metadatas to the library
* \param fileInfo the file info of the media
* \sa addClip( Clip* clip )
* \sa media( const QUuid& uuid)
* \sa clip( const QUuid& uuid )
*/
void addMedia( const QFileInfo& fileInfo );
/**
......@@ -167,11 +173,6 @@ private:
* \brief The list of media being queued for deletion
*/
QHash<QUuid, Media*> m_mediaToDelete;
/**
* \brief The List of clips loaded into the library
* \warning This list should be removed to used clips existing inside medias
*/
QHash<QUuid, Clip*> m_clips;
/**
* \brief This method allows to get whereas Media or clip by uuid
* \param container The type of container used for storage, where T is Clip or Media
......
......@@ -74,6 +74,7 @@ Media::Media( const QString& filePath, const QString& uuid /*= QString()*/ )
m_audioValueList = new QList<int>();
m_vlcMedia = new LibVLCpp::Media( m_mrl );
m_baseClip = new Clip( this );
}
Media::~Media()
......
......@@ -146,6 +146,7 @@ public:
QList<int>* getAudioValues() { return m_audioValueList; }
Clip* baseClip() { return m_baseClip; }
private:
void setFileType();
......@@ -168,6 +169,7 @@ protected:
MetadataState m_metadataState;
QString m_fileName;
QStringList m_metaTags;
Clip* m_baseClip;
QHash<QUuid, Clip*> m_clips;
QList<int>* m_audioValueList;
......
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