mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
* Made a few of PlayableModel's methods virtual.
This commit is contained in:
@@ -101,9 +101,9 @@ public:
|
|||||||
|
|
||||||
virtual void ensureResolved();
|
virtual void ensureResolved();
|
||||||
|
|
||||||
PlayableItem* itemFromIndex( const QModelIndex& index ) const;
|
virtual PlayableItem* itemFromIndex( const QModelIndex& index ) const;
|
||||||
PlayableItem* itemFromQuery( const Tomahawk::query_ptr& query ) const;
|
virtual PlayableItem* itemFromQuery( const Tomahawk::query_ptr& query ) const;
|
||||||
PlayableItem* itemFromResult( const Tomahawk::result_ptr& result ) const;
|
virtual PlayableItem* itemFromResult( const Tomahawk::result_ptr& result ) const;
|
||||||
|
|
||||||
/// Returns a flat list of all tracks in this model
|
/// Returns a flat list of all tracks in this model
|
||||||
QList< Tomahawk::query_ptr > queries() const;
|
QList< Tomahawk::query_ptr > queries() const;
|
||||||
|
@@ -426,27 +426,59 @@ TreeModel::indexFromAlbum( const Tomahawk::album_ptr& album ) const
|
|||||||
QModelIndex
|
QModelIndex
|
||||||
TreeModel::indexFromResult( const Tomahawk::result_ptr& result ) const
|
TreeModel::indexFromResult( const Tomahawk::result_ptr& result ) const
|
||||||
{
|
{
|
||||||
QModelIndex artistIdx = indexFromArtist( result->artist() );
|
QModelIndex albumIdx = indexFromAlbum( result->album() );
|
||||||
for ( int i = 0; i < rowCount( artistIdx ); i++ )
|
for ( int i = 0; i < rowCount( albumIdx ); i++ )
|
||||||
{
|
{
|
||||||
QModelIndex idx = index( i, 0, artistIdx );
|
QModelIndex idx = index( i, 0, albumIdx );
|
||||||
PlayableItem* albumItem = itemFromIndex( idx );
|
PlayableItem* item = itemFromIndex( idx );
|
||||||
if ( albumItem && albumItem->album() == result->album() )
|
tDebug() << item->result()->toString();
|
||||||
|
if ( item && item->result() == result )
|
||||||
{
|
{
|
||||||
for ( int j = 0; j < rowCount( idx ); j++ )
|
return idx;
|
||||||
{
|
|
||||||
QModelIndex subidx = index( j, 0, idx );
|
|
||||||
PlayableItem* item = itemFromIndex( subidx );
|
|
||||||
if ( item && item->result() == result )
|
|
||||||
{
|
|
||||||
return subidx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tDebug() << "Could not find item for result:" << result->toString();
|
tDebug() << "Could not find item for result:" << result->toString();
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QModelIndex
|
||||||
|
TreeModel::indexFromQuery( const Tomahawk::query_ptr& query ) const
|
||||||
|
{
|
||||||
|
Tomahawk::artist_ptr artist = Artist::get( query->artist(), false );
|
||||||
|
Tomahawk::album_ptr album = Album::get( artist, query->album(), false );
|
||||||
|
|
||||||
|
QModelIndex albumIdx = indexFromAlbum( album );
|
||||||
|
for ( int i = 0; i < rowCount( albumIdx ); i++ )
|
||||||
|
{
|
||||||
|
QModelIndex idx = index( i, 0, albumIdx );
|
||||||
|
PlayableItem* item = itemFromIndex( idx );
|
||||||
|
if ( item && item->result() && item->result()->toQuery()->equals( query ) )
|
||||||
|
{
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tDebug() << "Could not find item for query:" << query->toString();
|
||||||
|
return QModelIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PlayableItem*
|
||||||
|
TreeModel::itemFromResult( const Tomahawk::result_ptr& result ) const
|
||||||
|
{
|
||||||
|
QModelIndex albumIdx = indexFromAlbum( result->album() );
|
||||||
|
for ( int i = 0; i < rowCount( albumIdx ); i++ )
|
||||||
|
{
|
||||||
|
QModelIndex idx = index( i, 0, albumIdx );
|
||||||
|
PlayableItem* item = itemFromIndex( idx );
|
||||||
|
if ( item && item->result() == result )
|
||||||
|
{
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tDebug() << "Could not find item for result:" << result->toString();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@@ -61,9 +61,12 @@ public:
|
|||||||
|
|
||||||
void getCover( const QModelIndex& index );
|
void getCover( const QModelIndex& index );
|
||||||
|
|
||||||
QModelIndex indexFromArtist( const Tomahawk::artist_ptr& artist ) const;
|
virtual PlayableItem* itemFromResult( const Tomahawk::result_ptr& result ) const;
|
||||||
QModelIndex indexFromAlbum( const Tomahawk::album_ptr& album ) const;
|
|
||||||
QModelIndex indexFromResult( const Tomahawk::result_ptr& result ) const;
|
virtual QModelIndex indexFromArtist( const Tomahawk::artist_ptr& artist ) const;
|
||||||
|
virtual QModelIndex indexFromAlbum( const Tomahawk::album_ptr& album ) const;
|
||||||
|
virtual QModelIndex indexFromResult( const Tomahawk::result_ptr& result ) const;
|
||||||
|
virtual QModelIndex indexFromQuery( const Tomahawk::query_ptr& query ) const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addAlbums( const QModelIndex& parent, const QList<Tomahawk::album_ptr>& albums );
|
void addAlbums( const QModelIndex& parent, const QList<Tomahawk::album_ptr>& albums );
|
||||||
|
Reference in New Issue
Block a user