1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-08 23:26:40 +02:00

* Fixed filter in TreeProxyModel.

This commit is contained in:
Christian Muehlhaeuser
2011-09-17 20:24:24 +02:00
parent e1d4088d98
commit b99a1a753c

View File

@@ -191,8 +191,7 @@ TreeProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent
if ( result->track() == pi->result()->track() && if ( result->track() == pi->result()->track() &&
( result->albumpos() == pi->result()->albumpos() || result->albumpos() == 0 ) ) ( result->albumpos() == pi->result()->albumpos() || result->albumpos() == 0 ) )
{ {
if ( result.data() != pi->result().data() ) return ( result.data() == pi->result().data() );
return false;
} }
} }
@@ -213,19 +212,18 @@ TreeProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent
return false; return false;
} }
} }
// tDebug() << "Accepting:" << pi->result()->toString() << pi->result()->collection()->source()->id();
m_cache.insertMulti( sourceParent, pi->result() );
} }
bool accepted = false;
if ( m_filter.isEmpty() ) if ( m_filter.isEmpty() )
return true; accepted = true;
else if ( !pi->artist().isNull() )
if ( !pi->artist().isNull() ) accepted = m_artistsFilter.contains( pi->artist() );
return m_artistsFilter.contains( pi->artist() ); else if ( !pi->album().isNull() )
if ( !pi->album().isNull() ) accepted = m_albumsFilter.contains( pi->album() );
return m_albumsFilter.contains( pi->album() );
if ( !accepted )
{
QStringList sl = m_filter.split( " ", QString::SkipEmptyParts ); QStringList sl = m_filter.split( " ", QString::SkipEmptyParts );
foreach( const QString& s, sl ) foreach( const QString& s, sl )
{ {
@@ -236,7 +234,9 @@ TreeProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent
return false; return false;
} }
} }
}
m_cache.insertMulti( sourceParent, pi->result() );
return true; return true;
} }