mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-23 01:09:42 +01:00
* Hopefully the last set of debug spam cleanup :-)
This commit is contained in:
parent
b2b836ff01
commit
5b9ab4b478
@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@ -41,7 +41,7 @@ ACLSystem::ACLSystem( QObject* parent )
|
||||
{
|
||||
s_instance = this;
|
||||
//qRegisterMetaType< QHash< QString, QHash< QString, ACL > > >("ACLSystem::ACLCacheHash");
|
||||
|
||||
|
||||
QStringList savedEntries = TomahawkSettings::instance()->aclEntries();
|
||||
if( !savedEntries.empty() && savedEntries.size() % 3 == 0 )
|
||||
{
|
||||
@ -54,7 +54,7 @@ ACLSystem::ACLSystem( QObject* parent )
|
||||
index += 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
m_saveTimer.setSingleShot( false );
|
||||
m_saveTimer.setInterval( 60000 );
|
||||
connect( &m_saveTimer, SIGNAL( timeout() ), this, SLOT( saveTimerFired() ) );
|
||||
@ -70,10 +70,10 @@ ACLSystem::~ACLSystem()
|
||||
ACLSystem::ACL
|
||||
ACLSystem::isAuthorizedUser( const QString& dbid )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
QMutexLocker locker( &m_cacheMutex );
|
||||
qDebug() << "Current cache keys = " << m_cache.keys();
|
||||
qDebug() << "Looking up dbid";
|
||||
qDebug() << "Current cache keys =" << m_cache.keys();
|
||||
// qDebug() << "Looking up dbid";
|
||||
if( !m_cache.contains( dbid ) )
|
||||
return ACLSystem::NotFound;
|
||||
else
|
||||
@ -88,12 +88,12 @@ ACLSystem::isAuthorizedUser( const QString& dbid )
|
||||
void
|
||||
ACLSystem::authorizeUser( const QString& dbid, ACLSystem::ACL globalType )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
if( globalType == ACLSystem::NotFound )
|
||||
return;
|
||||
|
||||
|
||||
QMutexLocker locker( &m_cacheMutex );
|
||||
|
||||
|
||||
QHash< QString, ACL > peerHash;
|
||||
if( m_cache.contains( dbid ) )
|
||||
peerHash = m_cache[dbid];
|
||||
@ -105,10 +105,10 @@ ACLSystem::ACL
|
||||
ACLSystem::isAuthorizedPath( const QString& dbid, const QString& path )
|
||||
{
|
||||
QMutexLocker locker( &m_cacheMutex );
|
||||
|
||||
|
||||
if( !m_cache.contains( dbid ) )
|
||||
return ACLSystem::NotFound;
|
||||
|
||||
|
||||
QHash< QString, ACL > peerHash = m_cache[dbid];
|
||||
if( !peerHash.contains( path ) )
|
||||
{
|
||||
|
@ -185,7 +185,7 @@ Collection::station( const QString& guid )
|
||||
void
|
||||
Collection::setPlaylists( const QList<Tomahawk::playlist_ptr>& plists )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << plists.count();
|
||||
// qDebug() << Q_FUNC_INFO << plists.count();
|
||||
foreach ( const playlist_ptr& p, plists )
|
||||
{
|
||||
// qDebug() << "Batch inserting playlist:" << p->guid();
|
||||
@ -198,7 +198,7 @@ Collection::setPlaylists( const QList<Tomahawk::playlist_ptr>& plists )
|
||||
void
|
||||
Collection::setAutoPlaylists( const QList< Tomahawk::dynplaylist_ptr >& plists )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << plists.count();
|
||||
// qDebug() << Q_FUNC_INFO << plists.count();
|
||||
|
||||
foreach ( const dynplaylist_ptr& p, plists )
|
||||
{
|
||||
@ -212,7 +212,7 @@ Collection::setAutoPlaylists( const QList< Tomahawk::dynplaylist_ptr >& plists )
|
||||
void
|
||||
Collection::setStations( const QList< dynplaylist_ptr >& stations )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << stations.count();
|
||||
// qDebug() << Q_FUNC_INFO << stations.count();
|
||||
|
||||
foreach ( const dynplaylist_ptr& s, stations )
|
||||
{
|
||||
@ -226,7 +226,7 @@ Collection::setStations( const QList< dynplaylist_ptr >& stations )
|
||||
void
|
||||
Collection::setTracks( const QList<Tomahawk::query_ptr>& tracks )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << tracks.count() << name();
|
||||
// qDebug() << Q_FUNC_INFO << tracks.count() << name();
|
||||
|
||||
m_tracks << tracks;
|
||||
emit tracksAdded( tracks );
|
||||
|
@ -38,7 +38,6 @@ DatabaseCollection::DatabaseCollection( const source_ptr& src, QObject* parent )
|
||||
void
|
||||
DatabaseCollection::loadPlaylists()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
DatabaseCommand_LoadAllPlaylists* cmd = new DatabaseCommand_LoadAllPlaylists( source() );
|
||||
|
||||
connect( cmd, SIGNAL( done( const QList<Tomahawk::playlist_ptr>& ) ),
|
||||
@ -51,7 +50,6 @@ DatabaseCollection::loadPlaylists()
|
||||
void
|
||||
DatabaseCollection::loadAutoPlaylists()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
DatabaseCommand_LoadAllAutoPlaylists* cmd = new DatabaseCommand_LoadAllAutoPlaylists( source() );
|
||||
|
||||
connect( cmd, SIGNAL( autoPlaylistLoaded( Tomahawk::source_ptr, QVariantList ) ),
|
||||
@ -60,10 +58,10 @@ DatabaseCollection::loadAutoPlaylists()
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DatabaseCollection::loadStations()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
DatabaseCommand_LoadAllStations* cmd = new DatabaseCommand_LoadAllStations( source() );
|
||||
|
||||
connect( cmd, SIGNAL( stationLoaded( Tomahawk::source_ptr, QVariantList ) ),
|
||||
@ -110,8 +108,6 @@ DatabaseCollection::removeTracks( const QDir& dir )
|
||||
QList< Tomahawk::playlist_ptr >
|
||||
DatabaseCollection::playlists()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
if ( Collection::playlists().isEmpty() )
|
||||
{
|
||||
loadPlaylists();
|
||||
@ -124,8 +120,6 @@ DatabaseCollection::playlists()
|
||||
QList< dynplaylist_ptr >
|
||||
DatabaseCollection::autoPlaylists()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
if ( Collection::autoPlaylists().isEmpty() )
|
||||
{
|
||||
loadAutoPlaylists();
|
||||
@ -134,11 +128,10 @@ DatabaseCollection::autoPlaylists()
|
||||
return Collection::autoPlaylists();
|
||||
}
|
||||
|
||||
|
||||
QList< dynplaylist_ptr >
|
||||
DatabaseCollection::stations()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
if ( Collection::stations().isEmpty() )
|
||||
{
|
||||
loadStations();
|
||||
@ -151,8 +144,6 @@ DatabaseCollection::stations()
|
||||
QList< Tomahawk::query_ptr >
|
||||
DatabaseCollection::tracks()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
if ( !isLoaded() )
|
||||
{
|
||||
loadTracks();
|
||||
@ -161,6 +152,7 @@ DatabaseCollection::tracks()
|
||||
return Collection::tracks();
|
||||
}
|
||||
|
||||
|
||||
void DatabaseCollection::autoPlaylistCreated( const source_ptr& source, const QVariantList& data )
|
||||
{
|
||||
dynplaylist_ptr p( new DynamicPlaylist( source, //src
|
||||
@ -177,6 +169,7 @@ void DatabaseCollection::autoPlaylistCreated( const source_ptr& source, const QV
|
||||
addAutoPlaylist( p );
|
||||
}
|
||||
|
||||
|
||||
void DatabaseCollection::stationCreated( const source_ptr& source, const QVariantList& data )
|
||||
{
|
||||
dynplaylist_ptr p( new DynamicPlaylist( source, //src
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@ -31,17 +31,18 @@
|
||||
class DatabaseCommand_LoadDynamicPlaylist : public DatabaseCommand_LoadPlaylistEntries
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
explicit DatabaseCommand_LoadDynamicPlaylist( QString revision_guid, QObject* parent = 0 )
|
||||
: DatabaseCommand_LoadPlaylistEntries( revision_guid, parent )
|
||||
{ qDebug() << "loaded with:" << revision_guid << guid(); }
|
||||
|
||||
|
||||
{
|
||||
// qDebug() << "loaded with:" << revision_guid << guid();
|
||||
}
|
||||
|
||||
virtual void exec( DatabaseImpl* );
|
||||
virtual bool doesMutates() const { return false; }
|
||||
virtual QString commandname() const { return "loaddynamicplaylist"; }
|
||||
|
||||
|
||||
signals:
|
||||
// used if loading an ondemand playlist
|
||||
void done( QString,
|
||||
@ -58,7 +59,7 @@ signals:
|
||||
bool,
|
||||
QMap< QString, Tomahawk::plentry_ptr >,
|
||||
bool );
|
||||
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
@ -108,31 +108,31 @@ Servent::startListening( QHostAddress ha, bool upnp, int port )
|
||||
defPortAlso = listen( ha, defPort );
|
||||
if( !defPortAlso )
|
||||
{
|
||||
qDebug() << "Failed to listen on both port " << m_port << " and port " << defPort;
|
||||
qDebug() << "Error string is " << errorString();
|
||||
qDebug() << "Failed to listen on both port" << m_port << "and port" << defPort;
|
||||
qDebug() << "Error string is" << errorString();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
qDebug() << "Servent listening on port " << defPort << " servent thread:" << thread();
|
||||
qDebug() << "Servent listening on port" << defPort << "servent thread:" << thread();
|
||||
}
|
||||
else
|
||||
{
|
||||
bool defPortAlso = listen( ha, defPort );
|
||||
qDebug() << "Servent listening on port " << m_port << " servent thread:" << thread();
|
||||
qDebug() << "Servent listening on port" << m_port << "servent thread:" << thread();
|
||||
if( defPortAlso )
|
||||
qDebug() << "Servent also listening on port " << defPort << " servent thread:" << thread();
|
||||
qDebug() << "Servent also listening on port" << defPort << "servent thread:" << thread();
|
||||
}
|
||||
|
||||
// --lanhack means to advertise your LAN IP over jabber as if it were externallyVisible
|
||||
qDebug() << "Address mode = " << (int)(TomahawkSettings::instance()->externalAddressMode());
|
||||
qDebug() << "Static host/port preferred ? = " << ( TomahawkSettings::instance()->preferStaticHostPort() ? "true" : "false" );
|
||||
qDebug() << "Address mode =" << (int)(TomahawkSettings::instance()->externalAddressMode());
|
||||
qDebug() << "Static host/port preferred =" << ( TomahawkSettings::instance()->preferStaticHostPort() ? "true" : "false" );
|
||||
|
||||
if( TomahawkSettings::instance()->preferStaticHostPort() )
|
||||
{
|
||||
qDebug() << "Forcing static preferred host and port";
|
||||
m_externalHostname = TomahawkSettings::instance()->externalHostname();
|
||||
m_externalPort = TomahawkSettings::instance()->externalPort();
|
||||
qDebug() << m_externalHostname << m_externalPort;
|
||||
// qDebug() << m_externalHostname << m_externalPort;
|
||||
emit ready();
|
||||
return true;
|
||||
}
|
||||
@ -176,7 +176,7 @@ Servent::startListening( QHostAddress ha, bool upnp, int port )
|
||||
QString
|
||||
Servent::createConnectionKey( const QString& name, const QString &nodeid, const QString &key, bool onceOnly )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
Q_ASSERT( this->thread() == QThread::currentThread() );
|
||||
|
||||
QString _key = ( key.isEmpty() ? uuid() : key );
|
||||
@ -226,7 +226,7 @@ Servent::registerOffer( const QString& key, Connection* conn )
|
||||
void
|
||||
Servent::registerControlConnection( ControlConnection* conn )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << conn->id();
|
||||
// qDebug() << Q_FUNC_INFO << conn->id();
|
||||
m_controlconnections.append( conn );
|
||||
}
|
||||
|
||||
@ -274,7 +274,7 @@ Servent::incomingConnection( int sd )
|
||||
|
||||
connect( sock, SIGNAL( readyRead() ), SLOT( readyRead() ), Qt::QueuedConnection );
|
||||
connect( sock, SIGNAL( disconnected() ), sock, SLOT( deleteLater() ), Qt::QueuedConnection );
|
||||
qDebug() << "connection accepted.";
|
||||
// qDebug() << "connection accepted.";
|
||||
}
|
||||
|
||||
|
||||
@ -324,13 +324,13 @@ Servent::readyRead()
|
||||
nodeid = m.value( "nodeid" ).toString();
|
||||
controlid = m.value( "controlid" ).toString();
|
||||
|
||||
qDebug() << "Incoming connection details: " << m;
|
||||
qDebug() << "Incoming connection details:" << m;
|
||||
|
||||
if( !nodeid.isEmpty() ) // only control connections send nodeid
|
||||
{
|
||||
foreach( ControlConnection* con, m_controlconnections )
|
||||
{
|
||||
qDebug() << con->socket() << sock;
|
||||
// qDebug() << con->socket() << sock;
|
||||
if( con->id() == nodeid )
|
||||
{
|
||||
qDebug() << "Duplicate control connection detected, dropping:" << nodeid << conntype;
|
||||
@ -420,7 +420,7 @@ Servent::socketConnected()
|
||||
{
|
||||
QTcpSocketExtra* sock = (QTcpSocketExtra*)sender();
|
||||
|
||||
qDebug() << "Servent::SocketConnected" << thread() << "socket:" << sock;
|
||||
// qDebug() << "Servent::SocketConnected" << thread() << "socket:" << sock;
|
||||
|
||||
Connection* conn = sock->_conn;
|
||||
handoverSocket( conn, sock );
|
||||
@ -565,7 +565,7 @@ Servent::reverseOfferRequest( ControlConnection* orig_conn, const QString &their
|
||||
Connection*
|
||||
Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString &key, const QHostAddress peer )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
|
||||
bool noauth = qApp->arguments().contains( "--noauth" );
|
||||
|
||||
@ -722,7 +722,7 @@ Servent::checkACL( const Connection* conn, const QString &nodeid, bool showDialo
|
||||
QSharedPointer<QIODevice>
|
||||
Servent::remoteIODeviceFactory( const result_ptr& result )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << thread();
|
||||
// qDebug() << Q_FUNC_INFO << thread();
|
||||
QSharedPointer<QIODevice> sp;
|
||||
|
||||
QStringList parts = result->url().mid( QString( "servent://" ).length() ).split( "\t" );
|
||||
@ -809,10 +809,10 @@ bool
|
||||
Servent::connectedToSession( const QString& session )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
qDebug() << "Checking against" << session;
|
||||
// qDebug() << "Checking against" << session;
|
||||
foreach( ControlConnection* cc, m_controlconnections )
|
||||
{
|
||||
qDebug() << "Checking session" << cc->id();
|
||||
// qDebug() << "Checking session" << cc->id();
|
||||
if( cc->id() == session )
|
||||
return true;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ DynamicPlaylist::DynamicPlaylist ( const Tomahawk::source_ptr& src,
|
||||
const QString& guid )
|
||||
: Playlist( src, currentrevision, title, info, creator, createdOn, shared, lastmod, guid )
|
||||
{
|
||||
qDebug() << "Creating Dynamic Playlist 1";
|
||||
// qDebug() << "Creating Dynamic Playlist 1";
|
||||
// TODO instantiate generator
|
||||
m_generator = geninterface_ptr( GeneratorFactory::create( type ) );
|
||||
m_generator->setMode( mode );
|
||||
@ -74,7 +74,7 @@ DynamicPlaylist::DynamicPlaylist ( const Tomahawk::source_ptr& author,
|
||||
bool shared )
|
||||
: Playlist ( author, guid, title, info, creator, shared )
|
||||
{
|
||||
qDebug() << "Creating Dynamic Playlist 2";
|
||||
// qDebug() << "Creating Dynamic Playlist 2";
|
||||
m_generator = geninterface_ptr( GeneratorFactory::create( type ) );
|
||||
m_generator->setMode( mode );
|
||||
}
|
||||
@ -208,7 +208,7 @@ DynamicPlaylist::createNewRevision( const QString& newrev,
|
||||
void
|
||||
DynamicPlaylist::loadRevision( const QString& rev )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "Loading with:" << ( rev.isEmpty() ? currentrevision() : rev );
|
||||
// qDebug() << Q_FUNC_INFO << "Loading with:" << ( rev.isEmpty() ? currentrevision() : rev );
|
||||
|
||||
setBusy( true );
|
||||
DatabaseCommand_LoadDynamicPlaylist* cmd = new DatabaseCommand_LoadDynamicPlaylist( rev.isEmpty() ? currentrevision() : rev );
|
||||
@ -258,7 +258,7 @@ DynamicPlaylist::remove( const Tomahawk::dynplaylist_ptr& playlist )
|
||||
void
|
||||
DynamicPlaylist::reportCreated( const Tomahawk::dynplaylist_ptr& self )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
Q_ASSERT( self.data() == this );
|
||||
Q_ASSERT( !author().isNull() );
|
||||
Q_ASSERT( !author()->collection().isNull() );
|
||||
@ -274,7 +274,7 @@ DynamicPlaylist::reportCreated( 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 );
|
||||
// will emit Collection::playlistDeleted(...)
|
||||
if( self->mode() == Static )
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@ -34,7 +34,7 @@ Tomahawk::EchonestControl::EchonestControl( const QString& selectedType, const Q
|
||||
m_editingTimer.setInterval( 500 ); //timeout to edits
|
||||
m_editingTimer.setSingleShot( true );
|
||||
connect( &m_editingTimer, SIGNAL( timeout() ), this, SLOT( editTimerFired() ) );
|
||||
|
||||
|
||||
m_delayedEditTimer.setInterval( 250 ); // additional timer for "just typing" without enter or focus change
|
||||
m_delayedEditTimer.setSingleShot( true );
|
||||
connect( &m_delayedEditTimer, SIGNAL( timeout() ), &m_editingTimer, SLOT( start() ) );
|
||||
@ -54,7 +54,7 @@ Tomahawk::EchonestControl::matchSelector()
|
||||
return m_match.data();
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
Tomahawk::EchonestControl::setSelectedType ( const QString& type )
|
||||
{
|
||||
if( type != selectedType() ) {
|
||||
@ -62,11 +62,11 @@ Tomahawk::EchonestControl::setSelectedType ( const QString& type )
|
||||
delete m_input.data();
|
||||
if( !m_match.isNull() )
|
||||
delete m_match.data();
|
||||
|
||||
|
||||
Tomahawk::DynamicControl::setSelectedType ( type );
|
||||
updateWidgets();
|
||||
updateData();
|
||||
qDebug() << "Setting new type, set data to:" << m_data.first << m_data.second;
|
||||
// qDebug() << "Setting new type, set data to:" << m_data.first << m_data.second;
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,34 +81,34 @@ Tomahawk::EchonestControl::toENParam() const
|
||||
return m_data;
|
||||
}
|
||||
|
||||
QString
|
||||
QString
|
||||
Tomahawk::EchonestControl::input() const
|
||||
{
|
||||
return m_data.second.toString();
|
||||
}
|
||||
|
||||
QString
|
||||
QString
|
||||
Tomahawk::EchonestControl::match() const
|
||||
{
|
||||
return m_matchData;
|
||||
}
|
||||
|
||||
QString
|
||||
QString
|
||||
Tomahawk::EchonestControl::matchString() const
|
||||
{
|
||||
return m_matchString;
|
||||
}
|
||||
|
||||
QString
|
||||
QString
|
||||
Tomahawk::EchonestControl::summary() const
|
||||
{
|
||||
{
|
||||
if( m_summary.isEmpty() )
|
||||
const_cast< EchonestControl* >( this )->calculateSummary();
|
||||
|
||||
|
||||
return m_summary;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
Tomahawk::EchonestControl::setInput(const QString& input)
|
||||
{
|
||||
// TODO generate widgets
|
||||
@ -116,7 +116,7 @@ Tomahawk::EchonestControl::setInput(const QString& input)
|
||||
updateWidgetsFromData();
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
Tomahawk::EchonestControl::setMatch(const QString& match)
|
||||
{
|
||||
// TODO generate widgets
|
||||
@ -124,7 +124,7 @@ Tomahawk::EchonestControl::setMatch(const QString& match)
|
||||
updateWidgetsFromData();
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
Tomahawk::EchonestControl::updateWidgets()
|
||||
{
|
||||
if( !m_input.isNull() )
|
||||
@ -132,54 +132,54 @@ Tomahawk::EchonestControl::updateWidgets()
|
||||
if( !m_match.isNull() )
|
||||
delete m_match.data();
|
||||
m_overrideType = -1;
|
||||
|
||||
|
||||
// make sure the widgets are the proper kind for the selected type, and hook up to their slots
|
||||
if( selectedType() == "Artist" ) {
|
||||
m_currentType = Echonest::DynamicPlaylist::Artist;
|
||||
|
||||
|
||||
QComboBox* match = new QComboBox();
|
||||
QLineEdit* input = new QLineEdit();
|
||||
|
||||
|
||||
match->addItem( "Limit To", Echonest::DynamicPlaylist::ArtistType );
|
||||
match->addItem( "Similar To", Echonest::DynamicPlaylist::ArtistRadioType );
|
||||
m_matchString = match->currentText();
|
||||
m_matchData = match->itemData( match->currentIndex() ).toString();
|
||||
|
||||
|
||||
input->setPlaceholderText( "Artist name" );
|
||||
input->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Fixed );
|
||||
|
||||
|
||||
connect( match, SIGNAL( currentIndexChanged(int) ), this, SLOT( updateData() ) );
|
||||
connect( match, SIGNAL( currentIndexChanged(int) ), this, SIGNAL( changed() ) );
|
||||
connect( input, SIGNAL( textChanged(QString) ), this, SLOT( updateData() ) );
|
||||
connect( input, SIGNAL( editingFinished() ), this, SLOT( editingFinished() ) );
|
||||
connect( input, SIGNAL( textEdited( QString ) ), &m_editingTimer, SLOT( stop() ) );
|
||||
connect( input, SIGNAL( textEdited( QString ) ), &m_delayedEditTimer, SLOT( start() ) );
|
||||
|
||||
|
||||
match->hide();
|
||||
input->hide();
|
||||
m_match = QWeakPointer< QWidget >( match );
|
||||
m_input = QWeakPointer< QWidget >( input );
|
||||
} else if( selectedType() == "Artist Description" ) {
|
||||
m_currentType = Echonest::DynamicPlaylist::Description;
|
||||
|
||||
|
||||
QLabel* match = new QLabel( tr( "is" ) );
|
||||
QLineEdit* input = new QLineEdit();
|
||||
|
||||
|
||||
m_matchString = QString();
|
||||
m_matchData = QString::number( (int)Echonest::DynamicPlaylist::ArtistDescriptionType );
|
||||
|
||||
|
||||
connect( input, SIGNAL( textChanged(QString) ), this, SLOT( updateData() ) );
|
||||
connect( input, SIGNAL( editingFinished() ), this, SLOT( editingFinished() ) );
|
||||
connect( input, SIGNAL( textEdited( QString ) ), &m_editingTimer, SLOT( stop() ) );
|
||||
connect( input, SIGNAL( textEdited( QString ) ), &m_delayedEditTimer, SLOT( start() ) );
|
||||
|
||||
|
||||
match->hide();
|
||||
input->hide();
|
||||
m_match = QWeakPointer< QWidget >( match );
|
||||
m_input = QWeakPointer< QWidget >( input );
|
||||
} else if( selectedType() == "Variety" ) {
|
||||
m_currentType = Echonest::DynamicPlaylist::Variety;
|
||||
|
||||
|
||||
QLabel* match = new QLabel( tr( "is" ) );
|
||||
LabeledSlider* input = new LabeledSlider( tr( "Less" ), tr( "More" ) );
|
||||
input->slider()->setRange( 0, 10000 );
|
||||
@ -188,47 +188,47 @@ Tomahawk::EchonestControl::updateWidgets()
|
||||
|
||||
m_matchString = match->text();
|
||||
m_matchData = match->text();
|
||||
|
||||
|
||||
|
||||
|
||||
connect( input->slider(), SIGNAL( valueChanged( int ) ), this, SLOT( updateData() ) );
|
||||
connect( input->slider(), SIGNAL( valueChanged( int ) ), this, SLOT( editingFinished() ) );
|
||||
|
||||
|
||||
match->hide();
|
||||
input->hide();
|
||||
m_match = QWeakPointer< QWidget >( match );
|
||||
m_input = QWeakPointer< QWidget >( input );
|
||||
} else if( selectedType() == "Tempo" ) {
|
||||
m_currentType = Echonest::DynamicPlaylist::MinTempo;
|
||||
|
||||
|
||||
setupMinMaxWidgets( Echonest::DynamicPlaylist::MinTempo, Echonest::DynamicPlaylist::MaxTempo, tr( "0 BPM" ), tr( "500 BPM" ), 500 );
|
||||
} else if( selectedType() == "Duration" ) {
|
||||
m_currentType = Echonest::DynamicPlaylist::MinDuration;
|
||||
|
||||
|
||||
setupMinMaxWidgets( Echonest::DynamicPlaylist::MinDuration, Echonest::DynamicPlaylist::MaxDuration, tr( "0 secs" ), tr( "3600 secs" ), 3600 );
|
||||
} else if( selectedType() == "Loudness" ) {
|
||||
m_currentType = Echonest::DynamicPlaylist::MinLoudness;
|
||||
|
||||
|
||||
setupMinMaxWidgets( Echonest::DynamicPlaylist::MinLoudness, Echonest::DynamicPlaylist::MaxLoudness, tr( "-100 dB" ), tr( "100 dB" ), 100 );
|
||||
qobject_cast< LabeledSlider* >( m_input.data() )->slider()->setMinimum( -100 );
|
||||
} else if( selectedType() == "Danceability" ) {
|
||||
m_currentType = Echonest::DynamicPlaylist::MinDanceability;
|
||||
|
||||
|
||||
setupMinMaxWidgets( Echonest::DynamicPlaylist::MinDanceability, Echonest::DynamicPlaylist::MaxDanceability, tr( "Less" ), tr( "More" ), 10000 );
|
||||
} else if( selectedType() == "Energy" ) {
|
||||
m_currentType = Echonest::DynamicPlaylist::MinEnergy;
|
||||
|
||||
|
||||
setupMinMaxWidgets( Echonest::DynamicPlaylist::MinEnergy, Echonest::DynamicPlaylist::MaxEnergy, tr( "Less" ), tr( "More" ), 10000 );
|
||||
} else if( selectedType() == "Artist Familiarity" ) {
|
||||
m_currentType = Echonest::DynamicPlaylist::ArtistMinFamiliarity;
|
||||
|
||||
|
||||
setupMinMaxWidgets( Echonest::DynamicPlaylist::ArtistMinFamiliarity, Echonest::DynamicPlaylist::ArtistMaxFamiliarity, tr( "Less" ), tr( "More" ), 10000 );
|
||||
} else if( selectedType() == "Artist Hotttnesss" ) {
|
||||
m_currentType = Echonest::DynamicPlaylist::ArtistMinHotttnesss;
|
||||
|
||||
|
||||
setupMinMaxWidgets( Echonest::DynamicPlaylist::ArtistMinHotttnesss, Echonest::DynamicPlaylist::ArtistMaxHotttnesss, tr( "Less" ), tr( "More" ), 10000 );
|
||||
} else if( selectedType() == "Song Hotttnesss" ) {
|
||||
m_currentType = Echonest::DynamicPlaylist::SongMinHotttnesss;
|
||||
|
||||
|
||||
setupMinMaxWidgets( Echonest::DynamicPlaylist::SongMinHotttnesss, Echonest::DynamicPlaylist::SongMaxHotttnesss, tr( "Less" ), tr( "More" ), 10000 );
|
||||
} else if( selectedType() == "Latitude" ) {
|
||||
m_currentType = Echonest::DynamicPlaylist::ArtistMinLatitude;
|
||||
@ -242,26 +242,26 @@ Tomahawk::EchonestControl::updateWidgets()
|
||||
qobject_cast< LabeledSlider* >( m_input.data() )->slider()->setMinimum( -180 );
|
||||
} else if( selectedType() == "Mode" ) {
|
||||
m_currentType = Echonest::DynamicPlaylist::Mode;
|
||||
|
||||
|
||||
QLabel* match = new QLabel( tr( "is" ) );
|
||||
QComboBox* combo = new QComboBox;
|
||||
combo->addItem( tr( "Major" ), QString::number( 1 ) );
|
||||
combo->addItem( tr( "Minor" ), QString::number( 0 ) );
|
||||
|
||||
|
||||
m_matchString = match->text();
|
||||
m_matchData = match->text();
|
||||
|
||||
|
||||
|
||||
|
||||
connect( combo, SIGNAL( activated( int ) ), this, SLOT( updateData() ) );
|
||||
connect( combo, SIGNAL( activated( int ) ), this, SLOT( editingFinished() ) );
|
||||
|
||||
|
||||
match->hide();
|
||||
combo->hide();
|
||||
m_match = QWeakPointer< QWidget >( match );
|
||||
m_input = QWeakPointer< QWidget >( combo );
|
||||
} else if( selectedType() == "Key" ) {
|
||||
m_currentType = Echonest::DynamicPlaylist::Key;
|
||||
|
||||
|
||||
QLabel* match = new QLabel( tr( "is" ) );
|
||||
QComboBox* combo = new QComboBox;
|
||||
combo->addItem( tr( "C" ), QString::number( 0 ) );
|
||||
@ -276,25 +276,25 @@ Tomahawk::EchonestControl::updateWidgets()
|
||||
combo->addItem( tr( "A" ), QString::number( 9 ) );
|
||||
combo->addItem( tr( "B Flat" ), QString::number( 10 ) );
|
||||
combo->addItem( tr( "B" ), QString::number( 11 ) );
|
||||
|
||||
|
||||
m_matchString = match->text();
|
||||
m_matchData = match->text();
|
||||
|
||||
|
||||
|
||||
|
||||
connect( combo, SIGNAL( activated( int ) ), this, SLOT( updateData() ) );
|
||||
connect( combo, SIGNAL( activated( int ) ), this, SLOT( editingFinished() ) );
|
||||
|
||||
|
||||
match->hide();
|
||||
combo->hide();
|
||||
m_match = QWeakPointer< QWidget >( match );
|
||||
m_input = QWeakPointer< QWidget >( combo );
|
||||
} else if( selectedType() == "Sorting" ) {
|
||||
m_currentType = Echonest::DynamicPlaylist::Key;
|
||||
|
||||
|
||||
QComboBox* match = new QComboBox();
|
||||
match->addItem( tr( "Ascending" ), 0 );
|
||||
match->addItem( tr( "Descending" ), 1 );
|
||||
|
||||
|
||||
QComboBox* combo = new QComboBox;
|
||||
combo->addItem( tr( "Tempo" ), QString::number( Echonest::DynamicPlaylist::SortTempoAscending ) );
|
||||
combo->addItem( tr( "Duration" ), QString::number( Echonest::DynamicPlaylist::SortDurationAscending ) );
|
||||
@ -308,15 +308,15 @@ Tomahawk::EchonestControl::updateWidgets()
|
||||
combo->addItem( tr( "Key" ), QString::number( Echonest::DynamicPlaylist::SortKeyAscending ) );
|
||||
combo->addItem( tr( "Energy" ), QString::number( Echonest::DynamicPlaylist::SortEnergyAscending ) );
|
||||
combo->addItem( tr( "Danceability" ), QString::number( Echonest::DynamicPlaylist::SortDanceabilityAscending ) );
|
||||
|
||||
|
||||
m_matchString = "Ascending"; // default
|
||||
m_matchData = Echonest::DynamicPlaylist::SortTempoAscending;
|
||||
|
||||
|
||||
connect( match, SIGNAL( activated( int ) ), this, SLOT( updateData() ) );
|
||||
connect( match, SIGNAL( activated( int ) ), this, SLOT( editingFinished() ) );
|
||||
connect( combo, SIGNAL( activated( int ) ), this, SLOT( updateData() ) );
|
||||
connect( combo, SIGNAL( activated( int ) ), this, SLOT( editingFinished() ) );
|
||||
|
||||
|
||||
match->hide();
|
||||
combo->hide();
|
||||
m_match = QWeakPointer< QWidget >( match );
|
||||
@ -329,26 +329,26 @@ Tomahawk::EchonestControl::updateWidgets()
|
||||
calculateSummary();
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
Tomahawk::EchonestControl::setupMinMaxWidgets( Echonest::DynamicPlaylist::PlaylistParam min, Echonest::DynamicPlaylist::PlaylistParam max, const QString& leftL, const QString& rightL, int maxRange )
|
||||
{
|
||||
QComboBox* match = new QComboBox;
|
||||
match->addItem( "At Least", min );
|
||||
match->addItem( "At Most", max );
|
||||
|
||||
|
||||
LabeledSlider* input = new LabeledSlider( leftL, rightL );
|
||||
input->slider()->setRange( 0, maxRange );
|
||||
input->slider()->setTickInterval( 1 );
|
||||
input->slider()->setTracking( false );
|
||||
|
||||
|
||||
m_matchString = match->currentText();
|
||||
m_matchData = match->itemData( match->currentIndex() ).toString();
|
||||
|
||||
|
||||
connect( match, SIGNAL( activated( int ) ), this, SLOT( updateData() ) );
|
||||
connect( match, SIGNAL( activated( int ) ), this, SLOT( editingFinished() ) );
|
||||
connect( input->slider(), SIGNAL( valueChanged( int ) ), this, SLOT( updateData() ) );
|
||||
connect( input->slider(), SIGNAL( valueChanged( int ) ), this, SLOT( editingFinished() ) );
|
||||
|
||||
|
||||
match->hide();
|
||||
input->hide();
|
||||
m_match = QWeakPointer< QWidget >( match );
|
||||
@ -356,7 +356,7 @@ Tomahawk::EchonestControl::setupMinMaxWidgets( Echonest::DynamicPlaylist::Playli
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
Tomahawk::EchonestControl::updateData()
|
||||
{
|
||||
if( selectedType() == "Artist" ) {
|
||||
@ -394,7 +394,7 @@ Tomahawk::EchonestControl::updateData()
|
||||
if( match && input ) {
|
||||
m_matchString = match->currentText();
|
||||
m_matchData = match->itemData( match->currentIndex() ).toString();
|
||||
|
||||
|
||||
// what a HACK
|
||||
int enumVal = input->itemData( input->currentIndex() ).toInt() + m_matchData.toInt();
|
||||
m_data.first = Echonest::DynamicPlaylist::Sort;
|
||||
@ -402,11 +402,11 @@ Tomahawk::EchonestControl::updateData()
|
||||
// qDebug() << "SAVING" << input->currentIndex() << "AS" << enumVal << "(" << input->itemData( input->currentIndex() ).toInt() << "+" << m_matchData.toInt() << ")";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
calculateSummary();
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
Tomahawk::EchonestControl::updateFromComboAndSlider( bool smooth )
|
||||
{
|
||||
QComboBox* combo = qobject_cast<QComboBox*>( m_match.data() );
|
||||
@ -421,7 +421,7 @@ Tomahawk::EchonestControl::updateFromComboAndSlider( bool smooth )
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
Tomahawk::EchonestControl::updateFromLabelAndCombo()
|
||||
{
|
||||
QComboBox* s = qobject_cast<QComboBox*>( m_input.data() );
|
||||
@ -433,7 +433,7 @@ Tomahawk::EchonestControl::updateFromLabelAndCombo()
|
||||
|
||||
|
||||
// fills in the current widget with the data from json or dbcmd (m_data.second and m_matchData)
|
||||
void
|
||||
void
|
||||
Tomahawk::EchonestControl::updateWidgetsFromData()
|
||||
{
|
||||
if( selectedType() == "Artist" ) {
|
||||
@ -452,7 +452,7 @@ Tomahawk::EchonestControl::updateWidgetsFromData()
|
||||
if( s )
|
||||
s->slider()->setValue( m_data.second.toDouble() * 10000 );
|
||||
} else if( selectedType() == "Tempo" || selectedType() == "Duration" || selectedType() == "Loudness" || selectedType() == "Latitude" || selectedType() == "Longitude" ) {
|
||||
updateToComboAndSlider();
|
||||
updateToComboAndSlider();
|
||||
} else if( selectedType() == "Danceability" || selectedType() == "Energy" || selectedType() == "Artist Familiarity" || selectedType() == "Artist Hotttnesss" || selectedType() == "Song Hotttnesss" ) {
|
||||
updateToComboAndSlider( true );
|
||||
} else if( selectedType() == "Mode" || selectedType() == "Key" ) {
|
||||
@ -462,7 +462,7 @@ Tomahawk::EchonestControl::updateWidgetsFromData()
|
||||
QComboBox* input = qobject_cast< QComboBox* >( m_input.data() );
|
||||
if( match && input ) {
|
||||
match->setCurrentIndex( match->findData( m_matchData ));
|
||||
|
||||
|
||||
// HACK alert. if it's odd, subtract 1
|
||||
int val = ( m_data.second.toInt() - ( m_data.second.toInt() % 2 ) ) / 2;
|
||||
input->setCurrentIndex( val );
|
||||
@ -472,7 +472,7 @@ Tomahawk::EchonestControl::updateWidgetsFromData()
|
||||
calculateSummary();
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
Tomahawk::EchonestControl::updateToComboAndSlider( bool smooth )
|
||||
{
|
||||
QComboBox* combo = qobject_cast<QComboBox*>( m_match.data() );
|
||||
@ -491,26 +491,26 @@ void Tomahawk::EchonestControl::updateToLabelAndCombo()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
Tomahawk::EchonestControl::editingFinished()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
m_editingTimer.start();
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
Tomahawk::EchonestControl::editTimerFired()
|
||||
{
|
||||
// make sure it's really changed
|
||||
if( m_cacheData != m_data.second ) { // new, so emit changed
|
||||
emit changed();
|
||||
}
|
||||
|
||||
|
||||
m_cacheData = m_data.second;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
Tomahawk::EchonestControl::calculateSummary()
|
||||
{
|
||||
// turns the current control into an english phrase suitable for embedding into a sentence summary
|
||||
@ -522,7 +522,7 @@ Tomahawk::EchonestControl::calculateSummary()
|
||||
else if( static_cast< Echonest::DynamicPlaylist::ArtistTypeEnum >( m_matchData.toInt() ) == Echonest::DynamicPlaylist::ArtistRadioType )
|
||||
summary = QString( "similar to ~%1" ).arg( m_data.second.toString() );
|
||||
} else if( selectedType() == "Artist Description" ) {
|
||||
summary = QString( "with genre ~%1" ).arg( m_data.second.toString() );
|
||||
summary = QString( "with genre ~%1" ).arg( m_data.second.toString() );
|
||||
} else if( selectedType() == "Variety" || selectedType() == "Danceability" || selectedType() == "Artist Hotttnesss" || selectedType() == "Energy" || selectedType() == "Artist Familiarity" || selectedType() == "Song Hotttnesss" ) {
|
||||
QString modifier;
|
||||
qreal sliderVal = m_data.second.toReal();
|
||||
@ -560,11 +560,11 @@ Tomahawk::EchonestControl::calculateSummary()
|
||||
Q_ASSERT( !m_input.isNull() );
|
||||
Q_ASSERT( qobject_cast< QComboBox* >( m_input.data() ) );
|
||||
QString sortType = qobject_cast< QComboBox* >( m_input.data() )->currentText().toLower();
|
||||
|
||||
|
||||
Q_ASSERT( !m_match.isNull() );
|
||||
Q_ASSERT( qobject_cast< QComboBox* >( m_match.data() ) );
|
||||
QString ascdesc = qobject_cast< QComboBox* >( m_match.data() )->currentText().toLower();
|
||||
|
||||
|
||||
summary = QString( "sorted in %1 %2 order" ).arg( ascdesc ).arg( sortType );
|
||||
}
|
||||
m_summary = summary;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@ -27,27 +27,27 @@ using namespace Tomahawk;
|
||||
EchonestFactory::EchonestFactory()
|
||||
{}
|
||||
|
||||
GeneratorInterface*
|
||||
GeneratorInterface*
|
||||
EchonestFactory::create()
|
||||
{
|
||||
return new EchonestGenerator();
|
||||
}
|
||||
|
||||
dyncontrol_ptr
|
||||
dyncontrol_ptr
|
||||
EchonestFactory::createControl( const QString& controlType )
|
||||
{
|
||||
return dyncontrol_ptr( new EchonestControl( controlType, typeSelectors() ) );
|
||||
}
|
||||
|
||||
QStringList
|
||||
QStringList
|
||||
EchonestFactory::typeSelectors() const
|
||||
{
|
||||
return QStringList() << "Artist" << "Artist Description" << "Variety" << "Tempo" << "Duration" << "Loudness"
|
||||
<< "Danceability" << "Energy" << "Artist Familiarity" << "Artist Hotttnesss" << "Song Hotttnesss"
|
||||
return QStringList() << "Artist" << "Artist Description" << "Variety" << "Tempo" << "Duration" << "Loudness"
|
||||
<< "Danceability" << "Energy" << "Artist Familiarity" << "Artist Hotttnesss" << "Song Hotttnesss"
|
||||
<< "Longitude" << "Latitude" << "Mode" << "Key" << "Sorting";
|
||||
}
|
||||
|
||||
EchonestGenerator::EchonestGenerator ( QObject* parent )
|
||||
EchonestGenerator::EchonestGenerator ( QObject* parent )
|
||||
: GeneratorInterface ( parent )
|
||||
, m_dynPlaylist( new Echonest::DynamicPlaylist() )
|
||||
, m_steeredSinceLastTrack( false )
|
||||
@ -55,7 +55,7 @@ EchonestGenerator::EchonestGenerator ( QObject* parent )
|
||||
m_type = "echonest";
|
||||
m_mode = OnDemand;
|
||||
m_logo.load( RESPATH "/images/echonest_logo.png" );
|
||||
qDebug() << "ECHONEST:" << m_logo.size();
|
||||
// qDebug() << "ECHONEST:" << m_logo.size();
|
||||
}
|
||||
|
||||
EchonestGenerator::~EchonestGenerator()
|
||||
@ -63,7 +63,7 @@ EchonestGenerator::~EchonestGenerator()
|
||||
delete m_dynPlaylist;
|
||||
}
|
||||
|
||||
dyncontrol_ptr
|
||||
dyncontrol_ptr
|
||||
EchonestGenerator::createControl( const QString& type )
|
||||
{
|
||||
m_controls << dyncontrol_ptr( new EchonestControl( type, GeneratorFactory::typeSelectors( m_type ) ) );
|
||||
@ -76,18 +76,18 @@ QPixmap EchonestGenerator::logo()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
EchonestGenerator::generate ( int number )
|
||||
void
|
||||
EchonestGenerator::generate( int number )
|
||||
{
|
||||
// convert to an echonest query, and fire it off
|
||||
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 )
|
||||
qDebug() << ctrl->selectedType() << ctrl->match() << ctrl->input();
|
||||
|
||||
|
||||
try {
|
||||
Echonest::DynamicPlaylist::PlaylistParams params = getParams();
|
||||
|
||||
|
||||
params.append( Echonest::DynamicPlaylist::PlaylistParamData( Echonest::DynamicPlaylist::Results, number ) );
|
||||
QNetworkReply* reply = Echonest::DynamicPlaylist::staticPlaylist( params );
|
||||
qDebug() << "Generating a static playlist from echonest!" << reply->url().toString();
|
||||
@ -98,12 +98,12 @@ EchonestGenerator::generate ( int number )
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
EchonestGenerator::startOnDemand()
|
||||
{
|
||||
try {
|
||||
Echonest::DynamicPlaylist::PlaylistParams params = getParams();
|
||||
|
||||
|
||||
QNetworkReply* reply = m_dynPlaylist->start( params );
|
||||
qDebug() << "starting a dynamic playlist from echonest!" << reply->url().toString();
|
||||
connect( reply, SIGNAL( finished() ), this, SLOT( dynamicStarted() ) );
|
||||
@ -113,7 +113,7 @@ EchonestGenerator::startOnDemand()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
EchonestGenerator::fetchNext( int rating )
|
||||
{
|
||||
if( m_dynPlaylist->sessionId().isEmpty() ) {
|
||||
@ -121,7 +121,7 @@ EchonestGenerator::fetchNext( int rating )
|
||||
qWarning() << Q_FUNC_INFO << "asked to fetch next dynamic song when we're not in the middle of a playlist!";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
QNetworkReply* reply;
|
||||
if( m_steeredSinceLastTrack ) {
|
||||
qDebug() << "Steering dynamic playlist!" << m_steerData.first << m_steerData.second;
|
||||
@ -135,34 +135,34 @@ EchonestGenerator::fetchNext( int rating )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
EchonestGenerator::staticFinished()
|
||||
{
|
||||
Q_ASSERT( sender() );
|
||||
Q_ASSERT( qobject_cast< QNetworkReply* >( sender() ) );
|
||||
|
||||
|
||||
QNetworkReply* reply = qobject_cast< QNetworkReply* >( sender() );
|
||||
|
||||
|
||||
Echonest::SongList songs;
|
||||
try {
|
||||
songs = Echonest::DynamicPlaylist::parseStaticPlaylist( reply );
|
||||
} catch( const Echonest::ParseError& e ) {
|
||||
qWarning() << "libechonest threw an error trying to parse the static playlist! code" << e.errorType() << "error desc:" << e.what();
|
||||
|
||||
qWarning() << "libechonest threw an error trying to parse the static playlist code" << e.errorType() << "error desc:" << e.what();
|
||||
|
||||
emit error( "The Echo Nest returned an error creating the playlist", e.what() );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
QList< query_ptr > queries;
|
||||
foreach( const Echonest::Song& song, songs ) {
|
||||
qDebug() << "EchonestGenerator got song:" << song;
|
||||
queries << queryFromSong( song );
|
||||
}
|
||||
|
||||
|
||||
emit generated( queries );
|
||||
}
|
||||
|
||||
Echonest::DynamicPlaylist::PlaylistParams
|
||||
Echonest::DynamicPlaylist::PlaylistParams
|
||||
EchonestGenerator::getParams() const throw( std::runtime_error )
|
||||
{
|
||||
Echonest::DynamicPlaylist::PlaylistParams params;
|
||||
@ -173,14 +173,14 @@ EchonestGenerator::getParams() const throw( std::runtime_error )
|
||||
return params;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
EchonestGenerator::dynamicStarted()
|
||||
{
|
||||
Q_ASSERT( sender() );
|
||||
Q_ASSERT( qobject_cast< QNetworkReply* >( sender() ) );
|
||||
QNetworkReply* reply = qobject_cast< QNetworkReply* >( sender() );
|
||||
|
||||
try
|
||||
|
||||
try
|
||||
{
|
||||
Echonest::Song song = m_dynPlaylist->parseStart( reply );
|
||||
query_ptr songQuery = queryFromSong( song );
|
||||
@ -191,19 +191,19 @@ EchonestGenerator::dynamicStarted()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
EchonestGenerator::dynamicFetched()
|
||||
{
|
||||
Q_ASSERT( sender() );
|
||||
Q_ASSERT( qobject_cast< QNetworkReply* >( sender() ) );
|
||||
QNetworkReply* reply = qobject_cast< QNetworkReply* >( sender() );
|
||||
|
||||
resetSteering();
|
||||
|
||||
|
||||
resetSteering();
|
||||
|
||||
if( !m_steerer.isNull() )
|
||||
m_steerer.data()->resetSteering( true );
|
||||
|
||||
try
|
||||
|
||||
try
|
||||
{
|
||||
Echonest::Song song = m_dynPlaylist->parseNextSong( reply );
|
||||
query_ptr songQuery = queryFromSong( song );
|
||||
@ -214,7 +214,7 @@ EchonestGenerator::dynamicFetched()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
EchonestGenerator::steerDescription( const QString& desc )
|
||||
{
|
||||
m_steeredSinceLastTrack = true;
|
||||
@ -222,7 +222,7 @@ EchonestGenerator::steerDescription( const QString& desc )
|
||||
m_steerData.second = desc;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
EchonestGenerator::steerField( const QString& field )
|
||||
{
|
||||
m_steeredSinceLastTrack = true;
|
||||
@ -230,7 +230,7 @@ EchonestGenerator::steerField( const QString& field )
|
||||
m_steerData.second = field;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
EchonestGenerator::resetSteering()
|
||||
{
|
||||
m_steeredSinceLastTrack = false;
|
||||
@ -239,12 +239,12 @@ EchonestGenerator::resetSteering()
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
bool
|
||||
EchonestGenerator::onlyThisArtistType( Echonest::DynamicPlaylist::ArtistTypeEnum type ) const throw( std::runtime_error )
|
||||
{
|
||||
bool only = true;
|
||||
bool some = false;
|
||||
|
||||
|
||||
foreach( const dyncontrol_ptr& control, m_controls ) {
|
||||
if( ( control->selectedType() == "Artist" || control->selectedType() == "Artist Description" ) && static_cast<Echonest::DynamicPlaylist::ArtistTypeEnum>( control->match().toInt() ) != type ) {
|
||||
only = false;
|
||||
@ -257,11 +257,11 @@ EchonestGenerator::onlyThisArtistType( Echonest::DynamicPlaylist::ArtistTypeEnum
|
||||
} else if( some && !only ) {
|
||||
throw std::runtime_error( "All artist match types must be the same" );
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
EchonestGenerator::appendRadioType( Echonest::DynamicPlaylist::PlaylistParams& params ) const throw( std::runtime_error )
|
||||
{
|
||||
/**
|
||||
@ -269,9 +269,9 @@ EchonestGenerator::appendRadioType( Echonest::DynamicPlaylist::PlaylistParams& p
|
||||
* the types are artist, artist-radio, artist-description, catalog, catalog-radio, song-radio. we don't care about the catalog ones, and
|
||||
* we can't use the song ones since for the moment EN only accepts Song IDs, not names, and we don't want to insert an extra song.search
|
||||
* call first.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/// 1. artist: If all the artist controls are Limit-To. If some were but not all, error out.
|
||||
/// 2. artist-description: If all the artist entries are Description. If some were but not all, error out.
|
||||
/// 3. artist-radio: If all the artist entries are Similar To. If some were but not all, error out.
|
||||
@ -283,34 +283,34 @@ EchonestGenerator::appendRadioType( Echonest::DynamicPlaylist::PlaylistParams& p
|
||||
params.append( Echonest::DynamicPlaylist::PlaylistParamData( Echonest::DynamicPlaylist::Type, Echonest::DynamicPlaylist::ArtistRadioType ) );
|
||||
}
|
||||
|
||||
query_ptr
|
||||
query_ptr
|
||||
EchonestGenerator::queryFromSong(const Echonest::Song& song)
|
||||
{
|
||||
// track[ "album" ] = song.release(); // TODO should we include it? can be quite specific
|
||||
return Query::get( song.artistName(), song.title(), QString(), uuid() );
|
||||
}
|
||||
|
||||
QWidget*
|
||||
QWidget*
|
||||
EchonestGenerator::steeringWidget()
|
||||
{
|
||||
if( m_steerer.isNull() ) {
|
||||
m_steerer = QWeakPointer< EchonestSteerer >( new EchonestSteerer );
|
||||
|
||||
|
||||
connect( m_steerer.data(), SIGNAL( steerField( QString ) ), this, SLOT( steerField( QString ) ) );
|
||||
connect( m_steerer.data(), SIGNAL( steerDescription( QString ) ), this, SLOT( steerDescription( QString ) ) );
|
||||
connect( m_steerer.data(), SIGNAL( reset() ), this, SLOT( resetSteering() ) );
|
||||
}
|
||||
|
||||
|
||||
return m_steerer.data();
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
QString
|
||||
EchonestGenerator::sentenceSummary()
|
||||
{
|
||||
/**
|
||||
* The idea is we generate an english sentence from the individual phrases of the controls. We have to follow a few rules, but othewise it's quite straightforward.
|
||||
*
|
||||
*
|
||||
* Rules:
|
||||
* - Sentence starts with "Songs "
|
||||
* - Artists always go first
|
||||
@ -318,16 +318,16 @@ EchonestGenerator::sentenceSummary()
|
||||
* - sorting always at end
|
||||
* - collapse artists. "Like X, like Y, like Z, ..." -> "Like X, Y, and Z"
|
||||
* - skip empty artist entries
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
QList< dyncontrol_ptr > allcontrols = m_controls;
|
||||
QString sentence = "Songs ";
|
||||
|
||||
|
||||
/// 1. Collect all artist filters
|
||||
/// 2. Get the sorted by filter if it exists.
|
||||
QList< dyncontrol_ptr > artists;
|
||||
QList< dyncontrol_ptr > artists;
|
||||
dyncontrol_ptr sorting;
|
||||
foreach( const dyncontrol_ptr& control, allcontrols ) {
|
||||
if( control->selectedType() == "Artist" || control->selectedType() == "Artist Description" )
|
||||
@ -337,7 +337,7 @@ EchonestGenerator::sentenceSummary()
|
||||
}
|
||||
if( !sorting.isNull() )
|
||||
allcontrols.removeAll( sorting );
|
||||
|
||||
|
||||
/// Skip empty artists
|
||||
QList< dyncontrol_ptr > empty;
|
||||
foreach( const dyncontrol_ptr& artist, artists ) {
|
||||
@ -349,20 +349,20 @@ EchonestGenerator::sentenceSummary()
|
||||
artists.removeAll( toremove );
|
||||
allcontrols.removeAll( toremove );
|
||||
}
|
||||
|
||||
|
||||
/// If there are no artists and no filters, show some help text
|
||||
if( artists.isEmpty() && allcontrols.isEmpty() )
|
||||
sentence = "No configured filters!";
|
||||
|
||||
/// Do the assembling. Start with the artists if there are any, then do all the rest.
|
||||
|
||||
/// Do the assembling. Start with the artists if there are any, then do all the rest.
|
||||
for( int i = 0; i < artists.size(); i++ ) {
|
||||
dyncontrol_ptr artist = artists.value( i );
|
||||
allcontrols.removeAll( artist ); // remove from pool while we're here
|
||||
|
||||
|
||||
/// Collapse artist lists
|
||||
QString center, suffix;
|
||||
QString summary = artist.dynamicCast< EchonestControl >()->summary();
|
||||
|
||||
|
||||
if( i == 0 ) { // if it's the first.. special casez
|
||||
center = summary.remove( "~" );
|
||||
if( artists.size() == 2 ) // special case for 2, no comma. ( X and Y )
|
||||
@ -399,12 +399,12 @@ EchonestGenerator::sentenceSummary()
|
||||
sentence += prefix + allcontrols.value( i ).dynamicCast< EchonestControl >()->summary() + suffix;
|
||||
}
|
||||
qDebug() << "Got artists and contents:" << sentence;
|
||||
|
||||
|
||||
if( !sorting.isNull() ) {
|
||||
sentence += "and " + sorting.dynamicCast< EchonestControl >()->summary() + ".";
|
||||
}
|
||||
qDebug() << "Got full summary:" << sentence;
|
||||
|
||||
|
||||
return sentence;
|
||||
}
|
||||
|
||||
|
@ -349,7 +349,7 @@ nam()
|
||||
{
|
||||
if ( s_nam.isNull() )
|
||||
return 0;
|
||||
|
||||
|
||||
return s_nam.data();
|
||||
}
|
||||
|
||||
@ -373,7 +373,7 @@ setProxy( QNetworkProxy* proxy )
|
||||
{
|
||||
s_proxy = proxy;
|
||||
s_nam.data()->setProxy( *proxy );
|
||||
qDebug() << Q_FUNC_INFO << " setting proxy to use proxy DNS? " << (TomahawkSettings::instance()->proxyDns() ? "true" : "false");
|
||||
qDebug() << Q_FUNC_INFO << "setting proxy to use proxy DNS?" << (TomahawkSettings::instance()->proxyDns() ? "true" : "false");
|
||||
if ( !TomahawkSettings::instance()->proxyDns() )
|
||||
s_proxy->setCapabilities( QNetworkProxy::TunnelingCapability | QNetworkProxy::ListeningCapability | QNetworkProxy::UdpTunnelingCapability );
|
||||
}
|
||||
@ -410,8 +410,7 @@ DNSResolver::resolve( QString &host, QString type )
|
||||
// For the moment, assume we are looking for XMPP...
|
||||
QString fullHost( "_xmpp-client._tcp." + host );
|
||||
|
||||
qDebug() << "Looking up SRV record for " << fullHost.toUtf8();
|
||||
|
||||
qDebug() << "Looking up SRV record for" << fullHost.toUtf8();
|
||||
m_dnsSharedRequest->query( fullHost.toUtf8(), QJDns::Srv );
|
||||
}
|
||||
else
|
||||
@ -429,7 +428,7 @@ DNSResolver::resultsReady()
|
||||
QList<QJDns::Record> results = m_dnsSharedRequest->results();
|
||||
foreach( QJDns::Record r, results )
|
||||
{
|
||||
qDebug() << "Found result (of some type): " << QString( r.name );
|
||||
qDebug() << "Found result (of some type):" << QString( r.name );
|
||||
if( r.type == QJDns::Srv )
|
||||
{
|
||||
QString foundResult( r.name );
|
||||
@ -438,7 +437,7 @@ DNSResolver::resultsReady()
|
||||
}
|
||||
}
|
||||
}
|
||||
qDebug() << "DNS resolve request was NOT successful! Error: " << (int)(m_dnsSharedRequest->error());
|
||||
qDebug() << "DNS resolve request was NOT successful! Error:" << (int)(m_dnsSharedRequest->error());
|
||||
QString badResult( "NONE" );
|
||||
emit result( badResult );
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ CollectionItem::playlistsDeletedInternal( SourceTreeItem* parent, const QList< T
|
||||
void
|
||||
CollectionItem::onPlaylistsAdded( const QList< playlist_ptr >& playlists )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << m_source->friendlyName() << playlists.count();
|
||||
// qDebug() << Q_FUNC_INFO << m_source->friendlyName() << playlists.count();
|
||||
|
||||
if( playlists.isEmpty() )
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user