1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-11 00:24:12 +02: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() ) while( query.next() )
{ {
Tomahawk::source_ptr s;
QString url = query.value( 8 ).toString(); QString url = query.value( 8 ).toString();
Tomahawk::source_ptr s = SourceList::instance()->get( query.value( 9 ).toUInt() );
if ( query.value( 9 ).toUInt() == 0 ) if ( !s )
{ {
s = SourceList::instance()->getLocal(); Q_ASSERT( false );
continue;
} }
else if ( !s->isLocal() )
{
s = SourceList::instance()->get( query.value( 9 ).toUInt() );
if ( s.isNull() )
{
Q_ASSERT( false );
continue;
}
url = QString( "servent://%1\t%2" ).arg( s->nodeId() ).arg( url ); url = QString( "servent://%1\t%2" ).arg( s->nodeId() ).arg( url );
}
QString artist, track, album, composer; QString artist, track, album, composer;
artist = query.value( 1 ).toString(); artist = query.value( 1 ).toString();

View File

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

View File

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

View File

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

View File

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