1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-13 20:39:57 +01:00

* Convenience method PlayableModel::indexFromSource.

This commit is contained in:
Christian Muehlhaeuser 2014-08-13 01:13:17 +02:00
parent a4daf7b4fb
commit e3bab55a26
2 changed files with 19 additions and 0 deletions

View File

@ -1238,3 +1238,21 @@ PlayableModel::itemFromResult( const Tomahawk::result_ptr& result ) const
tDebug() << "Could not find item for result:" << result->toString();
return 0;
}
QModelIndex
PlayableModel::indexFromSource( const Tomahawk::source_ptr& source ) const
{
for ( int i = 0; i < rowCount( QModelIndex() ); i++ )
{
QModelIndex idx = index( i, 0, QModelIndex() );
PlayableItem* item = itemFromIndex( idx );
if ( item && item->source() == source )
{
return idx;
}
}
tDebug() << "Could not find item for source:" << source->friendlyName();
return QModelIndex();
}

View File

@ -124,6 +124,7 @@ public:
virtual PlayableItem* itemFromIndex( const QModelIndex& index ) const;
virtual PlayableItem* itemFromQuery( const Tomahawk::query_ptr& query ) const;
virtual PlayableItem* itemFromResult( const Tomahawk::result_ptr& result ) const;
virtual QModelIndex indexFromSource( const Tomahawk::source_ptr& source ) const;
/// Returns a flat list of all tracks in this model
QList< Tomahawk::query_ptr > queries() const;