mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-04 21:27:58 +02:00
* Show proper origin name for script-resolved results.
This commit is contained in:
@@ -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() )
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
return 0.0;
|
||||
{
|
||||
// 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();
|
||||
}
|
||||
|
@@ -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; }
|
||||
@@ -65,7 +67,7 @@ public:
|
||||
void setSize( unsigned int size ) { m_size = size; }
|
||||
void setAlbumPos( unsigned int albumpos ) { m_albumpos = albumpos; }
|
||||
void setModificationTime( unsigned int modtime ) { m_modtime = modtime; }
|
||||
|
||||
|
||||
QVariantMap attributes() const { return m_attributes; }
|
||||
void setAttributes( const QVariantMap& map ) { m_attributes = map; updateAttributes(); }
|
||||
|
||||
@@ -74,7 +76,7 @@ public:
|
||||
signals:
|
||||
// emitted when the collection this result comes from is going offline/online:
|
||||
void statusChanged();
|
||||
|
||||
|
||||
private slots:
|
||||
void onOffline();
|
||||
void onOnline();
|
||||
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user