1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-05 13:47:26 +02:00

* Show proper origin name for script-resolved results.

This commit is contained in:
Christian Muehlhaeuser
2011-03-16 01:48:26 +01:00
parent d2a7a367e0
commit 057cb04e9c
5 changed files with 28 additions and 7 deletions

View File

@@ -236,7 +236,7 @@ AudioControls::onPlaybackLoading( const Tomahawk::result_ptr& result )
ui->artistTrackLabel->setResult( result );
ui->albumLabel->setResult( result );
ui->ownerLabel->setText( result->collection()->source()->friendlyName() );
ui->ownerLabel->setText( result->friendlySource() );
ui->coverImage->setPixmap( m_defaultCover );
if ( ui->timeLabel->text().isEmpty() )

View File

@@ -176,7 +176,7 @@ TrackModel::data( const QModelIndex& index, int role ) const
break;
case Origin:
return query->results().first()->collection()->source()->friendlyName();
return query->results().first()->friendlySource();
break;
}
}

View File

@@ -46,12 +46,18 @@ Result::collection() const
float
Result::score() const
{
if ( collection()->source()->isOnline() )
if ( !collection().isNull() && collection()->source()->isOnline() )
{
return m_score;
}
else
{
// check if this a valid collection-less result (e.g. from youtube, but ignore offline sources still)
if ( collection().isNull() )
return m_score;
else
return 0.0;
}
}
@@ -144,3 +150,15 @@ Result::setCollection( const Tomahawk::collection_ptr& collection )
connect( m_collection->source().data(), SIGNAL( online() ), SLOT( onOnline() ), Qt::QueuedConnection );
connect( m_collection->source().data(), SIGNAL( offline() ), SLOT( onOffline() ), Qt::QueuedConnection );
}
QString
Result::friendlySource() const
{
if ( collection().isNull() )
{
return m_friendlySource;
}
else
return collection()->source()->friendlyName();
}

View File

@@ -43,6 +43,7 @@ public:
QString track() const { return m_track; }
QString url() const { return m_url; }
QString mimetype() const { return m_mimetype; }
QString friendlySource() const;
unsigned int duration() const { return m_duration; }
unsigned int bitrate() const { return m_bitrate; }
@@ -55,6 +56,7 @@ public:
void setId( unsigned int id ) { m_id = id; }
void setRID( RID id ) { m_rid = id; }
void setCollection( const Tomahawk::collection_ptr& collection );
void setFriendlySource( const QString& s ) { m_friendlySource = s; }
void setArtist( const Tomahawk::artist_ptr& artist );
void setAlbum( const Tomahawk::album_ptr& album );
void setTrack( const QString& track ) { m_track = track; }
@@ -90,6 +92,7 @@ private:
QString m_track;
QString m_url;
QString m_mimetype;
QString m_friendlySource;
unsigned int m_duration;
unsigned int m_bitrate;

View File

@@ -134,7 +134,7 @@ ScriptResolver::handleMsg( const QByteArray& msg )
rp->setSize( m.value( "size" ).toUInt() );
rp->setScore( m.value( "score" ).toFloat() * ( (float)weight() / 100.0 ) );
rp->setRID( uuid() );
rp->setCollection( coll );
rp->setFriendlySource( m_name );
results << rp;
}