mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 00:24:12 +02:00
fix up a bit
This commit is contained in:
@@ -52,6 +52,7 @@ DynamicPlaylist::DynamicPlaylist ( const Tomahawk::source_ptr& src,
|
|||||||
{
|
{
|
||||||
qDebug() << "Creating Dynamic Playlist 1";
|
qDebug() << "Creating Dynamic Playlist 1";
|
||||||
// TODO instantiate generator
|
// TODO instantiate generator
|
||||||
|
m_generator = geninterface_ptr( GeneratorFactory::create( type ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -65,46 +66,52 @@ DynamicPlaylist::DynamicPlaylist ( const Tomahawk::source_ptr& author,
|
|||||||
bool shared )
|
bool shared )
|
||||||
: Playlist ( author, guid, title, info, creator, shared )
|
: Playlist ( author, guid, title, info, creator, shared )
|
||||||
{
|
{
|
||||||
qDebug() << "Creating Dynamic Playlist 2";
|
qDebug() << "Creating Dynamic Playlist 2";
|
||||||
// TODO instantiate generator
|
m_generator = geninterface_ptr( GeneratorFactory::create( type ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
geninterface_ptr DynamicPlaylist::generator() const
|
geninterface_ptr
|
||||||
|
DynamicPlaylist::generator() const
|
||||||
{
|
{
|
||||||
return m_generator;
|
return m_generator;
|
||||||
}
|
}
|
||||||
|
|
||||||
GeneratorMode DynamicPlaylist::mode() const
|
GeneratorMode
|
||||||
|
DynamicPlaylist::mode() const
|
||||||
{
|
{
|
||||||
return m_generator->mode();
|
return m_generator->mode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicPlaylist::setGenerator(const Tomahawk::geninterface_ptr& gen_ptr)
|
void
|
||||||
|
DynamicPlaylist::setGenerator(const Tomahawk::geninterface_ptr& gen_ptr)
|
||||||
{
|
{
|
||||||
m_generator = gen_ptr;
|
m_generator = gen_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DynamicPlaylist::type() const
|
QString
|
||||||
|
DynamicPlaylist::type() const
|
||||||
{
|
{
|
||||||
return m_generator->type();
|
return m_generator->type();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicPlaylist::setMode(GeneratorMode mode)
|
void
|
||||||
|
DynamicPlaylist::setMode(GeneratorMode mode)
|
||||||
{
|
{
|
||||||
m_generator->setMode( mode );
|
m_generator->setMode( mode );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dynplaylist_ptr DynamicPlaylist::create( const Tomahawk::source_ptr& author,
|
dynplaylist_ptr
|
||||||
|
DynamicPlaylist::create( const Tomahawk::source_ptr& author,
|
||||||
const QString& guid,
|
const QString& guid,
|
||||||
const QString& title,
|
const QString& title,
|
||||||
const QString& info,
|
const QString& info,
|
||||||
const QString& creator,
|
const QString& creator,
|
||||||
bool shared )
|
bool shared )
|
||||||
{
|
{
|
||||||
// TODO default generator?
|
// default generator
|
||||||
QString type = "default_generator";
|
QString type = "";
|
||||||
dynplaylist_ptr dynplaylist = dynplaylist_ptr( new DynamicPlaylist( author, guid, title, info, creator, type, shared ) );
|
dynplaylist_ptr dynplaylist = dynplaylist_ptr( new DynamicPlaylist( author, guid, title, info, creator, type, shared ) );
|
||||||
|
|
||||||
DatabaseCommand_CreateDynamicPlaylist* cmd = new DatabaseCommand_CreateDynamicPlaylist( author, dynplaylist );
|
DatabaseCommand_CreateDynamicPlaylist* cmd = new DatabaseCommand_CreateDynamicPlaylist( author, dynplaylist );
|
||||||
@@ -116,7 +123,8 @@ dynplaylist_ptr DynamicPlaylist::create( const Tomahawk::source_ptr& author,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create a new revision that will be a static playlist, as it has entries
|
// create a new revision that will be a static playlist, as it has entries
|
||||||
void DynamicPlaylist::createNewRevision( const QString& newrev,
|
void
|
||||||
|
DynamicPlaylist::createNewRevision( const QString& newrev,
|
||||||
const QString& oldrev,
|
const QString& oldrev,
|
||||||
const QString& type,
|
const QString& type,
|
||||||
const QList< dyncontrol_ptr>& controls,
|
const QList< dyncontrol_ptr>& controls,
|
||||||
@@ -142,13 +150,14 @@ void DynamicPlaylist::createNewRevision( const QString& newrev,
|
|||||||
orderedguids,
|
orderedguids,
|
||||||
added,
|
added,
|
||||||
type,
|
type,
|
||||||
OnDemand,
|
Static,
|
||||||
controls );
|
controls );
|
||||||
APP->database()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
APP->database()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a new revision that will be an ondemand playlist, as it has no entries
|
// create a new revision that will be an ondemand playlist, as it has no entries
|
||||||
void DynamicPlaylist::createNewRevision( const QString& newrev,
|
void
|
||||||
|
DynamicPlaylist::createNewRevision( const QString& newrev,
|
||||||
const QString& oldrev,
|
const QString& oldrev,
|
||||||
const QString& type,
|
const QString& type,
|
||||||
const QList< dyncontrol_ptr>& controls )
|
const QList< dyncontrol_ptr>& controls )
|
||||||
@@ -162,12 +171,13 @@ void DynamicPlaylist::createNewRevision( const QString& newrev,
|
|||||||
newrev,
|
newrev,
|
||||||
oldrev,
|
oldrev,
|
||||||
type,
|
type,
|
||||||
Static,
|
OnDemand,
|
||||||
controls );
|
controls );
|
||||||
APP->database()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
APP->database()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicPlaylist::loadRevision( const QString& rev )
|
void
|
||||||
|
DynamicPlaylist::loadRevision( const QString& rev )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
@@ -206,29 +216,37 @@ void DynamicPlaylist::loadRevision( const QString& rev )
|
|||||||
APP->database()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
APP->database()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DynamicPlaylist::remove( const Tomahawk::dynplaylist_ptr& playlist )
|
bool
|
||||||
|
DynamicPlaylist::remove( const Tomahawk::dynplaylist_ptr& playlist )
|
||||||
{
|
{
|
||||||
return Playlist::remove( playlist.staticCast<Tomahawk::Playlist>() );
|
// TODO
|
||||||
|
// DatabaseCommand_DeletePlaylist* cmd = new DatabaseCommand_DeletePlaylist( playlist->author(), playlist->guid() );
|
||||||
|
// APP->database()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicPlaylist::reportCreated( const Tomahawk::dynplaylist_ptr& self )
|
void
|
||||||
|
DynamicPlaylist::reportCreated( const Tomahawk::dynplaylist_ptr& self )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
Q_ASSERT( self.data() == this );
|
Q_ASSERT( self.data() == this );
|
||||||
// will emit Collection::playlistCreated(...)
|
// will emit Collection::playlistCreated(...)
|
||||||
author()->collection()->addPlaylist( self.staticCast<Tomahawk::Playlist>() );
|
author()->collection()->addDynamicPlaylist( self );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicPlaylist::reportDeleted( const Tomahawk::dynplaylist_ptr& self )
|
void
|
||||||
|
DynamicPlaylist::reportDeleted( const Tomahawk::dynplaylist_ptr& self )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
Q_ASSERT( self.data() == this );
|
Q_ASSERT( self.data() == this );
|
||||||
// will emit Collection::playlistCreated(...)
|
// will emit Collection::playlistCreated(...)
|
||||||
author()->collection()->deletePlaylist( self.staticCast<Tomahawk::Playlist>() );
|
author()->collection()->deleteDynamicPlaylist( self );
|
||||||
}
|
}
|
||||||
|
|
||||||
// static version
|
// static version
|
||||||
void DynamicPlaylist::setRevision( const QString& rev,
|
void
|
||||||
|
DynamicPlaylist::setRevision( const QString& rev,
|
||||||
const QList< QString >& neworderedguids,
|
const QList< QString >& neworderedguids,
|
||||||
const QList< QString >& oldorderedguids,
|
const QList< QString >& oldorderedguids,
|
||||||
const QString& type,
|
const QString& type,
|
||||||
@@ -273,7 +291,8 @@ void DynamicPlaylist::setRevision( const QString& rev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ondemand version
|
// ondemand version
|
||||||
void DynamicPlaylist::setRevision( const QString& rev,
|
void
|
||||||
|
DynamicPlaylist::setRevision( const QString& rev,
|
||||||
bool is_newest_rev,
|
bool is_newest_rev,
|
||||||
const QString& type,
|
const QString& type,
|
||||||
const QList< dyncontrol_ptr>& controls,
|
const QList< dyncontrol_ptr>& controls,
|
||||||
|
@@ -7,6 +7,9 @@ QHash< QString, GeneratorFactoryInterface* > GeneratorFactory::s_factories = QHa
|
|||||||
|
|
||||||
geninterface_ptr GeneratorFactory::create ( const QString& type )
|
geninterface_ptr GeneratorFactory::create ( const QString& type )
|
||||||
{
|
{
|
||||||
|
if( type.isEmpty() && !s_factories.isEmpty() ) // default, return first
|
||||||
|
return geninterface_ptr( s_factories.begin().value()->create() );
|
||||||
|
|
||||||
if( !s_factories.contains( type ) )
|
if( !s_factories.contains( type ) )
|
||||||
return geninterface_ptr();
|
return geninterface_ptr();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user