mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 15:59:42 +01:00
* Properly exclude queries without album position.
This commit is contained in:
parent
7f9fc557a9
commit
b80f3717b8
@ -192,18 +192,18 @@ TreeProxyModel::filterFinished()
|
||||
bool
|
||||
TreeProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
|
||||
{
|
||||
TreeModelItem* pi = sourceModel()->itemFromIndex( sourceModel()->index( sourceRow, 0, sourceParent ) );
|
||||
Q_ASSERT( pi );
|
||||
TreeModelItem* item = sourceModel()->itemFromIndex( sourceModel()->index( sourceRow, 0, sourceParent ) );
|
||||
Q_ASSERT( item );
|
||||
|
||||
if ( m_model->mode() == Tomahawk::DatabaseMode && !pi->result().isNull() )
|
||||
if ( m_model->mode() == Tomahawk::DatabaseMode && !item->result().isNull() )
|
||||
{
|
||||
QList< Tomahawk::result_ptr > rl = m_cache.values( sourceParent );
|
||||
foreach ( const Tomahawk::result_ptr& result, rl )
|
||||
foreach ( const Tomahawk::result_ptr& cachedResult, rl )
|
||||
{
|
||||
if ( result->track() == pi->result()->track() &&
|
||||
( result->albumpos() == pi->result()->albumpos() || result->albumpos() == 0 ) )
|
||||
if ( cachedResult->track() == item->result()->track() &&
|
||||
( cachedResult->albumpos() == item->result()->albumpos() || cachedResult->albumpos() == 0 ) )
|
||||
{
|
||||
return ( result.data() == pi->result().data() );
|
||||
return ( cachedResult.data() == item->result().data() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -214,13 +214,13 @@ TreeProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent
|
||||
|
||||
TreeModelItem* ti = sourceModel()->itemFromIndex( sourceModel()->index( i, 0, sourceParent ) );
|
||||
|
||||
if ( ti->name() == pi->name() &&
|
||||
( ti->result()->albumpos() == pi->result()->albumpos() || ti->result()->albumpos() == 0 ) )
|
||||
if ( ti->name() == item->name() &&
|
||||
( ti->result()->albumpos() == item->result()->albumpos() || ti->result()->albumpos() == 0 || item->result()->albumpos() == 0 ) )
|
||||
{
|
||||
if ( !pi->result()->isOnline() && ti->result()->isOnline() )
|
||||
if ( !item->result()->isOnline() && ti->result()->isOnline() )
|
||||
return false;
|
||||
|
||||
if ( !pi->result()->collection()->source()->isLocal() && ti->result()->collection()->source()->isLocal() )
|
||||
if ( !item->result()->collection()->source()->isLocal() && ti->result()->collection()->source()->isLocal() )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -229,26 +229,26 @@ TreeProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent
|
||||
bool accepted = false;
|
||||
if ( m_filter.isEmpty() )
|
||||
accepted = true;
|
||||
else if ( !pi->artist().isNull() )
|
||||
accepted = m_artistsFilter.contains( pi->artist() );
|
||||
else if ( !pi->album().isNull() )
|
||||
accepted = m_albumsFilter.contains( pi->album()->id() );
|
||||
else if ( !item->artist().isNull() )
|
||||
accepted = m_artistsFilter.contains( item->artist() );
|
||||
else if ( !item->album().isNull() )
|
||||
accepted = m_albumsFilter.contains( item->album()->id() );
|
||||
|
||||
if ( !accepted )
|
||||
{
|
||||
QStringList sl = m_filter.split( " ", QString::SkipEmptyParts );
|
||||
foreach( const QString& s, sl )
|
||||
{
|
||||
if ( !pi->name().contains( s, Qt::CaseInsensitive ) &&
|
||||
!pi->albumName().contains( s, Qt::CaseInsensitive ) &&
|
||||
!pi->artistName().contains( s, Qt::CaseInsensitive ) )
|
||||
if ( !item->name().contains( s, Qt::CaseInsensitive ) &&
|
||||
!item->albumName().contains( s, Qt::CaseInsensitive ) &&
|
||||
!item->artistName().contains( s, Qt::CaseInsensitive ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_cache.insertMulti( sourceParent, pi->result() );
|
||||
m_cache.insertMulti( sourceParent, item->result() );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user