diff --git a/src/libtomahawk/database/DatabaseCommand_AllTracks.cpp b/src/libtomahawk/database/DatabaseCommand_AllTracks.cpp index dcf1b0e51..56878142c 100644 --- a/src/libtomahawk/database/DatabaseCommand_AllTracks.cpp +++ b/src/libtomahawk/database/DatabaseCommand_AllTracks.cpp @@ -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(); diff --git a/src/libtomahawk/database/DatabaseCommand_PlaybackHistory.cpp b/src/libtomahawk/database/DatabaseCommand_PlaybackHistory.cpp index 2c1709031..fd5695997 100644 --- a/src/libtomahawk/database/DatabaseCommand_PlaybackHistory.cpp +++ b/src/libtomahawk/database/DatabaseCommand_PlaybackHistory.cpp @@ -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; diff --git a/src/libtomahawk/database/DatabaseCommand_Resolve.cpp b/src/libtomahawk/database/DatabaseCommand_Resolve.cpp index 73f6eccc7..7d847bbdb 100644 --- a/src/libtomahawk/database/DatabaseCommand_Resolve.cpp +++ b/src/libtomahawk/database/DatabaseCommand_Resolve.cpp @@ -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 ); diff --git a/src/libtomahawk/database/DatabaseImpl.cpp b/src/libtomahawk/database/DatabaseImpl.cpp index 246b890f2..5c604336d 100644 --- a/src/libtomahawk/database/DatabaseImpl.cpp +++ b/src/libtomahawk/database/DatabaseImpl.cpp @@ -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 ); diff --git a/src/libtomahawk/widgets/RecentPlaylistsModel.cpp b/src/libtomahawk/widgets/RecentPlaylistsModel.cpp index 4b26d4c0c..1d44adfcc 100644 --- a/src/libtomahawk/widgets/RecentPlaylistsModel.cpp +++ b/src/libtomahawk/widgets/RecentPlaylistsModel.cpp @@ -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 );