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:
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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();
|
||||
|
||||
|
Reference in New Issue
Block a user