1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-13 17:43:59 +02:00

Merge remote-tracking branch 'origin' into phonon

This commit is contained in:
Christian Muehlhaeuser
2011-03-16 01:52:20 +01:00
6 changed files with 35 additions and 9 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

@@ -459,7 +459,7 @@ DatabaseImpl::result( const QString& url )
{
TomahawkSqlQuery query = newquery();
Tomahawk::source_ptr s;
Tomahawk::result_ptr res = Tomahawk::result_ptr( new Tomahawk::Result() );
Tomahawk::result_ptr res;
QString fileUrl;
if ( url.contains( "servent://" ) )
@@ -477,8 +477,13 @@ DatabaseImpl::result( const QString& url )
fileUrl = url;
}
else
Q_ASSERT( false );
{
// Q_ASSERT( false );
qDebug() << "We don't support non-servent / non-file result-hints yet.";
return res;
}
res = Tomahawk::result_ptr( new Tomahawk::Result() );
bool searchlocal = s->isLocal();
QString sql = QString( "SELECT "

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;
}