Commit 09960e99 authored by Christophe Courtaut's avatar Christophe Courtaut

Partial Library Code documentation

parent fec0e4c2
......@@ -26,27 +26,29 @@
* It can load and unload Medias (Medias.h/Media.cpp)
*/
#include <QtDebug>
#include <QMessageBox>
#include <QDomElement>
#include <QUuid>
#include <QHash>
#include "Clip.h"
#include "Library.h"
#include "Media.h"
#include "Clip.h"
#include "MetaDataManager.h"
#include <QDebug>
#include <QDomElement>
#include <QHash>
#include <QMessageBox>
#include <QUuid>
Library::Library()
{
}
Media* Library::getMedia( const QUuid& uuid )
Media*
Library::getMedia( const QUuid& uuid )
{
return getElementByUuid( m_medias, uuid );
}
Clip* Library::getClip( const QUuid& uuid )
Clip*
Library::getClip( const QUuid& uuid )
{
Clip* clip;
clip = getElementByUuid( m_clips, uuid );
......@@ -54,7 +56,8 @@ Clip* Library::getClip( const QUuid& uuid )
return clip;
}
void Library::removingMediaAsked( const QUuid& uuid )
void
Library::removingMediaAsked( const QUuid& uuid )
{
QHash<QUuid, Media*>::iterator it = m_medias.find( uuid );
if ( it == m_medias.end() )
......@@ -69,7 +72,8 @@ void Library::removingMediaAsked( const QUuid& uuid )
deleteMedia( media );
}
void Library::deleteMedia( Media *media )
void
Library::deleteMedia( Media *media )
{
if ( media->getMetadata() == Media::ParsedWithAudioSpectrum )
delete media;
......@@ -80,7 +84,8 @@ void Library::deleteMedia( Media *media )
}
}
void Library::audioSpectrumComputed( Media *media )
void
Library::audioSpectrumComputed( Media *media )
{
disconnect( media, SIGNAL( audioSpectrumComputed( Media* ) ), this, SLOT( audioSpectrumComputed( Media* ) ) );
if ( m_mediaToDelete.contains( media ) )
......@@ -90,7 +95,8 @@ void Library::audioSpectrumComputed( Media *media )
}
}
void Library::metaDataComputed( Media* media )
void
Library::metaDataComputed( Media* media )
{
emit newMediaLoaded( media );
Clip* clip = new Clip( media );
......@@ -107,7 +113,8 @@ void Library::metaDataComputed( Media* media )
}
}
void Library::newMediaLoadingAsked( const QString& filePath, const QString& uuid )
void
Library::newMediaLoadingAsked( const QString& filePath, const QString& uuid )
{
Media* media;
if ( mediaAlreadyLoaded( filePath ) == true )
......@@ -118,7 +125,8 @@ void Library::newMediaLoadingAsked( const QString& filePath, const QStrin
emit metadataRequired( media );
}
void Library::addMedia( Media* media )
void
Library::addMedia( Media* media )
{
QUuid id;
foreach( id, m_medias.keys() )
......@@ -140,7 +148,8 @@ void Library::addClip( Clip* clip )
m_clips[clip->getUuid()] = clip;
}
void Library::loadMedia( const QString& path, const QUuid& uuid )
void
Library::loadMedia( const QString& path, const QUuid& uuid )
{
Media* it;
foreach ( it, m_medias )
......@@ -164,7 +173,8 @@ void Library::loadMedia( const QString& path, const QUuid& uuid )
m_medias[uuid] = media;
}
bool Library::mediaAlreadyLoaded( const QString& filePath )
bool
Library::mediaAlreadyLoaded( const QString& filePath )
{
Media* media;
foreach ( media, m_medias )
......@@ -175,7 +185,8 @@ bool Library::mediaAlreadyLoaded( const QString& filePath )
return false;
}
void Library::loadProject( const QDomElement& medias )
void
Library::loadProject( const QDomElement& medias )
{
if ( medias.isNull() == true || medias.tagName() != "medias" )
{
......@@ -230,7 +241,8 @@ void Library::loadProject( const QDomElement& medias )
emit projectLoaded();
}
void Library::saveProject( QDomDocument& doc, QDomElement& rootNode )
void
Library::saveProject( QDomDocument& doc, QDomElement& rootNode )
{
QHash<QUuid, Media*>::iterator it = m_medias.begin();
QHash<QUuid, Media*>::iterator end = m_medias.end();
......@@ -258,7 +270,8 @@ void Library::saveProject( QDomDocument& doc, QDomElement& rootNode )
rootNode.appendChild( medias );
}
void Library::clear()
void
Library::clear()
{
QHash<QUuid, Media*>::iterator it = m_medias.begin();
QHash<QUuid, Media*>::iterator end = m_medias.end();
......
......@@ -21,57 +21,113 @@
*****************************************************************************/
/** \file
* This file the library contains class declaration/definition.
* It's the the backend part of the Library widget of vlmc.
* It can load and unload Clips (Clip.h/Clip.cpp)
*/
* This file the library contains class declaration/definition.
* It's the the backend part of the Library widget of vlmc.
* It can load and unload Clips (Clip.h/Clip.cpp)
*/
#ifndef LIBRARY_H
#define LIBRARY_H
#include <QObject>
#include "Singleton.hpp"
#include <QHash>
#include <QObject>
#include <QUuid>
#include "Singleton.hpp"
class QDomDocument;
class QDomElement;
class Media;
class Clip;
class Media;
class Library : public QObject, public Singleton<Library>
/**
* \class Library
* \brief Library Object that handles medias
*/
class Library : public QObject, public Singleton<Library>
{
Q_OBJECT
Q_DISABLE_COPY( Library );
public:
Media* getMedia( const QUuid& uuid );
Clip* getClip( const QUuid& uudi );
/**
* \brief Add Media with already computed metadatas
* \param media The media to add.
* \brief returns the media that match the unique identifier
* \param uuid the unique identifier of the media
* \return a pointer to the required media, or NULL if no medias matches
* \sa getClip( const QUuid& uuid )
*/
Media* getMedia( const QUuid& uuid );
/**
* \brief returns the clip that match the unique identifier
* \param uuid the unique identifier of the media
* \return a pointer to the required clip, or NULL if no clips matches
* \sa getMedia( const QUuid& uuid )
*/
void addMedia( Media* media );
void deleteMedia( Media* media );
void addClip( Clip* clip );
Clip* getClip( const QUuid& uuid );
/**
* \brief Add the media with already computed metadatas to the library
* \param media The media to add.
* \sa addClip( Clip* clip )
* \sa getMedia( const QUuid& uuid)
* \sa getClip( const QUuid& uuid )
*/
void addMedia( Media* media );
/**
* \brief Add the clip to the library
* \param clip The clip to add.
* \sa addMedia( Media* media )
* \sa getMedia( const QUuid& uuid)
* \sa getClip( const QUuid& uuid )
*/
void addClip( Clip* clip );
/**
* \brief Delete the media.
* \param the media to delete
* \warning this method does not seem to remove the media from the library
*/
void deleteMedia( Media* media );
private:
/**
* \brief Library Object Constructor
*/
Library();
/**
* \brief Tells the media has already been loaded into library or not
* \param filePath The path of the media file
* \return true if the media is already loaded, false otherwhise
*/
bool mediaAlreadyLoaded( const QString& filePath );
/**
* \brief This method is used to load a media directly from it's
* path, with a specified UUID.
* It shouldn't used for something else that loading a project file
**/
* \brief This method is used to load a media directly from it's
* path, with a specified UUID.
* It shouldn't used for something else that loading a project file
* \param path The path of the media file
* \param uuid The uuid you want for the new media
*/
void loadMedia( const QString& path, const QUuid& uuid );
/**
* \brief The List of medias loaded into the library
*/
QHash<QUuid, Media*> m_medias;
/**
* \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 The list of media being queued for deletion
*/
QList<Media*> m_mediaToDelete;
/**
* \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
* \param uuid The uuid of the element you are looking for
*/
template <typename T>
T getElementByUuid( const QHash<QUuid, T>& container , const QUuid& uuid )
T getElementByUuid( const QHash<QUuid, T>& container ,
const QUuid& uuid )
{
typename QHash<QUuid, T>::const_iterator it = container.find( uuid );
if ( it == container.end() )
......@@ -80,7 +136,17 @@ private:
}
public slots:
void newMediaLoadingAsked( const QString& filePath, const QString& uuid = QString() );
/**
* \brief This slot must be called when you want a new media to be loaded
* \param filePath The path of the media
* \param uuid The uuid of the newly created media, by default create a new one
*/
void newMediaLoadingAsked( const QString& filePath,
const QString& uuid = QString() );
/**
* \brief This slot must be called when you want a media to be removed from library
* \param uuid The uuid of the media to be removed
*/
void removingMediaAsked( const QUuid& uuid );
void loadProject( const QDomElement& project );
......@@ -89,14 +155,25 @@ public slots:
* \brief Clear the library (remove all the loaded media and delete them)
*/
void clear();
private slots:
void metaDataComputed( Media* );
void audioSpectrumComputed( Media* media );
signals:
void metadataRequired( Media* );
void newMediaLoaded( Media* );
/**
* \brief This signal should be emitted to begin metadata computing
* \param media The media you want to compute the metadata
*/
void metadataRequired( Media* media );
/**
* \brief This signal should be emiteted to tell a new media have been loaded
* \param media The newly loaded media
*/
void newMediaLoaded( Media* media );
/**
* \brief This signal should be emiteted when a media has been removed
* \param uuid The removed media uuid
*/
void mediaRemoved( const QUuid& );
void projectLoaded();
......
......@@ -26,19 +26,19 @@
* and start it.
*/
#include "MainWindow.h"
#include <QApplication>
#include <QSettings>
#include <QPalette>
#include <QColor>
#include "MainWindow.h"
#include <QPalette>
#include <QSettings>
#ifndef VLMC_VERSION
#define VLMC_VERSION Unknown
#endif
#define EXPAND(x) #x
#define STRINGIFY(x) EXPAND(x)
#define EXPAND( x ) #x
#define STRINGIFY( x ) EXPAND( x )
/**
* VLMC Entry point
......@@ -47,7 +47,8 @@
* \param argv
* \return Return value of vlmc
*/
int main( int argc, char **argv )
int
main( int argc, char **argv )
{
QApplication app( argc, argv );
app.setApplicationName( "vlmc" );
......@@ -89,7 +90,7 @@ int main( int argc, char **argv )
MainWindow w;
QSettings s;
s.setValue( "VlmcVersion", STRINGIFY(VLMC_VERSION) );
s.setValue( "VlmcVersion", STRINGIFY( VLMC_VERSION ) );
w.show();
return app.exec();
}
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