1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-18 23:09:42 +01:00

* No need to manually check for source id being 0.

This commit is contained in:
Christian Muehlhaeuser 2013-04-26 11:46:41 +02:00
parent 4aa85bce34
commit a027f4f0b2
5 changed files with 24 additions and 84 deletions

View File

@ -96,24 +96,15 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
while( query.next() )
{
Tomahawk::source_ptr s;
QString url = query.value( 8 ).toString();
if ( query.value( 9 ).toUInt() == 0 )
Tomahawk::source_ptr s = SourceList::instance()->get( query.value( 9 ).toUInt() );
if ( !s )
{
s = SourceList::instance()->getLocal();
Q_ASSERT( false );
continue;
}
else
{
s = SourceList::instance()->get( query.value( 9 ).toUInt() );
if ( s.isNull() )
{
Q_ASSERT( false );
continue;
}
if ( !s->isLocal() )
url = QString( "servent://%1\t%2" ).arg( s->nodeId() ).arg( url );
}
QString artist, track, album, composer;
artist = query.value( 1 ).toString();

View File

@ -73,15 +73,7 @@ DatabaseCommand_PlaybackHistory::exec( DatabaseImpl* dbi )
Tomahawk::PlaybackLog log;
log.timestamp = query.value( 1 ).toUInt();
log.secsPlayed = query.value( 2 ).toUInt();
if ( query.value( 3 ).toUInt() == 0 )
{
log.source = SourceList::instance()->getLocal();
}
else
{
log.source = SourceList::instance()->get( query.value( 3 ).toUInt() );
}
log.source = SourceList::instance()->get( query.value( 3 ).toUInt() );
logs << log;
tl << track;

View File

@ -123,24 +123,15 @@ DatabaseCommand_Resolve::resolve( DatabaseImpl* lib )
while ( files_query.next() )
{
source_ptr s;
QString url = files_query.value( 0 ).toString();
if ( files_query.value( 16 ).toUInt() == 0 )
source_ptr s = SourceList::instance()->get( files_query.value( 16 ).toUInt() );
if ( !s )
{
s = SourceList::instance()->getLocal();
tDebug() << "Could not find source" << files_query.value( 16 ).toUInt();
continue;
}
else
{
s = SourceList::instance()->get( files_query.value( 16 ).toUInt() );
if ( s.isNull() )
{
qDebug() << "Could not find source" << files_query.value( 16 ).toUInt();
continue;
}
if ( !s->isLocal() )
url = QString( "servent://%1\t%2" ).arg( s->nodeId() ).arg( url );
}
Tomahawk::result_ptr result = Tomahawk::Result::get( url );
if ( result->isValid() )
@ -253,24 +244,15 @@ DatabaseCommand_Resolve::fullTextResolve( DatabaseImpl* lib )
while ( files_query.next() )
{
source_ptr s;
QString url = files_query.value( 0 ).toString();
if ( files_query.value( 16 ).toUInt() == 0 )
source_ptr s = SourceList::instance()->get( files_query.value( 16 ).toUInt() );
if ( !s )
{
s = SourceList::instance()->getLocal();
tDebug() << "Could not find source" << files_query.value( 16 ).toUInt();
continue;
}
else
{
s = SourceList::instance()->get( files_query.value( 16 ).toUInt() );
if ( s.isNull() )
{
qDebug() << "Could not find source" << files_query.value( 16 ).toUInt();
continue;
}
if ( !s->isLocal() )
url = QString( "servent://%1\t%2" ).arg( s->nodeId() ).arg( url );
}
bool cached = Tomahawk::Result::isCached( url );
Tomahawk::result_ptr result = Tomahawk::Result::get( url );

View File

@ -278,23 +278,12 @@ DatabaseImpl::file( int fid )
if ( query.next() )
{
Tomahawk::source_ptr s;
QString url = query.value( 0 ).toString();
if ( query.value( 15 ).toUInt() == 0 )
{
s = SourceList::instance()->getLocal();
}
else
{
s = SourceList::instance()->get( query.value( 15 ).toUInt() );
if ( s.isNull() )
{
return r;
}
Tomahawk::source_ptr s = SourceList::instance()->get( query.value( 15 ).toUInt() );
if ( !s )
return r;
if ( !s->isLocal() )
url = QString( "servent://%1\t%2" ).arg( s->nodeId() ).arg( url );
}
r = Tomahawk::Result::get( url );
@ -670,23 +659,12 @@ DatabaseImpl::resultFromHint( const Tomahawk::query_ptr& origquery )
if( query.next() )
{
Tomahawk::source_ptr s;
QString url = query.value( 0 ).toString();
if ( query.value( 15 ).toUInt() == 0 )
{
s = SourceList::instance()->getLocal();
}
else
{
s = SourceList::instance()->get( query.value( 15 ).toUInt() );
if ( s.isNull() )
{
return res;
}
Tomahawk::source_ptr s = SourceList::instance()->get( query.value( 15 ).toUInt() );
if ( !s )
return res;
if ( !s->isLocal() )
url = QString( "servent://%1\t%2" ).arg( s->nodeId() ).arg( url );
}
res = Tomahawk::Result::get( url );

View File

@ -99,9 +99,6 @@ RecentPlaylistsModel::playlistsLoaded( const QList<DatabaseCommand_LoadAllSorted
if ( s.isNull() )
continue;
if ( plPair.first == 0 )
s = SourceList::instance()->getLocal();
playlist_ptr pl = s->dbCollection()->playlist( plPair.second );
if ( pl.isNull() )
pl = s->dbCollection()->autoPlaylist( plPair.second );