mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 13:47:26 +02:00
* Make results singletons, based on its url. Now we can call Result's toQuery() without re-resolving. Much nicer.
This commit is contained in:
@@ -193,7 +193,7 @@ DatabaseCommand_AddFiles::exec( DatabaseImpl* dbi )
|
|||||||
|
|
||||||
Tomahawk::artist_ptr artistptr = Tomahawk::Artist::get( artistid, artist );
|
Tomahawk::artist_ptr artistptr = Tomahawk::Artist::get( artistid, artist );
|
||||||
Tomahawk::album_ptr albumptr = Tomahawk::Album::get( albumid, album, artistptr );
|
Tomahawk::album_ptr albumptr = Tomahawk::Album::get( albumid, album, artistptr );
|
||||||
Tomahawk::result_ptr result = Tomahawk::result_ptr( new Tomahawk::Result() );
|
Tomahawk::result_ptr result = Tomahawk::Result::get( url );
|
||||||
result->setModificationTime( mtime );
|
result->setModificationTime( mtime );
|
||||||
result->setSize( size );
|
result->setSize( size );
|
||||||
result->setMimetype( mimetype );
|
result->setMimetype( mimetype );
|
||||||
@@ -206,7 +206,6 @@ DatabaseCommand_AddFiles::exec( DatabaseImpl* dbi )
|
|||||||
result->setAttributes( attr );
|
result->setAttributes( attr );
|
||||||
result->setCollection( source()->collection() );
|
result->setCollection( source()->collection() );
|
||||||
result->setScore( 1.0 );
|
result->setScore( 1.0 );
|
||||||
result->setUrl( url );
|
|
||||||
result->setId( trackid );
|
result->setId( trackid );
|
||||||
|
|
||||||
QList<Tomahawk::result_ptr> results;
|
QList<Tomahawk::result_ptr> results;
|
||||||
|
@@ -91,24 +91,23 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
|
|||||||
|
|
||||||
while( query.next() )
|
while( query.next() )
|
||||||
{
|
{
|
||||||
Tomahawk::result_ptr result = Tomahawk::result_ptr( new Tomahawk::Result() );
|
|
||||||
Tomahawk::source_ptr s;
|
Tomahawk::source_ptr s;
|
||||||
|
QString url = query.value( 7 ).toString();
|
||||||
|
|
||||||
if( query.value( 8 ).toUInt() == 0 )
|
if ( query.value( 8 ).toUInt() == 0 )
|
||||||
{
|
{
|
||||||
s = SourceList::instance()->getLocal();
|
s = SourceList::instance()->getLocal();
|
||||||
result->setUrl( query.value( 7 ).toString() );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s = SourceList::instance()->get( query.value( 8 ).toUInt() );
|
s = SourceList::instance()->get( query.value( 8 ).toUInt() );
|
||||||
if( s.isNull() )
|
if ( s.isNull() )
|
||||||
{
|
{
|
||||||
Q_ASSERT( false );
|
Q_ASSERT( false );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
result->setUrl( QString( "servent://%1\t%2" ).arg( s->userName() ).arg( query.value( 7 ).toString() ) );
|
url = QString( "servent://%1\t%2" ).arg( s->userName() ).arg( url );
|
||||||
}
|
}
|
||||||
|
|
||||||
QString artist, track, album;
|
QString artist, track, album;
|
||||||
@@ -116,6 +115,7 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
|
|||||||
album = query.value( 2 ).toString();
|
album = query.value( 2 ).toString();
|
||||||
track = query.value( 3 ).toString();
|
track = query.value( 3 ).toString();
|
||||||
|
|
||||||
|
Tomahawk::result_ptr result = Tomahawk::Result::get( url );
|
||||||
Tomahawk::query_ptr qry = Tomahawk::Query::get( artist, track, album );
|
Tomahawk::query_ptr qry = Tomahawk::Query::get( artist, track, album );
|
||||||
Tomahawk::artist_ptr artistptr = Tomahawk::Artist::get( query.value( 12 ).toUInt(), artist );
|
Tomahawk::artist_ptr artistptr = Tomahawk::Artist::get( query.value( 12 ).toUInt(), artist );
|
||||||
Tomahawk::album_ptr albumptr = Tomahawk::Album::get( query.value( 13 ).toUInt(), album, artistptr );
|
Tomahawk::album_ptr albumptr = Tomahawk::Album::get( query.value( 13 ).toUInt(), album, artistptr );
|
||||||
|
@@ -39,8 +39,16 @@ DatabaseCommand_LogPlayback::postCommitHook()
|
|||||||
connect( this, SIGNAL( trackPlayed( Tomahawk::query_ptr ) ),
|
connect( this, SIGNAL( trackPlayed( Tomahawk::query_ptr ) ),
|
||||||
source().data(), SLOT( onPlaybackFinished( Tomahawk::query_ptr ) ), Qt::QueuedConnection );
|
source().data(), SLOT( onPlaybackFinished( Tomahawk::query_ptr ) ), Qt::QueuedConnection );
|
||||||
|
|
||||||
// do not auto resolve this track
|
Tomahawk::query_ptr q;
|
||||||
Tomahawk::query_ptr q = Tomahawk::Query::get( m_artist, m_track, QString() );
|
if ( !m_result.isNull() )
|
||||||
|
{
|
||||||
|
q = m_result->toQuery();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// do not auto resolve this track
|
||||||
|
q = Tomahawk::Query::get( m_artist, m_track, QString() );
|
||||||
|
}
|
||||||
q->setPlayedBy( source(), m_playtime );
|
q->setPlayedBy( source(), m_playtime );
|
||||||
|
|
||||||
if ( m_action == Finished )
|
if ( m_action == Finished )
|
||||||
|
@@ -118,29 +118,28 @@ DatabaseCommand_Resolve::resolve( DatabaseImpl* lib )
|
|||||||
files_query.prepare( sql );
|
files_query.prepare( sql );
|
||||||
files_query.exec();
|
files_query.exec();
|
||||||
|
|
||||||
while( files_query.next() )
|
while ( files_query.next() )
|
||||||
{
|
{
|
||||||
Tomahawk::result_ptr result( new Tomahawk::Result() );
|
|
||||||
source_ptr s;
|
source_ptr s;
|
||||||
|
QString url = files_query.value( 0 ).toString();
|
||||||
|
|
||||||
const QString url_str = files_query.value( 0 ).toString();
|
if ( files_query.value( 13 ).toUInt() == 0 )
|
||||||
if( files_query.value( 13 ).toUInt() == 0 )
|
|
||||||
{
|
{
|
||||||
s = SourceList::instance()->getLocal();
|
s = SourceList::instance()->getLocal();
|
||||||
result->setUrl( url_str );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s = SourceList::instance()->get( files_query.value( 13 ).toUInt() );
|
s = SourceList::instance()->get( files_query.value( 13 ).toUInt() );
|
||||||
if( s.isNull() )
|
if( s.isNull() )
|
||||||
{
|
{
|
||||||
qDebug() << "WTF: Could not find source" << files_query.value( 13 ).toUInt();
|
qDebug() << "Could not find source" << files_query.value( 13 ).toUInt();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
result->setUrl( QString( "servent://%1\t%2" ).arg( s->userName() ).arg( url_str ) );
|
url = QString( "servent://%1\t%2" ).arg( s->userName() ).arg( url );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Tomahawk::result_ptr result = Tomahawk::Result::get( url );
|
||||||
Tomahawk::artist_ptr artist = Tomahawk::Artist::get( files_query.value( 15 ).toUInt(), files_query.value( 10 ).toString() );
|
Tomahawk::artist_ptr artist = Tomahawk::Artist::get( files_query.value( 15 ).toUInt(), files_query.value( 10 ).toString() );
|
||||||
Tomahawk::album_ptr album = Tomahawk::Album::get( files_query.value( 16 ).toUInt(), files_query.value( 11 ).toString(), artist );
|
Tomahawk::album_ptr album = Tomahawk::Album::get( files_query.value( 16 ).toUInt(), files_query.value( 11 ).toString(), artist );
|
||||||
|
|
||||||
@@ -233,27 +232,26 @@ DatabaseCommand_Resolve::fullTextResolve( DatabaseImpl* lib )
|
|||||||
|
|
||||||
while( files_query.next() )
|
while( files_query.next() )
|
||||||
{
|
{
|
||||||
Tomahawk::result_ptr result( new Tomahawk::Result() );
|
|
||||||
source_ptr s;
|
source_ptr s;
|
||||||
|
QString url = files_query.value( 0 ).toString();
|
||||||
|
|
||||||
const QString url_str = files_query.value( 0 ).toString();
|
if ( files_query.value( 13 ).toUInt() == 0 )
|
||||||
if( files_query.value( 13 ).toUInt() == 0 )
|
|
||||||
{
|
{
|
||||||
s = SourceList::instance()->getLocal();
|
s = SourceList::instance()->getLocal();
|
||||||
result->setUrl( url_str );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s = SourceList::instance()->get( files_query.value( 13 ).toUInt() );
|
s = SourceList::instance()->get( files_query.value( 13 ).toUInt() );
|
||||||
if( s.isNull() )
|
if( s.isNull() )
|
||||||
{
|
{
|
||||||
qDebug() << "WTF: Could not find source" << files_query.value( 13 ).toUInt();
|
qDebug() << "Could not find source" << files_query.value( 13 ).toUInt();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
result->setUrl( QString( "servent://%1\t%2" ).arg( s->userName() ).arg( url_str ) );
|
url = QString( "servent://%1\t%2" ).arg( s->userName() ).arg( url );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Tomahawk::result_ptr result = Tomahawk::Result::get( url );
|
||||||
Tomahawk::artist_ptr artist = Tomahawk::Artist::get( files_query.value( 15 ).toUInt(), files_query.value( 10 ).toString() );
|
Tomahawk::artist_ptr artist = Tomahawk::Artist::get( files_query.value( 15 ).toUInt(), files_query.value( 10 ).toString() );
|
||||||
Tomahawk::album_ptr album = Tomahawk::Album::get( files_query.value( 16 ).toUInt(), files_query.value( 11 ).toString(), artist );
|
Tomahawk::album_ptr album = Tomahawk::Album::get( files_query.value( 16 ).toUInt(), files_query.value( 11 ).toString(), artist );
|
||||||
|
|
||||||
|
@@ -213,7 +213,7 @@ DatabaseImpl::cleanSql( const QString& sql )
|
|||||||
Tomahawk::result_ptr
|
Tomahawk::result_ptr
|
||||||
DatabaseImpl::file( int fid )
|
DatabaseImpl::file( int fid )
|
||||||
{
|
{
|
||||||
Tomahawk::result_ptr r = Tomahawk::result_ptr( new Tomahawk::Result() );
|
Tomahawk::result_ptr r;
|
||||||
TomahawkSqlQuery query = newquery();
|
TomahawkSqlQuery query = newquery();
|
||||||
query.exec( QString( "SELECT url, mtime, size, md5, mimetype, duration, bitrate, "
|
query.exec( QString( "SELECT url, mtime, size, md5, mimetype, duration, bitrate, "
|
||||||
"file_join.artist, file_join.album, file_join.track, "
|
"file_join.artist, file_join.album, file_join.track, "
|
||||||
@@ -228,8 +228,8 @@ DatabaseImpl::file( int fid )
|
|||||||
if ( query.next() )
|
if ( query.next() )
|
||||||
{
|
{
|
||||||
Tomahawk::source_ptr s;
|
Tomahawk::source_ptr s;
|
||||||
|
QString url = query.value( 0 ).toString();
|
||||||
|
|
||||||
const QString url_str = query.value( 0 ).toString();
|
|
||||||
if ( query.value( 13 ).toUInt() == 0 )
|
if ( query.value( 13 ).toUInt() == 0 )
|
||||||
{
|
{
|
||||||
s = SourceList::instance()->getLocal();
|
s = SourceList::instance()->getLocal();
|
||||||
@@ -242,13 +242,13 @@ DatabaseImpl::file( int fid )
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
r->setUrl( QString( "servent://%1\t%2" ).arg( s->userName() ).arg( url_str ) );
|
url = QString( "servent://%1\t%2" ).arg( s->userName() ).arg( url );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r = Tomahawk::Result::get( url );
|
||||||
Tomahawk::artist_ptr artist = Tomahawk::Artist::get( query.value( 7 ).toUInt(), query.value( 10 ).toString() );
|
Tomahawk::artist_ptr artist = Tomahawk::Artist::get( query.value( 7 ).toUInt(), query.value( 10 ).toString() );
|
||||||
Tomahawk::album_ptr album = Tomahawk::Album::get( query.value( 8 ).toUInt(), query.value( 11 ).toString(), artist );
|
Tomahawk::album_ptr album = Tomahawk::Album::get( query.value( 8 ).toUInt(), query.value( 11 ).toString(), artist );
|
||||||
|
|
||||||
r->setUrl( query.value( 0 ).toString() );
|
|
||||||
r->setModificationTime( query.value( 1 ).toUInt() );
|
r->setModificationTime( query.value( 1 ).toUInt() );
|
||||||
r->setSize( query.value( 2 ).toUInt() );
|
r->setSize( query.value( 2 ).toUInt() );
|
||||||
r->setMimetype( query.value( 4 ).toString() );
|
r->setMimetype( query.value( 4 ).toString() );
|
||||||
@@ -556,7 +556,6 @@ DatabaseImpl::resultFromHint( const Tomahawk::query_ptr& origquery )
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = Tomahawk::result_ptr( new Tomahawk::Result() );
|
|
||||||
bool searchlocal = s->isLocal();
|
bool searchlocal = s->isLocal();
|
||||||
|
|
||||||
QString sql = QString( "SELECT "
|
QString sql = QString( "SELECT "
|
||||||
@@ -587,12 +586,11 @@ DatabaseImpl::resultFromHint( const Tomahawk::query_ptr& origquery )
|
|||||||
if( query.next() )
|
if( query.next() )
|
||||||
{
|
{
|
||||||
Tomahawk::source_ptr s;
|
Tomahawk::source_ptr s;
|
||||||
|
QString url = query.value( 0 ).toString();
|
||||||
|
|
||||||
const QString url_str = query.value( 0 ).toString();
|
|
||||||
if ( query.value( 13 ).toUInt() == 0 )
|
if ( query.value( 13 ).toUInt() == 0 )
|
||||||
{
|
{
|
||||||
s = SourceList::instance()->getLocal();
|
s = SourceList::instance()->getLocal();
|
||||||
res->setUrl( url_str );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -602,9 +600,10 @@ DatabaseImpl::resultFromHint( const Tomahawk::query_ptr& origquery )
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
res->setUrl( QString( "servent://%1\t%2" ).arg( s->userName() ).arg( url_str ) );
|
url = QString( "servent://%1\t%2" ).arg( s->userName() ).arg( url );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
res = Tomahawk::Result::get( url );
|
||||||
Tomahawk::artist_ptr artist = Tomahawk::Artist::get( query.value( 15 ).toUInt(), query.value( 10 ).toString() );
|
Tomahawk::artist_ptr artist = Tomahawk::Artist::get( query.value( 15 ).toUInt(), query.value( 10 ).toString() );
|
||||||
Tomahawk::album_ptr album = Tomahawk::Album::get( query.value( 16 ).toUInt(), query.value( 11 ).toString(), artist );
|
Tomahawk::album_ptr album = Tomahawk::Album::get( query.value( 16 ).toUInt(), query.value( 11 ).toString(), artist );
|
||||||
|
|
||||||
|
@@ -117,6 +117,8 @@ Pipeline::resolve( const QList<query_ptr>& qlist, bool prioritized, bool tempora
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
foreach( const query_ptr& q, qlist )
|
foreach( const query_ptr& q, qlist )
|
||||||
{
|
{
|
||||||
|
if ( q->resolvingFinished() )
|
||||||
|
continue;
|
||||||
if ( m_queries_pending.contains( q ) )
|
if ( m_queries_pending.contains( q ) )
|
||||||
continue;
|
continue;
|
||||||
if ( m_qidsState.contains( q->id() ) )
|
if ( m_qidsState.contains( q->id() ) )
|
||||||
|
@@ -393,7 +393,7 @@ TrackModel::ensureResolved()
|
|||||||
{
|
{
|
||||||
query_ptr query = itemFromIndex( index( i, 0, QModelIndex() ) )->query();
|
query_ptr query = itemFromIndex( index( i, 0, QModelIndex() ) )->query();
|
||||||
|
|
||||||
if ( !query->numResults() )
|
if ( !query->resolvingFinished() )
|
||||||
Pipeline::instance()->resolve( query );
|
Pipeline::instance()->resolve( query );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -165,6 +165,7 @@ Query::addResults( const QList< Tomahawk::result_ptr >& newresults )
|
|||||||
void
|
void
|
||||||
Query::refreshResults()
|
Query::refreshResults()
|
||||||
{
|
{
|
||||||
|
setResolveFinished( false );
|
||||||
Pipeline::instance()->resolve( id() );
|
Pipeline::instance()->resolve( id() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -32,8 +32,28 @@
|
|||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
|
||||||
Result::Result()
|
Tomahawk::result_ptr
|
||||||
|
Result::get( const QString& url )
|
||||||
|
{
|
||||||
|
static QHash< QString, result_ptr > s_results;
|
||||||
|
static QMutex s_mutex;
|
||||||
|
|
||||||
|
QMutexLocker lock( &s_mutex );
|
||||||
|
if ( s_results.contains( url ) )
|
||||||
|
{
|
||||||
|
return s_results.value( url );
|
||||||
|
}
|
||||||
|
|
||||||
|
result_ptr r = result_ptr( new Result( url ) );
|
||||||
|
s_results.insert( url, r );
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Result::Result( const QString& url )
|
||||||
: QObject()
|
: QObject()
|
||||||
|
, m_url( url )
|
||||||
, m_duration( 0 )
|
, m_duration( 0 )
|
||||||
, m_bitrate( 0 )
|
, m_bitrate( 0 )
|
||||||
, m_size( 0 )
|
, m_size( 0 )
|
||||||
@@ -142,6 +162,11 @@ Tomahawk::query_ptr
|
|||||||
Result::toQuery() const
|
Result::toQuery() const
|
||||||
{
|
{
|
||||||
Tomahawk::query_ptr query = Tomahawk::Query::get( artist()->name(), track(), album()->name() );
|
Tomahawk::query_ptr query = Tomahawk::Query::get( artist()->name(), track(), album()->name() );
|
||||||
|
QList<Tomahawk::result_ptr> rl;
|
||||||
|
rl << Result::get( m_url );
|
||||||
|
|
||||||
|
query->addResults( rl );
|
||||||
|
query->setResolveFinished( true );
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -56,7 +56,7 @@ friend class ::DatabaseCommand_AddFiles;
|
|||||||
friend class ::DatabaseCommand_LoadFile;
|
friend class ::DatabaseCommand_LoadFile;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Result();
|
static Tomahawk::result_ptr get( const QString& url );
|
||||||
virtual ~Result();
|
virtual ~Result();
|
||||||
|
|
||||||
QVariant toVariant() const;
|
QVariant toVariant() const;
|
||||||
@@ -92,7 +92,6 @@ public:
|
|||||||
void setArtist( const Tomahawk::artist_ptr& artist );
|
void setArtist( const Tomahawk::artist_ptr& artist );
|
||||||
void setAlbum( const Tomahawk::album_ptr& album );
|
void setAlbum( const Tomahawk::album_ptr& album );
|
||||||
void setTrack( const QString& track ) { m_track = track; }
|
void setTrack( const QString& track ) { m_track = track; }
|
||||||
void setUrl( const QString& url ) { m_url = url; }
|
|
||||||
void setMimetype( const QString& mimetype ) { m_mimetype = mimetype; }
|
void setMimetype( const QString& mimetype ) { m_mimetype = mimetype; }
|
||||||
void setDuration( unsigned int duration ) { m_duration = duration; }
|
void setDuration( unsigned int duration ) { m_duration = duration; }
|
||||||
void setBitrate( unsigned int bitrate ) { m_bitrate = bitrate; }
|
void setBitrate( unsigned int bitrate ) { m_bitrate = bitrate; }
|
||||||
@@ -124,6 +123,9 @@ private slots:
|
|||||||
void onOnline();
|
void onOnline();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// private constructor
|
||||||
|
explicit Result( const QString& url );
|
||||||
|
|
||||||
void updateAttributes();
|
void updateAttributes();
|
||||||
void parseSocialActions();
|
void parseSocialActions();
|
||||||
|
|
||||||
|
@@ -316,13 +316,12 @@ QtScriptResolver::parseResultVariantList( const QVariantList& reslist )
|
|||||||
{
|
{
|
||||||
QVariantMap m = rv.toMap();
|
QVariantMap m = rv.toMap();
|
||||||
|
|
||||||
Tomahawk::result_ptr rp( new Tomahawk::Result() );
|
Tomahawk::result_ptr rp = Tomahawk::Result::get( m.value( "url" ).toString() );
|
||||||
Tomahawk::artist_ptr ap = Tomahawk::Artist::get( 0, m.value( "artist" ).toString() );
|
Tomahawk::artist_ptr ap = Tomahawk::Artist::get( 0, m.value( "artist" ).toString() );
|
||||||
rp->setArtist( ap );
|
rp->setArtist( ap );
|
||||||
rp->setAlbum( Tomahawk::Album::get( 0, m.value( "album" ).toString(), ap ) );
|
rp->setAlbum( Tomahawk::Album::get( 0, m.value( "album" ).toString(), ap ) );
|
||||||
rp->setTrack( m.value( "track" ).toString() );
|
rp->setTrack( m.value( "track" ).toString() );
|
||||||
rp->setBitrate( m.value( "bitrate" ).toUInt() );
|
rp->setBitrate( m.value( "bitrate" ).toUInt() );
|
||||||
rp->setUrl( m.value( "url" ).toString() );
|
|
||||||
rp->setSize( m.value( "size" ).toUInt() );
|
rp->setSize( m.value( "size" ).toUInt() );
|
||||||
rp->setRID( uuid() );
|
rp->setRID( uuid() );
|
||||||
rp->setFriendlySource( name() );
|
rp->setFriendlySource( name() );
|
||||||
|
@@ -212,14 +212,13 @@ ScriptResolver::handleMsg( const QByteArray& msg )
|
|||||||
QVariantMap m = rv.toMap();
|
QVariantMap m = rv.toMap();
|
||||||
qDebug() << "Found result:" << m;
|
qDebug() << "Found result:" << m;
|
||||||
|
|
||||||
Tomahawk::result_ptr rp( new Tomahawk::Result() );
|
Tomahawk::result_ptr rp = Tomahawk::Result::get( m.value( "url" ).toString() );
|
||||||
Tomahawk::artist_ptr ap = Tomahawk::Artist::get( 0, m.value( "artist" ).toString() );
|
Tomahawk::artist_ptr ap = Tomahawk::Artist::get( 0, m.value( "artist" ).toString() );
|
||||||
rp->setArtist( ap );
|
rp->setArtist( ap );
|
||||||
rp->setAlbum( Tomahawk::Album::get( 0, m.value( "album" ).toString(), ap ) );
|
rp->setAlbum( Tomahawk::Album::get( 0, m.value( "album" ).toString(), ap ) );
|
||||||
rp->setTrack( m.value( "track" ).toString() );
|
rp->setTrack( m.value( "track" ).toString() );
|
||||||
rp->setDuration( m.value( "duration" ).toUInt() );
|
rp->setDuration( m.value( "duration" ).toUInt() );
|
||||||
rp->setBitrate( m.value( "bitrate" ).toUInt() );
|
rp->setBitrate( m.value( "bitrate" ).toUInt() );
|
||||||
rp->setUrl( m.value( "url" ).toString() );
|
|
||||||
rp->setSize( m.value( "size" ).toUInt() );
|
rp->setSize( m.value( "size" ).toUInt() );
|
||||||
rp->setRID( uuid() );
|
rp->setRID( uuid() );
|
||||||
rp->setFriendlySource( m_name );
|
rp->setFriendlySource( m_name );
|
||||||
|
@@ -48,12 +48,12 @@ CollectionItem::CollectionItem( SourcesModel* mdl, SourceTreeItem* parent, cons
|
|||||||
{
|
{
|
||||||
m_lovedTracksItem = new GenericPageItem( model(), this, ( m_source.isNull() ? tr( "Top Loved Tracks" ) : tr( "Loved Tracks" ) ), QIcon( RESPATH "images/loved_playlist.png" ),
|
m_lovedTracksItem = new GenericPageItem( model(), this, ( m_source.isNull() ? tr( "Top Loved Tracks" ) : tr( "Loved Tracks" ) ), QIcon( RESPATH "images/loved_playlist.png" ),
|
||||||
boost::bind( &CollectionItem::lovedTracksClicked, this ),
|
boost::bind( &CollectionItem::lovedTracksClicked, this ),
|
||||||
boost::bind( &CollectionItem::getLovedTracksPage, this )
|
boost::bind( &CollectionItem::getLovedTracksPage, this ) );
|
||||||
);
|
|
||||||
m_lovedTracksItem->setSortValue( -250 );
|
m_lovedTracksItem->setSortValue( -250 );
|
||||||
|
|
||||||
|
if ( m_source.isNull() )
|
||||||
if( m_source.isNull() ) { // super collection
|
{
|
||||||
|
// super collection
|
||||||
connect( ViewManager::instance(), SIGNAL( tempPageActivated( Tomahawk::ViewPage*) ), this, SLOT( tempPageActivated( Tomahawk::ViewPage* ) ) );
|
connect( ViewManager::instance(), SIGNAL( tempPageActivated( Tomahawk::ViewPage*) ), this, SLOT( tempPageActivated( Tomahawk::ViewPage* ) ) );
|
||||||
|
|
||||||
// add misc children of root node
|
// add misc children of root node
|
||||||
@@ -84,8 +84,7 @@ CollectionItem::CollectionItem( SourcesModel* mdl, SourceTreeItem* parent, cons
|
|||||||
|
|
||||||
m_sourceInfoItem = new GenericPageItem( model(), this, tr( "New Additions" ), QIcon( RESPATH "images/new-additions.png" ),
|
m_sourceInfoItem = new GenericPageItem( model(), this, tr( "New Additions" ), QIcon( RESPATH "images/new-additions.png" ),
|
||||||
boost::bind( &CollectionItem::sourceInfoClicked, this ),
|
boost::bind( &CollectionItem::sourceInfoClicked, this ),
|
||||||
boost::bind( &CollectionItem::getSourceInfoPage, this )
|
boost::bind( &CollectionItem::getSourceInfoPage, this ) );
|
||||||
);
|
|
||||||
m_sourceInfoItem->setSortValue( -300 );
|
m_sourceInfoItem->setSortValue( -300 );
|
||||||
|
|
||||||
// create category items if there are playlists to show, or stations to show
|
// create category items if there are playlists to show, or stations to show
|
||||||
@@ -238,9 +237,11 @@ CollectionItem::playlistDeletedInternal( SourceTreeItem* parent, const T& p )
|
|||||||
{
|
{
|
||||||
Q_ASSERT( parent ); // How can we delete playlists if we have none?
|
Q_ASSERT( parent ); // How can we delete playlists if we have none?
|
||||||
int curCount = parent->children().count();
|
int curCount = parent->children().count();
|
||||||
for( int i = 0; i < curCount; i++ ) {
|
for( int i = 0; i < curCount; i++ )
|
||||||
|
{
|
||||||
PlaylistItem* pl = qobject_cast< PlaylistItem* >( parent->children().at( i ) );
|
PlaylistItem* pl = qobject_cast< PlaylistItem* >( parent->children().at( i ) );
|
||||||
if( pl && pl->playlist() == p ) {
|
if( pl && pl->playlist() == p )
|
||||||
|
{
|
||||||
parent->beginRowsRemoved( i, i );
|
parent->beginRowsRemoved( i, i );
|
||||||
parent->removeChild( pl );
|
parent->removeChild( pl );
|
||||||
parent->endRowsRemoved();
|
parent->endRowsRemoved();
|
||||||
@@ -324,7 +325,9 @@ CollectionItem::onAutoPlaylistsAdded( const QList< dynplaylist_ptr >& playlists
|
|||||||
if( playlists.isEmpty() )
|
if( playlists.isEmpty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( !m_playlists ) { // add the category too
|
if( !m_playlists )
|
||||||
|
{
|
||||||
|
// add the category too
|
||||||
int cur = children().count();
|
int cur = children().count();
|
||||||
beginRowsAdded( cur, cur );
|
beginRowsAdded( cur, cur );
|
||||||
m_playlists = new CategoryItem( model(), this, SourcesModel::PlaylistsCategory, source()->isLocal() );
|
m_playlists = new CategoryItem( model(), this, SourcesModel::PlaylistsCategory, source()->isLocal() );
|
||||||
@@ -351,7 +354,9 @@ CollectionItem::onStationsAdded( const QList< dynplaylist_ptr >& stations )
|
|||||||
if( stations.isEmpty() )
|
if( stations.isEmpty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( !m_stations ) { // add the category too
|
if( !m_stations )
|
||||||
|
{
|
||||||
|
// add the category too
|
||||||
int cur = children().count();
|
int cur = children().count();
|
||||||
beginRowsAdded( cur, cur );
|
beginRowsAdded( cur, cur );
|
||||||
m_stations = new CategoryItem( model(), this, SourcesModel::StationsCategory, source()->isLocal() );
|
m_stations = new CategoryItem( model(), this, SourcesModel::StationsCategory, source()->isLocal() );
|
||||||
@@ -397,6 +402,7 @@ CollectionItem::tempPageActivated( Tomahawk::ViewPage* v )
|
|||||||
emit selectRequest( tempPage );
|
emit selectRequest( tempPage );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ViewPage*
|
ViewPage*
|
||||||
CollectionItem::sourceInfoClicked()
|
CollectionItem::sourceInfoClicked()
|
||||||
{
|
{
|
||||||
@@ -414,6 +420,7 @@ CollectionItem::getSourceInfoPage() const
|
|||||||
return m_sourceInfoPage;
|
return m_sourceInfoPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ViewPage*
|
ViewPage*
|
||||||
CollectionItem::coolPlaylistsClicked()
|
CollectionItem::coolPlaylistsClicked()
|
||||||
{
|
{
|
||||||
@@ -427,12 +434,14 @@ CollectionItem::coolPlaylistsClicked()
|
|||||||
return m_coolPlaylistsPage;
|
return m_coolPlaylistsPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ViewPage*
|
ViewPage*
|
||||||
CollectionItem::getCoolPlaylistsPage() const
|
CollectionItem::getCoolPlaylistsPage() const
|
||||||
{
|
{
|
||||||
return m_coolPlaylistsPage;
|
return m_coolPlaylistsPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ViewPage*
|
ViewPage*
|
||||||
CollectionItem::lovedTracksClicked()
|
CollectionItem::lovedTracksClicked()
|
||||||
{
|
{
|
||||||
@@ -443,6 +452,7 @@ CollectionItem::lovedTracksClicked()
|
|||||||
return m_lovedTracksPage;
|
return m_lovedTracksPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ViewPage*
|
ViewPage*
|
||||||
CollectionItem::getLovedTracksPage() const
|
CollectionItem::getLovedTracksPage() const
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user