mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-17 19:37:09 +02:00
* Stations shouldn't depend on widgets / controls.
This commit is contained in:
committed by
Michael Zanetti
parent
2841593a85
commit
f3a50bedbd
@@ -225,7 +225,10 @@ GlobalActionManager::copyPlaylistToClipboard( const dynplaylist_ptr& playlist )
|
|||||||
TomahawkUtils::urlAddQueryItem( link, "type", "echonest" );
|
TomahawkUtils::urlAddQueryItem( link, "type", "echonest" );
|
||||||
TomahawkUtils::urlAddQueryItem( link, "title", playlist->title() );
|
TomahawkUtils::urlAddQueryItem( link, "title", playlist->title() );
|
||||||
|
|
||||||
QList< dyncontrol_ptr > controls = playlist->generator()->controls();
|
Q_ASSERT( false );
|
||||||
|
//FIXME
|
||||||
|
/*
|
||||||
|
QVariantList controls = playlist->generator()->controls();
|
||||||
foreach ( const dyncontrol_ptr& c, controls )
|
foreach ( const dyncontrol_ptr& c, controls )
|
||||||
{
|
{
|
||||||
if ( c->selectedType() == "Artist" )
|
if ( c->selectedType() == "Artist" )
|
||||||
@@ -252,7 +255,7 @@ GlobalActionManager::copyPlaylistToClipboard( const dynplaylist_ptr& playlist )
|
|||||||
|
|
||||||
TomahawkUtils::urlAddQueryItem( link, name, c->input() );
|
TomahawkUtils::urlAddQueryItem( link, name, c->input() );
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
QClipboard* cb = QApplication::clipboard();
|
QClipboard* cb = QApplication::clipboard();
|
||||||
QByteArray data = percentEncode( link );
|
QByteArray data = percentEncode( link );
|
||||||
@@ -886,7 +889,8 @@ GlobalActionManager::loadDynamicPlaylist( const QUrl& url, bool station )
|
|||||||
return Tomahawk::dynplaylist_ptr();
|
return Tomahawk::dynplaylist_ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( parts[ 0 ] == "create" )
|
Q_ASSERT( false );
|
||||||
|
/* if ( parts[ 0 ] == "create" )
|
||||||
{
|
{
|
||||||
if ( !urlHasQueryItem( url, "title" ) || !urlHasQueryItem( url, "type" ) )
|
if ( !urlHasQueryItem( url, "title" ) || !urlHasQueryItem( url, "type" ) )
|
||||||
{
|
{
|
||||||
@@ -1057,7 +1061,7 @@ GlobalActionManager::loadDynamicPlaylist( const QUrl& url, bool station )
|
|||||||
|
|
||||||
ViewManager::instance()->show( pl );
|
ViewManager::instance()->show( pl );
|
||||||
return pl;
|
return pl;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return Tomahawk::dynplaylist_ptr();
|
return Tomahawk::dynplaylist_ptr();
|
||||||
}
|
}
|
||||||
|
@@ -52,7 +52,7 @@ DatabaseCommand_LoadDynamicPlaylistEntries::exec( DatabaseImpl* dbi )
|
|||||||
QString type;
|
QString type;
|
||||||
GeneratorMode mode;
|
GeneratorMode mode;
|
||||||
|
|
||||||
QList< QVariantMap > controls;
|
QVariantList controls;
|
||||||
QString playlist_guid;
|
QString playlist_guid;
|
||||||
// qDebug() << "Loading controls..." << revisionGuid();
|
// qDebug() << "Loading controls..." << revisionGuid();
|
||||||
// qDebug() << "SELECT playlist_revision.playlist, controls, plmode, pltype "
|
// qDebug() << "SELECT playlist_revision.playlist, controls, plmode, pltype "
|
||||||
@@ -71,7 +71,7 @@ DatabaseCommand_LoadDynamicPlaylistEntries::exec( DatabaseImpl* dbi )
|
|||||||
type = controlsQuery.value( 3 ).toString();
|
type = controlsQuery.value( 3 ).toString();
|
||||||
mode = static_cast<GeneratorMode>( controlsQuery.value( 2 ).toInt() );
|
mode = static_cast<GeneratorMode>( controlsQuery.value( 2 ).toInt() );
|
||||||
|
|
||||||
QStringList controlIds = v.toStringList();
|
/* QStringList controlIds = v.toStringList();
|
||||||
// qDebug() << "Got controls in dynamic playlist, loading:" << controlIds << controlsQuery.value(1);
|
// qDebug() << "Got controls in dynamic playlist, loading:" << controlIds << controlsQuery.value(1);
|
||||||
foreach( const QString& controlId, controlIds )
|
foreach( const QString& controlId, controlIds )
|
||||||
{
|
{
|
||||||
@@ -91,7 +91,7 @@ DatabaseCommand_LoadDynamicPlaylistEntries::exec( DatabaseImpl* dbi )
|
|||||||
c[ "input" ] = controlQuery.value( 2 ).toString();
|
c[ "input" ] = controlQuery.value( 2 ).toString();
|
||||||
controls << c;
|
controls << c;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -47,14 +47,14 @@ signals:
|
|||||||
void done( QString,
|
void done( QString,
|
||||||
bool,
|
bool,
|
||||||
QString,
|
QString,
|
||||||
QList< QVariantMap>,
|
QVariantList,
|
||||||
bool );
|
bool );
|
||||||
// used when loading a static playlist
|
// used when loading a static playlist
|
||||||
void done( QString,
|
void done( QString,
|
||||||
QList< QString >,
|
QList< QString >,
|
||||||
QList< QString >,
|
QList< QString >,
|
||||||
QString,
|
QString,
|
||||||
QList< QVariantMap>,
|
QVariantList,
|
||||||
bool,
|
bool,
|
||||||
QMap< QString, Tomahawk::plentry_ptr >,
|
QMap< QString, Tomahawk::plentry_ptr >,
|
||||||
bool );
|
bool );
|
||||||
|
@@ -37,7 +37,7 @@ DatabaseCommand_SetDynamicPlaylistRevision::DatabaseCommand_SetDynamicPlaylistRe
|
|||||||
const QList<plentry_ptr>& entries,
|
const QList<plentry_ptr>& entries,
|
||||||
const QString& type,
|
const QString& type,
|
||||||
GeneratorMode mode,
|
GeneratorMode mode,
|
||||||
const QList< dyncontrol_ptr >& controls )
|
const QVariantList& controls )
|
||||||
: DatabaseCommand_SetPlaylistRevision( s, playlistguid, newrev, oldrev, orderedguids, addedentries, entries )
|
: DatabaseCommand_SetPlaylistRevision( s, playlistguid, newrev, oldrev, orderedguids, addedentries, entries )
|
||||||
, m_type( type )
|
, m_type( type )
|
||||||
, m_mode( mode )
|
, m_mode( mode )
|
||||||
@@ -54,7 +54,7 @@ DatabaseCommand_SetDynamicPlaylistRevision::DatabaseCommand_SetDynamicPlaylistRe
|
|||||||
const QString& oldrev,
|
const QString& oldrev,
|
||||||
const QString& type,
|
const QString& type,
|
||||||
GeneratorMode mode,
|
GeneratorMode mode,
|
||||||
const QList< dyncontrol_ptr >& controls )
|
const QVariantList& controls )
|
||||||
: DatabaseCommand_SetPlaylistRevision( s, playlistguid, newrev, oldrev, QStringList(), QList< plentry_ptr >(), QList< plentry_ptr >() )
|
: DatabaseCommand_SetPlaylistRevision( s, playlistguid, newrev, oldrev, QStringList(), QList< plentry_ptr >(), QList< plentry_ptr >() )
|
||||||
, m_type( type )
|
, m_type( type )
|
||||||
, m_mode( mode )
|
, m_mode( mode )
|
||||||
@@ -68,18 +68,7 @@ DatabaseCommand_SetDynamicPlaylistRevision::DatabaseCommand_SetDynamicPlaylistRe
|
|||||||
QVariantList
|
QVariantList
|
||||||
DatabaseCommand_SetDynamicPlaylistRevision::controlsV()
|
DatabaseCommand_SetDynamicPlaylistRevision::controlsV()
|
||||||
{
|
{
|
||||||
if ( m_controls.isEmpty() )
|
return m_controls;
|
||||||
return m_controlsV;
|
|
||||||
|
|
||||||
if ( !m_controls.isEmpty() && m_controlsV.isEmpty() )
|
|
||||||
{
|
|
||||||
foreach ( const dyncontrol_ptr& control, m_controls )
|
|
||||||
{
|
|
||||||
m_controlsV << QJson::QObjectHelper::qobject2qvariant( control.data() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_controlsV;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -117,7 +106,7 @@ DatabaseCommand_SetDynamicPlaylistRevision::postCommitHook()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !m_controlsV.isEmpty() && m_controls.isEmpty() )
|
/* if ( !m_controlsV.isEmpty() && m_controls.isEmpty() )
|
||||||
{
|
{
|
||||||
QList<QVariantMap> controlMap;
|
QList<QVariantMap> controlMap;
|
||||||
foreach( const QVariant& v, m_controlsV )
|
foreach( const QVariant& v, m_controlsV )
|
||||||
@@ -139,7 +128,7 @@ DatabaseCommand_SetDynamicPlaylistRevision::postCommitHook()
|
|||||||
m_addedmap,
|
m_addedmap,
|
||||||
m_applied );
|
m_applied );
|
||||||
}
|
}
|
||||||
else
|
else*/
|
||||||
{
|
{
|
||||||
if ( m_mode == OnDemand )
|
if ( m_mode == OnDemand )
|
||||||
rawPl->setRevision( newrev(),
|
rawPl->setRevision( newrev(),
|
||||||
@@ -169,20 +158,10 @@ DatabaseCommand_SetDynamicPlaylistRevision::exec( DatabaseImpl* lib )
|
|||||||
DatabaseCommand_SetPlaylistRevision::exec( lib );
|
DatabaseCommand_SetPlaylistRevision::exec( lib );
|
||||||
|
|
||||||
QVariantList newcontrols;
|
QVariantList newcontrols;
|
||||||
if ( m_controlsV.isEmpty() && !m_controls.isEmpty() )
|
foreach( const QVariant& v, m_controls )
|
||||||
{
|
|
||||||
foreach( const dyncontrol_ptr& control, m_controls )
|
|
||||||
{
|
|
||||||
newcontrols << control->id();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( !m_controlsV.isEmpty() )
|
|
||||||
{
|
|
||||||
foreach( const QVariant& v, m_controlsV )
|
|
||||||
{
|
{
|
||||||
newcontrols << v.toMap().value( "id" );
|
newcontrols << v.toMap().value( "id" );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
QJson::Serializer ser;
|
QJson::Serializer ser;
|
||||||
const QByteArray newcontrols_data = ser.serialize( newcontrols );
|
const QByteArray newcontrols_data = ser.serialize( newcontrols );
|
||||||
@@ -209,23 +188,8 @@ DatabaseCommand_SetDynamicPlaylistRevision::exec( DatabaseImpl* lib )
|
|||||||
TomahawkSqlQuery controlsQuery = lib->newquery();
|
TomahawkSqlQuery controlsQuery = lib->newquery();
|
||||||
controlsQuery.prepare( "INSERT INTO dynamic_playlist_controls( id, playlist, selectedType, match, input ) "
|
controlsQuery.prepare( "INSERT INTO dynamic_playlist_controls( id, playlist, selectedType, match, input ) "
|
||||||
"VALUES( ?, ?, ?, ?, ? )" );
|
"VALUES( ?, ?, ?, ?, ? )" );
|
||||||
if ( m_controlsV.isEmpty() && !m_controls.isEmpty() )
|
|
||||||
{
|
|
||||||
foreach ( const dyncontrol_ptr& control, m_controls )
|
|
||||||
{
|
|
||||||
qDebug() << "inserting dynamic control:" << control->id() << m_playlistguid << control->selectedType() << control->match() << control->input();
|
|
||||||
controlsQuery.addBindValue( control->id() );
|
|
||||||
controlsQuery.addBindValue( m_playlistguid );
|
|
||||||
controlsQuery.addBindValue( control->selectedType() );
|
|
||||||
controlsQuery.addBindValue( control->match() );
|
|
||||||
controlsQuery.addBindValue( control->input() );
|
|
||||||
|
|
||||||
controlsQuery.exec();
|
foreach ( const QVariant& v, m_controls )
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
foreach ( const QVariant& v, m_controlsV )
|
|
||||||
{
|
{
|
||||||
QVariantMap control = v.toMap();
|
QVariantMap control = v.toMap();
|
||||||
qDebug() << "inserting dynamic control from JSON:" << control.value( "id" ) << m_playlistguid << control.value( "selectedType" ) << control.value( "match" ) << control.value( "input" );
|
qDebug() << "inserting dynamic control from JSON:" << control.value( "id" ) << m_playlistguid << control.value( "selectedType" ) << control.value( "match" ) << control.value( "input" );
|
||||||
@@ -237,7 +201,6 @@ DatabaseCommand_SetDynamicPlaylistRevision::exec( DatabaseImpl* lib )
|
|||||||
|
|
||||||
controlsQuery.exec();
|
controlsQuery.exec();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( m_applied )
|
if ( m_applied )
|
||||||
{
|
{
|
||||||
@@ -252,6 +215,7 @@ DatabaseCommand_SetDynamicPlaylistRevision::exec( DatabaseImpl* lib )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DatabaseCommand_SetDynamicPlaylistRevision::setPlaylist( DynamicPlaylist* pl )
|
DatabaseCommand_SetDynamicPlaylistRevision::setPlaylist( DynamicPlaylist* pl )
|
||||||
{
|
{
|
||||||
|
@@ -45,7 +45,7 @@ public:
|
|||||||
const QList<plentry_ptr>& entries,
|
const QList<plentry_ptr>& entries,
|
||||||
const QString& type,
|
const QString& type,
|
||||||
GeneratorMode mode,
|
GeneratorMode mode,
|
||||||
const QList< dyncontrol_ptr >& controls );
|
const QVariantList& controls );
|
||||||
|
|
||||||
explicit DatabaseCommand_SetDynamicPlaylistRevision( const source_ptr& s,
|
explicit DatabaseCommand_SetDynamicPlaylistRevision( const source_ptr& s,
|
||||||
const QString& playlistguid,
|
const QString& playlistguid,
|
||||||
@@ -53,7 +53,7 @@ public:
|
|||||||
const QString& oldrev,
|
const QString& oldrev,
|
||||||
const QString& type,
|
const QString& type,
|
||||||
GeneratorMode mode,
|
GeneratorMode mode,
|
||||||
const QList< dyncontrol_ptr >& controls );
|
const QVariantList& controls );
|
||||||
|
|
||||||
QString commandname() const { return "setdynamicplaylistrevision"; }
|
QString commandname() const { return "setdynamicplaylistrevision"; }
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ public:
|
|||||||
|
|
||||||
void setControlsV( const QVariantList& vlist )
|
void setControlsV( const QVariantList& vlist )
|
||||||
{
|
{
|
||||||
m_controlsV = vlist;
|
m_controls = vlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantList controlsV();
|
QVariantList controlsV();
|
||||||
@@ -80,8 +80,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
QString m_type;
|
QString m_type;
|
||||||
GeneratorMode m_mode;
|
GeneratorMode m_mode;
|
||||||
QList< dyncontrol_ptr > m_controls;
|
QVariantList m_controls;
|
||||||
QList< QVariant > m_controlsV;
|
|
||||||
|
|
||||||
// ARG i hate sharedpointers sometimes
|
// ARG i hate sharedpointers sometimes
|
||||||
DynamicPlaylist* m_playlist; // Only used if setting revision of a non-autoloaded playlist, as those aren't able to be looked up by guid
|
DynamicPlaylist* m_playlist; // Only used if setting revision of a non-autoloaded playlist, as those aren't able to be looked up by guid
|
||||||
|
@@ -185,7 +185,7 @@ void
|
|||||||
DynamicPlaylist::createNewRevision( const QString& newrev,
|
DynamicPlaylist::createNewRevision( const QString& newrev,
|
||||||
const QString& oldrev,
|
const QString& oldrev,
|
||||||
const QString& type,
|
const QString& type,
|
||||||
const QList< dyncontrol_ptr>& controls,
|
const QVariantList& controls,
|
||||||
const QList< plentry_ptr >& entries )
|
const QList< plentry_ptr >& entries )
|
||||||
{
|
{
|
||||||
Q_ASSERT( m_source->isLocal() || newrev == oldrev );
|
Q_ASSERT( m_source->isLocal() || newrev == oldrev );
|
||||||
@@ -233,7 +233,7 @@ void
|
|||||||
DynamicPlaylist::createNewRevision( const QString& newrev,
|
DynamicPlaylist::createNewRevision( const QString& newrev,
|
||||||
const QString& oldrev,
|
const QString& oldrev,
|
||||||
const QString& type,
|
const QString& type,
|
||||||
const QList< dyncontrol_ptr>& controls )
|
const QVariantList& controls )
|
||||||
{
|
{
|
||||||
Q_ASSERT( m_source->isLocal() || newrev == oldrev );
|
Q_ASSERT( m_source->isLocal() || newrev == oldrev );
|
||||||
|
|
||||||
@@ -275,19 +275,19 @@ DynamicPlaylist::loadRevision( const QString& rev )
|
|||||||
connect( cmd, SIGNAL( done( QString,
|
connect( cmd, SIGNAL( done( QString,
|
||||||
bool,
|
bool,
|
||||||
QString,
|
QString,
|
||||||
QList< QVariantMap >,
|
QVariantList,
|
||||||
bool ) ),
|
bool ) ),
|
||||||
SLOT( setRevision( QString,
|
SLOT( setRevision( QString,
|
||||||
bool,
|
bool,
|
||||||
QString,
|
QString,
|
||||||
QList< QVariantMap >,
|
QVariantList,
|
||||||
bool) ) );
|
bool) ) );
|
||||||
} else if ( m_generator->mode() == Static ) {
|
} else if ( m_generator->mode() == Static ) {
|
||||||
connect( cmd, SIGNAL( done( QString,
|
connect( cmd, SIGNAL( done( QString,
|
||||||
QList< QString >,
|
QList< QString >,
|
||||||
QList< QString >,
|
QList< QString >,
|
||||||
QString,
|
QString,
|
||||||
QList< QVariantMap >,
|
QVariantList,
|
||||||
bool,
|
bool,
|
||||||
QMap< QString, Tomahawk::plentry_ptr >,
|
QMap< QString, Tomahawk::plentry_ptr >,
|
||||||
bool ) ),
|
bool ) ),
|
||||||
@@ -295,7 +295,7 @@ DynamicPlaylist::loadRevision( const QString& rev )
|
|||||||
QList< QString >,
|
QList< QString >,
|
||||||
QList< QString >,
|
QList< QString >,
|
||||||
QString,
|
QString,
|
||||||
QList< QVariantMap >,
|
QVariantList,
|
||||||
bool,
|
bool,
|
||||||
QMap< QString, Tomahawk::plentry_ptr >,
|
QMap< QString, Tomahawk::plentry_ptr >,
|
||||||
bool ) ) );
|
bool ) ) );
|
||||||
@@ -376,7 +376,7 @@ 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,
|
||||||
const QList< dyncontrol_ptr >& controls,
|
const QVariantList& controls,
|
||||||
bool is_newest_rev,
|
bool is_newest_rev,
|
||||||
const QMap< QString, plentry_ptr >& addedmap,
|
const QMap< QString, plentry_ptr >& addedmap,
|
||||||
bool applied )
|
bool applied )
|
||||||
@@ -391,7 +391,7 @@ DynamicPlaylist::setRevision( const QString& rev,
|
|||||||
Q_ARG( QList<QString> , neworderedguids ),
|
Q_ARG( QList<QString> , neworderedguids ),
|
||||||
Q_ARG( QList<QString> , oldorderedguids ),
|
Q_ARG( QList<QString> , oldorderedguids ),
|
||||||
Q_ARG( QString , type ),
|
Q_ARG( QString , type ),
|
||||||
QGenericArgument( "QList< Tomahawk::dyncontrol_ptr > " , (const void*)&controls ),
|
Q_ARG( QVariantList , controls ),
|
||||||
Q_ARG( bool, is_newest_rev ),
|
Q_ARG( bool, is_newest_rev ),
|
||||||
QGenericArgument( "QMap< QString,Tomahawk::plentry_ptr > " , (const void*)&addedmap ),
|
QGenericArgument( "QMap< QString,Tomahawk::plentry_ptr > " , (const void*)&addedmap ),
|
||||||
Q_ARG( bool, applied ) );
|
Q_ARG( bool, applied ) );
|
||||||
@@ -421,42 +421,11 @@ DynamicPlaylist::setRevision( const QString& rev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DynamicPlaylist::setRevision( const QString& rev,
|
|
||||||
const QList< QString >& neworderedguids,
|
|
||||||
const QList< QString >& oldorderedguids,
|
|
||||||
const QString& type,
|
|
||||||
const QList< QVariantMap>& controlsV,
|
|
||||||
bool is_newest_rev,
|
|
||||||
const QMap< QString, Tomahawk::plentry_ptr >& addedmap,
|
|
||||||
bool applied )
|
|
||||||
{
|
|
||||||
if ( QThread::currentThread() != thread() )
|
|
||||||
{
|
|
||||||
QMetaObject::invokeMethod( this,
|
|
||||||
"setRevision",
|
|
||||||
Qt::BlockingQueuedConnection,
|
|
||||||
Q_ARG( QString, rev ),
|
|
||||||
Q_ARG( QList<QString> , neworderedguids ),
|
|
||||||
Q_ARG( QList<QString> , oldorderedguids ),
|
|
||||||
Q_ARG( QString , type ),
|
|
||||||
QGenericArgument( "QList< QVariantMap > " , (const void*)&controlsV ),
|
|
||||||
Q_ARG( bool, is_newest_rev ),
|
|
||||||
QGenericArgument( "QMap< QString,Tomahawk::plentry_ptr > " , (const void*)&addedmap ),
|
|
||||||
Q_ARG( bool, applied ) );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<dyncontrol_ptr> controls = variantsToControl( controlsV );
|
|
||||||
setRevision( rev, neworderedguids, oldorderedguids, type, controls, is_newest_rev, addedmap, applied );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicPlaylist::setRevision( const QString& rev,
|
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 QVariantList& controls,
|
||||||
bool applied )
|
bool applied )
|
||||||
{
|
{
|
||||||
if ( QThread::currentThread() != thread() )
|
if ( QThread::currentThread() != thread() )
|
||||||
@@ -498,32 +467,7 @@ DynamicPlaylist::setRevision( const QString& rev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
/*QList< dyncontrol_ptr >
|
||||||
DynamicPlaylist::setRevision( const QString& rev,
|
|
||||||
bool is_newest_rev,
|
|
||||||
const QString& type,
|
|
||||||
const QList< QVariantMap >& controlsV,
|
|
||||||
bool applied )
|
|
||||||
{
|
|
||||||
if ( QThread::currentThread() != thread() )
|
|
||||||
{
|
|
||||||
QMetaObject::invokeMethod( this,
|
|
||||||
"setRevision",
|
|
||||||
Qt::BlockingQueuedConnection,
|
|
||||||
Q_ARG( QString, rev ),
|
|
||||||
Q_ARG( bool, is_newest_rev ),
|
|
||||||
Q_ARG( QString, type ),
|
|
||||||
QGenericArgument( "QList< QVariantMap >" , (const void*)&controlsV ),
|
|
||||||
Q_ARG( bool, applied ) );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<dyncontrol_ptr> controls = variantsToControl( controlsV );
|
|
||||||
setRevision( rev, is_newest_rev, type, controls, applied );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QList< dyncontrol_ptr >
|
|
||||||
DynamicPlaylist::variantsToControl( const QList< QVariantMap >& controlsV )
|
DynamicPlaylist::variantsToControl( const QList< QVariantMap >& controlsV )
|
||||||
{
|
{
|
||||||
QList<dyncontrol_ptr> realControls;
|
QList<dyncontrol_ptr> realControls;
|
||||||
@@ -534,7 +478,7 @@ DynamicPlaylist::variantsToControl( const QList< QVariantMap >& controlsV )
|
|||||||
realControls << control;
|
realControls << control;
|
||||||
}
|
}
|
||||||
return realControls;
|
return realControls;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -49,10 +49,10 @@ class DatabaseCommand_LoadDynamicPlaylist;
|
|||||||
struct DynQueueItem : RevisionQueueItem
|
struct DynQueueItem : RevisionQueueItem
|
||||||
{
|
{
|
||||||
QString type;
|
QString type;
|
||||||
QList <dyncontrol_ptr> controls;
|
QVariantList controls;
|
||||||
int mode;
|
int mode;
|
||||||
|
|
||||||
DynQueueItem( const QString& nRev, const QString& oRev, const QString& typ, const QList< dyncontrol_ptr >& ctrls, int m, const QList< plentry_ptr >& e, bool latest ) :
|
DynQueueItem( const QString& nRev, const QString& oRev, const QString& typ, const QVariantList& ctrls, int m, const QList< plentry_ptr >& e, bool latest ) :
|
||||||
RevisionQueueItem( nRev, oRev, e, latest ), type( typ ), controls( ctrls ), mode( m ) {}
|
RevisionQueueItem( nRev, oRev, e, latest ), type( typ ), controls( ctrls ), mode( m ) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -125,9 +125,9 @@ public slots:
|
|||||||
// want to update the playlist from the model?
|
// want to update the playlist from the model?
|
||||||
// generate a newrev using uuid() and call this:
|
// generate a newrev using uuid() and call this:
|
||||||
// if this is a static playlist, pass it a new list of entries. implicitly sets mode to static
|
// if this is a static playlist, pass it a new list of entries. implicitly sets mode to static
|
||||||
void createNewRevision( const QString& newrev, const QString& oldrev, const QString& type, const QList< dyncontrol_ptr>& controls, const QList< plentry_ptr >& entries );
|
void createNewRevision( const QString& newrev, const QString& oldrev, const QString& type, const QVariantList& controls, const QList< plentry_ptr >& entries );
|
||||||
// if it is ondemand, no entries are needed implicitly sets mode to ondemand
|
// if it is ondemand, no entries are needed implicitly sets mode to ondemand
|
||||||
void createNewRevision( const QString& newrev, const QString& oldrev, const QString& type, const QList< dyncontrol_ptr>& controls );
|
void createNewRevision( const QString& newrev, const QString& oldrev, const QString& type, const QVariantList& controls );
|
||||||
|
|
||||||
void reportCreated( const Tomahawk::dynplaylist_ptr& self );
|
void reportCreated( const Tomahawk::dynplaylist_ptr& self );
|
||||||
void reportDeleted( const Tomahawk::dynplaylist_ptr& self );
|
void reportDeleted( const Tomahawk::dynplaylist_ptr& self );
|
||||||
@@ -142,15 +142,7 @@ public slots:
|
|||||||
const QList<QString>& neworderedguids,
|
const QList<QString>& neworderedguids,
|
||||||
const QList<QString>& oldorderedguids,
|
const QList<QString>& oldorderedguids,
|
||||||
const QString& type,
|
const QString& type,
|
||||||
const QList< QVariantMap >& controls,
|
const QVariantList& controls,
|
||||||
bool is_newest_rev,
|
|
||||||
const QMap< QString, Tomahawk::plentry_ptr >& addedmap,
|
|
||||||
bool applied );
|
|
||||||
void setRevision( const QString& rev,
|
|
||||||
const QList<QString>& neworderedguids,
|
|
||||||
const QList<QString>& oldorderedguids,
|
|
||||||
const QString& type,
|
|
||||||
const QList< Tomahawk::dyncontrol_ptr >& controls,
|
|
||||||
bool is_newest_rev,
|
bool is_newest_rev,
|
||||||
const QMap< QString, Tomahawk::plentry_ptr >& addedmap,
|
const QMap< QString, Tomahawk::plentry_ptr >& addedmap,
|
||||||
bool applied );
|
bool applied );
|
||||||
@@ -158,13 +150,9 @@ public slots:
|
|||||||
void setRevision( const QString& rev,
|
void setRevision( const QString& rev,
|
||||||
bool is_newest_rev,
|
bool is_newest_rev,
|
||||||
const QString& type,
|
const QString& type,
|
||||||
const QList< QVariantMap>& controls,
|
const QVariantList& controls,
|
||||||
bool applied );
|
|
||||||
void setRevision( const QString& rev,
|
|
||||||
bool is_newest_rev,
|
|
||||||
const QString& type,
|
|
||||||
const QList< Tomahawk::dyncontrol_ptr>& controls,
|
|
||||||
bool applied );
|
bool applied );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// called from loadAllPlaylists DB cmd via databasecollection (in GUI thread)
|
// called from loadAllPlaylists DB cmd via databasecollection (in GUI thread)
|
||||||
explicit DynamicPlaylist( const source_ptr& src,
|
explicit DynamicPlaylist( const source_ptr& src,
|
||||||
@@ -192,8 +180,6 @@ private:
|
|||||||
|
|
||||||
void checkRevisionQueue();
|
void checkRevisionQueue();
|
||||||
|
|
||||||
QList< dyncontrol_ptr > variantsToControl( const QList< QVariantMap >& controlsV );
|
|
||||||
|
|
||||||
geninterface_ptr m_generator;
|
geninterface_ptr m_generator;
|
||||||
bool m_autoLoad;
|
bool m_autoLoad;
|
||||||
|
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
DynamicPlaylistRevision::DynamicPlaylistRevision(const PlaylistRevision &other)
|
DynamicPlaylistRevision::DynamicPlaylistRevision( const PlaylistRevision &other )
|
||||||
{
|
{
|
||||||
revisionguid = other.revisionguid;
|
revisionguid = other.revisionguid;
|
||||||
oldrevisionguid = other.oldrevisionguid;
|
oldrevisionguid = other.oldrevisionguid;
|
||||||
|
@@ -29,7 +29,7 @@ struct DLLEXPORT DynamicPlaylistRevision : PlaylistRevision
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QList< dyncontrol_ptr > controls;
|
QVariantList controls;
|
||||||
Tomahawk::GeneratorMode mode;
|
Tomahawk::GeneratorMode mode;
|
||||||
QString type;
|
QString type;
|
||||||
|
|
||||||
|
@@ -40,14 +40,14 @@ GeneratorFactory::create ( const QString& type )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
dyncontrol_ptr
|
/*dyncontrol_ptr
|
||||||
GeneratorFactory::createControl( const QString& generatorType, const QString& controlType )
|
GeneratorFactory::createControl( const QString& generatorType, const QString& controlType )
|
||||||
{
|
{
|
||||||
if( generatorType.isEmpty() || !s_factories.contains( generatorType ) )
|
if( generatorType.isEmpty() || !s_factories.contains( generatorType ) )
|
||||||
return dyncontrol_ptr();
|
return dyncontrol_ptr();
|
||||||
|
|
||||||
return s_factories.value( generatorType )->createControl( controlType );
|
return s_factories.value( generatorType )->createControl( controlType );
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -46,7 +46,7 @@ public:
|
|||||||
* Create a control for this generator, not tied to this generator itself. Used when loading dynamic
|
* Create a control for this generator, not tied to this generator itself. Used when loading dynamic
|
||||||
* playlists from a dbcmd.
|
* playlists from a dbcmd.
|
||||||
*/
|
*/
|
||||||
virtual dyncontrol_ptr createControl( const QString& controlType = QString() ) = 0;
|
// virtual dyncontrol_ptr createControl( const QString& controlType = QString() ) = 0;
|
||||||
|
|
||||||
virtual QStringList typeSelectors() const = 0;
|
virtual QStringList typeSelectors() const = 0;
|
||||||
};
|
};
|
||||||
@@ -59,7 +59,7 @@ class DLLEXPORT GeneratorFactory
|
|||||||
public:
|
public:
|
||||||
static geninterface_ptr create( const QString& type );
|
static geninterface_ptr create( const QString& type );
|
||||||
// only used when loading from dbcmd
|
// only used when loading from dbcmd
|
||||||
static dyncontrol_ptr createControl( const QString& generatorType, const QString& controlType = QString() );
|
// static dyncontrol_ptr createControl( const QString& generatorType, const QString& controlType = QString() );
|
||||||
|
|
||||||
static void registerFactory( const QString& type, GeneratorFactoryInterface* interface );
|
static void registerFactory( const QString& type, GeneratorFactoryInterface* interface );
|
||||||
static QStringList types();
|
static QStringList types();
|
||||||
|
@@ -34,17 +34,6 @@ Tomahawk::GeneratorInterface::~GeneratorInterface()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList< Tomahawk::dyncontrol_ptr >
|
|
||||||
Tomahawk::GeneratorInterface::controls()
|
|
||||||
{
|
|
||||||
// if( m_controls.isEmpty() ) { // return a default control (so the user can add more)
|
|
||||||
// return QList< Tomahawk::dyncontrol_ptr >() << createControl();
|
|
||||||
// }
|
|
||||||
|
|
||||||
return m_controls;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QPixmap
|
QPixmap
|
||||||
Tomahawk::GeneratorInterface::logo()
|
Tomahawk::GeneratorInterface::logo()
|
||||||
{
|
{
|
||||||
@@ -52,38 +41,15 @@ Tomahawk::GeneratorInterface::logo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
QVariantList
|
||||||
Tomahawk::GeneratorInterface::addControl( const Tomahawk::dyncontrol_ptr& control )
|
Tomahawk::GeneratorInterface::controls() const
|
||||||
{
|
{
|
||||||
m_controls << control;
|
return m_controls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Tomahawk::GeneratorInterface::clearControls()
|
Tomahawk::GeneratorInterface::setControls( const QVariantList& controls )
|
||||||
{
|
|
||||||
m_controls.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
Tomahawk::GeneratorInterface::setControls( const QList< Tomahawk::dyncontrol_ptr >& controls )
|
|
||||||
{
|
{
|
||||||
m_controls = controls;
|
m_controls = controls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
Tomahawk::GeneratorInterface::removeControl( const Tomahawk::dyncontrol_ptr& control )
|
|
||||||
{
|
|
||||||
m_controls.removeAll( control );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Tomahawk::dyncontrol_ptr
|
|
||||||
Tomahawk::GeneratorInterface::createControl( const QString& type )
|
|
||||||
{
|
|
||||||
Q_UNUSED( type );
|
|
||||||
Q_ASSERT( false );
|
|
||||||
return dyncontrol_ptr();
|
|
||||||
}
|
|
||||||
|
@@ -47,6 +47,7 @@ class DLLEXPORT GeneratorInterface : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY( QString type READ type )
|
Q_PROPERTY( QString type READ type )
|
||||||
|
Q_PROPERTY( QString summary READ sentenceSummary)
|
||||||
/// oh qjson.
|
/// oh qjson.
|
||||||
Q_PROPERTY( int mode READ mode WRITE setMode )
|
Q_PROPERTY( int mode READ mode WRITE setMode )
|
||||||
|
|
||||||
@@ -55,12 +56,6 @@ public:
|
|||||||
explicit GeneratorInterface( QObject* parent = 0 );
|
explicit GeneratorInterface( QObject* parent = 0 );
|
||||||
virtual ~GeneratorInterface();
|
virtual ~GeneratorInterface();
|
||||||
|
|
||||||
// Can't make it pure otherwise we can't shove it in QVariants :-/
|
|
||||||
// empty QString means use default
|
|
||||||
/// The generator will keep track of all the controls it creates. No need to tell it about controls
|
|
||||||
/// you ask it to create
|
|
||||||
virtual dyncontrol_ptr createControl( const QString& type = QString() );
|
|
||||||
|
|
||||||
/// A logo to display for this generator, if it has one
|
/// A logo to display for this generator, if it has one
|
||||||
virtual QPixmap logo();
|
virtual QPixmap logo();
|
||||||
|
|
||||||
@@ -98,17 +93,17 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual bool onDemandSteerable() const { return false; }
|
virtual bool onDemandSteerable() const { return false; }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a widget used to steer the OnDemand dynamic playlist.
|
* Returns the controls for this station.
|
||||||
* If this generator doesn't support this (and returns false for
|
|
||||||
* \c onDemandSteerable) this will be null. The generator is responsible
|
|
||||||
* for reacting to changes in the widget.
|
|
||||||
*
|
|
||||||
* Steering widgets may emit a \c steeringChanged() signal, which will cause the model to toss any
|
|
||||||
* upcoming tracks and re-fetch them.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
virtual QWidget* steeringWidget() { return 0; }
|
virtual QVariantList controls() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the controls (for example when loaded from database)
|
||||||
|
*/
|
||||||
|
virtual void setControls( const QVariantList& controls );
|
||||||
|
|
||||||
|
|
||||||
/// The type of this generator
|
/// The type of this generator
|
||||||
QString type() const { return m_type; }
|
QString type() const { return m_type; }
|
||||||
@@ -116,22 +111,20 @@ public:
|
|||||||
int mode() const { return (int)m_mode; }
|
int mode() const { return (int)m_mode; }
|
||||||
void setMode( int mode ) { m_mode = (GeneratorMode)mode; }
|
void setMode( int mode ) { m_mode = (GeneratorMode)mode; }
|
||||||
|
|
||||||
// control functions
|
virtual bool startFromTrack( const Tomahawk::query_ptr& query ) = 0;
|
||||||
QList< dyncontrol_ptr > controls();
|
virtual bool startFromArtist( const Tomahawk::artist_ptr& artist ) = 0;
|
||||||
void addControl( const dyncontrol_ptr& control );
|
virtual bool startFromGenre( const QString& genre ) = 0;
|
||||||
void clearControls();
|
|
||||||
void setControls( const QList< dyncontrol_ptr>& controls );
|
|
||||||
void removeControl( const dyncontrol_ptr& control );
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void error( const QString& title, const QString& body);
|
void error( const QString& title, const QString& body);
|
||||||
void generated( const QList< Tomahawk::query_ptr>& queries );
|
void generated( const QList< Tomahawk::query_ptr>& queries );
|
||||||
void nextTrackGenerated( const Tomahawk::query_ptr& track );
|
void nextTrackGenerated( const Tomahawk::query_ptr& track );
|
||||||
|
void summaryChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString m_type;
|
QString m_type;
|
||||||
GeneratorMode m_mode;
|
GeneratorMode m_mode;
|
||||||
QList< dyncontrol_ptr > m_controls;
|
QVariantList m_controls;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QSharedPointer<GeneratorInterface> geninterface_ptr;
|
typedef QSharedPointer<GeneratorInterface> geninterface_ptr;
|
||||||
|
@@ -36,10 +36,10 @@ namespace Tomahawk
|
|||||||
DatabaseFactory() {}
|
DatabaseFactory() {}
|
||||||
|
|
||||||
virtual GeneratorInterface* create();
|
virtual GeneratorInterface* create();
|
||||||
virtual dyncontrol_ptr createControl( const QString& controlType = QString() );
|
// virtual dyncontrol_ptr createControl( const QString& controlType = QString() );
|
||||||
|
|
||||||
// TO create a special SQL resolver that consists of a pre-baked SQL query and a description of it
|
// TO create a special SQL resolver that consists of a pre-baked SQL query and a description of it
|
||||||
virtual dyncontrol_ptr createControl( const QString& sql, DatabaseCommand_GenericSelect::QueryType type, const QString& summary );
|
// virtual dyncontrol_ptr createControl( const QString& sql, DatabaseCommand_GenericSelect::QueryType type, const QString& summary );
|
||||||
|
|
||||||
virtual QStringList typeSelectors() const;
|
virtual QStringList typeSelectors() const;
|
||||||
};
|
};
|
||||||
@@ -55,8 +55,8 @@ namespace Tomahawk
|
|||||||
explicit DatabaseGenerator( QObject* parent = 0 );
|
explicit DatabaseGenerator( QObject* parent = 0 );
|
||||||
virtual ~DatabaseGenerator();
|
virtual ~DatabaseGenerator();
|
||||||
|
|
||||||
virtual dyncontrol_ptr createControl( const QString& type = QString() );
|
/* virtual dyncontrol_ptr createControl( const QString& type = QString() );
|
||||||
virtual dyncontrol_ptr createControl( const QString& sql, DatabaseCommand_GenericSelect::QueryType type, const QString& summary );
|
virtual dyncontrol_ptr createControl( const QString& sql, DatabaseCommand_GenericSelect::QueryType type, const QString& summary );*/
|
||||||
|
|
||||||
virtual QPixmap logo();
|
virtual QPixmap logo();
|
||||||
virtual void generate ( int number = -1 );
|
virtual void generate ( int number = -1 );
|
||||||
|
@@ -61,11 +61,11 @@ EchonestFactory::create()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
dyncontrol_ptr
|
/*dyncontrol_ptr
|
||||||
EchonestFactory::createControl( const QString& controlType )
|
EchonestFactory::createControl( const QString& controlType )
|
||||||
{
|
{
|
||||||
return dyncontrol_ptr( new EchonestControl( controlType, typeSelectors() ) );
|
return dyncontrol_ptr( new EchonestControl( controlType, typeSelectors() ) );
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
QStringList
|
QStringList
|
||||||
@@ -160,12 +160,12 @@ EchonestGenerator::setupCatalogs()
|
|||||||
// qDebug() << "ECHONEST:" << m_logo.size();
|
// qDebug() << "ECHONEST:" << m_logo.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
dyncontrol_ptr
|
/*dyncontrol_ptr
|
||||||
EchonestGenerator::createControl( const QString& type )
|
EchonestGenerator::createControl( const QString& type )
|
||||||
{
|
{
|
||||||
m_controls << dyncontrol_ptr( new EchonestControl( type, GeneratorFactory::typeSelectors( m_type ) ) );
|
m_controls << dyncontrol_ptr( new EchonestControl( type, GeneratorFactory::typeSelectors( m_type ) ) );
|
||||||
return m_controls.last();
|
return m_controls.last();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
QPixmap EchonestGenerator::logo()
|
QPixmap EchonestGenerator::logo()
|
||||||
@@ -176,11 +176,11 @@ QPixmap EchonestGenerator::logo()
|
|||||||
void
|
void
|
||||||
EchonestGenerator::knownCatalogsChanged()
|
EchonestGenerator::knownCatalogsChanged()
|
||||||
{
|
{
|
||||||
// Refresh all contrls
|
/* // Refresh all contrls
|
||||||
foreach( const dyncontrol_ptr& control, m_controls )
|
foreach( const dyncontrol_ptr& control, m_controls )
|
||||||
{
|
{
|
||||||
control.staticCast< EchonestControl >()->updateWidgetsFromData();
|
control.staticCast< EchonestControl >()->updateWidgetsFromData();
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -188,7 +188,7 @@ void
|
|||||||
EchonestGenerator::generate( int number )
|
EchonestGenerator::generate( int number )
|
||||||
{
|
{
|
||||||
// convert to an echonest query, and fire it off
|
// convert to an echonest query, and fire it off
|
||||||
qDebug() << Q_FUNC_INFO;
|
/* qDebug() << Q_FUNC_INFO;
|
||||||
qDebug() << "Generating playlist with" << m_controls.size();
|
qDebug() << "Generating playlist with" << m_controls.size();
|
||||||
foreach( const dyncontrol_ptr& ctrl, m_controls )
|
foreach( const dyncontrol_ptr& ctrl, m_controls )
|
||||||
qDebug() << ctrl->selectedType() << ctrl->match() << ctrl->input();
|
qDebug() << ctrl->selectedType() << ctrl->match() << ctrl->input();
|
||||||
@@ -202,7 +202,16 @@ EchonestGenerator::generate( int number )
|
|||||||
} catch( std::runtime_error& e ) {
|
} catch( std::runtime_error& e ) {
|
||||||
qWarning() << "Got invalid controls!" << e.what();
|
qWarning() << "Got invalid controls!" << e.what();
|
||||||
emit error( "Filters are not valid", e.what() );
|
emit error( "Filters are not valid", e.what() );
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
QList< query_ptr > queries;
|
||||||
|
queries << Query::get("Colour Haze", "All", QString(), uuid(), true);
|
||||||
|
queries << Query::get("Colour Haze", "Sun", QString(), uuid(), true);
|
||||||
|
queries << Query::get("Colour Haze", "Zen", QString(), uuid(), true);
|
||||||
|
queries << Query::get("Colour Haze", "Outside", QString(), uuid(), true);
|
||||||
|
queries << Query::get("Colour Haze", "Dirt", QString(), uuid(), true);
|
||||||
|
|
||||||
|
emit generated( queries );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -226,6 +235,81 @@ EchonestGenerator::startOnDemand()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
EchonestGenerator::startFromTrack( const Tomahawk::query_ptr& query )
|
||||||
|
{
|
||||||
|
tDebug() << "Generating station content by query:" << query->toString();
|
||||||
|
|
||||||
|
Echonest::DynamicPlaylist::PlaylistParamData data;
|
||||||
|
data.first = Echonest::DynamicPlaylist::SongId;
|
||||||
|
data.second = query->track()->artist() + " " + query->track()->track();
|
||||||
|
|
||||||
|
Echonest::DynamicPlaylist::PlaylistParams params;
|
||||||
|
params.append( Echonest::DynamicPlaylist::PlaylistParamData( Echonest::DynamicPlaylist::Type, Echonest::DynamicPlaylist::SongRadioType ) );
|
||||||
|
params << data;
|
||||||
|
|
||||||
|
// FIXME!
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
EchonestGenerator::startFromArtist( const Tomahawk::artist_ptr& artist )
|
||||||
|
{
|
||||||
|
tDebug() << "Generating station content by artist:" << artist->name();
|
||||||
|
|
||||||
|
if ( !m_dynPlaylist->sessionId().isNull() )
|
||||||
|
{
|
||||||
|
// Running session, delete it
|
||||||
|
QNetworkReply* deleteReply = m_dynPlaylist->deleteSession();
|
||||||
|
connect( deleteReply, SIGNAL( finished() ), deleteReply, SLOT( deleteLater() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
connect( this, SIGNAL( paramsGenerated( Echonest::DynamicPlaylist::PlaylistParams ) ), this, SLOT( doStartOnDemand( Echonest::DynamicPlaylist::PlaylistParams ) ) );
|
||||||
|
|
||||||
|
Echonest::DynamicPlaylist::PlaylistParamData data;
|
||||||
|
data.first = Echonest::DynamicPlaylist::Artist;
|
||||||
|
data.second = artist->name();
|
||||||
|
|
||||||
|
Echonest::DynamicPlaylist::PlaylistParams params;
|
||||||
|
params << data;
|
||||||
|
// params.append( Echonest::DynamicPlaylist::PlaylistParamData( Echonest::DynamicPlaylist::Type, Echonest::DynamicPlaylist::SongRadioType ) );
|
||||||
|
emit paramsGenerated( params );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
EchonestGenerator::startFromGenre( const QString& genre )
|
||||||
|
{
|
||||||
|
tDebug() << "Generating station content by genre:" << genre;
|
||||||
|
|
||||||
|
if ( !m_dynPlaylist->sessionId().isNull() )
|
||||||
|
{
|
||||||
|
// Running session, delete it
|
||||||
|
QNetworkReply* deleteReply = m_dynPlaylist->deleteSession();
|
||||||
|
connect( deleteReply, SIGNAL( finished() ), deleteReply, SLOT( deleteLater() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
connect( this, SIGNAL( paramsGenerated( Echonest::DynamicPlaylist::PlaylistParams ) ), this, SLOT( doGenerate( Echonest::DynamicPlaylist::PlaylistParams ) ) );
|
||||||
|
|
||||||
|
setProperty( "number", 20 );
|
||||||
|
|
||||||
|
Echonest::DynamicPlaylist::PlaylistParamData data;
|
||||||
|
data.first = Echonest::DynamicPlaylist::Description;
|
||||||
|
data.second = genre;
|
||||||
|
|
||||||
|
Echonest::DynamicPlaylist::PlaylistParams params;
|
||||||
|
params << data;
|
||||||
|
params.append( Echonest::DynamicPlaylist::PlaylistParamData( Echonest::DynamicPlaylist::Type, Echonest::DynamicPlaylist::ArtistDescriptionType ) );
|
||||||
|
emit paramsGenerated( params );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
EchonestGenerator::doGenerate( const Echonest::DynamicPlaylist::PlaylistParams& paramsIn )
|
EchonestGenerator::doGenerate( const Echonest::DynamicPlaylist::PlaylistParams& paramsIn )
|
||||||
{
|
{
|
||||||
@@ -308,7 +392,7 @@ void
|
|||||||
EchonestGenerator::getParams() throw( std::runtime_error )
|
EchonestGenerator::getParams() throw( std::runtime_error )
|
||||||
{
|
{
|
||||||
Echonest::DynamicPlaylist::PlaylistParams params;
|
Echonest::DynamicPlaylist::PlaylistParams params;
|
||||||
foreach( const dyncontrol_ptr& control, m_controls ) {
|
/* foreach( const dyncontrol_ptr& control, m_controls ) {
|
||||||
params.append( control.dynamicCast<EchonestControl>()->toENParam() );
|
params.append( control.dynamicCast<EchonestControl>()->toENParam() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,7 +427,7 @@ EchonestGenerator::getParams() throw( std::runtime_error )
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
emit paramsGenerated( params );
|
emit paramsGenerated( params );
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -440,7 +524,7 @@ EchonestGenerator::userCatalogs()
|
|||||||
return s_catalogs->catalogs().keys();
|
return s_catalogs->catalogs().keys();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
/*bool
|
||||||
EchonestGenerator::onlyThisArtistType( Echonest::DynamicPlaylist::ArtistTypeEnum type ) const throw( std::runtime_error )
|
EchonestGenerator::onlyThisArtistType( Echonest::DynamicPlaylist::ArtistTypeEnum type ) const throw( std::runtime_error )
|
||||||
{
|
{
|
||||||
bool only = true;
|
bool only = true;
|
||||||
@@ -460,7 +544,7 @@ EchonestGenerator::onlyThisArtistType( Echonest::DynamicPlaylist::ArtistTypeEnum
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
Echonest::DynamicPlaylist::ArtistTypeEnum
|
Echonest::DynamicPlaylist::ArtistTypeEnum
|
||||||
@@ -477,7 +561,7 @@ EchonestGenerator::appendRadioType( Echonest::DynamicPlaylist::PlaylistParams& p
|
|||||||
/// 3. artist-description: If all the artist entries are Description. If some were but not all, error out.
|
/// 3. artist-description: If all the artist entries are Description. If some were but not all, error out.
|
||||||
/// 4. artist-radio: If all the artist entries are Similar To. If some were but not all, error out.
|
/// 4. artist-radio: If all the artist entries are Similar To. If some were but not all, error out.
|
||||||
/// 5. song-radio: If all the artist entries are Similar To. If some were but not all, error out.
|
/// 5. song-radio: If all the artist entries are Similar To. If some were but not all, error out.
|
||||||
bool someCatalog = false;
|
/* bool someCatalog = false;
|
||||||
bool genreType = false;
|
bool genreType = false;
|
||||||
foreach( const dyncontrol_ptr& control, m_controls ) {
|
foreach( const dyncontrol_ptr& control, m_controls ) {
|
||||||
if ( control->selectedType() == "User Radio" )
|
if ( control->selectedType() == "User Radio" )
|
||||||
@@ -498,7 +582,7 @@ EchonestGenerator::appendRadioType( Echonest::DynamicPlaylist::PlaylistParams& p
|
|||||||
else if( onlyThisArtistType( Echonest::DynamicPlaylist::SongRadioType ) )
|
else if( onlyThisArtistType( Echonest::DynamicPlaylist::SongRadioType ) )
|
||||||
params.append( Echonest::DynamicPlaylist::PlaylistParamData( Echonest::DynamicPlaylist::Type, Echonest::DynamicPlaylist::SongRadioType ) );
|
params.append( Echonest::DynamicPlaylist::PlaylistParamData( Echonest::DynamicPlaylist::Type, Echonest::DynamicPlaylist::SongRadioType ) );
|
||||||
else // no artist or song or description types. default to artist-description
|
else // no artist or song or description types. default to artist-description
|
||||||
params.append( Echonest::DynamicPlaylist::PlaylistParamData( Echonest::DynamicPlaylist::Type, Echonest::DynamicPlaylist::ArtistDescriptionType ) );
|
params.append( Echonest::DynamicPlaylist::PlaylistParamData( Echonest::DynamicPlaylist::Type, Echonest::DynamicPlaylist::ArtistDescriptionType ) );*/
|
||||||
|
|
||||||
return static_cast< Echonest::DynamicPlaylist::ArtistTypeEnum >( params.last().second.toInt() );
|
return static_cast< Echonest::DynamicPlaylist::ArtistTypeEnum >( params.last().second.toInt() );
|
||||||
}
|
}
|
||||||
@@ -529,7 +613,7 @@ EchonestGenerator::sentenceSummary()
|
|||||||
* NOTE / TODO: In order for the sentence to be grammatically correct, we must follow the EN API rules. That means we can't have multiple of some types of filters,
|
* NOTE / TODO: In order for the sentence to be grammatically correct, we must follow the EN API rules. That means we can't have multiple of some types of filters,
|
||||||
* and all Artist types must be the same. The filters aren't checked at the moment until Generate / Play is pressed. Consider doing a check on hide as well.
|
* and all Artist types must be the same. The filters aren't checked at the moment until Generate / Play is pressed. Consider doing a check on hide as well.
|
||||||
*/
|
*/
|
||||||
QList< dyncontrol_ptr > allcontrols = m_controls;
|
/* QList< dyncontrol_ptr > allcontrols = m_controls;
|
||||||
QString sentence = "Songs ";
|
QString sentence = "Songs ";
|
||||||
|
|
||||||
/// 1. Collect all required filters
|
/// 1. Collect all required filters
|
||||||
@@ -612,7 +696,9 @@ EchonestGenerator::sentenceSummary()
|
|||||||
sentence += "and " + sorting.dynamicCast< EchonestControl >()->summary() + ".";
|
sentence += "and " + sorting.dynamicCast< EchonestControl >()->summary() + ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
return sentence;
|
return sentence;*/
|
||||||
|
|
||||||
|
return "This is a station!";
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -60,7 +60,7 @@ public:
|
|||||||
EchonestFactory();
|
EchonestFactory();
|
||||||
|
|
||||||
virtual GeneratorInterface* create();
|
virtual GeneratorInterface* create();
|
||||||
virtual dyncontrol_ptr createControl( const QString& controlType = QString() );
|
// virtual dyncontrol_ptr createControl( const QString& controlType = QString() );
|
||||||
virtual QStringList typeSelectors() const;
|
virtual QStringList typeSelectors() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ public:
|
|||||||
explicit EchonestGenerator( QObject* parent = 0 );
|
explicit EchonestGenerator( QObject* parent = 0 );
|
||||||
virtual ~EchonestGenerator();
|
virtual ~EchonestGenerator();
|
||||||
|
|
||||||
virtual dyncontrol_ptr createControl( const QString& type = QString() );
|
// virtual dyncontrol_ptr createControl( const QString& type = QString() );
|
||||||
virtual QPixmap logo();
|
virtual QPixmap logo();
|
||||||
virtual void generate ( int number = -1 );
|
virtual void generate ( int number = -1 );
|
||||||
virtual void startOnDemand();
|
virtual void startOnDemand();
|
||||||
@@ -80,6 +80,10 @@ public:
|
|||||||
virtual bool onDemandSteerable() const { return false; }
|
virtual bool onDemandSteerable() const { return false; }
|
||||||
virtual QWidget* steeringWidget() { return 0; }
|
virtual QWidget* steeringWidget() { return 0; }
|
||||||
|
|
||||||
|
virtual bool startFromTrack( const Tomahawk::query_ptr& query );
|
||||||
|
virtual bool startFromArtist( const Tomahawk::artist_ptr& artist );
|
||||||
|
virtual bool startFromGenre( const QString& genre );
|
||||||
|
|
||||||
static QStringList styles();
|
static QStringList styles();
|
||||||
static QStringList moods();
|
static QStringList moods();
|
||||||
static QStringList genres();
|
static QStringList genres();
|
||||||
@@ -118,7 +122,7 @@ private:
|
|||||||
|
|
||||||
query_ptr queryFromSong( const Echonest::Song& song );
|
query_ptr queryFromSong( const Echonest::Song& song );
|
||||||
Echonest::DynamicPlaylist::ArtistTypeEnum appendRadioType( Echonest::DynamicPlaylist::PlaylistParams& params ) const throw( std::runtime_error );
|
Echonest::DynamicPlaylist::ArtistTypeEnum appendRadioType( Echonest::DynamicPlaylist::PlaylistParams& params ) const throw( std::runtime_error );
|
||||||
bool onlyThisArtistType( Echonest::DynamicPlaylist::ArtistTypeEnum type ) const throw( std::runtime_error );
|
// bool onlyThisArtistType( Echonest::DynamicPlaylist::ArtistTypeEnum type ) const throw( std::runtime_error );
|
||||||
|
|
||||||
void loadStylesMoodsAndGenres();
|
void loadStylesMoodsAndGenres();
|
||||||
|
|
||||||
|
@@ -163,7 +163,7 @@ CategoryAddItem::dropMimeData( const QMimeData* data, Qt::DropAction )
|
|||||||
|
|
||||||
QString firstArtist;
|
QString firstArtist;
|
||||||
// now we want to add each artist as a filter...
|
// now we want to add each artist as a filter...
|
||||||
QList< dyncontrol_ptr > contrls;
|
/* QList< dyncontrol_ptr > contrls;
|
||||||
while ( !stream.atEnd() )
|
while ( !stream.atEnd() )
|
||||||
{
|
{
|
||||||
QString artist;
|
QString artist;
|
||||||
@@ -183,7 +183,7 @@ CategoryAddItem::dropMimeData( const QMimeData* data, Qt::DropAction )
|
|||||||
QString name = firstArtist.isEmpty() ? tr( "New Station" ) : tr( "%1 Station" ).arg( firstArtist );
|
QString name = firstArtist.isEmpty() ? tr( "New Station" ) : tr( "%1 Station" ).arg( firstArtist );
|
||||||
newpl->createNewRevision( uuid(), newpl->currentrevision(), newpl->type(), contrls );
|
newpl->createNewRevision( uuid(), newpl->currentrevision(), newpl->type(), contrls );
|
||||||
newpl->setProperty( "newname", name );
|
newpl->setProperty( "newname", name );
|
||||||
connect( newpl.data(), SIGNAL( dynamicRevisionLoaded( Tomahawk::DynamicPlaylistRevision ) ), this, SLOT( playlistToRenameLoaded() ) );
|
connect( newpl.data(), SIGNAL( dynamicRevisionLoaded( Tomahawk::DynamicPlaylistRevision ) ), this, SLOT( playlistToRenameLoaded() ) );*/
|
||||||
|
|
||||||
ViewManager::instance()->show( newpl );
|
ViewManager::instance()->show( newpl );
|
||||||
return true;
|
return true;
|
||||||
@@ -295,7 +295,7 @@ CategoryAddItem::parsedDroppedTracks( const QList< query_ptr >& tracks )
|
|||||||
newpl->setMode( OnDemand );
|
newpl->setMode( OnDemand );
|
||||||
|
|
||||||
// now we want to add each query as a song or similar artist filter...
|
// now we want to add each query as a song or similar artist filter...
|
||||||
QList< dyncontrol_ptr > controls;
|
/* QList< dyncontrol_ptr > controls;
|
||||||
foreach ( const Tomahawk::query_ptr& q, tracks )
|
foreach ( const Tomahawk::query_ptr& q, tracks )
|
||||||
{
|
{
|
||||||
dyncontrol_ptr c = newpl->generator()->createControl( "Song" );
|
dyncontrol_ptr c = newpl->generator()->createControl( "Song" );
|
||||||
@@ -303,7 +303,7 @@ CategoryAddItem::parsedDroppedTracks( const QList< query_ptr >& tracks )
|
|||||||
controls << c;
|
controls << c;
|
||||||
}
|
}
|
||||||
|
|
||||||
newpl->createNewRevision( uuid(), newpl->currentrevision(), newpl->type(), controls );
|
newpl->createNewRevision( uuid(), newpl->currentrevision(), newpl->type(), controls );*/
|
||||||
|
|
||||||
ViewManager::instance()->show( newpl );
|
ViewManager::instance()->show( newpl );
|
||||||
connect( newpl.data(), SIGNAL( dynamicRevisionLoaded( Tomahawk::DynamicPlaylistRevision ) ), this, SLOT( playlistToRenameLoaded() ) );
|
connect( newpl.data(), SIGNAL( dynamicRevisionLoaded( Tomahawk::DynamicPlaylistRevision ) ), this, SLOT( playlistToRenameLoaded() ) );
|
||||||
|
Reference in New Issue
Block a user