예제 #1
0
bool
TreeModel::canFetchMore( const QModelIndex& parent ) const
{
    PlayableItem* parentItem = itemFromIndex( parent );

    if ( parentItem->fetchingMore() )
        return false;

    if ( !parentItem->artist().isNull() )
    {
        return true;
    }
    else if ( !parentItem->album().isNull() )
    {
        return true;
    }

    return false;
}
예제 #2
0
void
TreeModel::fetchMore( const QModelIndex& parent )
{
    PlayableItem* parentItem = itemFromIndex( parent );
    if ( !parentItem || parentItem->fetchingMore() )
        return;

    parentItem->setFetchingMore( true );
    if ( !parentItem->artist().isNull() )
    {
        tDebug() << Q_FUNC_INFO << "Loading Artist:" << parentItem->artist()->name();
        fetchAlbums( parentItem->artist() );
    }
    else if ( !parentItem->album().isNull() )
    {
        tDebug() << Q_FUNC_INFO << "Loading Album:" << parentItem->album()->artist()->name() << parentItem->album()->name() << parentItem->album()->id();
        addTracks( parentItem->album(), parent );
    }
    else
        Q_ASSERT( false );
}