mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 00:24:12 +02:00
* Filter out duplicate tracks in the Tree Collection.
This commit is contained in:
@@ -589,10 +589,9 @@ TreeModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const QVaria
|
|||||||
|
|
||||||
if ( crows.second > 0 )
|
if ( crows.second > 0 )
|
||||||
emit endInsertRows();
|
emit endInsertRows();
|
||||||
else
|
|
||||||
emit dataChanged( item->index, item->index.sibling( item->index.row(), columnCount( QModelIndex() ) - 1 ) );
|
|
||||||
|
|
||||||
qDebug() << rowCount( parent );
|
emit dataChanged( item->index.sibling( 0, 0 ), item->index.sibling( item->index.row(), columnCount( QModelIndex() ) - 1 ) );
|
||||||
|
|
||||||
emit loadingFinished();
|
emit loadingFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -75,15 +75,42 @@ TreeProxyModel::setFilter( const QString& pattern )
|
|||||||
bool
|
bool
|
||||||
TreeProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
|
TreeProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const
|
||||||
{
|
{
|
||||||
|
TreeModelItem* pi = sourceModel()->itemFromIndex( sourceModel()->index( sourceRow, 0, sourceParent ) );
|
||||||
|
Q_ASSERT( pi );
|
||||||
|
|
||||||
|
if ( !pi->result().isNull() )
|
||||||
|
{
|
||||||
|
QList< Tomahawk::result_ptr > rl = m_cache.values( sourceParent );
|
||||||
|
foreach ( const Tomahawk::result_ptr& result, rl )
|
||||||
|
{
|
||||||
|
if ( result->track() == pi->result()->track() )
|
||||||
|
return ( result.data() == pi->result().data() );
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( int i = 0; i < sourceModel()->rowCount( sourceParent ); i++ )
|
||||||
|
{
|
||||||
|
if ( i == sourceRow )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
TreeModelItem* ti = sourceModel()->itemFromIndex( sourceModel()->index( i, 0, sourceParent ) );
|
||||||
|
if ( ti->result()->track() == pi->result()->track() )
|
||||||
|
{
|
||||||
|
if ( !pi->result()->isOnline() && ti->result()->isOnline() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ( ti->result()->collection()->source()->isLocal() )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tDebug() << "Accepting:" << pi->result()->toString() << pi->result()->collection()->source()->id();
|
||||||
|
m_cache.insertMulti( sourceParent, pi->result() );
|
||||||
|
}
|
||||||
|
|
||||||
if ( filterRegExp().isEmpty() )
|
if ( filterRegExp().isEmpty() )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
TreeModelItem* pi = sourceModel()->itemFromIndex( sourceModel()->index( sourceRow, 0, sourceParent ) );
|
|
||||||
if ( !pi )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
QStringList sl = filterRegExp().pattern().split( " ", QString::SkipEmptyParts );
|
QStringList sl = filterRegExp().pattern().split( " ", QString::SkipEmptyParts );
|
||||||
|
|
||||||
bool found = true;
|
bool found = true;
|
||||||
foreach( const QString& s, sl )
|
foreach( const QString& s, sl )
|
||||||
{
|
{
|
||||||
|
@@ -84,6 +84,8 @@ protected:
|
|||||||
private:
|
private:
|
||||||
QString textForItem( TreeModelItem* item ) const;
|
QString textForItem( TreeModelItem* item ) const;
|
||||||
|
|
||||||
|
mutable QMap< QPersistentModelIndex, Tomahawk::result_ptr > m_cache;
|
||||||
|
|
||||||
TreeModel* m_model;
|
TreeModel* m_model;
|
||||||
RepeatMode m_repeatMode;
|
RepeatMode m_repeatMode;
|
||||||
bool m_shuffled;
|
bool m_shuffled;
|
||||||
|
Reference in New Issue
Block a user