1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-30 19:00:12 +02:00

* Added itemFromQuery method to PlayableModel and PlayableProxyModel.

This commit is contained in:
Christian Muehlhaeuser
2012-11-15 17:12:10 +01:00
parent c8c6875739
commit d5c9d523db
3 changed files with 21 additions and 0 deletions

View File

@@ -844,3 +844,21 @@ PlayableModel::setIcon( const QPixmap& pixmap )
m_icon = pixmap;
emit changed();
}
PlayableItem*
PlayableModel::itemFromQuery( const Tomahawk::query_ptr& query ) const
{
for ( int i = 0; i < rowCount( QModelIndex() ); i++ )
{
QModelIndex idx = index( i, 0, QModelIndex() );
PlayableItem* item = itemFromIndex( idx );
if ( item && item->query() == query )
{
return item;
}
}
tDebug() << "Could not find item for query:" << query->toString();
return 0;
}

View File

@@ -101,6 +101,8 @@ public:
virtual void ensureResolved();
PlayableItem* itemFromIndex( const QModelIndex& index ) const;
PlayableItem* itemFromQuery( const Tomahawk::query_ptr& query ) const;
/// Returns a flat list of all tracks in this model
QList< Tomahawk::query_ptr > queries() const;

View File

@@ -69,6 +69,7 @@ public:
virtual void setMaxVisibleItems( int items );
virtual PlayableItem* itemFromIndex( const QModelIndex& index ) const { return sourceModel()->itemFromIndex( index ); }
virtual PlayableItem* itemFromQuery( const Tomahawk::query_ptr& query ) const { return sourceModel()->itemFromQuery( query ); }
virtual Tomahawk::playlistinterface_ptr playlistInterface();