mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-13 17:43:59 +02:00
Properly save (or not) resulthints in playlist_entries
This commit is contained in:
@@ -153,7 +153,7 @@ DatabaseCommand_SetPlaylistRevision::exec( DatabaseImpl* lib )
|
|||||||
if ( !e->query()->numResults() )
|
if ( !e->query()->numResults() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
adde.bindValue( 0, e->query()->results().first()->url() );
|
adde.bindValue( 0, hintFromQuery( e->query() ) );
|
||||||
adde.bindValue( 1, e->guid() );
|
adde.bindValue( 1, e->guid() );
|
||||||
adde.exec();
|
adde.exec();
|
||||||
}
|
}
|
||||||
@@ -189,7 +189,7 @@ DatabaseCommand_SetPlaylistRevision::exec( DatabaseImpl* lib )
|
|||||||
"VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
|
"VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
|
||||||
adde.prepare( sql );
|
adde.prepare( sql );
|
||||||
|
|
||||||
qDebug() << "Num new playlist_items to add:" << m_addedentries.length();
|
// qDebug() << "Num new playlist_items to add:" << m_addedentries.length();
|
||||||
foreach( const plentry_ptr& e, m_addedentries )
|
foreach( const plentry_ptr& e, m_addedentries )
|
||||||
{
|
{
|
||||||
if ( !e->isValid() )
|
if ( !e->isValid() )
|
||||||
@@ -199,19 +199,7 @@ DatabaseCommand_SetPlaylistRevision::exec( DatabaseImpl* lib )
|
|||||||
|
|
||||||
m_addedmap.insert( e->guid(), e ); // needed in postcommithook
|
m_addedmap.insert( e->guid(), e ); // needed in postcommithook
|
||||||
|
|
||||||
QString resultHint, foundResult;
|
const QString resultHint = hintFromQuery( e->query() );
|
||||||
if ( !e->query()->results().isEmpty() )
|
|
||||||
foundResult = e->query()->results().first()->url();
|
|
||||||
else if ( !e->query()->resultHint().isEmpty() )
|
|
||||||
foundResult = e->query()->resultHint();
|
|
||||||
|
|
||||||
if ( foundResult.startsWith( "file://" ) ||
|
|
||||||
foundResult.startsWith( "servent://" ) || // Save resulthints for local files and peers automatically
|
|
||||||
( foundResult.startsWith( "http" ) && e->query()->saveHTTPResultHint() ) )
|
|
||||||
{
|
|
||||||
resultHint = foundResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
adde.bindValue( 0, e->guid() );
|
adde.bindValue( 0, e->guid() );
|
||||||
adde.bindValue( 1, m_playlistguid );
|
adde.bindValue( 1, m_playlistguid );
|
||||||
@@ -279,3 +267,24 @@ DatabaseCommand_SetPlaylistRevision::exec( DatabaseImpl* lib )
|
|||||||
// Q_ASSERT( false );
|
// Q_ASSERT( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
DatabaseCommand_SetPlaylistRevision::hintFromQuery( const query_ptr& query ) const
|
||||||
|
{
|
||||||
|
QString resultHint, foundResult;
|
||||||
|
if ( !query->results().isEmpty() )
|
||||||
|
foundResult = query->results().first()->url();
|
||||||
|
else if ( !query->resultHint().isEmpty() )
|
||||||
|
foundResult = query->resultHint();
|
||||||
|
|
||||||
|
if ( foundResult.startsWith( "file://" ) ||
|
||||||
|
foundResult.startsWith( "servent://" ) || // Save resulthints for local files and peers automatically
|
||||||
|
( foundResult.startsWith( "http" ) && query->saveHTTPResultHint() ) )
|
||||||
|
{
|
||||||
|
resultHint = foundResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultHint;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -122,6 +122,8 @@ protected:
|
|||||||
QString m_currentRevision;
|
QString m_currentRevision;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QString hintFromQuery( const query_ptr& query ) const;
|
||||||
|
|
||||||
QVariantList m_orderedguids;
|
QVariantList m_orderedguids;
|
||||||
QList<Tomahawk::plentry_ptr> m_addedentries, m_entries;
|
QList<Tomahawk::plentry_ptr> m_addedentries, m_entries;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user