mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
* Only update playlist when a result-hint has been changed.
This commit is contained in:
@@ -64,7 +64,7 @@ PlaylistEntry::setQueryVariant( const QVariant& v )
|
|||||||
QString album = m.value( "album" ).toString();
|
QString album = m.value( "album" ).toString();
|
||||||
QString track = m.value( "track" ).toString();
|
QString track = m.value( "track" ).toString();
|
||||||
|
|
||||||
m_query = Tomahawk::Query::get( artist, track, album );
|
setQuery( Tomahawk::Query::get( artist, track, album ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -79,6 +79,8 @@ void
|
|||||||
PlaylistEntry::setQuery( const Tomahawk::query_ptr& q )
|
PlaylistEntry::setQuery( const Tomahawk::query_ptr& q )
|
||||||
{
|
{
|
||||||
m_query = q;
|
m_query = q;
|
||||||
|
|
||||||
|
connect( q.data(), SIGNAL( resolvingFinished( bool ) ), SLOT( onQueryResolved( bool ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -103,6 +105,48 @@ PlaylistEntry::setLastSource( source_ptr s )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistEntry::onQueryResolved( bool hasResults )
|
||||||
|
{
|
||||||
|
if ( !hasResults )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( resultHint().isEmpty() )
|
||||||
|
setResultHint( hintFromQuery() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistEntry::setResultHint( const QString& s )
|
||||||
|
{
|
||||||
|
if ( m_resulthint == s )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_resulthint = s;
|
||||||
|
emit resultChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
PlaylistEntry::hintFromQuery() const
|
||||||
|
{
|
||||||
|
QString resultHint, foundResult;
|
||||||
|
if ( !m_query->results().isEmpty() )
|
||||||
|
foundResult = m_query->results().first()->url();
|
||||||
|
else if ( !m_query->resultHint().isEmpty() )
|
||||||
|
foundResult = m_query->resultHint();
|
||||||
|
|
||||||
|
if ( foundResult.startsWith( "file://" ) ||
|
||||||
|
foundResult.startsWith( "servent://" ) || // Save resulthints for local files and peers automatically
|
||||||
|
( TomahawkUtils::whitelistedHttpResultHint( foundResult ) && m_query->saveHTTPResultHint() ) )
|
||||||
|
{
|
||||||
|
resultHint = foundResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultHint;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Playlist::Playlist( const source_ptr& author )
|
Playlist::Playlist( const source_ptr& author )
|
||||||
: m_source( author )
|
: m_source( author )
|
||||||
, m_lastmodified( 0 )
|
, m_lastmodified( 0 )
|
||||||
@@ -533,8 +577,7 @@ Playlist::setRevision( const QString& rev,
|
|||||||
|
|
||||||
foreach( const plentry_ptr& entry, m_entries )
|
foreach( const plentry_ptr& entry, m_entries )
|
||||||
{
|
{
|
||||||
connect( entry->query().data(), SIGNAL( resultsChanged() ),
|
connect( entry.data(), SIGNAL( resultChanged() ), SLOT( onResultsChanged() ), Qt::UniqueConnection );
|
||||||
SLOT( onResultsChanged() ), Qt::UniqueConnection );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setBusy( false );
|
setBusy( false );
|
||||||
|
@@ -76,7 +76,7 @@ public:
|
|||||||
void setAnnotation( const QString& s ) { m_annotation = s; }
|
void setAnnotation( const QString& s ) { m_annotation = s; }
|
||||||
|
|
||||||
QString resultHint() const { return m_resulthint; }
|
QString resultHint() const { return m_resulthint; }
|
||||||
void setResultHint( const QString& s ) { m_resulthint= s; }
|
void setResultHint( const QString& s );
|
||||||
|
|
||||||
unsigned int duration() const { return m_duration; }
|
unsigned int duration() const { return m_duration; }
|
||||||
void setDuration( unsigned int i ) { m_duration = i; }
|
void setDuration( unsigned int i ) { m_duration = i; }
|
||||||
@@ -87,7 +87,15 @@ public:
|
|||||||
source_ptr lastSource() const;
|
source_ptr lastSource() const;
|
||||||
void setLastSource( source_ptr s );
|
void setLastSource( source_ptr s );
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void resultChanged();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onQueryResolved( bool hasResults );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QString hintFromQuery() const;
|
||||||
|
|
||||||
QString m_guid;
|
QString m_guid;
|
||||||
Tomahawk::query_ptr m_query;
|
Tomahawk::query_ptr m_query;
|
||||||
QString m_annotation;
|
QString m_annotation;
|
||||||
|
Reference in New Issue
Block a user